X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/03f2fa83c13c1b532284205fa7efcab9b8b2c41f..607b7e02d77e7326161e8ec15639052d2040f745:/wp-includes/class-wp-admin-bar.php?ds=sidebyside diff --git a/wp-includes/class-wp-admin-bar.php b/wp-includes/class-wp-admin-bar.php index f4021008..49986ac2 100644 --- a/wp-includes/class-wp-admin-bar.php +++ b/wp-includes/class-wp-admin-bar.php @@ -27,7 +27,7 @@ class WP_Admin_Bar { return is_ssl() ? 'https://' : 'http://'; case 'menu' : - _deprecated_argument( 'WP_Admin_Bar', '3.3', 'Modify admin bar nodes with WP_Admin_Bar::get_node(), WP_Admin_Bar::add_node(), and WP_Admin_Bar::remove_node(), not the menu property.' ); + _deprecated_argument( 'WP_Admin_Bar', '3.3.0', 'Modify admin bar nodes with WP_Admin_Bar::get_node(), WP_Admin_Bar::add_node(), and WP_Admin_Bar::remove_node(), not the menu property.' ); return array(); // Sorry, folks. } } @@ -96,7 +96,11 @@ class WP_Admin_Bar { } /** - * Add a node to the menu. + * Adds a node to the menu. + * + * @since 3.1.0 + * @since 4.5.0 Added the ability to pass 'lang' and 'dir' meta data. + * @access public * * @param array $args { * Arguments for adding a node. @@ -106,7 +110,7 @@ class WP_Admin_Bar { * @type string $parent Optional. ID of the parent node. * @type string $href Optional. Link for the item. * @type bool $group Optional. Whether or not the node is a group. Default false. - * @type array $meta Meta data including the following keys: 'html', 'class', 'rel', + * @type array $meta Meta data including the following keys: 'html', 'class', 'rel', 'lang', 'dir', * 'onclick', 'target', 'title', 'tabindex'. Default empty. * } */ @@ -123,7 +127,7 @@ class WP_Admin_Bar { if ( empty( $args['title'] ) ) return; - _doing_it_wrong( __METHOD__, __( 'The menu ID should not be empty.' ), '3.3' ); + _doing_it_wrong( __METHOD__, __( 'The menu ID should not be empty.' ), '3.3.0' ); // Deprecated: Generate an ID from the title. $args['id'] = esc_attr( sanitize_title( trim( $args['title'] ) ) ); } @@ -473,8 +477,9 @@ class WP_Admin_Bar { $is_parent = ! empty( $node->children ); $has_link = ! empty( $node->href ); - $tabindex = isset( $node->meta['tabindex'] ) ? (int) $node->meta['tabindex'] : ''; - $aria_attributes = $tabindex ? 'tabindex="' . $tabindex . '"' : ''; + // Allow only numeric values, then casted to integers, and allow a tabindex value of `0` for a11y. + $tabindex = ( isset( $node->meta['tabindex'] ) && is_numeric( $node->meta['tabindex'] ) ) ? (int) $node->meta['tabindex'] : ''; + $aria_attributes = ( '' !== $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; $menuclass = ''; @@ -493,7 +498,7 @@ class WP_Admin_Bar {
  • > href="href ) ?>" href="href ) ?>"meta['onclick'] ) ) : ?> onclick="meta['onclick'] ); ?>"meta['rel'] ) ) : ?> rel="meta['rel'] ); ?>"meta['lang'] ) ) : + ?> lang="meta['lang'] ); ?>"meta['dir'] ) ) : + ?> dir="meta['dir'] ); ?>">
    meta['title'] ) ) : ?> title="meta['title'] ); ?>"meta['lang'] ) ) : + ?> lang="meta['lang'] ); ?>"meta['dir'] ) ) : + ?> dir="meta['dir'] ); ?>">_render_item( $node ); }