| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) || exit; |
| 3 |
|
| 4 |
/** |
| 5 |
* Get value from $_POST. |
| 6 |
* |
| 7 |
* @since 1.1.0 |
| 8 |
* |
| 9 |
* @param string $needle Name of the searched key. |
| 10 |
* @param mixed $default Optional. Value to return if the needle isn't found. |
| 11 |
* |
| 12 |
* @return string Returns the value if found; else $default is returned. |
| 13 |
*/ |
| 14 |
function sellkit_post( $needle, $default = null ) { |
| 15 |
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.CSRF.NonceVerification.NoNonceVerification -- Generic accessor; callers verify nonces when required. |
| 16 |
return sellkit_get( $needle, $_POST, $default ); |
| 17 |
} |
| 18 |
|
| 19 |
|
| 20 |
/** |
| 21 |
* Get value from $_GET or defined $haystack. |
| 22 |
* |
| 23 |
* @since 1.1.0 |
| 24 |
* |
| 25 |
* @param string $needle Name of the searched key. |
| 26 |
* @param mixed $haystack Optional. The target to search. If false, $_GET is set to be the $haystack. |
| 27 |
* @param mixed $default Optional. Value to return if the needle isn't found. |
| 28 |
* |
| 29 |
* @return string Returns the value if found; else $default is returned. |
| 30 |
*/ |
| 31 |
function sellkit_get( $needle, $haystack = false, $default = null ) { |
| 32 |
|
| 33 |
if ( false === $haystack ) { |
| 34 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.CSRF.NonceVerification.NoNonceVerification -- Generic read helper; callers verify nonces when required. |
| 35 |
$haystack = $_GET; |
| 36 |
} |
| 37 |
|
| 38 |
$haystack = (array) $haystack; |
| 39 |
|
| 40 |
if ( isset( $haystack[ $needle ] ) ) { |
| 41 |
return $haystack[ $needle ]; |
| 42 |
} |
| 43 |
|
| 44 |
return $default; |
| 45 |
} |
| 46 |
|