<!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' => 'publish', 'post_type' => 'nav_menu_item', 'post_author' => $user_ID,
</span><span class="cx">                         'ping_status' => 0, 'post_parent' => 0, 'menu_order' => $position,
</span><del>-                        'guid' => $custom_linkurl, 'post_excerpt' => $custom_anchor_title, 'tax_input' => array( 'nav_menu' => $menu_title ),
</del><ins>+                        'post_excerpt' => $custom_anchor_title, 'tax_input' => array( 'nav_menu' => $menu_title ),
</ins><span class="cx">                         'post_content' => $custom_description, 'post_title' => $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 > 0 && 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">                                                 <input type="hidden" name="position<?php echo esc_attr( $menu_item->menu_order ); ?>" id="position<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->menu_order ); ?>" />
</span><span class="cx">                                                 <input type="hidden" name="linktype<?php echo esc_attr( $menu_item->menu_order ); ?>" id="linktype<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( get_post_meta( $menu_item->ID, 'menu_type', true ) ); ?>" />
</span><span class="cx">                                                 <input type="hidden" name="anchortitle<?php echo esc_attr( $menu_item->menu_order ); ?>" id="anchortitle<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->post_excerpt ); ?>" />
</span><del>-                                                <input type="hidden" name="newwindow<?php echo esc_attr( $menu_item->menu_order ); ?>" id="newwindow<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo ( '' == $menu_item->post_content_filtered ? '0' : '1' ); ?>" />
</del><ins>+                                                <input type="hidden" name="newwindow<?php echo esc_attr( $menu_item->menu_order ); ?>" id="newwindow<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo ( get_post_meta( $menu_item->ID, 'menu_new_window', true ) ? '1' : '0' ); ?>" />
</ins><span class="cx"> <?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->type = get_post_meta($menu_item->ID, 'menu_type', true);
</span><span class="cx">                 $menu_item->object_id = get_post_meta($menu_item->ID, 'object_id', true);
</span><ins>+                $menu_item->target = ( get_post_meta( $menu_item->ID, 'menu_new_window', true ) ) ? 'target="_blank"' : '';
</ins><span class="cx">                 if ( isset( $parent_menu_order[ $menu_item->post_parent ] ) )
</span><span class="cx">                         $menu_item->parent_item = $parent_menu_order[ $menu_item->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->type ) {
</span><del>-                // Page Menu Item
-                case 'page':
</del><ins>+                case 'page' :
</ins><span class="cx">                         $menu_item->link = get_page_link( $menu_item->object_id );
</span><span class="cx">
</span><span class="cx">                         if ( $menu_item->post_title == '' )
</span><span class="lines">@@ -105,11 +105,9 @@
</span><span class="cx">                                 $menu_item->description = get_post_meta( $menu_item->ID, 'page-description', true );
</span><span class="cx">                         else
</span><span class="cx">                                 $menu_item->description = $menu_item->post_content;
</span><del>-                        $menu_item->target = '';
</del><span class="cx">                         $menu_item->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->link = get_category_link( $menu_item->object_id );
</span><span class="cx">
</span><span class="cx">                         if ( empty($menu_item->post_title) ) {
</span><span class="lines">@@ -123,17 +121,15 @@
</span><span class="cx">                                 $menu_item->description = strip_tags( category_description( $menu_item->object_id ) );
</span><span class="cx">                         else
</span><span class="cx">                                 $menu_item->description = $menu_item->post_content;
</span><del>-                        $menu_item->target = '';
</del><span class="cx">                         $menu_item->append = _x('Category', 'menu nav item type');
</span><del>-                break;
-                default:
-                        // Custom Menu Item
-                        $menu_item->link = $menu_item->guid;
</del><ins>+                        break;
+                case 'custom' :
+                default :
+                        $menu_item->link = esc_url_raw( get_post_meta( $menu_item->ID, 'menu_link', true ) );
</ins><span class="cx">                         $menu_item->title = $menu_item->post_title;
</span><span class="cx">                         $menu_item->description = $menu_item->post_content;
</span><del>-                        $menu_item->target = 'target="_blank"';
</del><span class="cx">                         $menu_item->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->li_class = '';
</span></span></pre>
</div>
</div>
</body>
</html>