| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* E2pdf Get Helper |
| 5 |
* |
| 6 |
* @copyright Copyright 2017 https://e2pdf.com |
| 7 |
* @license GPL v2 |
| 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_Get { |
| 17 |
|
| 18 |
private $get = array(); |
| 19 |
private $page = null; |
| 20 |
|
| 21 |
/** |
| 22 |
* On init |
| 23 |
* Assign $_GET params to $get |
| 24 |
* |
| 25 |
* @param string $url - Current url |
| 26 |
*/ |
| 27 |
public function __construct($url) { |
| 28 |
$this->get = wp_parse_args($url); |
| 29 |
$this->page = reset($this->get); |
| 30 |
array_shift($this->get); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Get value from $_GET |
| 35 |
* |
| 36 |
* @param string $key - Array key |
| 37 |
* |
| 38 |
* @return mixed - Return value by get key |
| 39 |
*/ |
| 40 |
public function get($key = false) { |
| 41 |
|
| 42 |
if (!$key) { |
| 43 |
if (!empty($this->get)) { |
| 44 |
return $this->get; |
| 45 |
} else { |
| 46 |
return array(); |
| 47 |
} |
| 48 |
} else { |
| 49 |
if (isset($this->get[$key])) { |
| 50 |
return $this->get[$key]; |
| 51 |
} else { |
| 52 |
return null; |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Get current page |
| 59 |
* |
| 60 |
* @return string - Current page |
| 61 |
*/ |
| 62 |
public function get_page() { |
| 63 |
return $this->page; |
| 64 |
} |
| 65 |
|
| 66 |
} |
| 67 |
|