WordPress.org

Make WordPress Core

Opened 12 months ago

Closed 11 months ago

Last modified 11 months ago

#51470 closed defect (bug) (invalid)

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

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

Description

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 12 months ago.
Create Patch

Download all attachments as: .zip

Change History (6)

#1 @sabernhardt
12 months ago

  • Component changed from General to Menus

@rejuancse
12 months ago

Create Patch

#2 @metalandcoffee
11 months 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
11 months ago

Hello @metalandcoffee,
Does not show any additional notices in PHP.
Please see this link https://prnt.sc/vd4p4q

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.

Thanks

#4 @helen
11 months 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: https://wordpress.org/support/topic/undefined-property-stdclasscontainer_aria_label/

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
11 months 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.