Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_admin_bar_site_menu [ WordPress Function ]

wp_admin_bar_site_menu ( $wp_admin_bar )
Defined at:



Add the "Site Name" menu.

Source


<?php
function wp_admin_bar_site_menu$wp_admin_bar ) {
    global 
$current_site;

    
// Don't show for logged out users.
    
if ( ! is_user_logged_in() )
        return;

    
// Show only when the user is a member of this site, or they're a super admin.
    
if ( ! is_user_member_of_blog() && ! is_super_admin() )
        return;

    
$blogname get_bloginfo('name');

    if ( empty( 
$blogname ) )
        
$blogname preg_replace'#^(https?://)?(www.)?#'''get_home_url() );

    if ( 
is_network_admin() ) {
        
$blogname sprintf__('Network Admin: %s'), esc_html$current_site->site_name ) );
    } elseif ( 
is_user_admin() ) {
        
$blogname sprintf__('Global Dashboard: %s'), esc_html$current_site->site_name ) );
    }

    
$title wp_html_excerpt$blogname40 );
    if ( 
$title != $blogname )
        
$title trim$title ) . '&hellip;';

    
$wp_admin_bar->add_menu( array(
        
'id'    => 'site-name',
        
'title' => $title,
        
'href'  => is_admin() ? home_url'/' ) : admin_url(),
    ) );

    
// Create submenu items.

    
if ( is_admin() ) {
        
// Add an option to visit the site.
        
$wp_admin_bar->add_menu( array(
            
'parent' => 'site-name',
            
'id'     => 'view-site',
            
'title'  => __'Visit Site' ),
            
'href'   => home_url'/' ),
        ) );

        if ( 
is_blog_admin() && is_multisite() && current_user_can'manage_sites' ) ) {
            
$wp_admin_bar->add_menu( array(
                
'parent' => 'site-name',
                
'id'     => 'edit-site',
                
'title'  => __'Edit Site' ),
                
'href'   => network_admin_url'site-info.php?id=' get_current_blog_id() ),
            ) );
        }

    } else {
        
// We're on the front end, link to the Dashboard.
        
$wp_admin_bar->add_menu( array(
            
'parent' => 'site-name',
            
'id'     => 'dashboard',
            
'title'  => __'Dashboard' ),
            
'href'   => admin_url(),
        ) );

        
// Add the appearance submenu items.
        
wp_admin_bar_appearance_menu$wp_admin_bar );
    }
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics