| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* E2pdf Post Helper |
| 5 |
* |
| 6 |
* @copyright Copyright 2017 https://e2pdf.com |
| 7 |
* @license GPLv3 |
| 8 |
* @version 1 |
| 9 |
* @link https://e2pdf.com |
| 10 |
* @since 0.00.01 |
| 11 |
*/ |
| 12 |
if (!defined('ABSPATH')) { |
| 13 |
die('Access denied.'); |
| 14 |
} |
| 15 |
|
| 16 |
class Helper_E2pdf_Post { |
| 17 |
|
| 18 |
private $post = array(); |
| 19 |
|
| 20 |
/** |
| 21 |
* On init |
| 22 |
* Assign $_POST params to $post |
| 23 |
*/ |
| 24 |
public function __construct() { |
| 25 |
if (!empty($_POST)) { |
| 26 |
$this->post = $_POST; |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Get value from $_POST |
| 32 |
* |
| 33 |
* @param string $key - Key of $_POST |
| 34 |
* |
| 35 |
* @return mixed |
| 36 |
*/ |
| 37 |
public function get($key = false) { |
| 38 |
if (!$key) { |
| 39 |
if (!empty($this->post)) { |
| 40 |
return $this->post; |
| 41 |
} else { |
| 42 |
return array(); |
| 43 |
} |
| 44 |
} else { |
| 45 |
if (isset($this->post[$key])) { |
| 46 |
return $this->post[$key]; |
| 47 |
} else { |
| 48 |
return null; |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Set option by Key |
| 55 |
* |
| 56 |
* @param string $key - Key of option |
| 57 |
* @param mixed $value - Value of option |
| 58 |
*/ |
| 59 |
public function set($key, $value) { |
| 60 |
$this->post[$key] = $value; |
| 61 |
} |
| 62 |
|
| 63 |
} |
| 64 |
|