<!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">                                 &lt;p class=&quot;field-css-classes description description-thin&quot;&gt;
</span><span class="cx">                                         &lt;label for=&quot;edit-menu-item-classes-&lt;?php echo $item_id; ?&gt;&quot;&gt;
</span><span class="cx">                                                 &lt;?php _e( 'CSS Classes (optional)' ); ?&gt;&lt;br /&gt;
</span><del>-                                                &lt;input type=&quot;text&quot; id=&quot;edit-menu-item-classes-&lt;?php echo $item_id; ?&gt;&quot; class=&quot;widefat code edit-menu-item-classes&quot; name=&quot;menu-item-classes[&lt;?php echo $item_id; ?&gt;]&quot; value=&quot;&lt;?php echo esc_attr( $item-&gt;classes ); ?&gt;&quot; /&gt;
</del><ins>+                                                &lt;input type=&quot;text&quot; id=&quot;edit-menu-item-classes-&lt;?php echo $item_id; ?&gt;&quot; class=&quot;widefat code edit-menu-item-classes&quot; name=&quot;menu-item-classes[&lt;?php echo $item_id; ?&gt;]&quot; value=&quot;&lt;?php echo esc_attr( implode(' ', $item-&gt;classes ) ); ?&gt;&quot; /&gt;
</ins><span class="cx">                                         &lt;/label&gt;
</span><span class="cx">                                 &lt;/p&gt;
</span><span class="cx">                                 &lt;p class=&quot;field-xfn description description-thin&quot;&gt;
</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-&gt;type );
</span><span class="cx">                 if ( !empty($item-&gt;classes) )
</span><del>-                        $classes = array_merge($classes, explode(' ', $item-&gt;classes) );
</del><ins>+                        $classes = array_merge( $classes, $item-&gt;classes );
</ins><span class="cx"> 
</span><span class="cx">                 if ( 'custom' != $item-&gt;type ) {
</span><span class="cx">                         $classes[] = 'menu-item-object-' . $item-&gt;object;
</span><span class="lines">@@ -170,7 +170,7 @@
</span><span class="cx">                 $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-target&quot; name=&quot;menu-item[' . $possible_object_id . '][menu-item-target]&quot; value=&quot;'. esc_attr( $item-&gt;target ) .'&quot; /&gt;';
</span><span class="cx">                 $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-attr_title&quot; name=&quot;menu-item[' . $possible_object_id . '][menu-item-attr_title]&quot; value=&quot;'. esc_attr( $item-&gt;attr_title ) .'&quot; /&gt;';
</span><span class="cx">                 $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-description&quot; name=&quot;menu-item[' . $possible_object_id . '][menu-item-description]&quot; value=&quot;'. esc_attr( $item-&gt;description ) .'&quot; /&gt;';
</span><del>-                $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-classes&quot; name=&quot;menu-item[' . $possible_object_id . '][menu-item-classes]&quot; value=&quot;'. esc_attr( $item-&gt;classes ) .'&quot; /&gt;';
</del><ins>+                $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-classes&quot; name=&quot;menu-item[' . $possible_object_id . '][menu-item-classes]&quot; value=&quot;'. esc_attr( implode( ' ', $item-&gt;classes ) ) .'&quot; /&gt;';
</ins><span class="cx">                 $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-xfn&quot; name=&quot;menu-item[' . $possible_object_id . '][menu-item-xfn]&quot; value=&quot;'. esc_attr( $item-&gt;xfn ) .'&quot; /&gt;';
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -338,7 +338,7 @@
</span><span class="cx">                                 ( 'taxonomy' == $menu_item-&gt;type &amp;&amp; ( $wp_query-&gt;is_category || $wp_query-&gt;is_tag || $wp_query-&gt;is_tax ) )
</span><span class="cx">                         )
</span><span class="cx">                 ) {
</span><del>-                        $menu_items[$key]-&gt;classes = trim( $menu_items[$key]-&gt;classes . ' ' . 'current-menu-item' );
</del><ins>+                        $menu_items[$key]-&gt;classes[] = 'current-menu-item';
</ins><span class="cx">                         $active_parent_item_ids[] = (int) $menu_item-&gt;menu_item_parent;
</span><span class="cx">                         $active_parent_object_ids[] = (int) $menu_item-&gt;post_parent;
</span><span class="cx">                         $active_object = $menu_item-&gt;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-&gt;url, '#' ) ? substr( $menu_item-&gt;url, 0, strpos( $menu_item-&gt;url, '#' ) ) : $menu_item-&gt;url;
</span><span class="cx">                         if ( $item_url == $current_url ) {
</span><del>-                                $menu_items[$key]-&gt;classes = trim( $menu_item-&gt;classes . ' ' . 'current-menu-item' );
</del><ins>+                                $menu_items[$key]-&gt;classes[] = 'current-menu-item';
</ins><span class="cx">                                 if ( untrailingslashit($current_url) == home_url() )
</span><del>-                                        $menu_items[$key]-&gt;classes .= ' menu-item-home';
</del><ins>+                                        $menu_items[$key]-&gt;classes[] = 'menu-item-home';
</ins><span class="cx">                                 $active_parent_item_ids[] = (int) $menu_item-&gt;menu_item_parent;
</span><span class="cx">                                 $active_parent_object_ids[] = (int) $menu_item-&gt;post_parent;
</span><span class="cx">                                 $active_object = $menu_item-&gt;object;
</span><span class="lines">@@ -359,7 +359,7 @@
</span><span class="cx">                 
</span><span class="cx">                 // back-compat with wp_page_menu: add &quot;current_page_parent&quot; to static home page link for any non-page query
</span><span class="cx">                 if ( ! empty( $home_page_id ) &amp;&amp; 'post_type' == $menu_item-&gt;type &amp;&amp; empty( $wp_query-&gt;is_page ) &amp;&amp; $home_page_id == $menu_item-&gt;object_id ) 
</span><del>-                        $menu_items[$key]-&gt;classes = trim( $menu_items[$key]-&gt;classes . ' ' . 'current_page_parent' );
</del><ins>+                        $menu_items[$key]-&gt;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-&gt;post_type ) &amp;&amp;
</span><span class="cx">                         in_array( $parent_item-&gt;object_id, $queried_object-&gt;ancestors )
</span><span class="cx">                 )
</span><del>-                        $menu_items[$key]-&gt;classes = trim( $parent_item-&gt;classes . ' ' . 'current-' . $queried_object-&gt;post_type . '-ancestor current-menu-ancestor' );
</del><ins>+                        $menu_items[$key]-&gt;classes[] = 'current-' . $queried_object-&gt;post_type . '-ancestor current-menu-ancestor';
</ins><span class="cx">                 if ( in_array( $parent_item-&gt;db_id, $active_parent_item_ids ) )
</span><del>-                        $menu_items[$key]-&gt;classes = trim( $parent_item-&gt;classes . ' ' . 'current-menu-parent' );
</del><ins>+                        $menu_items[$key]-&gt;classes[] = 'current-menu-parent';
</ins><span class="cx">                 if ( in_array( $parent_item-&gt;object_id, $active_parent_object_ids ) )
</span><del>-                        $menu_items[$key]-&gt;classes = trim( $parent_item-&gt;classes . ' ' . 'current-' . $active_object . '-parent' );
</del><ins>+                        $menu_items[$key]-&gt;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-&gt;attr_title = apply_filters( 'nav_menu_attr_title', $menu_item-&gt;post_excerpt );
</span><span class="cx">                         $menu_item-&gt;description = apply_filters( 'nav_menu_description', $menu_item-&gt;post_content );
</span><span class="cx"> 
</span><del>-                        $menu_item-&gt;classes = get_post_meta( $menu_item-&gt;ID, '_menu_item_classes', true );
</del><ins>+                        $menu_item-&gt;classes = (array) get_post_meta( $menu_item-&gt;ID, '_menu_item_classes', true );
</ins><span class="cx">                         $menu_item-&gt;xfn = get_post_meta( $menu_item-&gt;ID, '_menu_item_xfn', true );
</span><span class="cx">                 } else {
</span><span class="cx">                         $menu_item-&gt;db_id = 0;
</span><span class="lines">@@ -598,7 +597,7 @@
</span><span class="cx"> 
</span><span class="cx">                         $menu_item-&gt;attr_title = apply_filters( 'nav_menu_attr_title', $menu_item-&gt;post_excerpt );
</span><span class="cx">                         $menu_item-&gt;description = apply_filters( 'nav_menu_description', $menu_item-&gt;post_content );
</span><del>-                        $menu_item-&gt;classes = '';
</del><ins>+                        $menu_item-&gt;classes = array();
</ins><span class="cx">                         $menu_item-&gt;xfn = '';
</span><span class="cx">                 }
</span><span class="cx">         } elseif ( isset( $menu_item-&gt;taxonomy ) ) {
</span><span class="lines">@@ -618,7 +617,7 @@
</span><span class="cx">                 $menu_item-&gt;target = '';
</span><span class="cx">                 $menu_item-&gt;attr_title = '';
</span><span class="cx">                 $menu_item-&gt;description = get_term_field( 'description', $menu_item-&gt;term_id, $menu_item-&gt;taxonomy );
</span><del>-                $menu_item-&gt;classes = '';
</del><ins>+                $menu_item-&gt;classes = array();
</ins><span class="cx">                 $menu_item-&gt;xfn = '';
</span><span class="cx"> 
</span><span class="cx">         }
</span></span></pre>
</div>
</div>

</body>
</html>