WordPress.org

Make WordPress Core

Ticket #21652: 21652.patch

File 21652.patch, 601 bytes (added by bootsz, 6 years ago)

Assigns new WP_Error to $menu if $menu is false, and then returns the error.

  • nav-menu.php

     
    276276
    277277        $menu = wp_get_nav_menu_object( $menu_id );
    278278
    279         if ( ( ! $menu && 0 !== $menu_id ) || is_wp_error( $menu ) )
     279        if ( !$menu && 0 !== $menu_id )
     280                $menu = new WP_Error('nav_menu_id_nonexistent', __('The specified menu ID does not exist') );
     281
     282        if ( is_wp_error($menu) )
    280283                return $menu;
    281284
    282285        $menu_items = 0 == $menu_id ? array() : (array) wp_get_nav_menu_items( $menu_id, array( 'post_status' => 'publish,draft' ) );