PluginProbe ʕ •ᴥ•ʔ
پارسی دیت – Parsi Date / trunk
پارسی دیت – Parsi Date vtrunk
6.2 6.1 5.1.6 5.1.7 5.1.8 5.1.8.2 6.0 trunk 1.0 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.0.0-alpha 2.1 2.1.1 2.1.2 2.1.3 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0.1 2.3.0.2 2.3.1 2.3.2 2.3.3 2.3.4 3.0.1 3.0.2 3.0.3 4.0.0 4.0.1 4.0.2 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5
wp-parsidate / inc / Helper / Nonce.php
wp-parsidate / inc / Helper Last commit date
Assets.php 15 hours ago Cache.php 3 weeks ago Date.php 15 hours ago Debug.php 15 hours ago FeedReader.php 15 hours ago HTML.php 15 hours ago Helper.php 3 weeks ago JSON.php 3 weeks ago Nonce.php 3 weeks ago Notice.php 15 hours ago Number.php 3 weeks ago NumberConverter.php 15 hours ago Param.php 3 weeks ago Sanitizing.php 15 hours ago Strip.php 3 weeks ago Templates.php 3 weeks ago User.php 3 weeks ago Validating.php 3 weeks ago WooCommerce.php 3 weeks ago WordPress.php 15 hours ago
Nonce.php
38 lines
1 <?php
2
3 namespace WPParsidate\Helper;
4
5 class Nonce {
6 /**
7 * Create nonce
8 *
9 * @param string $action Scalar value to add context to the nonce.
10 *
11 * @return string The token.
12 */
13 public static function create( string $action = WP_PARSI_KEY ): string {
14 return wp_create_nonce( $action );
15 }
16
17 /**
18 * Verifies that a correct security nonce was used with time limit.
19 *
20 * A nonce is valid for between 12 and 24 hours (by default).
21 *
22 * @param string|null $nonce Nonce value that was used for verification, usually via a form field.
23 * @param string|int $action Should give context to what is taking place and be the same when nonce was created.
24 *
25 * @return int|false 1 if the nonce is valid and generated between 0-12 hours ago,
26 * 2 if the nonce is valid and generated between 12-24 hours ago.
27 * False if the nonce is invalid.
28 */
29 public static function verify( ?string $nonce = null, $action = WP_PARSI_KEY ) {
30 $nonce = is_null( $nonce ) && isset( $_POST['nonce'] ) ? Sanitizing::text( wp_unslash( Param::post( 'nonce' ) ) ) : $nonce;
31 if ( is_null( $nonce ) ) {
32 return false;
33 }
34
35 return wp_verify_nonce( $nonce, $action );
36 }
37 }
38