WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/28/2010 08:44:08 PM (11 years ago)
Author:
nacin
Message:

Fix handling of nav menu search, also menu naming conflicts. props filosofo, fixes #13138

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/nav-menu.php

    r14283 r14285  
    9090
    9191    if ( $menu_exists )
    92         return new WP_Error( 'menu_exists', sprintf( __('A menu named <strong>%s</strong> already exists; please try another name.'), esc_html( $menu_exists->name ) ) );
     92        return new WP_Error( 'menu_exists', sprintf( __('The menu name <strong>%s</strong> conflicts with another menu name. Please try another.'), esc_html( $menu_name ) ) );
    9393
    9494    if ( isset($args['slug']) )
     
    172172   
    173173        $menu_id = (int) $_menu->term_id;
     174
     175        // double-check that we're not changing a menu to the name of another
     176        $_possible_existing = get_term_by( 'name', $menu_data['menu-name'], 'nav_menu' );
     177        if (
     178            $_possible_existing &&
     179            ! is_wp_error( $_possible_existing ) &&
     180            isset( $_possible_existing->term_id ) &&
     181            $_possible_existing->term_id != $menu_id
     182        ) {
     183            return new WP_Error( 'menu_exists', sprintf( __('The menu name <strong>%s</strong> conflicts with another menu name. Please try another.'), esc_html( $menu_data['menu-name'] ) ) );
     184        }
    174185
    175186        $update_response = wp_update_term( $menu_id, 'nav_menu', $args );
Note: See TracChangeset for help on using the changeset viewer.