wp_admin_bar_wp_menu

Add the WordPress logo menu.

Description

wp_admin_bar_wp_menu( (WP_Admin_Bar) $wp_admin_bar ); 

Parameters (1)

0. $wp_admin_bar (WP_Admin_Bar)
The wp admin bar.

Usage

  1. if ( !function_exists( 'wp_admin_bar_wp_menu' ) ) { 
  2. require_once ABSPATH . WPINC . '/admin-bar.php'; 
  3.  
  4. // The wp admin bar. 
  5. $wp_admin_bar = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_admin_bar_wp_menu($wp_admin_bar); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/admin-bar.php  
  1. function wp_admin_bar_wp_menu( $wp_admin_bar ) { 
  2. if ( current_user_can( 'read' ) ) { 
  3. $about_url = self_admin_url( 'about.php' ); 
  4. } elseif ( is_multisite() ) { 
  5. $about_url = get_dashboard_url( get_current_user_id(), 'about.php' ); 
  6. } else { 
  7. $about_url = false; 
  8.  
  9. $wp_logo_menu_args = array( 
  10. 'id' => 'wp-logo',  
  11. 'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'About WordPress' ) . '</span>',  
  12. 'href' => $about_url,  
  13. ); 
  14.  
  15. // Set tabindex="0" to make sub menus accessible when no URL is available. 
  16. if ( ! $about_url ) { 
  17. $wp_logo_menu_args['meta'] = array( 
  18. 'tabindex' => 0,  
  19. ); 
  20.  
  21. $wp_admin_bar->add_menu( $wp_logo_menu_args ); 
  22.  
  23. if ( $about_url ) { 
  24. // Add "About WordPress" link 
  25. $wp_admin_bar->add_menu( array( 
  26. 'parent' => 'wp-logo',  
  27. 'id' => 'about',  
  28. 'title' => __('About WordPress'),  
  29. 'href' => $about_url,  
  30. ) ); 
  31.  
  32. // Add WordPress.org link 
  33. $wp_admin_bar->add_menu( array( 
  34. 'parent' => 'wp-logo-external',  
  35. 'id' => 'wporg',  
  36. 'title' => __('WordPress.org'),  
  37. 'href' => __('https://wordpress.org/'),  
  38. ) ); 
  39.  
  40. // Add codex link 
  41. $wp_admin_bar->add_menu( array( 
  42. 'parent' => 'wp-logo-external',  
  43. 'id' => 'documentation',  
  44. 'title' => __('Documentation'),  
  45. 'href' => __('https://codex.wordpress.org/'),  
  46. ) ); 
  47.  
  48. // Add forums link 
  49. $wp_admin_bar->add_menu( array( 
  50. 'parent' => 'wp-logo-external',  
  51. 'id' => 'support-forums',  
  52. 'title' => __('Support Forums'),  
  53. 'href' => __('https://wordpress.org/support/'),  
  54. ) ); 
  55.  
  56. // Add feedback link 
  57. $wp_admin_bar->add_menu( array( 
  58. 'parent' => 'wp-logo-external',  
  59. 'id' => 'feedback',  
  60. 'title' => __('Feedback'),  
  61. 'href' => __('https://wordpress.org/support/forum/requests-and-feedback'),  
  62. ) );