From cac815c4e9f789df12dff85067885b11193ce4b2 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 4 Dec 2013 20:37:11 +0000 Subject: [PATCH] Avoid a PHP notice on Edit Menus screen when a menu is attached to a non-existing location. props nofearinc. fixes #26287. Built from https://develop.svn.wordpress.org/trunk@26634 git-svn-id: http://core.svn.wordpress.org/trunk@26524 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/nav-menus.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/wp-admin/nav-menus.php b/wp-admin/nav-menus.php index a9d2ecc90b..b59f61b3f0 100644 --- a/wp-admin/nav-menus.php +++ b/wp-admin/nav-menus.php @@ -630,7 +630,9 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' ); if ( ! empty( $menu_locations ) && in_array( $_nav_menu->term_id, $menu_locations ) ) { $locations_assigned_to_this_menu = array(); foreach ( array_keys( $menu_locations, $_nav_menu->term_id ) as $menu_location_key ) { - $locations_assigned_to_this_menu[] = $locations[ $menu_location_key ]; + if ( isset( $locations[ $menu_location_key ] ) ) { + $locations_assigned_to_this_menu[] = $locations[ $menu_location_key ]; + } } /** @@ -643,10 +645,12 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' ); $assigned_locations = array_slice( $locations_assigned_to_this_menu, 0, absint( apply_filters( 'wp_nav_locations_listed_per_menu', 3 ) ) ); // Adds ellipses following the number of locations defined in $assigned_locations - printf( ' (%1$s%2$s)', - implode( ', ', $assigned_locations ), - count( $locations_assigned_to_this_menu ) > count( $assigned_locations ) ? ' …' : '' - ); + if ( ! empty( $assigned_locations ) ) { + printf( ' (%1$s%2$s)', + implode( ', ', $assigned_locations ), + count( $locations_assigned_to_this_menu ) > count( $assigned_locations ) ? ' …' : '' + ); + } } ?>