1 | <?php |
||
11 | abstract class Predefined_Options_Field extends Field { |
||
12 | /** |
||
13 | * Stores the field options (if any) |
||
14 | * |
||
15 | * @var array|callable |
||
16 | **/ |
||
17 | protected $options = array(); |
||
18 | |||
19 | /** |
||
20 | * Set the options of this field. |
||
21 | * Accepts either array of data or a callback that returns the data. |
||
22 | * |
||
23 | * @param array|callable $options |
||
24 | */ |
||
25 | 9 | public function set_options( $options ) { |
|
39 | |||
40 | /** |
||
41 | * Add new options to this field. |
||
42 | * Accepts an array of data. |
||
43 | * |
||
44 | * @param array|callable $options |
||
45 | */ |
||
46 | 9 | public function add_options( $options ) { |
|
62 | |||
63 | /** |
||
64 | * Check if there are callbacks and populate the options |
||
65 | */ |
||
66 | protected function load_options() { |
||
89 | |||
90 | /** |
||
91 | * Changes the options array structure. This is needed to keep the array items order when it is JSON encoded. |
||
92 | * Will also work with a callable that returns an array. |
||
93 | * |
||
94 | * @param array|callable $options |
||
95 | * @return array |
||
96 | */ |
||
97 | public function parse_options( $options ) { |
||
113 | |||
114 | /** |
||
115 | * Retrieve the current options. |
||
116 | * |
||
117 | * @return array|callable $options |
||
118 | */ |
||
119 | 8 | public function get_options() { |
|
122 | } // END Field |
||
123 |