<!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>[13685] trunk: Always use lowercase strings or menu type.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13685">13685</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-03-12 21:57:52 +0000 (Fri, 12 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Always use lowercase strings or menu type. Don't double save custom link menu items (remove the AJAX save). see <a href="http://trac.wordpress.org/ticket/12566">#12566</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminadminajaxphp">trunk/wp-admin/admin-ajax.php</a></li>
<li><a href="#trunkwpadminjsnavmenudefaultitemsdevjs">trunk/wp-admin/js/nav-menu-default-items.dev.js</a></li>
<li><a href="#trunkwpadminjsnavmenudefaultitemsjs">trunk/wp-admin/js/nav-menu-default-items.js</a></li>
<li><a href="#trunkwpadminnavmenusphp">trunk/wp-admin/nav-menus.php</a></li>
<li><a href="#trunkwpincludesnavmenutemplatephp">trunk/wp-includes/nav-menu-template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminadminajaxphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/admin-ajax.php (13684 => 13685)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/admin-ajax.php        2010-03-12 19:32:48 UTC (rev 13684)
+++ trunk/wp-admin/admin-ajax.php        2010-03-12 21:57:52 UTC (rev 13685)
</span><span class="lines">@@ -477,26 +477,6 @@
</span><span class="cx">         _wp_ajax_delete_comment_response( $comment-&gt;comment_ID );
</span><span class="cx">         die( '0' );
</span><span class="cx">         break;
</span><del>-case 'add-menu-link':
-        if ( !current_user_can( 'manage_links' ) )
-                die('-1');
-        
-        $link_url = isset($_POST['link_url']) ? $_POST['link_url'] : false;        
-        $link_name = isset($_POST['link_name']) ? $_POST['link_name'] : false;
-        
-        if ( !$link_url || !$link_name )
-                die('-1');
-        
-        $post = array( 'post_type' =&gt; 'nav_menu_item', 'post_title' =&gt; $link_name, 'ping_status' =&gt; false, 'post_excerpt' =&gt; '', 'post_content' =&gt; '' );
-        $db_id = wp_insert_post( $post );
-
-        update_post_meta( $db_id, 'menu_type', 'custom' );
-        update_post_meta( $db_id, 'object_id', '' );
-        update_post_meta( $db_id, 'menu_new_window', 0 );
-        update_post_meta( $db_id, 'menu_link', esc_url_raw( $link_url ) );
-        
-        echo $db_id;
-        break;
</del><span class="cx"> case 'add-link-category' : // On the Fly
</span><span class="cx">         check_ajax_referer( $action );
</span><span class="cx">         if ( !current_user_can( 'manage_categories' ) )
</span></span></pre></div>
<a id="trunkwpadminjsnavmenudefaultitemsdevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/nav-menu-default-items.dev.js (13684 => 13685)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/nav-menu-default-items.dev.js        2010-03-12 19:32:48 UTC (rev 13684)
+++ trunk/wp-admin/js/nav-menu-default-items.dev.js        2010-03-12 21:57:52 UTC (rev 13685)
</span><span class="lines">@@ -76,10 +76,10 @@
</span><span class="cx">                 $(this).hide();
</span><span class="cx">                 $(this).siblings('.show-all').show();
</span><span class="cx">         });
</span><del>-        
</del><ins>+
</ins><span class="cx">         // Add menu item to queue
</span><span class="cx">         $('.list input').click(function(){
</span><del>-                
</del><ins>+
</ins><span class="cx">                 var item_type = jQuery(this).parent().siblings('.item-type').val();
</span><span class="cx">                 var item_title = jQuery(this).parent().siblings('.item-title').val();
</span><span class="cx">                 var item_url = jQuery(this).parent().siblings('.item-url').val();
</span><span class="lines">@@ -89,12 +89,12 @@
</span><span class="cx">                 
</span><span class="cx">                 return wp_update_queue( $(this), item_type, item_title, item_url, item_id, item_parent_id, item_description );
</span><span class="cx">         });
</span><del>-        
</del><ins>+
</ins><span class="cx">         // Add queued menu items into the menu
</span><span class="cx">         $('.enqueue a').click(function(){
</span><span class="cx">                 return wp_add_queued_items_to_menu(this);
</span><span class="cx">         });
</span><del>-        
</del><ins>+
</ins><span class="cx">         // Create the link, add it to the menu + available links section
</span><span class="cx">         $('#add-custom-link .add-to-menu a').click(function(){
</span><span class="cx">                 var link_url = $(this).offsetParent().find('#menu-item-url').val();
</span><span class="lines">@@ -105,26 +105,8 @@
</span><span class="cx">                 // Don't save the link if it was left with it's default settings
</span><span class="cx">                 if ( 'http://' == link_url || 'Menu Item' == link_name )
</span><span class="cx">                         return;
</span><del>-                
-                // Parameters to send off
-                params = {
-                        action: 'add-menu-link',
-                        link_url: link_url,
-                        link_name: link_name,
-                };
-                
-                // save the link
-                $.post( ajaxurl, params, function(response) {
-                        if ( null == response || '-1' == response )
-                                return false;
-                        
-                        params.link_id = response;
-                        
-                        // add it to the available links section
-                        // wp_update_links_list( params );
-                        
-                        // and update the Menu with the new link
-                        wp_add_item_to_menu( 'Custom', params.link_name, params.link_url, params.link_id, 0, '' );
-                }, 'json');
</del><ins>+
+                // and update the Menu with the new link
+                wp_add_item_to_menu( 'custom', link_name, link_url, 0, 0, '' );
</ins><span class="cx">         });
</span><span class="cx"> });
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpadminjsnavmenudefaultitemsjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/nav-menu-default-items.js (13684 => 13685)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/nav-menu-default-items.js        2010-03-12 19:32:48 UTC (rev 13684)
+++ trunk/wp-admin/js/nav-menu-default-items.js        2010-03-12 21:57:52 UTC (rev 13685)
</span><span class="lines">@@ -1 +1 @@
</span><del>-jQuery(document).ready(function(a){wp_drag_and_drop();wp_update_post_data();a(&quot;#save_menu&quot;).click(function(){return wp_update_post_data()});a(&quot;.quick-search&quot;).click(function(){a(this).attr(&quot;value&quot;,&quot;&quot;)});a(&quot;.quick-search-submit&quot;).click(function(){a(this).siblings(&quot;.quick-search&quot;).search()});a(&quot;#menu-container .item-edit&quot;).click(function(){return wp_edit_menu_item(a(this).attr(&quot;value&quot;))});a(&quot;#menu-container .item-delete&quot;).live(&quot;click&quot;,function(){return wp_remove_menu_item(a(this).attr(&quot;value&quot;))});a(&quot;#update-menu-item&quot;).click(function(){wp_update_menu_item();tb_remove();var b=a(&quot;#edit-item-id&quot;).val();a(&quot;#menu-&quot;+b+&quot; dt:first&quot;).animate({backgroundColor:&quot;#FFFF33&quot;},{duration:&quot;normal&quot;,complete:function(){jQuery(this).css(&quot;backgroundColor&quot;,&quot;&quot;)}})});a(&quot;#cancel-save&quot;).click(function(){return tb_remove()});a(&quot;.show-all&quot;).click(function(){a(this).offsetParent().find(&quot;#add-buttons-actions&quot;).attr(&quot;style&quot;,&quot;margin-bottom: 10px;&quot;);a(this).offsetParent().find(&quot;.list-wrap&quot;).css(&quot;display&quot;,&quot;block&quot;);a(this).siblings(&quot;.quick-search&quot;).attr(&quot;value&quot;,&quot;&quot;);a(this).offsetParent().find(&quot;.list-wrap li&quot;).css(&quot;display&quot;,&quot;block&quot;);a(this).hide();a(this).siblings(&quot;.hide-all&quot;).show()});a(&quot;.hide-all&quot;).click(function(){a(this).offsetParent().find(&quot;#add-buttons-actions&quot;).attr(&quot;style&quot;,&quot;margin-bottom: 0px;&quot;);a(this).offsetParent().find(&quot;.list-wrap&quot;).css(&quot;display&quot;,&quot;none&quot;);a(this).siblings(&quot;.quick-search&quot;).attr(&quot;value&quot;,&quot;Search&quot;);a(this).offsetParent().find(&quot;.list-wrap li&quot;).css(&quot;display&quot;,&quot;none&quot;);a(this).hide();a(this).siblings(&quot;.show-all&quot;).show()});a(&quot;.list input&quot;).click(function(){var d=jQuery(this).parent().siblings(&quot;.item-type&quot;).val();var g=jQuery(this).parent().siblings(&quot;.item-title&quot;).val();var c=jQuery(this).parent().siblings(&quot;.item-url&quot;).val();var e=jQuery(this).parent().siblings(&quot;.item-dbid&quot;).val();var b=jQuery(this).parent().siblings(&quot;.item-parent&quot;).val();var f=jQuery(this).parent().siblings(&quot;.item-description&quot;).val();return wp_update_queue(a(this),d,g,c,e,b,f)});a(&quot;.enqueue a&quot;).click(function(){return wp_add_queued_items_to_menu(this)});a(&quot;#add-custom-link .add-to-menu a&quot;).click(function(){var b=a(this).offsetParent().find(&quot;#menu-item-url&quot;).val();var c=a(this).offsetParent().find(&quot;#menu-item-name&quot;).val();wp_add_queued_items_to_menu(this);if(&quot;http://&quot;==b||&quot;Menu Item&quot;==c){return}params={action:&quot;add-menu-link&quot;,link_url:b,link_name:c,};a.post(ajaxurl,params,function(d){if(null==d||&quot;-1&quot;==d){return false}params.link_id=d;wp_add_item_to_menu(&quot;Custom&quot;,params.link_name,params.link_url,params.link_id,0,&quot;&quot;)},&quot;json&quot;)})});
</del><span class="cx">\ No newline at end of file
</span><ins>+jQuery(document).ready(function(a){wp_drag_and_drop();wp_update_post_data();a(&quot;#save_menu&quot;).click(function(){return wp_update_post_data()});a(&quot;.quick-search&quot;).click(function(){a(this).attr(&quot;value&quot;,&quot;&quot;)});a(&quot;.quick-search-submit&quot;).click(function(){a(this).siblings(&quot;.quick-search&quot;).search()});a(&quot;#menu-container .item-edit&quot;).click(function(){return wp_edit_menu_item(a(this).attr(&quot;value&quot;))});a(&quot;#menu-container .item-delete&quot;).live(&quot;click&quot;,function(){return wp_remove_menu_item(a(this).attr(&quot;value&quot;))});a(&quot;#update-menu-item&quot;).click(function(){wp_update_menu_item();tb_remove();var b=a(&quot;#edit-item-id&quot;).val();a(&quot;#menu-&quot;+b+&quot; dt:first&quot;).animate({backgroundColor:&quot;#FFFF33&quot;},{duration:&quot;normal&quot;,complete:function(){jQuery(this).css(&quot;backgroundColor&quot;,&quot;&quot;)}})});a(&quot;#cancel-save&quot;).click(function(){return tb_remove()});a(&quot;.show-all&quot;).click(function(){a(this).offsetParent().find(&quot;#add-buttons-actions&quot;).attr(&quot;style&quot;,&quot;margin-bottom: 10px;&quot;);a(this).offsetParent().find(&quot;.list-wrap&quot;).css(&quot;display&quot;,&quot;block&quot;);a(this).siblings(&quot;.quick-search&quot;).attr(&quot;value&quot;,&quot;&quot;);a(this).offsetParent().find(&quot;.list-wrap li&quot;).css(&quot;display&quot;,&quot;block&quot;);a(this).hide();a(this).siblings(&quot;.hide-all&quot;).show()});a(&quot;.hide-all&quot;).click(function(){a(this).offsetParent().find(&quot;#add-buttons-actions&quot;).attr(&quot;style&quot;,&quot;margin-bottom: 0px;&quot;);a(this).offsetParent().find(&quot;.list-wrap&quot;).css(&quot;display&quot;,&quot;none&quot;);a(this).siblings(&quot;.quick-search&quot;).attr(&quot;value&quot;,&quot;Search&quot;);a(this).offsetParent().find(&quot;.list-wrap li&quot;).css(&quot;display&quot;,&quot;none&quot;);a(this).hide();a(this).siblings(&quot;.show-all&quot;).show()});a(&quot;.list input&quot;).click(function(){var d=jQuery(this).parent().siblings(&quot;.item-type&quot;).val();var g=jQuery(this).parent().siblings(&quot;.item-title&quot;).val();var c=jQuery(this).parent().siblings(&quot;.item-url&quot;).val();var e=jQuery(this).parent().siblings(&quot;.item-dbid&quot;).val();var b=jQuery(this).parent().siblings(&quot;.item-parent&quot;).val();var f=jQuery(this).parent().siblings(&quot;.item-description&quot;).val();return wp_update_queue(a(this),d,g,c,e,b,f)});a(&quot;.enqueue a&quot;).click(function(){return wp_add_queued_items_to_menu(this)});a(&quot;#add-custom-link .add-to-menu a&quot;).click(function(){var b=a(this).offsetParent().find(&quot;#menu-item-url&quot;).val();var c=a(this).offsetParent().find(&quot;#menu-item-name&quot;).val();wp_add_queued_items_to_menu(this);if(&quot;http://&quot;==b||&quot;Menu Item&quot;==c){return}wp_add_item_to_menu(&quot;custom&quot;,c,b,0,0,&quot;&quot;)})});
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpadminnavmenusphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/nav-menus.php (13684 => 13685)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/nav-menus.php        2010-03-12 19:32:48 UTC (rev 13684)
+++ trunk/wp-admin/nav-menus.php        2010-03-12 21:57:52 UTC (rev 13685)
</span><span class="lines">@@ -128,7 +128,7 @@
</span><span class="cx">                 $object_id = isset( $_POST['item-postmenu'.$k] )? $_POST['item-postmenu'.$k] : 0;
</span><span class="cx">                 $parent_id = isset( $_POST['item-parent'.$k] )? $_POST['item-parent'.$k] : 0;
</span><span class="cx">                 $custom_title = isset( $_POST['item-title'.$k] )?  $_POST['item-title'.$k] : '';
</span><del>-                $custom_linkurl = ( isset( $_POST['item-url'.$k] ) &amp;&amp; 'custom' == $_POST['linktype'.$k] ) ? $_POST['item-url'.$k] : '';
</del><ins>+                $custom_linkurl = ( isset( $_POST['item-url'.$k] ) &amp;&amp; 'custom' == $_POST['item-type'.$k] ) ? $_POST['item-url'.$k] : '';
</ins><span class="cx">                 $custom_description = isset( $_POST['item-description'.$k] )? $_POST['item-description'.$k] : '';
</span><span class="cx"> 
</span><span class="cx">                 // doesn't seem to be used by UI
</span></span></pre></div>
<a id="trunkwpincludesnavmenutemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/nav-menu-template.php (13684 => 13685)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/nav-menu-template.php        2010-03-12 19:32:48 UTC (rev 13684)
+++ trunk/wp-includes/nav-menu-template.php        2010-03-12 21:57:52 UTC (rev 13685)
</span><span class="lines">@@ -198,7 +198,7 @@
</span><span class="cx">                         $item .= '&lt;label class=&quot;item-title&quot;&gt;&lt;input type=&quot;checkbox&quot; id=&quot;'. esc_attr($menu_id) .'&quot; name=&quot;'. esc_attr( $menu_item-&gt;title ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;link ) .'&quot; /&gt;'. $menu_item-&gt;title .'&lt;/label&gt;';
</span><span class="cx">                         
</span><span class="cx">                         // Menu Item Settings
</span><del>-                        $item .= '&lt;input type=&quot;hidden&quot; class=&quot;item-type&quot; value=&quot;'. esc_attr( $menu_item-&gt;append ) .'&quot; /&gt;';
</del><ins>+                        $item .= '&lt;input type=&quot;hidden&quot; class=&quot;item-type&quot; value=&quot;'. esc_attr( $menu_item-&gt;type ) .'&quot; /&gt;';
</ins><span class="cx">                         $item .= '&lt;input type=&quot;hidden&quot; class=&quot;item-title&quot; value=&quot;'. esc_attr( $menu_item-&gt;title ) .'&quot; /&gt;';
</span><span class="cx">                         $item .= '&lt;input type=&quot;hidden&quot; class=&quot;item-url&quot; value=&quot;'. esc_attr( $menu_item-&gt;link ) .'&quot; /&gt;';
</span><span class="cx">                         $item .= '&lt;input type=&quot;hidden&quot; class=&quot;item-dbid&quot; value=&quot;'. esc_attr( $menu_item-&gt;ID ) .'&quot; /&gt;';
</span></span></pre>
</div>
</div>

</body>
</html>