| 1 |
<?php |
| 2 |
|
| 3 |
namespace SlimStat\Utils; |
| 4 |
|
| 5 |
class Request |
| 6 |
{ |
| 7 |
/** |
| 8 |
* Get a value from $_GET array |
| 9 |
* |
| 10 |
* @param string $key |
| 11 |
* @param mixed $default |
| 12 |
* @return mixed |
| 13 |
*/ |
| 14 |
public static function get($key, $default = null) |
| 15 |
{ |
| 16 |
return isset($_GET[$key]) ? \sanitize_text_field(\wp_unslash($_GET[$key])) : $default; |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Get a value from $_POST array |
| 21 |
* |
| 22 |
* @param string $key |
| 23 |
* @param mixed $default |
| 24 |
* @return mixed |
| 25 |
*/ |
| 26 |
public static function post($key, $default = null) |
| 27 |
{ |
| 28 |
return isset($_POST[$key]) ? \sanitize_text_field(\wp_unslash($_POST[$key])) : $default; |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Get a value from $_REQUEST array |
| 33 |
* |
| 34 |
* @param string $key |
| 35 |
* @param mixed $default |
| 36 |
* @return mixed |
| 37 |
*/ |
| 38 |
public static function request($key, $default = null) |
| 39 |
{ |
| 40 |
return isset($_REQUEST[$key]) ? \sanitize_text_field(\wp_unslash($_REQUEST[$key])) : $default; |
| 41 |
} |
| 42 |
} |