[wp-trac] [WordPress Trac] #34111: Menu CSS Classes are saved as comma separated inside the Customiser

WordPress Trac noreply at wordpress.org
Sat Oct 3 00:02:21 UTC 2015


#34111: Menu CSS Classes are saved as comma separated inside the Customiser
------------------------------+--------------------------
 Reporter:  paulwilde         |       Owner:  westonruter
     Type:  defect (bug)      |      Status:  accepted
 Priority:  normal            |   Milestone:  4.3.2
Component:  Customize         |     Version:  4.3.1
 Severity:  normal            |  Resolution:
 Keywords:  has-patch commit  |     Focuses:
------------------------------+--------------------------
Changes (by westonruter):

 * keywords:  has-patch => has-patch commit


Comment:

 Aside, since `xfn` and `classes` are sanitized in the same way, I was
 curious why the fix wasn't also needed for `xfn`. Turns out that
 `wp_setup_nav_menu_item()` ensures the former is an array but the latter
 is not:

 {{{#!php
 $menu_item->classes = ! isset( $menu_item->classes ) ? (array)
 get_post_meta( $menu_item->ID, '_menu_item_classes', true ) :
 $menu_item->classes;
 $menu_item->xfn = ! isset( $menu_item->xfn ) ? get_post_meta(
 $menu_item->ID, '_menu_item_xfn', true ) : $menu_item->xfn;
 }}}

 And also in `wp_update_nav_menu_item()`, it stores `classes` in postmeta
 as an array, but `xfn` is stored as a string:

 {{{#!php
 $args['menu-item-classes'] = array_map( 'sanitize_html_class', explode( '
 ', $args['menu-item-classes'] ) );
 $args['menu-item-xfn'] = implode( ' ', array_map( 'sanitize_html_class',
 explode( ' ', $args['menu-item-xfn'] ) ) );
 }}}

 Alas.

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


More information about the wp-trac mailing list