1 | <?php |
||
11 | class Theme_Options_Container extends Container { |
||
12 | |||
13 | /** |
||
14 | * Array of registered page slugs to verify uniqueness with |
||
15 | * |
||
16 | * @var array |
||
17 | */ |
||
18 | protected static $registered_pages = array(); |
||
19 | |||
20 | /** |
||
21 | * Array of container settings |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | public $settings = array( |
||
26 | 'parent' => '', |
||
27 | 'file' => '', |
||
28 | 'icon' => '', |
||
29 | 'position' => null, |
||
30 | ); |
||
31 | |||
32 | /** |
||
33 | * {@inheritDoc} |
||
34 | */ |
||
35 | public function __construct( $unique_id, $title, $type, $condition_collection, $condition_translator ) { |
||
42 | |||
43 | /** |
||
44 | * Sanitize a title to a filename |
||
45 | * |
||
46 | * @param string $title |
||
47 | * @return string |
||
48 | */ |
||
49 | protected function title_to_filename( $title, $extension ) { |
||
64 | |||
65 | /** |
||
66 | * Attach container as a theme options page/subpage. |
||
67 | */ |
||
68 | public function init() { |
||
82 | |||
83 | /** |
||
84 | * Checks whether the current save request is valid |
||
85 | * |
||
86 | * @return bool |
||
87 | */ |
||
88 | public function is_valid_save() { |
||
95 | |||
96 | /** |
||
97 | * Perform save operation after successful is_valid_save() check. |
||
98 | * The call is propagated to all fields in the container. |
||
99 | * |
||
100 | * @param mixed $user_data |
||
101 | */ |
||
102 | public function save( $user_data = null ) { |
||
115 | |||
116 | /** |
||
117 | * Get environment array for page request (in admin) |
||
118 | * |
||
119 | * @return array |
||
120 | */ |
||
121 | protected function get_environment_for_request() { |
||
124 | |||
125 | /** |
||
126 | * Perform checks whether the container should be attached during the current request |
||
127 | * |
||
128 | * @return bool True if the container is allowed to be attached |
||
129 | */ |
||
130 | public function is_valid_attach_for_request() { |
||
133 | |||
134 | /** |
||
135 | * Get environment array for object id |
||
136 | * |
||
137 | * @return array |
||
138 | */ |
||
139 | protected function get_environment_for_object( $object_id ) { |
||
142 | |||
143 | /** |
||
144 | * Check container attachment rules against object id |
||
145 | * |
||
146 | * @param int $object_id |
||
147 | * @return bool |
||
148 | */ |
||
149 | public function is_valid_attach_for_object( $object_id = null ) { |
||
152 | |||
153 | /** |
||
154 | * Add theme options container pages. |
||
155 | * Hook the container saving action. |
||
156 | */ |
||
157 | public function attach() { |
||
186 | |||
187 | /** |
||
188 | * Whether this container is currently viewed. |
||
189 | * |
||
190 | * @return boolean |
||
191 | */ |
||
192 | public function should_activate() { |
||
201 | |||
202 | /** |
||
203 | * Output the container markup |
||
204 | */ |
||
205 | public function render() { |
||
214 | |||
215 | /** |
||
216 | * Register the page while making sure it is unique. |
||
217 | * |
||
218 | * @return boolean |
||
219 | */ |
||
220 | protected function register_page() { |
||
248 | |||
249 | /** |
||
250 | * Change the parent theme options page of this container |
||
251 | * |
||
252 | * @return Container $this |
||
253 | */ |
||
254 | public function set_page_parent( $parent ) { |
||
262 | |||
263 | /** |
||
264 | * Set the icon of this theme options page. |
||
265 | * Applicable only for parent theme option pages. |
||
266 | * |
||
267 | * @return Container $this |
||
268 | */ |
||
269 | public function set_icon( $icon ) { |
||
273 | |||
274 | /** |
||
275 | * Set the theme options file name of this container. |
||
276 | * |
||
277 | * @return Container $this |
||
278 | */ |
||
279 | public function set_page_file( $file ) { |
||
283 | |||
284 | /** |
||
285 | * Set the page position of this container in the administration menu. |
||
286 | * |
||
287 | * @return Container $this |
||
288 | */ |
||
289 | public function set_page_position( $position ) { |
||
293 | } |
||
294 | |||
295 |