WordPress.org

Make WordPress Core

Changeset 27251


Ignore:
Timestamp:
02/25/2014 12:50:36 AM (8 years ago)
Author:
SergeyBiryukov
Message:

Consistently return a WP_Error object in case of an error in wp_update_nav_menu_item().

props bootsz, ocean90.
fixes #21652.

File:
1 edited

Legend:

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

    r27220 r27251  
    277277 * @param int $menu_item_db_id The ID of the menu item. If "0", creates a new menu item.
    278278 * @param array $menu_item_data The menu item's data.
    279  * @return int The menu item's database ID or WP_Error object on failure.
     279 * @return int|WP_Error The menu item's database ID or WP_Error object on failure.
    280280 */
    281281function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item_data = array() ) {
     
    285285    // make sure that we don't convert non-nav_menu_item objects into nav_menu_item objects
    286286    if ( ! empty( $menu_item_db_id ) && ! is_nav_menu_item( $menu_item_db_id ) )
    287         return new WP_Error('update_nav_menu_item_failed', __('The given object ID is not that of a menu item.'));
     287        return new WP_Error( 'update_nav_menu_item_failed', __( 'The given object ID is not that of a menu item.' ) );
    288288
    289289    $menu = wp_get_nav_menu_object( $menu_id );
    290290
    291     if ( ( ! $menu && 0 !== $menu_id ) || is_wp_error( $menu ) )
     291    if ( ! $menu && 0 !== $menu_id ) {
     292        return new WP_Error( 'invalid_menu_id', __( 'Invalid menu ID.' ) );
     293    }
     294
     295    if ( is_wp_error( $menu ) ) {
    292296        return $menu;
     297    }
    293298
    294299    $defaults = array(
Note: See TracChangeset for help on using the changeset viewer.