Skip to content

Commit

Permalink
Compare attr_title against title and its filtered values
Browse files Browse the repository at this point in the history
  • Loading branch information
sabernhardt committed Oct 3, 2024
1 parent ae13d2f commit 75196b1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/wp-includes/class-walker-nav-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ public function start_el( &$output, $data_object, $depth = 0, $args = null, $cur
/** This filter is documented in wp-includes/post-template.php */
$title = apply_filters( 'the_title', $menu_item->title, $menu_item->ID );

// Save filtered value before filtering again.
$title_filtered = $title;

/**
* Filters a menu item's title.
*
Expand Down Expand Up @@ -248,7 +251,10 @@ public function start_el( &$output, $data_object, $depth = 0, $args = null, $cur

$atts['aria-current'] = $menu_item->current ? 'page' : '';

// Add title attribute only if it does not match the link text (before or after filtering).
if ( ! empty( $menu_item->attr_title )
&& trim( strtolower( $menu_item->attr_title ) ) !== trim( strtolower( $menu_item->title ) )
&& trim( strtolower( $menu_item->attr_title ) ) !== trim( strtolower( $title_filtered ) )
&& trim( strtolower( $menu_item->attr_title ) ) !== trim( strtolower( $title ) )
) {
$atts['title'] = $menu_item->attr_title;
Expand Down

0 comments on commit 75196b1

Please sign in to comment.