[wp-trac] [WordPress Trac] #52949: All available nav menu locations checked by default when creating a new menu

WordPress Trac noreply at wordpress.org
Wed Mar 31 22:10:32 UTC 2021


#52949: All available nav menu locations checked by default when creating a new
menu
-------------------------------------+-----------------------------
 Reporter:  Chouby                   |       Owner:  davidbaumwald
     Type:  defect (bug)             |      Status:  assigned
 Priority:  normal                   |   Milestone:  5.7.1
Component:  Menus                    |     Version:  5.5
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-refresh  |     Focuses:  administration
-------------------------------------+-----------------------------
Changes (by davidbaumwald):

 * keywords:  has-patch => has-patch needs-refresh


Comment:

 Looked into this a bit, and the issue isn't the `isset` logic; it's that
 `$nav_menu_selected_id` is `0` for a new menu being created.  I've
 verified that adding a `0 !== $nav_menu_selected_id` to the checked
 conditional resolves the issue.

 @Chouby Are you up for re-working your patch to include this logic?

 One other note, after adding the third evaluation, I think it might be a
 bit more readable if we do something like this:
 {{{
 $checked = false;

 if ( isset( $menu_locations[ $location ] )
     && 0 !== $nav_menu_selected_id
     && $menu_locations[ $location ] === $nav_menu_selected_id
 ) {
     $checked = true;
 }
 }}}
 Versus the existing, one-liner setup.
 {{{
 $checked = isset( $menu_locations[ $location ] ) && 0 !==
 $nav_menu_selected_id && $menu_locations[ $location ] ===
 $nav_menu_selected_id;
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52949#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list