wp_nonce_tick
函数
wp_nonce_tick ( $action = -1 )
- 参数
-
-
(string|int)
$action
Optional. The nonce action. Default -1.- Required: 否
- Default: -1
-
(string|int)
- 返回值
-
- (float) Float value rounded up to the next highest integer.
- 定义位置
-
-
wp-includes/pluggable.php
, line 2248
-
wp-includes/pluggable.php
- 引入
- 2.5.0
- 弃用
- –
Returns the time-dependent variable for nonce creation.
A nonce has a lifespan of two ticks. Nonces in their second tick may be
updated, e.g. by autosave.
function wp_nonce_tick( $action = -1 ) { /** * Filters the lifespan of nonces in seconds. * * @since 2.5.0 * @since 6.1.0 Added `$action` argument to allow for more targeted filters. * * @param int $lifespan Lifespan of nonces in seconds. Default 86,400 seconds, or one day. * @param string|int $action The nonce action, or -1 if none was provided. */ $nonce_life = apply_filters( 'nonce_life', DAY_IN_SECONDS, $action ); return ceil( time() / ( $nonce_life / 2 ) ); } endif; if ( ! function_exists( 'wp_verify_nonce' ) ) : /** * Verifies that a correct security nonce was used with time limit. * * A nonce is valid for 24 hours (by default). * * @since 2.0.3 * * @param string $nonce Nonce value that was used for verification, usually via a form field. * @param string|int $action Should give context to what is taking place and be the same when nonce was created. * @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. */
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。