<!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>[13397] trunk: Use custom fields for custom URL and new window data.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13397">13397</a></dd>
<dt>Author</dt> <dd>markjaquith</dd>
<dt>Date</dt> <dd>2010-02-25 08:48:17 +0000 (Thu, 25 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use custom fields for custom URL and new window data. Links no longer automatically open in a new window. see <a href="http://trac.wordpress.org/ticket/11817">#11817</a></pre>

<h3>Modified Paths</h3>
<ul>
<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>
<li><a href="#trunkwpincludesnavmenuphp">trunk/wp-includes/nav-menu.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminnavmenusphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/nav-menus.php (13396 => 13397)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/nav-menus.php        2010-02-25 07:56:25 UTC (rev 13396)
+++ trunk/wp-admin/nav-menus.php        2010-02-25 08:48:17 UTC (rev 13397)
</span><span class="lines">@@ -117,15 +117,18 @@
</span><span class="cx"> 
</span><span class="cx">                 $post = array( 'post_status' =&gt; 'publish', 'post_type' =&gt; 'nav_menu_item', 'post_author' =&gt; $user_ID,
</span><span class="cx">                         'ping_status' =&gt; 0, 'post_parent' =&gt; 0, 'menu_order' =&gt; $position,
</span><del>-                        'guid' =&gt; $custom_linkurl, 'post_excerpt' =&gt; $custom_anchor_title, 'tax_input' =&gt; array( 'nav_menu' =&gt; $menu_title ),
</del><ins>+                        'post_excerpt' =&gt; $custom_anchor_title, 'tax_input' =&gt; array( 'nav_menu' =&gt; $menu_title ),
</ins><span class="cx">                         'post_content' =&gt; $custom_description, 'post_title' =&gt; $custom_title );
</span><span class="cx">                 if ( $new_window )
</span><del>-                        $post['post_content_filtered'] = '_blank';
</del><ins>+                        update_post_meta( $db_id, 'menu_new_window', 1 );
</ins><span class="cx">                 else
</span><del>-                        $post['post_content_filtered'] = '';
</del><ins>+                        update_post_meta( $db_id, 'menu_new_window', 0 );
</ins><span class="cx">                 if ( $parent_id &gt; 0 &amp;&amp; isset( $parent_menu_ids[$parent_id] ) )
</span><span class="cx">                         $post['post_parent'] = $parent_menu_ids[$parent_id];
</span><span class="cx"> 
</span><ins>+                if ( $custom_linkurl )
+                        update_post_meta( $db_id, 'menu_link', esc_url_raw( $custom_linkurl ) );
+
</ins><span class="cx">                 // New menu item
</span><span class="cx">                 if ( $db_id == 0 ) {
</span><span class="cx">                         $db_id = wp_insert_post( $post );
</span></span></pre></div>
<a id="trunkwpincludesnavmenutemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/nav-menu-template.php (13396 => 13397)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/nav-menu-template.php        2010-02-25 07:56:25 UTC (rev 13396)
+++ trunk/wp-includes/nav-menu-template.php        2010-02-25 08:48:17 UTC (rev 13397)
</span><span class="lines">@@ -116,7 +116,7 @@
</span><span class="cx">                                                 &lt;input type=&quot;hidden&quot; name=&quot;position&lt;?php echo esc_attr( $menu_item-&gt;menu_order ); ?&gt;&quot; id=&quot;position&lt;?php echo esc_attr( $menu_item-&gt;menu_order ); ?&gt;&quot; value=&quot;&lt;?php echo esc_attr( $menu_item-&gt;menu_order ); ?&gt;&quot; /&gt;
</span><span class="cx">                                                 &lt;input type=&quot;hidden&quot; name=&quot;linktype&lt;?php echo esc_attr( $menu_item-&gt;menu_order ); ?&gt;&quot; id=&quot;linktype&lt;?php echo esc_attr( $menu_item-&gt;menu_order ); ?&gt;&quot; value=&quot;&lt;?php echo esc_attr( get_post_meta( $menu_item-&gt;ID, 'menu_type', true ) ); ?&gt;&quot; /&gt;
</span><span class="cx">                                                 &lt;input type=&quot;hidden&quot; name=&quot;anchortitle&lt;?php echo esc_attr( $menu_item-&gt;menu_order ); ?&gt;&quot; id=&quot;anchortitle&lt;?php echo esc_attr( $menu_item-&gt;menu_order ); ?&gt;&quot; value=&quot;&lt;?php echo esc_attr( $menu_item-&gt;post_excerpt ); ?&gt;&quot; /&gt;
</span><del>-                                                &lt;input type=&quot;hidden&quot; name=&quot;newwindow&lt;?php echo esc_attr( $menu_item-&gt;menu_order ); ?&gt;&quot; id=&quot;newwindow&lt;?php echo esc_attr( $menu_item-&gt;menu_order ); ?&gt;&quot; value=&quot;&lt;?php echo ( '' == $menu_item-&gt;post_content_filtered ? '0' : '1' ); ?&gt;&quot; /&gt;
</del><ins>+                                                &lt;input type=&quot;hidden&quot; name=&quot;newwindow&lt;?php echo esc_attr( $menu_item-&gt;menu_order ); ?&gt;&quot; id=&quot;newwindow&lt;?php echo esc_attr( $menu_item-&gt;menu_order ); ?&gt;&quot; value=&quot;&lt;?php echo ( get_post_meta( $menu_item-&gt;ID, 'menu_new_window', true ) ? '1' : '0' ); ?&gt;&quot; /&gt;
</ins><span class="cx"> &lt;?php
</span><span class="cx">                 break;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludesnavmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/nav-menu.php (13396 => 13397)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/nav-menu.php        2010-02-25 07:56:25 UTC (rev 13396)
+++ trunk/wp-includes/nav-menu.php        2010-02-25 08:48:17 UTC (rev 13397)
</span><span class="lines">@@ -74,6 +74,7 @@
</span><span class="cx">         if ( 'item' == $type ) {
</span><span class="cx">                 $menu_item-&gt;type = get_post_meta($menu_item-&gt;ID, 'menu_type', true);
</span><span class="cx">                 $menu_item-&gt;object_id = get_post_meta($menu_item-&gt;ID, 'object_id', true);
</span><ins>+                $menu_item-&gt;target = ( get_post_meta( $menu_item-&gt;ID, 'menu_new_window', true ) ) ? 'target=&quot;_blank&quot;' : '';
</ins><span class="cx">                 if ( isset( $parent_menu_order[ $menu_item-&gt;post_parent ] ) )
</span><span class="cx">                         $menu_item-&gt;parent_item = $parent_menu_order[ $menu_item-&gt;post_parent ];
</span><span class="cx">                 else
</span><span class="lines">@@ -92,8 +93,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         switch ( $menu_item-&gt;type ) {
</span><del>-                // Page Menu Item
-                case 'page':
</del><ins>+                case 'page' :
</ins><span class="cx">                         $menu_item-&gt;link = get_page_link( $menu_item-&gt;object_id );
</span><span class="cx"> 
</span><span class="cx">                         if ( $menu_item-&gt;post_title == '' )
</span><span class="lines">@@ -105,11 +105,9 @@
</span><span class="cx">                                 $menu_item-&gt;description = get_post_meta( $menu_item-&gt;ID, 'page-description', true );
</span><span class="cx">                         else
</span><span class="cx">                                 $menu_item-&gt;description = $menu_item-&gt;post_content;
</span><del>-                        $menu_item-&gt;target = '';
</del><span class="cx">                         $menu_item-&gt;append = _x('Page', 'menu nav item type');
</span><del>-                break;
-                // Category Menu Item
-                case 'category':
</del><ins>+                        break;
+                case 'category' :
</ins><span class="cx">                         $menu_item-&gt;link = get_category_link( $menu_item-&gt;object_id );
</span><span class="cx"> 
</span><span class="cx">                         if ( empty($menu_item-&gt;post_title) ) {
</span><span class="lines">@@ -123,17 +121,15 @@
</span><span class="cx">                                 $menu_item-&gt;description = strip_tags( category_description( $menu_item-&gt;object_id ) );
</span><span class="cx">                         else
</span><span class="cx">                                 $menu_item-&gt;description = $menu_item-&gt;post_content;
</span><del>-                        $menu_item-&gt;target = '';
</del><span class="cx">                         $menu_item-&gt;append = _x('Category', 'menu nav item type');
</span><del>-                break;
-                default:
-                        // Custom Menu Item
-                        $menu_item-&gt;link = $menu_item-&gt;guid;
</del><ins>+                        break;
+                case 'custom' :
+                default :
+                        $menu_item-&gt;link = esc_url_raw( get_post_meta( $menu_item-&gt;ID, 'menu_link', true ) );
</ins><span class="cx">                         $menu_item-&gt;title =  $menu_item-&gt;post_title;
</span><span class="cx">                         $menu_item-&gt;description = $menu_item-&gt;post_content;
</span><del>-                        $menu_item-&gt;target = 'target=&quot;_blank&quot;';
</del><span class="cx">                         $menu_item-&gt;append = _x('Custom', 'menu nav item type');
</span><del>-                break;
</del><ins>+                        break;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         $menu_item-&gt;li_class = '';
</span></span></pre>
</div>
</div>

</body>
</html>