wp_create_nonce()
wp_create_nonce( string|int $action = -1 ) 创建绑定到特定操作、用户…
wp_create_nonce( string|int $action = -1 )
创建绑定到特定操作、用户、用户会话和时间窗口的加密令牌。
Creates a cryptographic token tied to a specific action, user, user session, and window of time.
目录锚点:#参数#源码#笔记
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $action | (string | int) | 将上下文添加到当前值的标量值。 |
源码(Source)
/**
* Creates a cryptographic token tied to a specific action, user, and window of time.
*
* @since 2.0.3
*
* @param string|int $action Scalar value to add context to the nonce.
* @return string The token.
*/
function wp_create_nonce($action = -1) {
$user = wp_get_current_user();
$uid = (int) $user->ID;
if ( ! $uid ) {
/** This filter is documented in wp-includes/pluggable.php */
$uid = apply_filters( 'nonce_user_logged_out', $uid, $action );
}
$token = wp_get_session_token();
$i = wp_nonce_tick();
return substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 );
}
endif;
if ( !function_exists('wp_salt') ) :| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 4.0.0 | wp-includes/pluggable.php | 11 | 11 |
笔记(Notes)
例子
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





还没有任何评论,赶紧来占个楼吧!