Index: wp-includes/default-filters.php =================================================================== --- wp-includes/default-filters.php (revision 15238) +++ wp-includes/default-filters.php (working copy) @@ -235,7 +235,7 @@ add_action( 'untrash_post', '_wp_untrash_menu_item' ); add_action( 'delete_post', '_wp_delete_post_menu_item' ); add_action( 'delete_term', '_wp_delete_tax_menu_item' ); -add_action( 'transition_post_status', '_wp_menu_changing_status_observer', 10, 3 ); +add_action( 'transition_post_status', '_wp_auto_add_pages_to_menu', 10, 3 ); // Post Thumbnail CSS class filtering add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add' ); Index: wp-includes/nav-menu.php =================================================================== --- wp-includes/nav-menu.php (revision 15238) +++ wp-includes/nav-menu.php (working copy) @@ -244,7 +244,7 @@ * * @since 3.0.0 * - * @param int $menu_id The ID of the menu. Required. If "0", makes the menu item a pending orphan. + * @param int $menu_id The ID of the menu. Required. If "0", makes the menu item a draft orphan. * @param int $menu_item_db_id The ID of the menu item. If "0", creates a new menu item. * @param array $menu_item_data The menu item's data. * @return int The menu item's database ID or WP_Error object on failure. @@ -262,7 +262,7 @@ if ( ( ! $menu && 0 !== $menu_id ) || is_wp_error( $menu ) ) return $menu; - $menu_items = 0 == $menu_id ? array() : (array) wp_get_nav_menu_items( $menu_id, array( 'post_status' => 'draft,pending,publish' ) ); + $menu_items = 0 == $menu_id ? array() : (array) wp_get_nav_menu_items( $menu_id, array( 'post_status' => 'publish,draft' ) ); $count = count( $menu_items ); @@ -339,10 +339,10 @@ if ( 0 != $menu_id ) $post['tax_input'] = array( 'nav_menu' => array( intval( $menu->term_id ) ) ); - // New menu item. Default is pending status + // New menu item. Default is draft status if ( 0 == $menu_item_db_id ) { $post['ID'] = 0; - $post['post_status'] = 'publish' == $args['menu-item-status'] ? 'publish' : 'pending'; + $post['post_status'] = 'publish' == $args['menu-item-status'] ? 'publish' : 'draft'; $menu_item_db_id = wp_insert_post( $post ); // Update existing menu item. Default is publish status @@ -497,7 +497,10 @@ unset($terms); } - $items = array_map( 'wp_setup_nav_menu_item', $items ); + if ( 'publish' == $args['post_status'] ) + $items = array_filter( array_map( 'wp_setup_nav_menu_item', $items, true ) ); + else + $items = array_map( 'wp_setup_nav_menu_item', $items ); if ( ARRAY_A == $args['output'] ) { $GLOBALS['_menu_item_sort_prop'] = $args['output_key']; @@ -535,7 +538,7 @@ * @param object $menu_item The menu item to modify. * @return object $menu_item The menu item with standard menu item properties. */ -function wp_setup_nav_menu_item( $menu_item ) { +function wp_setup_nav_menu_item( $menu_item, $published_post_only = false ) { if ( isset( $menu_item->post_type ) ) { if ( 'nav_menu_item' == $menu_item->post_type ) { $menu_item->db_id = (int) $menu_item->ID; @@ -545,11 +548,14 @@ $menu_item->type = empty( $menu_item->type ) ? get_post_meta( $menu_item->ID, '_menu_item_type', true ) : $menu_item->type; if ( 'post_type' == $menu_item->type ) { + $original_object = get_post( $menu_item->object_id ); + if ( $published_post_only && $original_object->post_status != 'publish' ) + return null; + $object = get_post_type_object( $menu_item->object ); $menu_item->type_label = $object->labels->singular_name; $menu_item->url = get_permalink( $menu_item->object_id ); - $original_object = get_post( $menu_item->object_id ); $original_title = $original_object->post_title; $menu_item->title = '' == $menu_item->post_title ? $original_title : $menu_item->post_title; @@ -670,7 +676,7 @@ foreach( (array) $menu_item_ids as $menu_item_id ) { $menu_item = get_post( $menu_item_id, ARRAY_A ); - $menu_item['post_status'] = 'pending'; + $menu_item['post_status'] = 'draft'; wp_insert_post($menu_item); } } @@ -735,7 +741,7 @@ } /** - * Modify a navigational menu upon post object status change, if appropos. + * Automatically add newly published page objects to menus with that as an option. * * @since 3.0.0 * @access private Index: wp-admin/includes/nav-menu.php =================================================================== --- wp-admin/includes/nav-menu.php (revision 15238) +++ wp-admin/includes/nav-menu.php (working copy) @@ -71,12 +71,8 @@ $title = $item->title; if ( isset( $item->post_status ) && 'draft' == $item->post_status ) { - $classes[] = 'draft'; - /* translators: %s: title of menu item in draft status */ - $title = sprintf( __('%s (Draft)'), $item->title ); - } elseif ( isset( $item->post_status ) && 'pending' == $item->post_status ) { $classes[] = 'pending'; - /* translators: %s: title of menu item in pending status */ + /* translators: %s: title of menu item in draft status */ $title = sprintf( __('%s (Pending)'), $item->title ); } @@ -198,7 +194,6 @@ -
@@ -952,7 +947,7 @@ * * @since 3.0.0 * - * @param int $menu_id The menu ID for which to save this item. $menu_id of 0 makes a pending, orphaned menu item. + * @param int $menu_id The menu ID for which to save this item. $menu_id of 0 makes a draft, orphaned menu item. * @param array $menu_data The unsanitized posted menu item data. * @return array The database IDs of the items saved */ @@ -1084,7 +1079,7 @@ $some_pending_menu_items = false; foreach( (array) $menu_items as $menu_item ) { - if ( isset( $menu_item->post_status ) && 'pending' == $menu_item->post_status ) + if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) $some_pending_menu_items = true; } @@ -1122,23 +1117,23 @@ } /** - * Deletes orphaned pending menu items + * Deletes orphaned draft menu items * * @access private * @since 3.0.0 * */ -function _wp_delete_orphaned_pending_menu_items() { +function _wp_delete_orphaned_draft_menu_items() { global $wpdb; $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS); - // 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 ) ); + // 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 ) ); foreach( (array) $menu_items_to_delete as $menu_item_id ) wp_delete_post( $menu_item_id, true ); } -add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_pending_menu_items'); +add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items'); ?> Index: wp-admin/nav-menus.php =================================================================== --- wp-admin/nav-menus.php (revision 15238) +++ wp-admin/nav-menus.php (working copy) @@ -327,13 +327,13 @@ // Update menu items if ( ! is_wp_error( $_menu_object ) ) { - $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') ); + $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') ); $menu_items = array(); // Index menu items by db ID foreach( $unsorted_menu_items as $_item ) $menu_items[$_item->db_id] = $_item; - $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' ); + $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' ); wp_defer_term_counting(true); // Loop through all the menu items' POST variables if ( ! empty( $_POST['menu-item-db-id'] ) ) {