check_ajax_referer

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

WordPress Version: 6.2

/**
 * Verifies the Ajax request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $stop      Optional. Whether to stop early when the nonce cannot be verified.
 *                                Default true.
 * @return int|false 1 if the nonce is valid and generated between 0-12 hours ago,
 *                   2 if the nonce is valid and generated between 12-24 hours ago.
 *                   False if the nonce is invalid.
 */
function check_ajax_referer($action = -1, $query_arg = false, $stop = true)
{
    if (-1 == $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify an action to be verified by using the first parameter.'), '4.7.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the Ajax request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The Ajax nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($stop && false === $result) {
        if (wp_doing_ajax()) {
            wp_die(-1, 403);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: 5.8

/**
 * Verifies the Ajax request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return int|false 1 if the nonce is valid and generated between 0-12 hours ago,
 *                   2 if the nonce is valid and generated between 12-24 hours ago.
 *                   False if the nonce is invalid.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 == $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify an action to be verified by using the first parameter.'), '4.7.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the Ajax request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The Ajax nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (wp_doing_ajax()) {
            wp_die(-1, 403);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: 5.4

/**
 * Verifies the Ajax request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return int|false 1 if the nonce is valid and generated between 0-12 hours ago,
 *                   2 if the nonce is valid and generated between 12-24 hours ago.
 *                   False if the nonce is invalid.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 == $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '4.7');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the Ajax request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The Ajax nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (wp_doing_ajax()) {
            wp_die(-1, 403);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: 4.7

/**
 * Verifies the Ajax request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 == $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '4.7');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the Ajax request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The Ajax nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (wp_doing_ajax()) {
            wp_die(-1, 403);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: 6.3

/**
 * Verifies the Ajax request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the Ajax request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The Ajax nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: .20

/**
 * Verifies the Ajax request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the Ajax request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The Ajax nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: 6.2

/**
 * Verifies the Ajax request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the Ajax request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The Ajax nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: .16

/**
 * Verifies the Ajax request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the Ajax request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The Ajax nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: 4.6

/**
 * Verifies the Ajax request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the Ajax request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The Ajax nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: 5.4

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: .30

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: 5.3

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: .20

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: 5.2

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: .19

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: 4.4

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: .30

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: 4.3

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: .20

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: 4.4

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    return $result;
}

WordPress Version: 3.4

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: .30

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: 3.3

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: .21

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: 4.3

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false === $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: 2.4

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: .30

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: 2.3

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: .25

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: 4.2

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string   $action    Action nonce.
 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
 *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
 *                                (in that order). Default false.
 * @param bool         $die       Optional. Whether to die early when the nonce cannot be verified.
 *                                Default true.
 * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
 *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string    $action The AJAX nonce action.
     * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
     *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: 1.5

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string $action    Action nonce
 * @param string     $query_arg Where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string $action The AJAX nonce action.
     * @param bool   $result Whether the AJAX request nonce was validated.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: .40

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string $action    Action nonce
 * @param string     $query_arg Where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string $action The AJAX nonce action.
     * @param bool   $result Whether the AJAX request nonce was validated.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: 1.4

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string $action    Action nonce
 * @param string     $query_arg Where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string $action The AJAX nonce action.
     * @param bool   $result Whether the AJAX request nonce was validated.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: .30

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string $action    Action nonce
 * @param string     $query_arg Where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string $action The AJAX nonce action.
     * @param bool   $result Whether the AJAX request nonce was validated.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: 1.3

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string $action    Action nonce
 * @param string     $query_arg Where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string $action The AJAX nonce action.
     * @param bool   $result Whether the AJAX request nonce was validated.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: .28

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string $action    Action nonce
 * @param string     $query_arg Where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string $action The AJAX nonce action.
     * @param bool   $result Whether the AJAX request nonce was validated.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: 4.1

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param int|string $action    Action nonce
 * @param string     $query_arg Where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string $action The AJAX nonce action.
     * @param bool   $result Whether the AJAX request nonce was validated.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: 0.4

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param string $action Action nonce
 * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string $action The AJAX nonce action.
     * @param bool   $result Whether the AJAX request nonce was validated.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: .30

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param string $action Action nonce
 * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string $action The AJAX nonce action.
     * @param bool   $result Whether the AJAX request nonce was validated.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: 0.3

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param string $action Action nonce
 * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string $action The AJAX nonce action.
     * @param bool   $result Whether the AJAX request nonce was validated.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: .28

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param string $action Action nonce
 * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string $action The AJAX nonce action.
     * @param bool   $result Whether the AJAX request nonce was validated.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: 3.9

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param string $action Action nonce
 * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    /**
     * Fires once the AJAX request has been validated or not.
     *
     * @since 2.1.0
     *
     * @param string $action The AJAX nonce action.
     * @param bool   $result Whether the AJAX request nonce was validated.
     */
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: 8.4

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param string $action Action nonce
 * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: .31

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param string $action Action nonce
 * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: 7.5

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param string $action Action nonce
 * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: .40

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param string $action Action nonce
 * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: 7.4

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param string $action Action nonce
 * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: .31

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param string $action Action nonce
 * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    if (-1 === $action) {
        _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
    }
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    do_action('check_ajax_referer', $action, $result);
    return $result;
}

WordPress Version: 3.7

/**
 * Verifies the AJAX request to prevent processing requests external of the blog.
 *
 * @since 2.0.3
 *
 * @param string $action Action nonce
 * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
 */
function check_ajax_referer($action = -1, $query_arg = false, $die = true)
{
    $nonce = '';
    if ($query_arg && isset($_REQUEST[$query_arg])) {
        $nonce = $_REQUEST[$query_arg];
    } elseif (isset($_REQUEST['_ajax_nonce'])) {
        $nonce = $_REQUEST['_ajax_nonce'];
    } elseif (isset($_REQUEST['_wpnonce'])) {
        $nonce = $_REQUEST['_wpnonce'];
    }
    $result = wp_verify_nonce($nonce, $action);
    if ($die && false == $result) {
        if (defined('DOING_AJAX') && DOING_AJAX) {
            wp_die(-1);
        } else {
            die('-1');
        }
    }
    do_action('check_ajax_referer', $action, $result);
    return $result;
}