NO! BEWARE !!!
Don't count on check_admin_referer()
without correct parameters! Because, in some cases it may not die()
(as opposed to your expectations), instead it will just return the false
response.
Look through the outlined behavior of source code logic:
function check_admin_referer( $action = -1, $query_arg = '_wpnonce' ) {
$result = isset( $_REQUEST[ $query_arg ] ) ? wp_verify_nonce( $_REQUEST[ $query_arg ], $action ) : false;
//Now, "die() check"
if ( ! $result && ( -1 !== $action || strpos( wp_get_referer(), admin_url() ) !== 0 ) ) {
die();
}
return $result;
}
So, you need to realize what the logic does. Here breakdown:
A) if you call just check_admin_referrer()
without parameters:
- REMEMBER, it will use the automatically built-in
_wpnonce
value (that is
safe, but still remember to have exactly that field when submitting).
- As you called it without paremeters, it uses default
-1
value for action, leading the die() check
to be skipped and function will not die()
- So, you should always use (when calling without parameters):
if ( check_admin_referer() ) exit;
B) if you want check_admin_referrer
to die automatically, then you should always create your nonces & call it with parameters:
check_admin_referrer($action_name, $name_field );