wp_ajax_menu_locations_save

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

WordPress Version: 6.3

/**
 * Handles saving menu locations via AJAX.
 *
 * @since 3.1.0
 */
function wp_ajax_menu_locations_save()
{
    if (!current_user_can('edit_theme_options')) {
        wp_die(-1);
    }
    check_ajax_referer('add-menu_item', 'menu-settings-column-nonce');
    if (!isset($_POST['menu-locations'])) {
        wp_die(0);
    }
    set_theme_mod('nav_menu_locations', array_map('absint', $_POST['menu-locations']));
    wp_die(1);
}

WordPress Version: 4.0

/**
 * Ajax handler for menu locations save.
 *
 * @since 3.1.0
 */
function wp_ajax_menu_locations_save()
{
    if (!current_user_can('edit_theme_options')) {
        wp_die(-1);
    }
    check_ajax_referer('add-menu_item', 'menu-settings-column-nonce');
    if (!isset($_POST['menu-locations'])) {
        wp_die(0);
    }
    set_theme_mod('nav_menu_locations', array_map('absint', $_POST['menu-locations']));
    wp_die(1);
}

WordPress Version: 3.7

function wp_ajax_menu_locations_save()
{
    if (!current_user_can('edit_theme_options')) {
        wp_die(-1);
    }
    check_ajax_referer('add-menu_item', 'menu-settings-column-nonce');
    if (!isset($_POST['menu-locations'])) {
        wp_die(0);
    }
    set_theme_mod('nav_menu_locations', array_map('absint', $_POST['menu-locations']));
    wp_die(1);
}