Ticket #38636: 38636.2.patch
File 38636.2.patch, 2.9 KB (added by , 4 years ago) |
---|
-
src/wp-includes/class-wp-admin-bar.php
108 108 * 109 109 * @since 3.1.0 110 110 * @since 4.5.0 Added the ability to pass 'lang' and 'dir' meta data. 111 * @since x.x.x Added the ability to pass most HTML attributes as meta data. 112 * @since x.x.x Added `aria-current` attribute. 111 113 * 114 * @global string $pagenow 115 * 112 116 * @param array $args { 113 117 * Arguments for adding a node. 114 118 * … … 117 121 * @type string $parent Optional. ID of the parent node. 118 122 * @type string $href Optional. Link for the item. 119 123 * @type bool $group Optional. Whether or not the node is a group. Default false. 120 * @type array $meta Meta data including the following keys: 'html', 'class', 'rel', 'lang', 'dir', 121 * 'onclick', 'target', 'title', 'tabindex'. Default empty. 124 * @type array $meta Optional. Meta data for the node. 125 * Add HTML attributes to the item, such as 126 * 'rel', 'lang', 'dir', 'onclick', 'target', 'title', 'tabindex'. 127 * Reserved attributes include 'href', 'aria-haspopup', 'aria-current'. 128 * Use 'html' to append arbitrary HTML content within the node. 129 * Use 'class' to apply classes to the node element. 130 * Default empty. 122 131 * } 123 132 */ 124 133 public function add_node( $args ) { … … 537 546 echo "<li id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$menuclass>"; 538 547 539 548 if ( $has_link ) { 540 $attributes = array( 'onclick', 'target', 'title', 'rel', 'lang', 'dir' ); 549 if ( is_admin() ) { 550 global $pagenow; 551 if ( $node->href == network_admin_url( $pagenow ) ) { 552 $aria_attributes .= ' aria-current="page"'; 553 } 554 } 541 555 echo "<a class='ab-item'$aria_attributes href='" . esc_url( $node->href ) . "'"; 542 556 } else { 543 $attributes = array( 'onclick', 'target', 'title', 'rel', 'lang', 'dir' );544 557 echo '<div class="ab-item ab-empty-item"' . $aria_attributes; 545 558 } 546 559 547 foreach ( $attributes as $attribute ) { 548 if ( empty( $node->meta[ $attribute ] ) ) { 560 $reserved = array( 'html', 'class', 'href', 'tabindex', 'aria-haspopup', 'aria-current' ); 561 562 foreach ( $node->meta as $attr => $value ) { 563 if ( in_array( $attr, $reserved ) || empty( $value ) ) { 549 564 continue; 550 565 } 551 566 552 if ( 'onclick' === $attribute ) {553 echo " $attribute='" . esc_js( $node->meta[ $attribute ] ) . "'";554 } else {555 echo " $attribute='" . esc_attr( $node->meta[ $attribute ] ) . "'";556 }567 printf( 568 ' %s="%s"', 569 $attr, 570 0 === stripos( $attr, 'on' ) ? esc_js( $value ) : esc_attr( $value ) 571 ); 557 572 } 558 573 559 574 echo ">{$arrow}{$node->title}";