wp_update_nav_menu_object

The timeline below displays how wordpress function wp_update_nav_menu_object has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Saves the properties of a menu or create a new menu with those properties.
 *
 * Note that `$menu_data` is expected to be pre-slashed.
 *
 * @since 3.0.0
 *
 * @param int   $menu_id   The ID of the menu or "0" to create a new menu.
 * @param array $menu_data The array of menu data.
 * @return int|WP_Error Menu ID on success, WP_Error object on failure.
 */
function wp_update_nav_menu_object($menu_id = 0, $menu_data = array())
{
    // expected_slashed ($menu_data)
    $menu_id = (int) $menu_id;
    $_menu = wp_get_nav_menu_object($menu_id);
    $args = array('description' => isset($menu_data['description']) ? $menu_data['description'] : '', 'name' => isset($menu_data['menu-name']) ? $menu_data['menu-name'] : '', 'parent' => isset($menu_data['parent']) ? (int) $menu_data['parent'] : 0, 'slug' => null);
    // Double-check that we're not going to have one menu take the name of another.
    $_possible_existing = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
    if ($_possible_existing && !is_wp_error($_possible_existing) && isset($_possible_existing->term_id) && $_possible_existing->term_id != $menu_id) {
        return new WP_Error('menu_exists', sprintf(
            /* translators: %s: Menu name. */
            __('The menu name %s conflicts with another menu name. Please try another.'),
            '<strong>' . esc_html($menu_data['menu-name']) . '</strong>'
        ));
    }
    // Menu doesn't already exist, so create a new menu.
    if (!$_menu || is_wp_error($_menu)) {
        $menu_exists = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
        if ($menu_exists) {
            return new WP_Error('menu_exists', sprintf(
                /* translators: %s: Menu name. */
                __('The menu name %s conflicts with another menu name. Please try another.'),
                '<strong>' . esc_html($menu_data['menu-name']) . '</strong>'
            ));
        }
        $_menu = wp_insert_term($menu_data['menu-name'], 'nav_menu', $args);
        if (is_wp_error($_menu)) {
            return $_menu;
        }
        /**
         * Fires after a navigation menu is successfully created.
         *
         * @since 3.0.0
         *
         * @param int   $term_id   ID of the new menu.
         * @param array $menu_data An array of menu data.
         */
        do_action('wp_create_nav_menu', $_menu['term_id'], $menu_data);
        return (int) $_menu['term_id'];
    }
    if (!$_menu || !isset($_menu->term_id)) {
        return 0;
    }
    $menu_id = (int) $_menu->term_id;
    $update_response = wp_update_term($menu_id, 'nav_menu', $args);
    if (is_wp_error($update_response)) {
        return $update_response;
    }
    $menu_id = (int) $update_response['term_id'];
    /**
     * Fires after a navigation menu has been successfully updated.
     *
     * @since 3.0.0
     *
     * @param int   $menu_id   ID of the updated menu.
     * @param array $menu_data An array of menu data.
     */
    do_action('wp_update_nav_menu', $menu_id, $menu_data);
    return $menu_id;
}

WordPress Version: 5.4

/**
 * Save the properties of a menu or create a new menu with those properties.
 *
 * Note that `$menu_data` is expected to be pre-slashed.
 *
 * @since 3.0.0
 *
 * @param int   $menu_id   The ID of the menu or "0" to create a new menu.
 * @param array $menu_data The array of menu data.
 * @return int|WP_Error Menu ID on success, WP_Error object on failure.
 */
function wp_update_nav_menu_object($menu_id = 0, $menu_data = array())
{
    // expected_slashed ($menu_data)
    $menu_id = (int) $menu_id;
    $_menu = wp_get_nav_menu_object($menu_id);
    $args = array('description' => isset($menu_data['description']) ? $menu_data['description'] : '', 'name' => isset($menu_data['menu-name']) ? $menu_data['menu-name'] : '', 'parent' => isset($menu_data['parent']) ? (int) $menu_data['parent'] : 0, 'slug' => null);
    // Double-check that we're not going to have one menu take the name of another.
    $_possible_existing = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
    if ($_possible_existing && !is_wp_error($_possible_existing) && isset($_possible_existing->term_id) && $_possible_existing->term_id != $menu_id) {
        return new WP_Error('menu_exists', sprintf(
            /* translators: %s: Menu name. */
            __('The menu name %s conflicts with another menu name. Please try another.'),
            '<strong>' . esc_html($menu_data['menu-name']) . '</strong>'
        ));
    }
    // Menu doesn't already exist, so create a new menu.
    if (!$_menu || is_wp_error($_menu)) {
        $menu_exists = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
        if ($menu_exists) {
            return new WP_Error('menu_exists', sprintf(
                /* translators: %s: Menu name. */
                __('The menu name %s conflicts with another menu name. Please try another.'),
                '<strong>' . esc_html($menu_data['menu-name']) . '</strong>'
            ));
        }
        $_menu = wp_insert_term($menu_data['menu-name'], 'nav_menu', $args);
        if (is_wp_error($_menu)) {
            return $_menu;
        }
        /**
         * Fires after a navigation menu is successfully created.
         *
         * @since 3.0.0
         *
         * @param int   $term_id   ID of the new menu.
         * @param array $menu_data An array of menu data.
         */
        do_action('wp_create_nav_menu', $_menu['term_id'], $menu_data);
        return (int) $_menu['term_id'];
    }
    if (!$_menu || !isset($_menu->term_id)) {
        return 0;
    }
    $menu_id = (int) $_menu->term_id;
    $update_response = wp_update_term($menu_id, 'nav_menu', $args);
    if (is_wp_error($update_response)) {
        return $update_response;
    }
    $menu_id = (int) $update_response['term_id'];
    /**
     * Fires after a navigation menu has been successfully updated.
     *
     * @since 3.0.0
     *
     * @param int   $menu_id   ID of the updated menu.
     * @param array $menu_data An array of menu data.
     */
    do_action('wp_update_nav_menu', $menu_id, $menu_data);
    return $menu_id;
}

WordPress Version: 5.3

/**
 * Save the properties of a menu or create a new menu with those properties.
 *
 * Note that `$menu_data` is expected to be pre-slashed.
 *
 * @since 3.0.0
 *
 * @param int   $menu_id   The ID of the menu or "0" to create a new menu.
 * @param array $menu_data The array of menu data.
 * @return int|WP_Error Menu ID on success, WP_Error object on failure.
 */
function wp_update_nav_menu_object($menu_id = 0, $menu_data = array())
{
    // expected_slashed ($menu_data)
    $menu_id = (int) $menu_id;
    $_menu = wp_get_nav_menu_object($menu_id);
    $args = array('description' => isset($menu_data['description']) ? $menu_data['description'] : '', 'name' => isset($menu_data['menu-name']) ? $menu_data['menu-name'] : '', 'parent' => isset($menu_data['parent']) ? (int) $menu_data['parent'] : 0, 'slug' => null);
    // double-check that we're not going to have one menu take the name of another
    $_possible_existing = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
    if ($_possible_existing && !is_wp_error($_possible_existing) && isset($_possible_existing->term_id) && $_possible_existing->term_id != $menu_id) {
        return new WP_Error('menu_exists', sprintf(
            /* translators: %s: Menu name. */
            __('The menu name %s conflicts with another menu name. Please try another.'),
            '<strong>' . esc_html($menu_data['menu-name']) . '</strong>'
        ));
    }
    // menu doesn't already exist, so create a new menu
    if (!$_menu || is_wp_error($_menu)) {
        $menu_exists = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
        if ($menu_exists) {
            return new WP_Error('menu_exists', sprintf(
                /* translators: %s: Menu name. */
                __('The menu name %s conflicts with another menu name. Please try another.'),
                '<strong>' . esc_html($menu_data['menu-name']) . '</strong>'
            ));
        }
        $_menu = wp_insert_term($menu_data['menu-name'], 'nav_menu', $args);
        if (is_wp_error($_menu)) {
            return $_menu;
        }
        /**
         * Fires after a navigation menu is successfully created.
         *
         * @since 3.0.0
         *
         * @param int   $term_id   ID of the new menu.
         * @param array $menu_data An array of menu data.
         */
        do_action('wp_create_nav_menu', $_menu['term_id'], $menu_data);
        return (int) $_menu['term_id'];
    }
    if (!$_menu || !isset($_menu->term_id)) {
        return 0;
    }
    $menu_id = (int) $_menu->term_id;
    $update_response = wp_update_term($menu_id, 'nav_menu', $args);
    if (is_wp_error($update_response)) {
        return $update_response;
    }
    $menu_id = (int) $update_response['term_id'];
    /**
     * Fires after a navigation menu has been successfully updated.
     *
     * @since 3.0.0
     *
     * @param int   $menu_id   ID of the updated menu.
     * @param array $menu_data An array of menu data.
     */
    do_action('wp_update_nav_menu', $menu_id, $menu_data);
    return $menu_id;
}

WordPress Version: 4.5

/**
 * Save the properties of a menu or create a new menu with those properties.
 *
 * Note that `$menu_data` is expected to be pre-slashed.
 *
 * @since 3.0.0
 *
 * @param int   $menu_id   The ID of the menu or "0" to create a new menu.
 * @param array $menu_data The array of menu data.
 * @return int|WP_Error Menu ID on success, WP_Error object on failure.
 */
function wp_update_nav_menu_object($menu_id = 0, $menu_data = array())
{
    // expected_slashed ($menu_data)
    $menu_id = (int) $menu_id;
    $_menu = wp_get_nav_menu_object($menu_id);
    $args = array('description' => isset($menu_data['description']) ? $menu_data['description'] : '', 'name' => isset($menu_data['menu-name']) ? $menu_data['menu-name'] : '', 'parent' => isset($menu_data['parent']) ? (int) $menu_data['parent'] : 0, 'slug' => null);
    // double-check that we're not going to have one menu take the name of another
    $_possible_existing = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
    if ($_possible_existing && !is_wp_error($_possible_existing) && isset($_possible_existing->term_id) && $_possible_existing->term_id != $menu_id) {
        return new WP_Error(
            'menu_exists',
            /* translators: %s: menu name */
            sprintf(__('The menu name %s conflicts with another menu name. Please try another.'), '<strong>' . esc_html($menu_data['menu-name']) . '</strong>')
        );
    }
    // menu doesn't already exist, so create a new menu
    if (!$_menu || is_wp_error($_menu)) {
        $menu_exists = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
        if ($menu_exists) {
            return new WP_Error(
                'menu_exists',
                /* translators: %s: menu name */
                sprintf(__('The menu name %s conflicts with another menu name. Please try another.'), '<strong>' . esc_html($menu_data['menu-name']) . '</strong>')
            );
        }
        $_menu = wp_insert_term($menu_data['menu-name'], 'nav_menu', $args);
        if (is_wp_error($_menu)) {
            return $_menu;
        }
        /**
         * Fires after a navigation menu is successfully created.
         *
         * @since 3.0.0
         *
         * @param int   $term_id   ID of the new menu.
         * @param array $menu_data An array of menu data.
         */
        do_action('wp_create_nav_menu', $_menu['term_id'], $menu_data);
        return (int) $_menu['term_id'];
    }
    if (!$_menu || !isset($_menu->term_id)) {
        return 0;
    }
    $menu_id = (int) $_menu->term_id;
    $update_response = wp_update_term($menu_id, 'nav_menu', $args);
    if (is_wp_error($update_response)) {
        return $update_response;
    }
    $menu_id = (int) $update_response['term_id'];
    /**
     * Fires after a navigation menu has been successfully updated.
     *
     * @since 3.0.0
     *
     * @param int   $menu_id   ID of the updated menu.
     * @param array $menu_data An array of menu data.
     */
    do_action('wp_update_nav_menu', $menu_id, $menu_data);
    return $menu_id;
}

WordPress Version: 4.4

/**
 * Save the properties of a menu or create a new menu with those properties.
 *
 * @since 3.0.0
 *
 * @param int   $menu_id   The ID of the menu or "0" to create a new menu.
 * @param array $menu_data The array of menu data.
 * @return int|WP_Error Menu ID on success, WP_Error object on failure.
 */
function wp_update_nav_menu_object($menu_id = 0, $menu_data = array())
{
    $menu_id = (int) $menu_id;
    $_menu = wp_get_nav_menu_object($menu_id);
    $args = array('description' => isset($menu_data['description']) ? $menu_data['description'] : '', 'name' => isset($menu_data['menu-name']) ? $menu_data['menu-name'] : '', 'parent' => isset($menu_data['parent']) ? (int) $menu_data['parent'] : 0, 'slug' => null);
    // double-check that we're not going to have one menu take the name of another
    $_possible_existing = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
    if ($_possible_existing && !is_wp_error($_possible_existing) && isset($_possible_existing->term_id) && $_possible_existing->term_id != $menu_id) {
        return new WP_Error(
            'menu_exists',
            /* translators: %s: menu name */
            sprintf(__('The menu name %s conflicts with another menu name. Please try another.'), '<strong>' . esc_html($menu_data['menu-name']) . '</strong>')
        );
    }
    // menu doesn't already exist, so create a new menu
    if (!$_menu || is_wp_error($_menu)) {
        $menu_exists = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
        if ($menu_exists) {
            return new WP_Error(
                'menu_exists',
                /* translators: %s: menu name */
                sprintf(__('The menu name %s conflicts with another menu name. Please try another.'), '<strong>' . esc_html($menu_data['menu-name']) . '</strong>')
            );
        }
        $_menu = wp_insert_term($menu_data['menu-name'], 'nav_menu', $args);
        if (is_wp_error($_menu)) {
            return $_menu;
        }
        /**
         * Fires after a navigation menu is successfully created.
         *
         * @since 3.0.0
         *
         * @param int   $term_id   ID of the new menu.
         * @param array $menu_data An array of menu data.
         */
        do_action('wp_create_nav_menu', $_menu['term_id'], $menu_data);
        return (int) $_menu['term_id'];
    }
    if (!$_menu || !isset($_menu->term_id)) {
        return 0;
    }
    $menu_id = (int) $_menu->term_id;
    $update_response = wp_update_term($menu_id, 'nav_menu', $args);
    if (is_wp_error($update_response)) {
        return $update_response;
    }
    $menu_id = (int) $update_response['term_id'];
    /**
     * Fires after a navigation menu has been successfully updated.
     *
     * @since 3.0.0
     *
     * @param int   $menu_id   ID of the updated menu.
     * @param array $menu_data An array of menu data.
     */
    do_action('wp_update_nav_menu', $menu_id, $menu_data);
    return $menu_id;
}

WordPress Version: 4.3

/**
 * Save the properties of a menu or create a new menu with those properties.
 *
 * @since 3.0.0
 *
 * @param int   $menu_id   The ID of the menu or "0" to create a new menu.
 * @param array $menu_data The array of menu data.
 * @return int|WP_Error Menu ID on success, WP_Error object on failure.
 */
function wp_update_nav_menu_object($menu_id = 0, $menu_data = array())
{
    $menu_id = (int) $menu_id;
    $_menu = wp_get_nav_menu_object($menu_id);
    $args = array('description' => isset($menu_data['description']) ? $menu_data['description'] : '', 'name' => isset($menu_data['menu-name']) ? $menu_data['menu-name'] : '', 'parent' => isset($menu_data['parent']) ? (int) $menu_data['parent'] : 0, 'slug' => null);
    // double-check that we're not going to have one menu take the name of another
    $_possible_existing = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
    if ($_possible_existing && !is_wp_error($_possible_existing) && isset($_possible_existing->term_id) && $_possible_existing->term_id != $menu_id) {
        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'])));
    }
    // menu doesn't already exist, so create a new menu
    if (!$_menu || is_wp_error($_menu)) {
        $menu_exists = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
        if ($menu_exists) {
            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'])));
        }
        $_menu = wp_insert_term($menu_data['menu-name'], 'nav_menu', $args);
        if (is_wp_error($_menu)) {
            return $_menu;
        }
        /**
         * Fires after a navigation menu is successfully created.
         *
         * @since 3.0.0
         *
         * @param int   $term_id   ID of the new menu.
         * @param array $menu_data An array of menu data.
         */
        do_action('wp_create_nav_menu', $_menu['term_id'], $menu_data);
        return (int) $_menu['term_id'];
    }
    if (!$_menu || !isset($_menu->term_id)) {
        return 0;
    }
    $menu_id = (int) $_menu->term_id;
    $update_response = wp_update_term($menu_id, 'nav_menu', $args);
    if (is_wp_error($update_response)) {
        return $update_response;
    }
    $menu_id = (int) $update_response['term_id'];
    /**
     * Fires after a navigation menu has been successfully updated.
     *
     * @since 3.0.0
     *
     * @param int   $menu_id   ID of the updated menu.
     * @param array $menu_data An array of menu data.
     */
    do_action('wp_update_nav_menu', $menu_id, $menu_data);
    return $menu_id;
}

WordPress Version: 4.0

/**
 * Save the properties of a menu or create a new menu with those properties.
 *
 * @since 3.0.0
 *
 * @param int $menu_id The ID of the menu or "0" to create a new menu.
 * @param array $menu_data The array of menu data.
 * @return int|WP_Error Menu ID on success, WP_Error object on failure.
 */
function wp_update_nav_menu_object($menu_id = 0, $menu_data = array())
{
    $menu_id = (int) $menu_id;
    $_menu = wp_get_nav_menu_object($menu_id);
    $args = array('description' => isset($menu_data['description']) ? $menu_data['description'] : '', 'name' => isset($menu_data['menu-name']) ? $menu_data['menu-name'] : '', 'parent' => isset($menu_data['parent']) ? (int) $menu_data['parent'] : 0, 'slug' => null);
    // double-check that we're not going to have one menu take the name of another
    $_possible_existing = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
    if ($_possible_existing && !is_wp_error($_possible_existing) && isset($_possible_existing->term_id) && $_possible_existing->term_id != $menu_id) {
        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'])));
    }
    // menu doesn't already exist, so create a new menu
    if (!$_menu || is_wp_error($_menu)) {
        $menu_exists = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
        if ($menu_exists) {
            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'])));
        }
        $_menu = wp_insert_term($menu_data['menu-name'], 'nav_menu', $args);
        if (is_wp_error($_menu)) {
            return $_menu;
        }
        /**
         * Fires after a navigation menu is successfully created.
         *
         * @since 3.0.0
         *
         * @param int   $term_id   ID of the new menu.
         * @param array $menu_data An array of menu data.
         */
        do_action('wp_create_nav_menu', $_menu['term_id'], $menu_data);
        return (int) $_menu['term_id'];
    }
    if (!$_menu || !isset($_menu->term_id)) {
        return 0;
    }
    $menu_id = (int) $_menu->term_id;
    $update_response = wp_update_term($menu_id, 'nav_menu', $args);
    if (is_wp_error($update_response)) {
        return $update_response;
    }
    /**
     * Fires after a navigation menu has been successfully updated.
     *
     * @since 3.0.0
     *
     * @param int   $menu_id   ID of the updated menu.
     * @param array $menu_data An array of menu data.
     */
    do_action('wp_update_nav_menu', $menu_id, $menu_data);
    return $menu_id;
}

WordPress Version: 3.9

/**
 * Save the properties of a menu or create a new menu with those properties.
 *
 * @since 3.0.0
 *
 * @param int $menu_id The ID of the menu or "0" to create a new menu.
 * @param array $menu_data The array of menu data.
 * @return int|WP_Error object The menu's ID or WP_Error object.
 */
function wp_update_nav_menu_object($menu_id = 0, $menu_data = array())
{
    $menu_id = (int) $menu_id;
    $_menu = wp_get_nav_menu_object($menu_id);
    $args = array('description' => isset($menu_data['description']) ? $menu_data['description'] : '', 'name' => isset($menu_data['menu-name']) ? $menu_data['menu-name'] : '', 'parent' => isset($menu_data['parent']) ? (int) $menu_data['parent'] : 0, 'slug' => null);
    // double-check that we're not going to have one menu take the name of another
    $_possible_existing = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
    if ($_possible_existing && !is_wp_error($_possible_existing) && isset($_possible_existing->term_id) && $_possible_existing->term_id != $menu_id) {
        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'])));
    }
    // menu doesn't already exist, so create a new menu
    if (!$_menu || is_wp_error($_menu)) {
        $menu_exists = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
        if ($menu_exists) {
            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'])));
        }
        $_menu = wp_insert_term($menu_data['menu-name'], 'nav_menu', $args);
        if (is_wp_error($_menu)) {
            return $_menu;
        }
        /**
         * Fires after a navigation menu is successfully created.
         *
         * @since 3.0.0
         *
         * @param int   $term_id   ID of the new menu.
         * @param array $menu_data An array of menu data.
         */
        do_action('wp_create_nav_menu', $_menu['term_id'], $menu_data);
        return (int) $_menu['term_id'];
    }
    if (!$_menu || !isset($_menu->term_id)) {
        return 0;
    }
    $menu_id = (int) $_menu->term_id;
    $update_response = wp_update_term($menu_id, 'nav_menu', $args);
    if (is_wp_error($update_response)) {
        return $update_response;
    }
    /**
     * Fires after a navigation menu has been successfully updated.
     *
     * @since 3.0.0
     *
     * @param int   $menu_id   ID of the updated menu.
     * @param array $menu_data An array of menu data.
     */
    do_action('wp_update_nav_menu', $menu_id, $menu_data);
    return $menu_id;
}

WordPress Version: 3.7

/**
 * Save the properties of a menu or create a new menu with those properties.
 *
 * @since 3.0.0
 *
 * @param int $menu_id The ID of the menu or "0" to create a new menu.
 * @param array $menu_data The array of menu data.
 * @return int|error object The menu's ID or WP_Error object.
 */
function wp_update_nav_menu_object($menu_id = 0, $menu_data = array())
{
    $menu_id = (int) $menu_id;
    $_menu = wp_get_nav_menu_object($menu_id);
    $args = array('description' => isset($menu_data['description']) ? $menu_data['description'] : '', 'name' => isset($menu_data['menu-name']) ? $menu_data['menu-name'] : '', 'parent' => isset($menu_data['parent']) ? (int) $menu_data['parent'] : 0, 'slug' => null);
    // double-check that we're not going to have one menu take the name of another
    $_possible_existing = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
    if ($_possible_existing && !is_wp_error($_possible_existing) && isset($_possible_existing->term_id) && $_possible_existing->term_id != $menu_id) {
        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'])));
    }
    // menu doesn't already exist, so create a new menu
    if (!$_menu || is_wp_error($_menu)) {
        $menu_exists = get_term_by('name', $menu_data['menu-name'], 'nav_menu');
        if ($menu_exists) {
            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'])));
        }
        $_menu = wp_insert_term($menu_data['menu-name'], 'nav_menu', $args);
        if (is_wp_error($_menu)) {
            return $_menu;
        }
        do_action('wp_create_nav_menu', $_menu['term_id'], $menu_data);
        return (int) $_menu['term_id'];
    }
    if (!$_menu || !isset($_menu->term_id)) {
        return 0;
    }
    $menu_id = (int) $_menu->term_id;
    $update_response = wp_update_term($menu_id, 'nav_menu', $args);
    if (is_wp_error($update_response)) {
        return $update_response;
    }
    do_action('wp_update_nav_menu', $menu_id, $menu_data);
    return $menu_id;
}