<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[14944] trunk: Make classes property for menus an array.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/14944">14944</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-05-26 15:41:21 +0000 (Wed, 26 May 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Make classes property for menus an array. Props filosofo. fixes <a href="http://trac.wordpress.org/ticket/13551">#13551</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesnavmenuphp">trunk/wp-admin/includes/nav-menu.php</a></li>
<li><a href="#trunkwpincludesnavmenutemplatephp">trunk/wp-includes/nav-menu-template.php</a></li>
<li><a href="#trunkwpincludesnavmenuphp">trunk/wp-includes/nav-menu.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesnavmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/nav-menu.php (14943 => 14944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/nav-menu.php        2010-05-26 14:49:43 UTC (rev 14943)
+++ trunk/wp-admin/includes/nav-menu.php        2010-05-26 15:41:21 UTC (rev 14944)
</span><span class="lines">@@ -132,7 +132,7 @@
</span><span class="cx">                                 <p class="field-css-classes description description-thin">
</span><span class="cx">                                         <label for="edit-menu-item-classes-<?php echo $item_id; ?>">
</span><span class="cx">                                                 <?php _e( 'CSS Classes (optional)' ); ?><br />
</span><del>-                                                <input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->classes ); ?>" />
</del><ins>+                                                <input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( implode(' ', $item->classes ) ); ?>" />
</ins><span class="cx">                                         </label>
</span><span class="cx">                                 </p>
</span><span class="cx">                                 <p class="field-xfn description description-thin">
</span></span></pre></div>
<a id="trunkwpincludesnavmenutemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/nav-menu-template.php (14943 => 14944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/nav-menu-template.php        2010-05-26 14:49:43 UTC (rev 14943)
+++ trunk/wp-includes/nav-menu-template.php        2010-05-26 15:41:21 UTC (rev 14944)
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx">
</span><span class="cx">                 $classes = array( 'menu-item', 'menu-item-type-' . $item->type );
</span><span class="cx">                 if ( !empty($item->classes) )
</span><del>-                        $classes = array_merge($classes, explode(' ', $item->classes) );
</del><ins>+                        $classes = array_merge( $classes, $item->classes );
</ins><span class="cx">
</span><span class="cx">                 if ( 'custom' != $item->type ) {
</span><span class="cx">                         $classes[] = 'menu-item-object-' . $item->object;
</span><span class="lines">@@ -170,7 +170,7 @@
</span><span class="cx">                 $output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="'. esc_attr( $item->target ) .'" />';
</span><span class="cx">                 $output .= '<input type="hidden" class="menu-item-attr_title" name="menu-item[' . $possible_object_id . '][menu-item-attr_title]" value="'. esc_attr( $item->attr_title ) .'" />';
</span><span class="cx">                 $output .= '<input type="hidden" class="menu-item-description" name="menu-item[' . $possible_object_id . '][menu-item-description]" value="'. esc_attr( $item->description ) .'" />';
</span><del>-                $output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="'. esc_attr( $item->classes ) .'" />';
</del><ins>+                $output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="'. esc_attr( implode( ' ', $item->classes ) ) .'" />';
</ins><span class="cx">                 $output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="'. esc_attr( $item->xfn ) .'" />';
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -338,7 +338,7 @@
</span><span class="cx">                                 ( 'taxonomy' == $menu_item->type && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax ) )
</span><span class="cx">                         )
</span><span class="cx">                 ) {
</span><del>-                        $menu_items[$key]->classes = trim( $menu_items[$key]->classes . ' ' . 'current-menu-item' );
</del><ins>+                        $menu_items[$key]->classes[] = 'current-menu-item';
</ins><span class="cx">                         $active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
</span><span class="cx">                         $active_parent_object_ids[] = (int) $menu_item->post_parent;
</span><span class="cx">                         $active_object = $menu_item->object;
</span><span class="lines">@@ -348,9 +348,9 @@
</span><span class="cx">                         $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
</span><span class="cx">                         $item_url = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url;
</span><span class="cx">                         if ( $item_url == $current_url ) {
</span><del>-                                $menu_items[$key]->classes = trim( $menu_item->classes . ' ' . 'current-menu-item' );
</del><ins>+                                $menu_items[$key]->classes[] = 'current-menu-item';
</ins><span class="cx">                                 if ( untrailingslashit($current_url) == home_url() )
</span><del>-                                        $menu_items[$key]->classes .= ' menu-item-home';
</del><ins>+                                        $menu_items[$key]->classes[] = 'menu-item-home';
</ins><span class="cx">                                 $active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
</span><span class="cx">                                 $active_parent_object_ids[] = (int) $menu_item->post_parent;
</span><span class="cx">                                 $active_object = $menu_item->object;
</span><span class="lines">@@ -359,7 +359,7 @@
</span><span class="cx">                 
</span><span class="cx">                 // back-compat with wp_page_menu: add "current_page_parent" to static home page link for any non-page query
</span><span class="cx">                 if ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id )
</span><del>-                        $menu_items[$key]->classes = trim( $menu_items[$key]->classes . ' ' . 'current_page_parent' );
</del><ins>+                        $menu_items[$key]->classes[] = 'current_page_parent';
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         $active_parent_item_ids = array_filter( array_unique( $active_parent_item_ids ) );
</span><span class="lines">@@ -374,11 +374,11 @@
</span><span class="cx">                         is_post_type_hierarchical( $queried_object->post_type ) &&
</span><span class="cx">                         in_array( $parent_item->object_id, $queried_object->ancestors )
</span><span class="cx">                 )
</span><del>-                        $menu_items[$key]->classes = trim( $parent_item->classes . ' ' . 'current-' . $queried_object->post_type . '-ancestor current-menu-ancestor' );
</del><ins>+                        $menu_items[$key]->classes[] = 'current-' . $queried_object->post_type . '-ancestor current-menu-ancestor';
</ins><span class="cx">                 if ( in_array( $parent_item->db_id, $active_parent_item_ids ) )
</span><del>-                        $menu_items[$key]->classes = trim( $parent_item->classes . ' ' . 'current-menu-parent' );
</del><ins>+                        $menu_items[$key]->classes[] = 'current-menu-parent';
</ins><span class="cx">                 if ( in_array( $parent_item->object_id, $active_parent_object_ids ) )
</span><del>-                        $menu_items[$key]->classes = trim( $parent_item->classes . ' ' . 'current-' . $active_object . '-parent' );
</del><ins>+                        $menu_items[$key]->classes[] = 'current-' . $active_object . '-parent';
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludesnavmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/nav-menu.php (14943 => 14944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/nav-menu.php        2010-05-26 14:49:43 UTC (rev 14943)
+++ trunk/wp-includes/nav-menu.php        2010-05-26 15:41:21 UTC (rev 14944)
</span><span class="lines">@@ -253,7 +253,6 @@
</span><span class="cx"> * @return int The menu item's database ID or WP_Error object on failure.
</span><span class="cx"> */
</span><span class="cx"> function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item_data = array() ) {
</span><del>-
</del><span class="cx">         $menu_id = (int) $menu_id;
</span><span class="cx">         $menu_item_db_id = (int) $menu_item_db_id;
</span><span class="cx">
</span><span class="lines">@@ -370,9 +369,9 @@
</span><span class="cx">                 update_post_meta( $menu_item_db_id, '_menu_item_object_id', (int) $args['menu-item-object-id'] );
</span><span class="cx">                 update_post_meta( $menu_item_db_id, '_menu_item_object', sanitize_key($args['menu-item-object']) );
</span><span class="cx">                 update_post_meta( $menu_item_db_id, '_menu_item_target', sanitize_key($args['menu-item-target']) );
</span><del>-                // @todo sanitize_html_classes()
-                foreach( array( 'menu-item-classes', 'menu-item-xfn') as $arg )
-                        $args[$arg] = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args[$arg] ) ) );
</del><ins>+                
+                $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'] ) ) );
</ins><span class="cx">                 update_post_meta( $menu_item_db_id, '_menu_item_classes', $args['menu-item-classes'] );
</span><span class="cx">                 update_post_meta( $menu_item_db_id, '_menu_item_xfn', $args['menu-item-xfn'] );
</span><span class="cx">
</span><span class="lines">@@ -533,7 +532,7 @@
</span><span class="cx"> * - title:                The title of this menu item.
</span><span class="cx"> * - target:                 The target attribute of the link element for this menu item.
</span><span class="cx"> * - attr_title:        The title attribute of the link element for this menu item.
</span><del>- * - classes:                The class attribute value for the link element of this menu item.
</del><ins>+ * - classes:                The array of class attribute values for the link element of this menu item.
</ins><span class="cx"> * - xfn:                The XFN relationship expressed in the link of this menu item.
</span><span class="cx"> * - description:        The description of this menu item.
</span><span class="cx"> *
</span><span class="lines">@@ -580,7 +579,7 @@
</span><span class="cx">                         $menu_item->attr_title = apply_filters( 'nav_menu_attr_title', $menu_item->post_excerpt );
</span><span class="cx">                         $menu_item->description = apply_filters( 'nav_menu_description', $menu_item->post_content );
</span><span class="cx">
</span><del>-                        $menu_item->classes = get_post_meta( $menu_item->ID, '_menu_item_classes', true );
</del><ins>+                        $menu_item->classes = (array) get_post_meta( $menu_item->ID, '_menu_item_classes', true );
</ins><span class="cx">                         $menu_item->xfn = get_post_meta( $menu_item->ID, '_menu_item_xfn', true );
</span><span class="cx">                 } else {
</span><span class="cx">                         $menu_item->db_id = 0;
</span><span class="lines">@@ -598,7 +597,7 @@
</span><span class="cx">
</span><span class="cx">                         $menu_item->attr_title = apply_filters( 'nav_menu_attr_title', $menu_item->post_excerpt );
</span><span class="cx">                         $menu_item->description = apply_filters( 'nav_menu_description', $menu_item->post_content );
</span><del>-                        $menu_item->classes = '';
</del><ins>+                        $menu_item->classes = array();
</ins><span class="cx">                         $menu_item->xfn = '';
</span><span class="cx">                 }
</span><span class="cx">         } elseif ( isset( $menu_item->taxonomy ) ) {
</span><span class="lines">@@ -618,7 +617,7 @@
</span><span class="cx">                 $menu_item->target = '';
</span><span class="cx">                 $menu_item->attr_title = '';
</span><span class="cx">                 $menu_item->description = get_term_field( 'description', $menu_item->term_id, $menu_item->taxonomy );
</span><del>-                $menu_item->classes = '';
</del><ins>+                $menu_item->classes = array();
</ins><span class="cx">                 $menu_item->xfn = '';
</span><span class="cx">
</span><span class="cx">         }
</span></span></pre>
</div>
</div>
</body>
</html>