1 | <?php |
||
3 | abstract class Tabify_Edit_Screen_Settings_Base { |
||
4 | private $type; |
||
5 | private $sections; |
||
6 | private $base_url; |
||
7 | private $tabs; |
||
8 | |||
9 | private $options; |
||
10 | |||
11 | protected $items = array(); |
||
12 | protected $defaults = array(); |
||
13 | |||
14 | /** |
||
15 | * Set properties and load the sections and tabs |
||
16 | * |
||
17 | * @param string $type Where the settings are for |
||
18 | * |
||
19 | * @since 0.4.0 |
||
20 | */ |
||
21 | public function __construct( $type ) { |
||
22 | $this->type = $type; |
||
23 | $this->sections = $this->load_sections(); |
||
24 | $this->base_url = remove_query_arg( array( 'type', 'section' ), $_SERVER["REQUEST_URI"] ); |
||
25 | |||
26 | $this->tabs = new Tabify_Edit_Screen_Tabs( $this->sections, 'vertical', 'subtab' ); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Set the items property when needed. |
||
31 | * |
||
32 | * @since 1.0.0 |
||
33 | */ |
||
34 | abstract protected function load_items(); |
||
35 | |||
36 | /** |
||
37 | * Set properties and load the sections and tabs |
||
38 | * |
||
39 | * @return array The sections |
||
40 | * |
||
41 | * @since 0.4.0 |
||
42 | */ |
||
43 | abstract protected function load_sections(); |
||
44 | |||
45 | /** |
||
46 | * Get sections |
||
47 | * |
||
48 | * @return array The sections |
||
49 | * |
||
50 | * @since 0.4.0 |
||
51 | */ |
||
52 | protected function get_sections() { |
||
53 | return $this->sections; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Get the sections as a tab menu |
||
58 | * |
||
59 | * @since 0.4.0 |
||
60 | */ |
||
61 | public function get_sections_menu() { |
||
62 | echo $this->tabs->get_tabs_with_container(); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Get all the metaboxes that should always be showed |
||
67 | * |
||
68 | * @return array All the metaboxes id's in an array |
||
69 | * |
||
70 | * @since 0.4.0 |
||
71 | */ |
||
72 | public function get_default_items( $id ) { |
||
78 | |||
79 | /** |
||
80 | * Echo all the items |
||
81 | * |
||
82 | * @since 0.4.0 |
||
83 | */ |
||
84 | public function get_sections_box() { |
||
98 | |||
99 | /** |
||
100 | * Get the html for one pacticular section |
||
101 | * |
||
102 | * @param string $section The section name |
||
103 | * |
||
104 | * @since 1.0.0 |
||
105 | */ |
||
106 | private function get_section_box( $section ) { |
||
180 | |||
181 | /** |
||
182 | * Get the html for one pacticular section |
||
183 | * |
||
184 | * @param string $section The section name |
||
185 | * @param string $title The title |
||
186 | * @param array $tab Tab information |
||
187 | * @param boolean $remove |
||
188 | * |
||
189 | * @since 0.4.0 |
||
190 | */ |
||
191 | private function get_section_tab_title( $section, $title, $tab, $remove ) { |
||
192 | echo '<h2><span class="hide-if-no-js">' . $title . '</span><input type="text" name="tabify[' . $this->type . '][' . $section . '][tabs][' . $tab['id'] . '][title]" value="' . esc_html( $title ) . '" class="hide-if-js" /></h2>'; |
||
193 | |||
194 | echo '<div class="tabify-title-box">'; |
||
195 | do_action( 'tabify_settings_tab_title_box', $tab, $section, $this->type ); |
||
196 | |||
197 | echo '<a href="#" class="tabify-remove-tab hide-if-no-js"'; |
||
198 | if ( ! $remove ) { |
||
199 | echo ' style="display: none;"'; |
||
200 | } |
||
201 | echo '>' . __( 'Remove', 'tabify-edit-screen' ) . '</a>'; |
||
202 | echo '</div>'; |
||
203 | |||
204 | echo '<div class="clear"></div>'; |
||
205 | do_action( 'tabify_settings_tab_title_after', $tab, $section, $this->type ); |
||
206 | } |
||
207 | |||
208 | /** |
||
209 | * Get the html for the section sortable list |
||
210 | * |
||
211 | * @param string $section The section name |
||
212 | * @param array $items List of all items in the section |
||
213 | * @param integer $tab_id The id of the tab the list is in |
||
214 | * @param array $default_items List of items that are always shown |
||
215 | * |
||
216 | * @since 1.0.0 |
||
217 | */ |
||
218 | private function get_section_box_list( $section, $items, $tab_id, $default_items ) { |
||
258 | |||
259 | /** |
||
260 | * Show the items for the sortable list |
||
261 | * |
||
262 | * @param integer $item_id The id of the item in the list |
||
263 | * @param string $item_title The title of the item |
||
264 | * @param integer $tab_id The id of the tab the list is in |
||
265 | * @param string $section The section name |
||
266 | * @param array $default_items List of items that are always shown |
||
267 | * |
||
268 | * @since 0.4.0 |
||
269 | */ |
||
270 | protected function list_show_items( $item_id, $item_title, $tab_id, $section, $default_items ) { |
||
316 | |||
317 | |||
318 | /** |
||
319 | * New tabify tab template |
||
320 | * |
||
321 | * @since 0.4.0 |
||
322 | */ |
||
323 | private function print_backbone_template() { |
||
337 | |||
338 | /** |
||
339 | * Get the options of the current type |
||
340 | * |
||
341 | * @since 0.4.0 |
||
342 | */ |
||
343 | protected function get_options( $type = null ) { |
||
354 | |||
355 | } |
||
356 |