[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> class-wp-admin-bar.php (source)

   1  <?php
   2  /**
   3   * Toolbar API: WP_Admin_Bar class
   4   *
   5   * @package WordPress
   6   * @subpackage Toolbar
   7   * @since 3.1.0
   8   */
   9  
  10  /**
  11   * Core class used to implement the Toolbar API.
  12   *
  13   * @since 3.1.0
  14   */
  15  #[AllowDynamicProperties]
  16  class WP_Admin_Bar {
  17      private $nodes = array();
  18      private $bound = false;
  19      public $user;
  20  
  21      /**
  22       * Deprecated menu property.
  23       *
  24       * @since 3.1.0
  25       * @deprecated 3.3.0 Modify admin bar nodes with WP_Admin_Bar::get_node(),
  26       *                   WP_Admin_Bar::add_node(), and WP_Admin_Bar::remove_node().
  27       * @var array
  28       */
  29      public $menu = array();
  30  
  31      /**
  32       * Initializes the admin bar.
  33       *
  34       * @since 3.1.0
  35       */
  36  	public function initialize() {
  37          $this->user = new stdClass();
  38  
  39          if ( is_user_logged_in() ) {
  40              /* Populate settings we need for the menu based on the current user. */
  41              $this->user->blogs = get_blogs_of_user( get_current_user_id() );
  42              if ( is_multisite() ) {
  43                  $this->user->active_blog    = get_active_blog_for_user( get_current_user_id() );
  44                  $this->user->domain         = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) );
  45                  $this->user->account_domain = $this->user->domain;
  46              } else {
  47                  $this->user->active_blog    = $this->user->blogs[ get_current_blog_id() ];
  48                  $this->user->domain         = trailingslashit( home_url() );
  49                  $this->user->account_domain = $this->user->domain;
  50              }
  51          }
  52  
  53          add_action( 'wp_head', 'wp_admin_bar_header' );
  54  
  55          add_action( 'admin_head', 'wp_admin_bar_header' );
  56  
  57          if ( current_theme_supports( 'admin-bar' ) ) {
  58              /**
  59               * To remove the default padding styles from WordPress for the Toolbar, use the following code:
  60               * add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) );
  61               */
  62              $admin_bar_args  = get_theme_support( 'admin-bar' );
  63              $header_callback = $admin_bar_args[0]['callback'];
  64          }
  65  
  66          if ( empty( $header_callback ) ) {
  67              $header_callback = '_admin_bar_bump_cb';
  68          }
  69  
  70          add_action( 'wp_head', $header_callback );
  71  
  72          wp_enqueue_script( 'admin-bar' );
  73          // Prefetched from the login screen by wp_prefetch_admin_assets(), which needs updating if this changes.
  74          wp_enqueue_style( 'admin-bar' );
  75  
  76          /**
  77           * Fires after WP_Admin_Bar is initialized.
  78           *
  79           * @since 3.1.0
  80           */
  81          do_action( 'admin_bar_init' );
  82      }
  83  
  84      /**
  85       * Adds a node (menu item) to the admin bar menu.
  86       *
  87       * @since 3.3.0
  88       *
  89       * @param array $node The attributes that define the node.
  90       */
  91  	public function add_menu( $node ) {
  92          $this->add_node( $node );
  93      }
  94  
  95      /**
  96       * Removes a node from the admin bar.
  97       *
  98       * @since 3.1.0
  99       *
 100       * @param string $id The menu slug to remove.
 101       */
 102  	public function remove_menu( $id ) {
 103          $this->remove_node( $id );
 104      }
 105  
 106      /**
 107       * Adds a node to the menu.
 108       *
 109       * @since 3.1.0
 110       * @since 4.5.0 Added the ability to pass 'lang' and 'dir' meta data.
 111       * @since 6.5.0 Added the ability to pass 'menu_title' for an ARIA menu name.
 112       * @since 7.2.0 Added the `icon` argument.
 113       *
 114       * @param array $args {
 115       *     Arguments for adding a node.
 116       *
 117       *     @type string $id     ID of the item.
 118       *     @type string $title  Title of the node.
 119       *     @type string $icon   Optional. Namespaced icon name in the form "collection/icon-name",
 120       *                          e.g. 'core-admin/pin'. Rendered before the title, and hides a
 121       *                          Dashicon that the node draws in an empty `<span class="ab-icon">`
 122       *                          or on `.ab-item::before`. Ignored if the icon is not registered.
 123       *     @type string $parent Optional. ID of the parent node.
 124       *     @type string $href   Optional. Link for the item.
 125       *     @type bool   $group  Optional. Whether or not the node is a group. Default false.
 126       *     @type array  $meta   Meta data including the following keys: 'html', 'class', 'rel', 'lang', 'dir',
 127       *                          'onclick', 'target', 'title', 'tabindex', 'menu_title'. Default empty.
 128       * }
 129       */
 130  	public function add_node( $args ) {
 131          // Shim for old method signature: add_node( $parent_id, $menu_obj, $args ).
 132          if ( func_num_args() >= 3 && is_string( $args ) ) {
 133              $args = array_merge( array( 'parent' => $args ), func_get_arg( 2 ) );
 134          }
 135  
 136          if ( is_object( $args ) ) {
 137              $args = get_object_vars( $args );
 138          }
 139  
 140          // Ensure we have a valid title.
 141          if ( empty( $args['id'] ) ) {
 142              if ( empty( $args['title'] ) ) {
 143                  return;
 144              }
 145  
 146              _doing_it_wrong( __METHOD__, __( 'The menu ID should not be empty.' ), '3.3.0' );
 147              // Deprecated: Generate an ID from the title.
 148              $args['id'] = esc_attr( sanitize_title( trim( $args['title'] ) ) );
 149          }
 150  
 151          $defaults = array(
 152              'id'     => false,
 153              'title'  => false,
 154              'icon'   => false,
 155              'parent' => false,
 156              'href'   => false,
 157              'group'  => false,
 158              'meta'   => array(),
 159          );
 160  
 161          // If the node already exists, keep any data that isn't provided.
 162          $maybe_defaults = $this->get_node( $args['id'] );
 163          if ( $maybe_defaults ) {
 164              $defaults = get_object_vars( $maybe_defaults );
 165          }
 166  
 167          // Do the same for 'meta' items.
 168          if ( ! empty( $defaults['meta'] ) && ! empty( $args['meta'] ) ) {
 169              $args['meta'] = wp_parse_args( $args['meta'], $defaults['meta'] );
 170          }
 171  
 172          $args = wp_parse_args( $args, $defaults );
 173  
 174          $back_compat_parents = array(
 175              'my-account-with-avatar' => array( 'my-account', '3.3' ),
 176              'my-blogs'               => array( 'my-sites', '3.3' ),
 177          );
 178  
 179          if ( is_string( $args['parent'] ) && isset( $back_compat_parents[ $args['parent'] ] ) ) {
 180              list( $new_parent, $version ) = $back_compat_parents[ $args['parent'] ];
 181              _deprecated_argument( __METHOD__, $version, sprintf( 'Use <code>%s</code> as the parent for the <code>%s</code> admin bar node instead of <code>%s</code>.', $new_parent, $args['id'], $args['parent'] ) );
 182              $args['parent'] = $new_parent;
 183          }
 184  
 185          $this->_set_node( $args );
 186      }
 187  
 188      /**
 189       * @since 3.3.0
 190       *
 191       * @param array $args
 192       */
 193  	final protected function _set_node( $args ) {
 194          $this->nodes[ $args['id'] ] = (object) $args;
 195      }
 196  
 197      /**
 198       * Gets a node.
 199       *
 200       * @since 3.3.0
 201       *
 202       * @param string $id
 203       * @return object|null Node.
 204       */
 205  	final public function get_node( $id ) {
 206          $node = $this->_get_node( $id );
 207          if ( $node ) {
 208              return clone $node;
 209          }
 210          return null;
 211      }
 212  
 213      /**
 214       * @since 3.3.0
 215       *
 216       * @param string $id
 217       * @return object|null
 218       */
 219  	final protected function _get_node( $id ) {
 220          if ( $this->bound ) {
 221              return null;
 222          }
 223  
 224          if ( empty( $id ) ) {
 225              $id = 'root';
 226          }
 227  
 228          return $this->nodes[ $id ] ?? null;
 229      }
 230  
 231      /**
 232       * @since 3.3.0
 233       *
 234       * @return array|null
 235       */
 236  	final public function get_nodes() {
 237          $nodes = $this->_get_nodes();
 238          if ( ! $nodes ) {
 239              return null;
 240          }
 241  
 242          foreach ( $nodes as &$node ) {
 243              $node = clone $node;
 244          }
 245          return $nodes;
 246      }
 247  
 248      /**
 249       * @since 3.3.0
 250       *
 251       * @return array|null
 252       */
 253  	final protected function _get_nodes() {
 254          if ( $this->bound ) {
 255              return null;
 256          }
 257  
 258          return $this->nodes;
 259      }
 260  
 261      /**
 262       * Adds a group to a toolbar menu node.
 263       *
 264       * Groups can be used to organize toolbar items into distinct sections of a toolbar menu.
 265       *
 266       * @since 3.3.0
 267       *
 268       * @param array $args {
 269       *     Array of arguments for adding a group.
 270       *
 271       *     @type string $id     ID of the item.
 272       *     @type string $parent Optional. ID of the parent node. Default 'root'.
 273       *     @type array  $meta   Meta data for the group including the following keys:
 274       *                         'class', 'onclick', 'target', and 'title'.
 275       * }
 276       */
 277  	final public function add_group( $args ) {
 278          $args['group'] = true;
 279  
 280          $this->add_node( $args );
 281      }
 282  
 283      /**
 284       * Remove a node.
 285       *
 286       * @since 3.1.0
 287       *
 288       * @param string $id The ID of the item.
 289       */
 290  	public function remove_node( $id ) {
 291          $this->_unset_node( $id );
 292      }
 293  
 294      /**
 295       * @since 3.3.0
 296       *
 297       * @param string $id
 298       */
 299  	final protected function _unset_node( $id ) {
 300          unset( $this->nodes[ $id ] );
 301      }
 302  
 303      /**
 304       * @since 3.1.0
 305       */
 306  	public function render() {
 307          $root = $this->_bind();
 308          if ( $root ) {
 309              $this->_render( $root );
 310          }
 311      }
 312  
 313      /**
 314       * @since 3.3.0
 315       *
 316       * @return object|null
 317       */
 318  	final protected function _bind() {
 319          if ( $this->bound ) {
 320              return null;
 321          }
 322  
 323          /*
 324           * Add the root node.
 325           * Clear it first, just in case. Don't mess with The Root.
 326           */
 327          $this->remove_node( 'root' );
 328          $this->add_node(
 329              array(
 330                  'id'    => 'root',
 331                  'group' => false,
 332              )
 333          );
 334  
 335          // Normalize nodes: define internal 'children' and 'type' properties.
 336          foreach ( $this->_get_nodes() as $node ) {
 337              $node->children = array();
 338              $node->type     = ( $node->group ) ? 'group' : 'item';
 339              unset( $node->group );
 340  
 341              // The Root wants your orphans. No lonely items allowed.
 342              if ( ! $node->parent ) {
 343                  $node->parent = 'root';
 344              }
 345          }
 346  
 347          foreach ( $this->_get_nodes() as $node ) {
 348              if ( 'root' === $node->id ) {
 349                  continue;
 350              }
 351  
 352              // Fetch the parent node. If it isn't registered, ignore the node.
 353              $parent = $this->_get_node( $node->parent );
 354              if ( ! $parent ) {
 355                  continue;
 356              }
 357  
 358              // Generate the group class (we distinguish between top level and other level groups).
 359              $group_class = ( 'root' === $node->parent ) ? 'ab-top-menu' : 'ab-submenu';
 360  
 361              if ( 'group' === $node->type ) {
 362                  if ( empty( $node->meta['class'] ) ) {
 363                      $node->meta['class'] = $group_class;
 364                  } else {
 365                      $node->meta['class'] .= ' ' . $group_class;
 366                  }
 367              }
 368  
 369              // Items in items aren't allowed. Wrap nested items in 'default' groups.
 370              if ( 'item' === $parent->type && 'item' === $node->type ) {
 371                  $default_id = $parent->id . '-default';
 372                  $default    = $this->_get_node( $default_id );
 373  
 374                  /*
 375                   * The default group is added here to allow groups that are
 376                   * added before standard menu items to render first.
 377                   */
 378                  if ( ! $default ) {
 379                      /*
 380                       * Use _set_node because add_node can be overloaded.
 381                       * Make sure to specify default settings for all properties.
 382                       */
 383                      $this->_set_node(
 384                          array(
 385                              'id'       => $default_id,
 386                              'parent'   => $parent->id,
 387                              'type'     => 'group',
 388                              'children' => array(),
 389                              'meta'     => array(
 390                                  'class' => $group_class,
 391                              ),
 392                              'title'    => false,
 393                              'href'     => false,
 394                          )
 395                      );
 396                      $default            = $this->_get_node( $default_id );
 397                      $parent->children[] = $default;
 398                  }
 399                  $parent = $default;
 400  
 401                  /*
 402                   * Groups in groups aren't allowed. Add a special 'container' node.
 403                   * The container will invisibly wrap both groups.
 404                   */
 405              } elseif ( 'group' === $parent->type && 'group' === $node->type ) {
 406                  $container_id = $parent->id . '-container';
 407                  $container    = $this->_get_node( $container_id );
 408  
 409                  // We need to create a container for this group, life is sad.
 410                  if ( ! $container ) {
 411                      /*
 412                       * Use _set_node because add_node can be overloaded.
 413                       * Make sure to specify default settings for all properties.
 414                       */
 415                      $this->_set_node(
 416                          array(
 417                              'id'       => $container_id,
 418                              'type'     => 'container',
 419                              'children' => array( $parent ),
 420                              'parent'   => false,
 421                              'title'    => false,
 422                              'href'     => false,
 423                              'meta'     => array(),
 424                          )
 425                      );
 426  
 427                      $container = $this->_get_node( $container_id );
 428  
 429                      // Link the container node if a grandparent node exists.
 430                      $grandparent = $this->_get_node( $parent->parent );
 431  
 432                      if ( $grandparent ) {
 433                          $container->parent = $grandparent->id;
 434  
 435                          $index = array_search( $parent, $grandparent->children, true );
 436                          if ( false === $index ) {
 437                              $grandparent->children[] = $container;
 438                          } else {
 439                              array_splice( $grandparent->children, $index, 1, array( $container ) );
 440                          }
 441                      }
 442  
 443                      $parent->parent = $container->id;
 444                  }
 445  
 446                  $parent = $container;
 447              }
 448  
 449              // Update the parent ID (it might have changed).
 450              $node->parent = $parent->id;
 451  
 452              // Add the node to the tree.
 453              $parent->children[] = $node;
 454          }
 455  
 456          $root        = $this->_get_node( 'root' );
 457          $this->bound = true;
 458          return $root;
 459      }
 460  
 461      /**
 462       * @since 3.3.0
 463       * @since 7.2.0 Added a link to skip the toolbar when it is rendered at the start of the page.
 464       *
 465       * @param object $root
 466       */
 467  	final protected function _render( $root ) {
 468          /*
 469           * Add browser classes.
 470           * We have to do this here since admin bar shows on the front end.
 471           */
 472          $class = 'nojq nojs';
 473          if ( wp_is_mobile() ) {
 474              $class .= ' mobile';
 475          }
 476  
 477          /*
 478           * On the front end, add a link to reach the toolbar when it is rendered in the footer
 479           * by themes without 'wp_body_open' support, or to skip it when it precedes the content.
 480           */
 481          $skip_to_toolbar   = ! is_admin() && ! did_action( 'wp_body_open' );
 482          $skip_past_toolbar = ! is_admin() && did_action( 'wp_body_open' ) && ! doing_action( 'wp_footer' );
 483  
 484          ?>
 485          <div id="wpadminbar" class="<?php echo $class; ?>">
 486              <?php if ( $skip_to_toolbar ) { ?>
 487                  <a class="screen-reader-shortcut" href="#wp-toolbar" tabindex="1"><?php _e( 'Skip to toolbar' ); ?></a>
 488              <?php } elseif ( $skip_past_toolbar ) { ?>
 489                  <a class="screen-reader-shortcut" href="#wp-toolbar-skip-target"><?php _e( 'Skip toolbar' ); ?></a>
 490              <?php } ?>
 491              <div class="quicklinks" id="wp-toolbar" role="navigation" aria-label="<?php esc_attr_e( 'Toolbar' ); ?>">
 492                  <?php
 493                  foreach ( $root->children as $group ) {
 494                      $this->_render_group( $group );
 495                  }
 496                  ?>
 497              </div>
 498              <?php if ( $skip_past_toolbar ) { ?>
 499                  <div id="wp-toolbar-skip-target"></div>
 500              <?php } ?>
 501          </div>
 502  
 503          <?php
 504      }
 505  
 506      /**
 507       * @since 3.3.0
 508       *
 509       * @param object $node
 510       */
 511  	final protected function _render_container( $node ) {
 512          if ( 'container' !== $node->type || empty( $node->children ) ) {
 513              return;
 514          }
 515  
 516          echo '<div id="' . esc_attr( 'wp-admin-bar-' . $node->id ) . '" class="ab-group-container">';
 517          foreach ( $node->children as $group ) {
 518              $this->_render_group( $group );
 519          }
 520          echo '</div>';
 521      }
 522  
 523      /**
 524       * @since 3.3.0
 525       * @since 6.5.0 Added `$menu_title` parameter to allow an ARIA menu name.
 526       *
 527       * @param object      $node
 528       * @param string|bool $menu_title The accessible name of this ARIA menu or false if not provided.
 529       */
 530  	final protected function _render_group( $node, $menu_title = false ) {
 531          if ( 'container' === $node->type ) {
 532              $this->_render_container( $node );
 533              return;
 534          }
 535          if ( 'group' !== $node->type || empty( $node->children ) ) {
 536              return;
 537          }
 538  
 539          if ( ! empty( $node->meta['class'] ) ) {
 540              $class = ' class="' . esc_attr( trim( $node->meta['class'] ) ) . '"';
 541          } else {
 542              $class = '';
 543          }
 544  
 545          if ( empty( $menu_title ) ) {
 546              echo "<ul role='menu' id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$class>";
 547          } else {
 548              echo "<ul role='menu' aria-label='" . esc_attr( $menu_title ) . "' id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$class>";
 549          }
 550          foreach ( $node->children as $item ) {
 551              $this->_render_item( $item );
 552          }
 553          echo '</ul>';
 554      }
 555  
 556      /**
 557       * @since 3.3.0
 558       *
 559       * @param object $node
 560       */
 561  	final protected function _render_item( $node ) {
 562          if ( 'item' !== $node->type ) {
 563              return;
 564          }
 565  
 566          $is_parent             = ! empty( $node->children );
 567          $has_link              = ! empty( $node->href );
 568          $is_root_top_item      = 'root-default' === $node->parent;
 569          $is_top_secondary_item = 'top-secondary' === $node->parent;
 570  
 571          // Allow only numeric values, then casted to integers, and allow a tabindex value of `0` for a11y.
 572          $tabindex         = ( isset( $node->meta['tabindex'] ) && is_numeric( $node->meta['tabindex'] ) ) ? (int) $node->meta['tabindex'] : '';
 573          $aria_attributes  = ( '' !== $tabindex ) ? ' tabindex="' . $tabindex . '"' : '';
 574          $aria_attributes .= ' role="menuitem"';
 575  
 576          $menuclass = '';
 577          $arrow     = '';
 578  
 579          if ( $is_parent ) {
 580              $menuclass        = 'menupop ';
 581              $aria_attributes .= ' aria-expanded="false"';
 582          }
 583  
 584          if ( ! empty( $node->meta['class'] ) ) {
 585              $menuclass .= $node->meta['class'];
 586          }
 587  
 588          // Print the arrow icon for the menu children with children.
 589          if ( ! $is_root_top_item && ! $is_top_secondary_item && $is_parent ) {
 590              $arrow = '<span class="wp-admin-bar-arrow" aria-hidden="true"></span>';
 591          }
 592  
 593          if ( $menuclass ) {
 594              $menuclass = ' class="' . esc_attr( trim( $menuclass ) ) . '"';
 595          }
 596  
 597          $icon_name = $node->icon;
 598  
 599          $icon = '';
 600          if ( wp_is_valid_icon_name( $icon_name ) ) {
 601              $icon = _wp_admin_bar_icon( $icon_name );
 602  
 603              if ( ! WP_Icons_Registry::get_instance()->is_registered( $icon_name ) ) {
 604                  _doing_it_wrong(
 605                      __METHOD__,
 606                      sprintf(
 607                          /* translators: 1: Icon name, 2: Admin bar node ID. */
 608                          __( 'The icon "%1$s" of the admin bar node "%2$s" is not registered.' ),
 609                          $icon_name,
 610                          $node->id
 611                      ),
 612                      '7.2.0'
 613                  );
 614              }
 615          }
 616  
 617          echo "<li role='group' id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$menuclass>";
 618  
 619          if ( $has_link ) {
 620              $attributes = array( 'onclick', 'target', 'title', 'rel', 'lang', 'dir' );
 621              echo "<a class='ab-item'$aria_attributes href='" . esc_url( $node->href ) . "'";
 622          } else {
 623              $attributes = array( 'onclick', 'target', 'title', 'rel', 'lang', 'dir' );
 624              echo '<div class="ab-item ab-empty-item"' . $aria_attributes;
 625          }
 626  
 627          foreach ( $attributes as $attribute ) {
 628              if ( empty( $node->meta[ $attribute ] ) ) {
 629                  continue;
 630              }
 631  
 632              if ( 'onclick' === $attribute ) {
 633                  echo " $attribute='" . esc_js( $node->meta[ $attribute ] ) . "'";
 634              } else {
 635                  echo " $attribute='" . esc_attr( $node->meta[ $attribute ] ) . "'";
 636              }
 637          }
 638  
 639          echo ">{$arrow}{$icon}{$node->title}";
 640  
 641          if ( $has_link ) {
 642              echo '</a>';
 643          } else {
 644              echo '</div>';
 645          }
 646  
 647          if ( $is_parent ) {
 648              echo '<div class="ab-sub-wrapper">';
 649              foreach ( $node->children as $group ) {
 650                  if ( empty( $node->meta['menu_title'] ) ) {
 651                      $this->_render_group( $group, false );
 652                  } else {
 653                      $this->_render_group( $group, $node->meta['menu_title'] );
 654                  }
 655              }
 656              echo '</div>';
 657          }
 658  
 659          if ( ! empty( $node->meta['html'] ) ) {
 660              echo $node->meta['html'];
 661          }
 662  
 663          echo '</li>';
 664      }
 665  
 666      /**
 667       * Renders toolbar items recursively.
 668       *
 669       * @since 3.1.0
 670       * @deprecated 3.3.0 Use WP_Admin_Bar::_render_item() or WP_Admin_bar::render() instead.
 671       * @see WP_Admin_Bar::_render_item()
 672       * @see WP_Admin_Bar::render()
 673       *
 674       * @param string $id    Unused.
 675       * @param object $node
 676       */
 677  	public function recursive_render( $id, $node ) {
 678          _deprecated_function( __METHOD__, '3.3.0', 'WP_Admin_bar::render(), WP_Admin_Bar::_render_item()' );
 679          $this->_render_item( $node );
 680      }
 681  
 682      /**
 683       * Adds menus to the admin bar.
 684       *
 685       * @since 3.1.0
 686       */
 687  	public function add_menus() {
 688          // User-related, aligned right.
 689          add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 0 );
 690          add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_item', 9991 );
 691          add_action( 'admin_bar_menu', 'wp_admin_bar_recovery_mode_menu', 9992 );
 692          add_action( 'admin_bar_menu', 'wp_admin_bar_search_menu', 9999 );
 693  
 694          // Site-related.
 695          add_action( 'admin_bar_menu', 'wp_admin_bar_sidebar_toggle', 0 );
 696          add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );
 697          add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 );
 698          add_action( 'admin_bar_menu', 'wp_admin_bar_site_menu', 30 );
 699          add_action( 'admin_bar_menu', 'wp_admin_bar_edit_site_menu', 40 );
 700          add_action( 'admin_bar_menu', 'wp_admin_bar_customize_menu', 40 );
 701          add_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 50 );
 702  
 703          // Command palette.
 704          add_action( 'admin_bar_menu', 'wp_admin_bar_command_palette_menu', 55 );
 705  
 706          // Content-related.
 707          if ( ! is_network_admin() && ! is_user_admin() ) {
 708              add_action( 'admin_bar_menu', 'wp_admin_bar_comments_menu', 60 );
 709              add_action( 'admin_bar_menu', 'wp_admin_bar_new_content_menu', 70 );
 710          }
 711          add_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 80 );
 712  
 713          add_action( 'admin_bar_menu', 'wp_admin_bar_add_secondary_groups', 200 );
 714  
 715          /**
 716           * Fires after menus are added to the menu bar.
 717           *
 718           * @since 3.1.0
 719           */
 720          do_action( 'add_admin_bar_menus' );
 721      }
 722  }


Generated : Thu Nov 26 08:20:01 2026 Cross-referenced by PHPXref