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