Ticket #38636: 38636.selective.patch
File 38636.selective.patch, 2.8 KB (added by , 3 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 'hreflang', 'aria-describedby' and data 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 including the following keys: 'html', 'class', 'rel', 'lang', 'dir', 125 * 'onclick', 'target', 'title', 'tabindex', 'hreflang', 'aria-describedby'. 126 * Use 'html' to append arbitrary HTML content within the node item. 127 * Use 'class' to apply classes to the node element. 128 * Default empty. 122 129 * } 123 130 */ 124 131 public function add_node( $args ) { … … 537 544 echo "<li id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$menuclass>"; 538 545 539 546 if ( $has_link ) { 540 $attributes = array( 'onclick', 'target', 'title', 'rel', 'lang', 'dir' ); 547 if ( is_admin() ) { 548 global $pagenow; 549 if ( $node->href == network_admin_url( $pagenow ) ) { 550 $aria_attributes .= ' aria-current="page"'; 551 } 552 } 541 553 echo "<a class='ab-item'$aria_attributes href='" . esc_url( $node->href ) . "'"; 542 554 } else { 543 $attributes = array( 'onclick', 'target', 'title', 'rel', 'lang', 'dir' );544 555 echo '<div class="ab-item ab-empty-item"' . $aria_attributes; 545 556 } 546 557 547 foreach ( $attributes as $attribute ) { 548 if ( empty( $node->meta[ $attribute ] ) ) { 558 $allowed = array( 'onclick', 'target', 'title', 'rel', 'lang', 'dir', 'hreflang', 'aria-describedby' ); 559 560 foreach ( $node->meta as $attr => $value ) { 561 if ( ( empty( $value ) || ! in_array( $attr, $allowed ) ) 562 && 0 !== stripos( $attr, 'data-' ) ) { 549 563 continue; 550 564 } 551 565 552 if ( 'onclick' === $attribute ) {553 echo " $attribute='" . esc_js( $node->meta[ $attribute ] ) . "'";554 } else {555 echo " $attribute='" . esc_attr( $node->meta[ $attribute ] ) . "'";556 }566 printf( 567 ' %s="%s"', 568 $attr, 569 "onclick" === $attr ? esc_js( $value ) : esc_attr( $value ) 570 ); 557 571 } 558 572 559 573 echo ">{$arrow}{$node->title}";