[wp-trac] [WordPress Trac] #43113: Multiple custom item classes are returned as single string when using 'nav_menu_link_attributes' filter with Customizer preview

WordPress Trac noreply at wordpress.org
Sun Dec 1 23:41:35 UTC 2019


#43113: Multiple custom item classes are returned as single string when using
'nav_menu_link_attributes' filter with Customizer preview
----------------------------------------------------+---------------------
 Reporter:  lrdn                                    |       Owner:  (none)
     Type:  defect (bug)                            |      Status:  new
 Priority:  normal                                  |   Milestone:  5.4
Component:  Customize                               |     Version:  4.3
 Severity:  normal                                  |  Resolution:
 Keywords:  has-patch has-unit-tests needs-testing  |     Focuses:
----------------------------------------------------+---------------------
Changes (by dlh):

 * keywords:   => has-patch has-unit-tests needs-testing
 * version:  4.9.2 => 4.3
 * milestone:  Awaiting Review => 5.4


Comment:

 Storing the classes as a string in the setting value seems right to me
 because `wp_update_nav_menu_item()` expects to receive a string for `menu-
 item-classes`.

 The problem occurs (I think) when the nav menu item's properties are
 overwritten with the customized state in
 `\WP_Customize_Nav_Menu_Item_Setting::filter_wp_get_nav_menu_items()`. The
 string setting value for `classes` overwrites the array value set by
 `wp_setup_nav_menu_item()`.

 [attachment:"43113.diff"] attempts to fix this in
 `\WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item()` by
 ensuring that a string `classes` is exploded into an array before it's
 used to overwrite the property.

 @lrdn, would you be able to refresh your memory about this issue and test
 the patch?

 Marking this as a potential small fix to get into 5.4 if it can be tested.

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


More information about the wp-trac mailing list