woocommerce-multilingual
/
addons
/
wpml-dependencies
/
vendor
/
wpml
/
wp
/
classes
Last commit date
Attachment.php
1 month ago
Cache.php
1 month ago
Gutenberg.php
1 month ago
Hooks.php
1 month ago
Http.php
1 month ago
Nonce.php
1 month ago
Option.php
1 month ago
Post.php
1 month ago
PostType.php
1 month ago
Resources.php
1 month ago
Roles.php
4 years ago
Transient.php
1 month ago
Url.php
1 month ago
User.php
1 month ago
WP.php
1 month ago
WPDB.php
1 month ago
Nonce.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPML\LIB\WP; |
| 4 | |
| 5 | use WPML\Collect\Support\Collection; |
| 6 | use WPML\Collect\Support\Traits\Macroable; |
| 7 | use WPML\FP\Either; |
| 8 | use function WPML\FP\curryN; |
| 9 | use function WPML\FP\partial; |
| 10 | |
| 11 | class Nonce { |
| 12 | |
| 13 | use Macroable; |
| 14 | |
| 15 | public static function init() { |
| 16 | self::macro( 'verify', curryN( 2, function ( $action, Collection $postData ) { |
| 17 | return wp_verify_nonce( $postData->get( 'nonce' ), $action ?: $postData->get( 'endpoint' ) ) |
| 18 | ? Either::right( $postData ) |
| 19 | : Either::left( 'Nonce error' ); |
| 20 | } ) ); |
| 21 | |
| 22 | self::macro( 'verifyEndPoint', self::verify( '' ) ); |
| 23 | |
| 24 | self::macro( 'create', curryN( 1, function( $str ) { return wp_create_nonce( $str ); } ) ); |
| 25 | } |
| 26 | |
| 27 | } |
| 28 | |
| 29 | Nonce::init(); |
| 30 |