check_admin_referer
do_action( ‘check_admin_referer’, string $action, false…
do_action( ‘check_admin_referer’, string $action, false|int $result )
动作钩子::在管理请求被验证或未验证后激发。
Action Hook: Fires once the admin request has been validated or not.
目录锚点:#参数#源码
参数(Parameters)
参数 | 类型 | 说明 |
---|---|---|
$action | (string) | 立即行动。 |
$result | (false | int) | 如果nonce无效,则为False;如果nonce有效并在0-12小时前生成,则为1;如果nonce有效并在12-24小时前生成,则为2。 |
源码(Source)
/** * Makes sure that a user was referred from another admin page. * * To avoid security exploits. * * @since 1.2.0 * * @param int|string $action Action nonce. * @param string $query_arg Optional. Key to check for nonce in `$_REQUEST` (since 2.5). * Default '_wpnonce'. * @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_admin_referer( $action = -1, $query_arg = '_wpnonce' ) { if ( -1 == $action ) _doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '3.2' ); $adminurl = strtolower(admin_url()); $referer = strtolower(wp_get_referer()); $result = isset($_REQUEST[$query_arg]) ? wp_verify_nonce($_REQUEST[$query_arg], $action) : false; /** * Fires once the admin request has been validated or not. * * @since 1.5.1 * * @param string $action The 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_admin_referer', $action, $result ); if ( ! $result && ! ( -1 == $action && strpos( $referer, $adminurl ) === 0 ) ) { wp_nonce_ays( $action ); die(); } return $result; } endif; if ( !function_exists('check_ajax_referer') ) :
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
1.5.1 | wp-includes/pluggable.php:1136 | 1 | 0 |
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
还没有任何评论,赶紧来占个楼吧!