Make WordPress Core

Changeset 26634


Ignore:
Timestamp:
12/04/2013 08:36:10 PM (13 years ago)
Author:
SergeyBiryukov
Message:

Avoid a PHP notice on Edit Menus screen when a menu is attached to a non-existing location.

props nofearinc.
fixes #26287.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/nav-menus.php

    r26518 r26634  
    631631                                                        $locations_assigned_to_this_menu = array();
    632632                                                        foreach ( array_keys( $menu_locations, $_nav_menu->term_id ) as $menu_location_key ) {
    633                                                                  $locations_assigned_to_this_menu[] = $locations[ $menu_location_key ];
     633                                                                if ( isset( $locations[ $menu_location_key ] ) ) {
     634                                                                        $locations_assigned_to_this_menu[] = $locations[ $menu_location_key ];
     635                                                                }
    634636                                                        }
    635637
     
    644646
    645647                                                        // Adds ellipses following the number of locations defined in $assigned_locations
    646                                                         printf( ' (%1$s%2$s)',
    647                                                                 implode( ', ', $assigned_locations ),
    648                                                                 count( $locations_assigned_to_this_menu ) > count( $assigned_locations ) ? ' …' : ''
    649                                                         );
     648                                                        if ( ! empty( $assigned_locations ) ) {
     649                                                                printf( ' (%1$s%2$s)',
     650                                                                        implode( ', ', $assigned_locations ),
     651                                                                        count( $locations_assigned_to_this_menu ) > count( $assigned_locations ) ? ' …' : ''
     652                                                                );
     653                                                        }
    650654                                                }
    651655                                                ?>
Note: See TracChangeset for help on using the changeset viewer.