<!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>[15254] trunk: Revert [15219], [15250], some of [15249] for 3.0,
revisit in 3.0.1.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/15254">15254</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-06-14 19:52:30 +0000 (Mon, 14 Jun 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Revert <a href="http://trac.wordpress.org/changeset/15219">[15219]</a>, <a href="http://trac.wordpress.org/changeset/15250">[15250]</a>, some of <a href="http://trac.wordpress.org/changeset/15249">[15249]</a> for 3.0, revisit in 3.0.1. see <a href="http://trac.wordpress.org/ticket/13822">#13822</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesnavmenuphp">trunk/wp-admin/includes/nav-menu.php</a></li>
<li><a href="#trunkwpadminnavmenusphp">trunk/wp-admin/nav-menus.php</a></li>
<li><a href="#trunkwpincludesdefaultfiltersphp">trunk/wp-includes/default-filters.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 (15253 => 15254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/nav-menu.php        2010-06-14 19:33:04 UTC (rev 15253)
+++ trunk/wp-admin/includes/nav-menu.php        2010-06-14 19:52:30 UTC (rev 15254)
</span><span class="lines">@@ -71,14 +71,9 @@
</span><span class="cx">                 $title = $item->title;
</span><span class="cx">
</span><span class="cx">                 if ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
</span><del>-                        $original_status = get_post_status_object( $original_object->post_status );
-                        $classes[] = "draft post-status-$original_object->post_status";
-                        /* translators: 1: title of menu item in draft status, 2: actual post status. */
-                        $title = sprintf( __('%1$s (%2$s)'), $item->title, $original_status->label );
-                } elseif ( isset( $item->post_status ) && 'pending' == $item->post_status ) {
-                        $classes[] = 'unsaved';
-                        /* translators: %s: title of menu item in pending status */
-                        $title = sprintf( __('%s (Unsaved)'), $item->title );
</del><ins>+                        $classes[] = 'pending';
+                        /* translators: %s: title of menu item in draft status */
+                        $title = sprintf( __('%s (Pending)'), $item->title );
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 $title = empty( $item->label ) ? $title : $item->label;
</span><span class="lines">@@ -177,27 +172,7 @@
</span><span class="cx">                                 <div class="menu-item-actions description-wide submitbox">
</span><span class="cx">                                         <?php if( 'custom' != $item->type ) : ?>
</span><span class="cx">                                                 <p class="link-to-original">
</span><del>-                                                        <?php
-                                                        $post_status = get_post_status( $item->object_id );
-                                                        if( 'publish' == $post_status ) {
-                                                                printf( __('Original: %s'), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>', '' );
-                                                        } else {
-                                                                $original_url = $item->url;
-                                                                if( 'trash' == $post_status ) {
-                                                                        $original_url = add_query_arg(
-                                                                                array(
-                                                                                        'post_status' => 'trash',
-                                                                                        'post_type' => $item->object,
-                                                                                ),
-                                                                                admin_url( 'edit.php' )
-                                                                        );
-                                                                }
-                                                                $post_status_obj = get_post_status_object( $post_status );
-                                                                /* translators: 1: title, 2: post status. */
-                                                                printf( __('Original: %1$s (%2$s)'), '<a href="' . esc_attr( $original_url ) . '">' . esc_html( $original_title ) . '</a>',
-                                                                $post_status_obj->label );
-                                                        }
-                                                        ?>
</del><ins>+                                                        <?php printf( __('Original: %s'), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?>
</ins><span class="cx">                                                 </p>
</span><span class="cx">                                         <?php endif; ?>
</span><span class="cx">                                         <a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="<?php
</span><span class="lines">@@ -219,7 +194,6 @@
</span><span class="cx">                                 <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
</span><span class="cx">                                 <input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_item_parent ); ?>" />
</span><span class="cx">                                 <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
</span><del>-                                <input class="menu-item-data-status" type="hidden" name="menu-item-status[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->post_status ); ?>" />
</del><span class="cx">                                 <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
</span><span class="cx">                         </div><!-- .menu-item-settings-->
</span><span class="cx">                         <ul class="menu-item-transport"></ul>
</span><span class="lines">@@ -973,7 +947,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @since 3.0.0
</span><span class="cx"> *
</span><del>- * @param int $menu_id The menu ID for which to save this item. $menu_id of 0 makes a pending, orphaned menu item.
</del><ins>+ * @param int $menu_id The menu ID for which to save this item. $menu_id of 0 makes a draft, orphaned menu item.
</ins><span class="cx"> * @param array $menu_data The unsanitized posted menu item data.
</span><span class="cx"> * @return array The database IDs of the items saved
</span><span class="cx"> */
</span><span class="lines">@@ -1105,12 +1079,12 @@
</span><span class="cx">
</span><span class="cx">                 $some_pending_menu_items = false;
</span><span class="cx">                 foreach( (array) $menu_items as $menu_item ) {
</span><del>-                        if ( isset( $menu_item->post_status ) && 'pending' == $menu_item->post_status )
</del><ins>+                        if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status )
</ins><span class="cx">                                 $some_pending_menu_items = true;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if ( $some_pending_menu_items )
</span><del>-                        $result .= '<div class="updated inline"><p>' . __('Click Save Menu to make unsaved menu items public.') . '</p></div>';
</del><ins>+                        $result .= '<div class="updated inline"><p>' . __('Click Save Menu to make pending menu items public.') . '</p></div>';
</ins><span class="cx">
</span><span class="cx">                 $result .= '<ul class="menu" id="menu-to-edit"> ';
</span><span class="cx">                 $result .= walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) );
</span><span class="lines">@@ -1143,23 +1117,23 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Deletes orphaned pending menu items
</del><ins>+ * Deletes orphaned draft menu items
</ins><span class="cx"> *
</span><span class="cx"> * @access private
</span><span class="cx"> * @since 3.0.0
</span><span class="cx"> *
</span><span class="cx"> */
</span><del>-function _wp_delete_orphaned_pending_menu_items() {
</del><ins>+function _wp_delete_orphaned_draft_menu_items() {
</ins><span class="cx">         global $wpdb;
</span><span class="cx">         $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);
</span><span class="cx">
</span><del>-        // delete orphaned pending menu items
-        $menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'pending' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) );
</del><ins>+        // delete orphaned draft menu items
+        $menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) );
</ins><span class="cx">
</span><span class="cx">         foreach( (array) $menu_items_to_delete as $menu_item_id )
</span><span class="cx">                 wp_delete_post( $menu_item_id, true );
</span><span class="cx"> }
</span><span class="cx">
</span><del>-add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_pending_menu_items');
</del><ins>+add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items');
</ins><span class="cx">
</span><span class="cx"> ?>
</span></span></pre></div>
<a id="trunkwpadminnavmenusphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/nav-menus.php (15253 => 15254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/nav-menus.php        2010-06-14 19:33:04 UTC (rev 15253)
+++ trunk/wp-admin/nav-menus.php        2010-06-14 19:52:30 UTC (rev 15254)
</span><span class="lines">@@ -327,13 +327,13 @@
</span><span class="cx">                         // Update menu items
</span><span class="cx">
</span><span class="cx">                         if ( ! is_wp_error( $_menu_object ) ) {
</span><del>-                                $unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,pending,publish') );
</del><ins>+                                $unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish') );
</ins><span class="cx">                                 $menu_items = array();
</span><span class="cx">                                 // Index menu items by db ID
</span><span class="cx">                                 foreach( $unsorted_menu_items as $_item )
</span><span class="cx">                                         $menu_items[$_item->db_id] = $_item;
</span><span class="cx">
</span><del>-                                $post_fields = array( 'menu-item-db-id', 'menu-item-object-id', 'menu-item-object', 'menu-item-parent-id', 'menu-item-position', 'menu-item-type', 'menu-item-title', 'menu-item-url', 'menu-item-description', 'menu-item-attr-title', 'menu-item-status', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn' );
</del><ins>+                                $post_fields = array( 'menu-item-db-id', 'menu-item-object-id', 'menu-item-object', 'menu-item-parent-id', 'menu-item-position', 'menu-item-type', 'menu-item-title', 'menu-item-url', 'menu-item-description', 'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn' );
</ins><span class="cx">                                 wp_defer_term_counting(true);
</span><span class="cx">                                 // Loop through all the menu items' POST variables
</span><span class="cx">                                 if ( ! empty( $_POST['menu-item-db-id'] ) ) {
</span></span></pre></div>
<a id="trunkwpincludesdefaultfiltersphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/default-filters.php (15253 => 15254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/default-filters.php        2010-06-14 19:33:04 UTC (rev 15253)
+++ trunk/wp-includes/default-filters.php        2010-06-14 19:52:30 UTC (rev 15254)
</span><span class="lines">@@ -233,7 +233,7 @@
</span><span class="cx"> // Navigation menu actions
</span><span class="cx"> add_action( 'delete_post', '_wp_delete_post_menu_item' );
</span><span class="cx"> add_action( 'delete_term', '_wp_delete_tax_menu_item' );
</span><del>-add_action( 'transition_post_status', '_wp_menu_changing_status_observer', 10, 3 );
</del><ins>+add_action( 'transition_post_status', '_wp_auto_add_pages_to_menu', 10, 3 );
</ins><span class="cx">
</span><span class="cx"> // Post Thumbnail CSS class filtering
</span><span class="cx"> add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add' );
</span></span></pre></div>
<a id="trunkwpincludesnavmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/nav-menu.php (15253 => 15254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/nav-menu.php        2010-06-14 19:33:04 UTC (rev 15253)
+++ trunk/wp-includes/nav-menu.php        2010-06-14 19:52:30 UTC (rev 15254)
</span><span class="lines">@@ -244,7 +244,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @since 3.0.0
</span><span class="cx"> *
</span><del>- * @param int $menu_id The ID of the menu. Required. If "0", makes the menu item a pending orphan.
</del><ins>+ * @param int $menu_id The ID of the menu. Required. If "0", makes the menu item a draft orphan.
</ins><span class="cx"> * @param int $menu_item_db_id The ID of the menu item. If "0", creates a new menu item.
</span><span class="cx"> * @param array $menu_item_data The menu item's data.
</span><span class="cx"> * @return int The menu item's database ID or WP_Error object on failure.
</span><span class="lines">@@ -262,7 +262,7 @@
</span><span class="cx">         if ( ( ! $menu && 0 !== $menu_id ) || is_wp_error( $menu ) )
</span><span class="cx">                 return $menu;
</span><span class="cx">
</span><del>-        $menu_items = 0 == $menu_id ? array() : (array) wp_get_nav_menu_items( $menu_id, array( 'post_status' => 'draft,pending,publish' ) );
</del><ins>+        $menu_items = 0 == $menu_id ? array() : (array) wp_get_nav_menu_items( $menu_id, array( 'post_status' => 'publish,draft' ) );
</ins><span class="cx">
</span><span class="cx">         $count = count( $menu_items );
</span><span class="cx">
</span><span class="lines">@@ -336,10 +336,10 @@
</span><span class="cx">         if ( 0 != $menu_id )
</span><span class="cx">                 $post['tax_input'] = array( 'nav_menu' => array( intval( $menu->term_id ) ) );
</span><span class="cx">
</span><del>-        // New menu item. Default is pending status
</del><ins>+        // New menu item. Default is draft status
</ins><span class="cx">         if ( 0 == $menu_item_db_id ) {
</span><span class="cx">                 $post['ID'] = 0;
</span><del>-                $post['post_status'] = 'publish' == $args['menu-item-status'] ? 'publish' : 'pending';
</del><ins>+                $post['post_status'] = 'publish' == $args['menu-item-status'] ? 'publish' : 'draft';
</ins><span class="cx">                 $menu_item_db_id = wp_insert_post( $post );
</span><span class="cx">
</span><span class="cx">         // Update existing menu item. Default is publish status
</span><span class="lines">@@ -690,7 +690,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Modify a navigational menu upon post object status change, if appropos.
</del><ins>+ * Automatically add newly published page objects to menus with that as an option.
</ins><span class="cx"> *
</span><span class="cx"> * @since 3.0.0
</span><span class="cx"> * @access private
</span><span class="lines">@@ -700,61 +700,34 @@
</span><span class="cx"> * @param object $post The post object being transitioned from one status to another.
</span><span class="cx"> * @return void
</span><span class="cx"> */
</span><del>-function _wp_menu_changing_status_observer( $new_status, $old_status, $post ) {
-        // append new top-level page objects to a menu for which that option is selected
-        if (
-                'publish' == $new_status &&
-                'publish' != $old_status &&
-                'page' == $post->post_type &&
-                empty( $post->post_parent )
-        ) {
-                $auto_add = get_option( 'nav_menu_options' );
-                if (
-                        isset( $auto_add['auto_add'] ) &&
-                        is_array( $auto_add['auto_add'] )
-                ) {
-                        $args = array(
-                                'menu-item-object-id' => $post->ID,
-                                'menu-item-object' => $post->post_type,
-                                'menu-item-type' => 'post_type',
-                                'menu-item-status' => 'publish',
-                        );
</del><ins>+function _wp_auto_add_pages_to_menu( $new_status, $old_status, $post ) {
+        if ( 'publish' != $new_status || 'publish' == $old_status || 'page' != $post->post_type )
+                return;
+        if ( ! empty( $post->post_parent ) )
+                return;
+        $auto_add = get_option( 'nav_menu_options' );
+        if ( empty( $auto_add ) || ! is_array( $auto_add ) || ! isset( $auto_add['auto_add'] ) )
+                return;
+        $auto_add = $auto_add['auto_add'];
+        if ( empty( $auto_add ) || ! is_array( $auto_add ) )
+                return;
</ins><span class="cx">
</span><del>-                        foreach ( $auto_add['auto_add'] as $menu_id ) {
-                                $items = wp_get_nav_menu_items( $menu_id, array( 'post_status' => 'draft,pending,publish' ) );
-                                if ( ! is_array( $items ) )
-                                        continue;
-                                foreach ( $items as $item ) {
-                                        if ( $post->ID == $item->object_id )
-                                                continue 2;
-                                }
-                                wp_update_nav_menu_item( $menu_id, 0, $args );
-                        }
-                }
-        }
</del><ins>+        $args = array(
+                'menu-item-object-id' => $post->ID,
+                'menu-item-object' => $post->post_type,
+                'menu-item-type' => 'post_type',
+                'menu-item-status' => 'publish',
+        );
</ins><span class="cx">
</span><del>-        // give menu items draft status if their associated post objects change from "publish" to "draft", or vice versa (draft item being re-published)
-        if (
-                ( $new_status != $old_status ) &&
-                ! empty( $post->ID ) && ! empty( $post->post_type ) &&
-                'nav_menu_item' != $post->post_type &&
-                ( 'publish' == $old_status || 'publish' == $new_status )
-        ) {
-                $menu_items = get_posts(array(
-                        'meta_key' => '_menu_item_object_id',
-                        'meta_value' => $post->ID,
-                        'post_status' => 'any',
-                        'post_type' => 'nav_menu_item',
-                ));
-
-                foreach( (array) $menu_items as $menu_item ) {
-                        if ( ! empty( $menu_item->ID ) ) {
-                                $properties = get_object_vars( $menu_item );
-                                $properties['post_status'] = 'publish' == $new_status ? 'publish' : 'draft';
-
-                                wp_insert_post( $properties );
-                        }
</del><ins>+        foreach ( $auto_add as $menu_id ) {
+                $items = wp_get_nav_menu_items( $menu_id, array( 'post_status' => 'publish,draft' ) );
+                if ( ! is_array( $items ) )
+                        continue;
+                foreach ( $items as $item ) {
+                        if ( $post->ID == $item->object_id )
+                                continue 2;
</ins><span class="cx">                 }
</span><ins>+                wp_update_nav_menu_item( $menu_id, 0, $args );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>