KeyValuePair.php
5 years ago
ListScreenOrder.php
5 years ago
Option.php
5 years ago
OptionFactory.php
5 years ago
SiteOption.php
5 years ago
Timestamp.php
5 years ago
Transaction.php
5 years ago
UserMeta.php
5 years ago
ListScreenOrder.php
39 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AC\Storage; |
| 4 | |
| 5 | class ListScreenOrder { |
| 6 | |
| 7 | const KEY = 'ac_list_screens_order'; |
| 8 | |
| 9 | public function get( $key ) { |
| 10 | $orders = $this->get_data(); |
| 11 | |
| 12 | if ( ! isset( $orders[ $key ] ) ) { |
| 13 | return []; |
| 14 | } |
| 15 | |
| 16 | return $orders[ $key ]; |
| 17 | } |
| 18 | |
| 19 | public function set( $key, array $list_screen_ids ) { |
| 20 | $data = $this->get_data(); |
| 21 | |
| 22 | $data[ $key ] = $list_screen_ids; |
| 23 | |
| 24 | update_option( self::KEY, $data, false ); |
| 25 | } |
| 26 | |
| 27 | public function add( $key, $id ) { |
| 28 | $ids = $this->get( $key ); |
| 29 | |
| 30 | array_unshift( $ids, $id ); |
| 31 | |
| 32 | $this->set( $key, $ids ); |
| 33 | } |
| 34 | |
| 35 | private function get_data() { |
| 36 | return get_option( self::KEY, [] ); |
| 37 | } |
| 38 | |
| 39 | } |