Advertisements

check_ajax_referer

Definition:
function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) {}

Verifies the AJAX request to prevent processing requests external of the blog.

Parameters

  • string $action: Action nonce
  • string $query_arg: where to look for nonce in $_REQUEST (since 2.5)
  • $die

Defined actions

  • check_ajax_referer
    do_action('check_ajax_referer', $action, $result);

Source code

function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) {

	if ( $query_arg )

		$nonce = $_REQUEST[$query_arg];

	else

		$nonce = isset($_REQUEST['_ajax_nonce']) ? $_REQUEST['_ajax_nonce'] : $_REQUEST['_wpnonce'];



	$result = wp_verify_nonce( $nonce, $action );



	if ( $die && false == $result )

		die('-1');



	do_action('check_ajax_referer', $action, $result);



	return $result;

}

595

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: