Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#51470 closed defect (bug) (invalid)

[walker-nav-menu] Undefined property stdclass::$current in nav-menu-template.php

Reported by: rejuancse's profile rejuancse Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.5
Component: Menus Keywords:
Focuses: Cc:


In wp-includes/nav-menu-template.php line 190 there’s a missing empty();
function around $args->container_aria_label.
Causes PHP errors everywhere wp_nav_menu(); function occurrence:

$aria_label = ( 'nav' === $args->container && $args->container_aria_label ) ? ' aria-label="' . esc_attr( $args->container_aria_label ) . '"' : '';

Should be:

$aria_label 	= ( 'nav' === $args->container && !empty($args->container_aria_label) ) ? ' aria-label="' . esc_attr( $args->container_aria_label ) . '"' : '';

Attachments (1)

51470.diff (1.2 KB) - added by rejuancse 3 years ago.
Create Patch

Download all attachments as: .zip

Change History (6)

#1 @sabernhardt
3 years ago

  • Component changed from General to Menus

3 years ago

Create Patch

#2 @metalandcoffee
3 years ago

I wasn't able to reproduce this.

Can you provide the exact PHP notice that you are getting as well as the steps to reproduce? Also, the title of this ticket does not seem related to the actual problem you are describing. Can you please confirm the problem you are seeing?

#3 @rejuancse
3 years ago

Hello @metalandcoffee,
Does not show any additional notices in PHP.
Please see this link

Fresh install in WordPress menu shows this Error. Maybe it's not a big issue, but if you use this condition then you get rid of this issue.


#4 @helen
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Version changed from trunk to 5.5

Hello - I take it this is coming from this forum post:

Your plugin needs to either set container_aria_label in the nav menu args in the filter you are using (appears to be overrite_functions_wp_megamenu()), or you need to judiciously only set the arguments you actually need instead of overwriting the entire array before returning.

#5 @rejuancse
3 years ago

Hello @helen,
Thank you so much. I fixed this issue.

Thanks and have a nice day

Note: See TracTickets for help on using tickets.