wp_admin_bar_wp_menu

Definition:
function wp_admin_bar_wp_menu( $wp_admin_bar ) {}

Add the WordPress logo menu.

Parameters

  • $wp_admin_bar

Source code

function wp_admin_bar_wp_menu( $wp_admin_bar ) {

	$wp_admin_bar->add_menu( array(

		'id'    => 'wp-logo',

		'title' => '<span class="ab-icon"></span>',

		'href'  => admin_url( 'about.php' ),

		'meta'  => array(

			'title' => __('About WordPress'),

		),

	) );



	if ( is_user_logged_in() ) {

		// Add "About WordPress" link

		$wp_admin_bar->add_menu( array(

			'parent' => 'wp-logo',

			'id'     => 'about',

			'title'  => __('About WordPress'),

			'href'   => admin_url('about.php'),

		) );

	}



	// Add WordPress.org link

	$wp_admin_bar->add_menu( array(

		'parent'    => 'wp-logo-external',

		'id'        => 'wporg',

		'title'     => __('WordPress.org'),

		'href'      => __('http://wordpress.org'),

	) );



	// Add codex link

	$wp_admin_bar->add_menu( array(

		'parent'    => 'wp-logo-external',

		'id'        => 'documentation',

		'title'     => __('Documentation'),

		'href'      => __('http://codex.wordpress.org'),

	) );



	// Add forums link

	$wp_admin_bar->add_menu( array(

		'parent'    => 'wp-logo-external',

		'id'        => 'support-forums',

		'title'     => __('Support Forums'),

		'href'      => __('http://wordpress.org/support/'),

	) );



	// Add feedback link

	$wp_admin_bar->add_menu( array(

		'parent'    => 'wp-logo-external',

		'id'        => 'feedback',

		'title'     => __('Feedback'),

		'href'      => __('http://wordpress.org/support/forum/requests-and-feedback'),

	) );

}

17422

wp_admin_bar_site_menu

Definition:
function wp_admin_bar_site_menu( $wp_admin_bar ) {}

Add the "Site Name" menu.

Parameters

  • $wp_admin_bar

Source code

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( $blogname, 40 );

	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( '/' ),

		) );



	// We're on the front end, print a copy of the admin menu.

	} else {

		// Add the dashboard item.

		$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 );

	}

}

17418

wp_admin_bar_search_menu

Definition:
function wp_admin_bar_search_menu( $wp_admin_bar ) {}

Add search form.

Parameters

  • $wp_admin_bar

Source code

function wp_admin_bar_search_menu( $wp_admin_bar ) {

	if ( is_admin() )

		return;



	$form  = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">';

	$form .= '<input class="adminbar-input" name="s" id="adminbar-search" tabindex="10" type="text" value="" maxlength="150" />';

	$form .= '<input type="submit" class="adminbar-button" value="' . __('Search') . '"/>';

	$form .= '</form>';



	$wp_admin_bar->add_menu( array(

		'parent' => 'top-secondary',

		'id'     => 'search',

		'title'  => $form,

		'meta'   => array(

			'class'    => 'admin-bar-search',

			'tabindex' => -1,

		)

	) );

}

17414

wp_admin_bar_dashboard_view_site_menu

Definition:
function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) {}

Add the "Dashboard"/"Visit Site" menu.

Parameters

  • $wp_admin_bar

Source code

function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) {

	_deprecated_function( __FUNCTION__, '3.3' );



	$user_id = get_current_user_id();



	if ( 0 != $user_id ) {

		if ( is_admin() )

			$wp_admin_bar->add_menu( array( 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url() ) );

		elseif ( is_multisite() )

			$wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) );

		else

			$wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) );

	}

}

17402