| 1 |
<?php |
| 2 |
/** |
| 3 |
* Security helpers for Sliderberg. |
| 4 |
* |
| 5 |
* @package Sliderberg |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Generate a nonce for the given action. |
| 14 |
* |
| 15 |
* Thin wrapper around wp_create_nonce() so callers don't depend directly on |
| 16 |
* the WP function name and the implementation can be swapped later. |
| 17 |
* |
| 18 |
* @param string $action Action name. |
| 19 |
* @return string Nonce value. |
| 20 |
*/ |
| 21 |
function sliderberg_generate_secure_nonce( $action ) { |
| 22 |
return wp_create_nonce( $action ); |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Verify a nonce for the given action. |
| 27 |
* |
| 28 |
* @param string $nonce Nonce value to verify. |
| 29 |
* @param string $action Action name. |
| 30 |
* @return bool True if valid, false otherwise. |
| 31 |
*/ |
| 32 |
function sliderberg_verify_secure_nonce( $nonce, $action ) { |
| 33 |
return (bool) wp_verify_nonce( $nonce, $action ); |
| 34 |
} |
| 35 |
|