Url
5 years ago
DateRange.php
5 years ago
ListScreenId.php
5 years ago
QueryAware.php
5 years ago
QueryAwareTrait.php
5 years ago
ToggleOptions.php
5 years ago
Url.php
5 years ago
QueryAwareTrait.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AC\Type; |
| 4 | |
| 5 | trait QueryAwareTrait { |
| 6 | |
| 7 | /** |
| 8 | * @var string |
| 9 | */ |
| 10 | protected $url; |
| 11 | |
| 12 | public function add_one( $key, $value ) { |
| 13 | $this->url = add_query_arg( $key, $value, $this->url ); |
| 14 | } |
| 15 | |
| 16 | public function add( array $params = [] ) { |
| 17 | foreach ( $params as $key => $value ) { |
| 18 | $this->add_one( $key, $value ); |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | public function remove( $key ) { |
| 23 | $this->url = remove_query_arg( $key, $this->url ); |
| 24 | } |
| 25 | |
| 26 | public function get_url() { |
| 27 | return $this->url; |
| 28 | } |
| 29 | |
| 30 | } |