wp_ajax_inline_save_tax

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

WordPress Version: 6.4

/**
 * Handles Quick Edit saving for a term via AJAX.
 *
 * @since 3.1.0
 */
function wp_ajax_inline_save_tax()
{
    check_ajax_referer('taxinlineeditnonce', '_inline_edit');
    $taxonomy = sanitize_key($_POST['taxonomy']);
    $taxonomy_object = get_taxonomy($taxonomy);
    if (!$taxonomy_object) {
        wp_die(0);
    }
    if (!isset($_POST['tax_ID']) || !(int) $_POST['tax_ID']) {
        wp_die(-1);
    }
    $id = (int) $_POST['tax_ID'];
    if (!current_user_can('edit_term', $id)) {
        wp_die(-1);
    }
    $wp_list_table = _get_list_table('WP_Terms_List_Table', array('screen' => 'edit-' . $taxonomy));
    $tag = get_term($id, $taxonomy);
    $_POST['description'] = $tag->description;
    $updated = wp_update_term($id, $taxonomy, $_POST);
    if ($updated && !is_wp_error($updated)) {
        $tag = get_term($updated['term_id'], $taxonomy);
        if (!$tag || is_wp_error($tag)) {
            if (is_wp_error($tag) && $tag->get_error_message()) {
                wp_die($tag->get_error_message());
            }
            wp_die(__('Item not updated.'));
        }
    } else {
        if (is_wp_error($updated) && $updated->get_error_message()) {
            wp_die($updated->get_error_message());
        }
        wp_die(__('Item not updated.'));
    }
    $level = 0;
    $parent = $tag->parent;
    while ($parent > 0) {
        $parent_tag = get_term($parent, $taxonomy);
        $parent = $parent_tag->parent;
        ++$level;
    }
    $wp_list_table->single_row($tag, $level);
    wp_die();
}

WordPress Version: 6.3

/**
 * Handles Quick Edit saving for a term via AJAX.
 *
 * @since 3.1.0
 */
function wp_ajax_inline_save_tax()
{
    check_ajax_referer('taxinlineeditnonce', '_inline_edit');
    $taxonomy = sanitize_key($_POST['taxonomy']);
    $taxonomy_object = get_taxonomy($taxonomy);
    if (!$taxonomy_object) {
        wp_die(0);
    }
    if (!isset($_POST['tax_ID']) || !(int) $_POST['tax_ID']) {
        wp_die(-1);
    }
    $id = (int) $_POST['tax_ID'];
    if (!current_user_can('edit_term', $id)) {
        wp_die(-1);
    }
    $wp_list_table = _get_list_table('WP_Terms_List_Table', array('screen' => 'edit-' . $taxonomy));
    $tag = get_term($id, $taxonomy);
    $_POST['description'] = $tag->description;
    $updated = wp_update_term($id, $taxonomy, $_POST);
    if ($updated && !is_wp_error($updated)) {
        $tag = get_term($updated['term_id'], $taxonomy);
        if (!$tag || is_wp_error($tag)) {
            if (is_wp_error($tag) && $tag->get_error_message()) {
                wp_die($tag->get_error_message());
            }
            wp_die(__('Item not updated.'));
        }
    } else {
        if (is_wp_error($updated) && $updated->get_error_message()) {
            wp_die($updated->get_error_message());
        }
        wp_die(__('Item not updated.'));
    }
    $level = 0;
    $parent = $tag->parent;
    while ($parent > 0) {
        $parent_tag = get_term($parent, $taxonomy);
        $parent = $parent_tag->parent;
        $level++;
    }
    $wp_list_table->single_row($tag, $level);
    wp_die();
}

WordPress Version: 6.1

/**
 * Ajax handler for quick edit saving for a term.
 *
 * @since 3.1.0
 */
function wp_ajax_inline_save_tax()
{
    check_ajax_referer('taxinlineeditnonce', '_inline_edit');
    $taxonomy = sanitize_key($_POST['taxonomy']);
    $taxonomy_object = get_taxonomy($taxonomy);
    if (!$taxonomy_object) {
        wp_die(0);
    }
    if (!isset($_POST['tax_ID']) || !(int) $_POST['tax_ID']) {
        wp_die(-1);
    }
    $id = (int) $_POST['tax_ID'];
    if (!current_user_can('edit_term', $id)) {
        wp_die(-1);
    }
    $wp_list_table = _get_list_table('WP_Terms_List_Table', array('screen' => 'edit-' . $taxonomy));
    $tag = get_term($id, $taxonomy);
    $_POST['description'] = $tag->description;
    $updated = wp_update_term($id, $taxonomy, $_POST);
    if ($updated && !is_wp_error($updated)) {
        $tag = get_term($updated['term_id'], $taxonomy);
        if (!$tag || is_wp_error($tag)) {
            if (is_wp_error($tag) && $tag->get_error_message()) {
                wp_die($tag->get_error_message());
            }
            wp_die(__('Item not updated.'));
        }
    } else {
        if (is_wp_error($updated) && $updated->get_error_message()) {
            wp_die($updated->get_error_message());
        }
        wp_die(__('Item not updated.'));
    }
    $level = 0;
    $parent = $tag->parent;
    while ($parent > 0) {
        $parent_tag = get_term($parent, $taxonomy);
        $parent = $parent_tag->parent;
        $level++;
    }
    $wp_list_table->single_row($tag, $level);
    wp_die();
}

WordPress Version: 5.3

/**
 * Ajax handler for quick edit saving for a term.
 *
 * @since 3.1.0
 */
function wp_ajax_inline_save_tax()
{
    check_ajax_referer('taxinlineeditnonce', '_inline_edit');
    $taxonomy = sanitize_key($_POST['taxonomy']);
    $tax = get_taxonomy($taxonomy);
    if (!$tax) {
        wp_die(0);
    }
    if (!isset($_POST['tax_ID']) || !(int) $_POST['tax_ID']) {
        wp_die(-1);
    }
    $id = (int) $_POST['tax_ID'];
    if (!current_user_can('edit_term', $id)) {
        wp_die(-1);
    }
    $wp_list_table = _get_list_table('WP_Terms_List_Table', array('screen' => 'edit-' . $taxonomy));
    $tag = get_term($id, $taxonomy);
    $_POST['description'] = $tag->description;
    $updated = wp_update_term($id, $taxonomy, $_POST);
    if ($updated && !is_wp_error($updated)) {
        $tag = get_term($updated['term_id'], $taxonomy);
        if (!$tag || is_wp_error($tag)) {
            if (is_wp_error($tag) && $tag->get_error_message()) {
                wp_die($tag->get_error_message());
            }
            wp_die(__('Item not updated.'));
        }
    } else {
        if (is_wp_error($updated) && $updated->get_error_message()) {
            wp_die($updated->get_error_message());
        }
        wp_die(__('Item not updated.'));
    }
    $level = 0;
    $parent = $tag->parent;
    while ($parent > 0) {
        $parent_tag = get_term($parent, $taxonomy);
        $parent = $parent_tag->parent;
        $level++;
    }
    $wp_list_table->single_row($tag, $level);
    wp_die();
}

WordPress Version: 4.7

/**
 * Ajax handler for quick edit saving for a term.
 *
 * @since 3.1.0
 */
function wp_ajax_inline_save_tax()
{
    check_ajax_referer('taxinlineeditnonce', '_inline_edit');
    $taxonomy = sanitize_key($_POST['taxonomy']);
    $tax = get_taxonomy($taxonomy);
    if (!$tax) {
        wp_die(0);
    }
    if (!isset($_POST['tax_ID']) || !$id = (int) $_POST['tax_ID']) {
        wp_die(-1);
    }
    if (!current_user_can('edit_term', $id)) {
        wp_die(-1);
    }
    $wp_list_table = _get_list_table('WP_Terms_List_Table', array('screen' => 'edit-' . $taxonomy));
    $tag = get_term($id, $taxonomy);
    $_POST['description'] = $tag->description;
    $updated = wp_update_term($id, $taxonomy, $_POST);
    if ($updated && !is_wp_error($updated)) {
        $tag = get_term($updated['term_id'], $taxonomy);
        if (!$tag || is_wp_error($tag)) {
            if (is_wp_error($tag) && $tag->get_error_message()) {
                wp_die($tag->get_error_message());
            }
            wp_die(__('Item not updated.'));
        }
    } else {
        if (is_wp_error($updated) && $updated->get_error_message()) {
            wp_die($updated->get_error_message());
        }
        wp_die(__('Item not updated.'));
    }
    $level = 0;
    $parent = $tag->parent;
    while ($parent > 0) {
        $parent_tag = get_term($parent, $taxonomy);
        $parent = $parent_tag->parent;
        $level++;
    }
    $wp_list_table->single_row($tag, $level);
    wp_die();
}

WordPress Version: 4.3

/**
 * Ajax handler for quick edit saving for a term.
 *
 * @since 3.1.0
 *
 * @global WP_List_Table $wp_list_table
 */
function wp_ajax_inline_save_tax()
{
    global $wp_list_table;
    check_ajax_referer('taxinlineeditnonce', '_inline_edit');
    $taxonomy = sanitize_key($_POST['taxonomy']);
    $tax = get_taxonomy($taxonomy);
    if (!$tax) {
        wp_die(0);
    }
    if (!current_user_can($tax->cap->edit_terms)) {
        wp_die(-1);
    }
    $wp_list_table = _get_list_table('WP_Terms_List_Table', array('screen' => 'edit-' . $taxonomy));
    if (!isset($_POST['tax_ID']) || !$id = (int) $_POST['tax_ID']) {
        wp_die(-1);
    }
    $tag = get_term($id, $taxonomy);
    $_POST['description'] = $tag->description;
    $updated = wp_update_term($id, $taxonomy, $_POST);
    if ($updated && !is_wp_error($updated)) {
        $tag = get_term($updated['term_id'], $taxonomy);
        if (!$tag || is_wp_error($tag)) {
            if (is_wp_error($tag) && $tag->get_error_message()) {
                wp_die($tag->get_error_message());
            }
            wp_die(__('Item not updated.'));
        }
    } else {
        if (is_wp_error($updated) && $updated->get_error_message()) {
            wp_die($updated->get_error_message());
        }
        wp_die(__('Item not updated.'));
    }
    $level = 0;
    $parent = $tag->parent;
    while ($parent > 0) {
        $parent_tag = get_term($parent, $taxonomy);
        $parent = $parent_tag->parent;
        $level++;
    }
    $wp_list_table->single_row($tag, $level);
    wp_die();
}

WordPress Version: 4.0

/**
 * Ajax handler for quick edit saving for a term.
 *
 * @since 3.1.0
 */
function wp_ajax_inline_save_tax()
{
    global $wp_list_table;
    check_ajax_referer('taxinlineeditnonce', '_inline_edit');
    $taxonomy = sanitize_key($_POST['taxonomy']);
    $tax = get_taxonomy($taxonomy);
    if (!$tax) {
        wp_die(0);
    }
    if (!current_user_can($tax->cap->edit_terms)) {
        wp_die(-1);
    }
    $wp_list_table = _get_list_table('WP_Terms_List_Table', array('screen' => 'edit-' . $taxonomy));
    if (!isset($_POST['tax_ID']) || !$id = (int) $_POST['tax_ID']) {
        wp_die(-1);
    }
    $tag = get_term($id, $taxonomy);
    $_POST['description'] = $tag->description;
    $updated = wp_update_term($id, $taxonomy, $_POST);
    if ($updated && !is_wp_error($updated)) {
        $tag = get_term($updated['term_id'], $taxonomy);
        if (!$tag || is_wp_error($tag)) {
            if (is_wp_error($tag) && $tag->get_error_message()) {
                wp_die($tag->get_error_message());
            }
            wp_die(__('Item not updated.'));
        }
    } else {
        if (is_wp_error($updated) && $updated->get_error_message()) {
            wp_die($updated->get_error_message());
        }
        wp_die(__('Item not updated.'));
    }
    $level = 0;
    $parent = $tag->parent;
    while ($parent > 0) {
        $parent_tag = get_term($parent, $taxonomy);
        $parent = $parent_tag->parent;
        $level++;
    }
    $wp_list_table->single_row($tag, $level);
    wp_die();
}

WordPress Version: 3.7

function wp_ajax_inline_save_tax()
{
    global $wp_list_table;
    check_ajax_referer('taxinlineeditnonce', '_inline_edit');
    $taxonomy = sanitize_key($_POST['taxonomy']);
    $tax = get_taxonomy($taxonomy);
    if (!$tax) {
        wp_die(0);
    }
    if (!current_user_can($tax->cap->edit_terms)) {
        wp_die(-1);
    }
    $wp_list_table = _get_list_table('WP_Terms_List_Table', array('screen' => 'edit-' . $taxonomy));
    if (!isset($_POST['tax_ID']) || !$id = (int) $_POST['tax_ID']) {
        wp_die(-1);
    }
    $tag = get_term($id, $taxonomy);
    $_POST['description'] = $tag->description;
    $updated = wp_update_term($id, $taxonomy, $_POST);
    if ($updated && !is_wp_error($updated)) {
        $tag = get_term($updated['term_id'], $taxonomy);
        if (!$tag || is_wp_error($tag)) {
            if (is_wp_error($tag) && $tag->get_error_message()) {
                wp_die($tag->get_error_message());
            }
            wp_die(__('Item not updated.'));
        }
    } else {
        if (is_wp_error($updated) && $updated->get_error_message()) {
            wp_die($updated->get_error_message());
        }
        wp_die(__('Item not updated.'));
    }
    $level = 0;
    $parent = $tag->parent;
    while ($parent > 0) {
        $parent_tag = get_term($parent, $taxonomy);
        $parent = $parent_tag->parent;
        $level++;
    }
    $wp_list_table->single_row($tag, $level);
    wp_die();
}