From e0630f2a93b38f740ddd2a0c1b35e625752f2139 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Wed, 26 May 2010 05:11:46 +0000 Subject: [PATCH] Don't store nonexistent (deleted) menus in the auto-add option. see #13447. git-svn-id: https://develop.svn.wordpress.org/trunk@14934 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/nav-menus.php | 2 ++ wp-includes/nav-menu.php | 4 +++- wp-includes/taxonomy.php | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-admin/nav-menus.php b/wp-admin/nav-menus.php index d41d6c5a2e..7cbdd38418 100644 --- a/wp-admin/nav-menus.php +++ b/wp-admin/nav-menus.php @@ -368,6 +368,8 @@ switch ( $action ) { if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) unset( $nav_menu_option['auto_add'][$key] ); } + // Remove nonexistent/deleted menus + $nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) ); update_option( 'nav_menu_options', $nav_menu_option ); wp_defer_term_counting(false); diff --git a/wp-includes/nav-menu.php b/wp-includes/nav-menu.php index 05a8cc8fb5..568594c188 100644 --- a/wp-includes/nav-menu.php +++ b/wp-includes/nav-menu.php @@ -765,7 +765,9 @@ function _wp_auto_add_pages_to_menu( $new_status, $old_status, $post ) { ); foreach ( $auto_add as $menu_id ) { - $items = (array) wp_get_nav_menu_items( $menu_id ); + $items = wp_get_nav_menu_items( $menu_id ); + if ( ! is_array( $items ) ) + continue; foreach ( $items as $item ) { if ( $post->ID == $item->object_id ) continue 2; diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index ceda0d8b58..73145528e2 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -714,7 +714,7 @@ function get_term_to_edit( $id, $taxonomy ) { * * The 'get_terms_orderby' filter passes the ORDER BY clause for the query * along with the $args array. - + * * The 'get_terms_fields' filter passes the fields for the SELECT query * along with the $args array. *