|
1 <?php |
|
2 /** |
|
3 * Initialize the options before anything else. |
|
4 */ |
|
5 add_action( 'admin_init', '_custom_theme_options', 1 ); |
|
6 |
|
7 /** |
|
8 * Theme Mode demo code of all the available option types. |
|
9 * |
|
10 * @return void |
|
11 * |
|
12 * @access private |
|
13 * @since 2.0 |
|
14 */ |
|
15 function _custom_theme_options() { |
|
16 |
|
17 /** |
|
18 * Get a copy of the saved settings array. |
|
19 */ |
|
20 $saved_settings = get_option( 'option_tree_settings', array() ); |
|
21 |
|
22 /** |
|
23 * Create a custom settings array that we pass to |
|
24 * the OptionTree Settings API Class. |
|
25 */ |
|
26 $custom_settings = array( |
|
27 'contextual_help' => array( |
|
28 'content' => array( |
|
29 array( |
|
30 'id' => 'general_help', |
|
31 'title' => 'General', |
|
32 'content' => '<p>Help content goes here!</p>' |
|
33 ) |
|
34 ), |
|
35 'sidebar' => '<p>Sidebar content goes here!</p>' |
|
36 ), |
|
37 'sections' => array( |
|
38 array( |
|
39 'title' => 'General', |
|
40 'id' => 'general_default' |
|
41 ), |
|
42 array( |
|
43 'title' => 'Miscellaneous ', |
|
44 'id' => 'miscellaneous' |
|
45 ) |
|
46 ), |
|
47 'settings' => array( |
|
48 array( |
|
49 'label' => 'Background', |
|
50 'id' => 'my_background', |
|
51 'type' => 'background', |
|
52 'desc' => 'BlahLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
53 'std' => '', |
|
54 'rows' => '', |
|
55 'post_type' => '', |
|
56 'taxonomy' => '', |
|
57 'class' => '', |
|
58 'section' => 'general_default' |
|
59 ), |
|
60 array( |
|
61 'label' => 'Category Checkbox', |
|
62 'id' => 'my_category_checkbox', |
|
63 'type' => 'category-checkbox', |
|
64 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
65 'std' => '', |
|
66 'rows' => '', |
|
67 'post_type' => '', |
|
68 'taxonomy' => '', |
|
69 'class' => '', |
|
70 'section' => 'general_default' |
|
71 ), |
|
72 array( |
|
73 'label' => 'Category Select', |
|
74 'id' => 'my_category_select', |
|
75 'type' => 'category-select', |
|
76 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
77 'std' => '', |
|
78 'rows' => '', |
|
79 'post_type' => '', |
|
80 'taxonomy' => '', |
|
81 'class' => '', |
|
82 'section' => 'general_default' |
|
83 ), |
|
84 array( |
|
85 'label' => 'Checkbox', |
|
86 'id' => 'my_checkbox', |
|
87 'type' => 'checkbox', |
|
88 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
89 'choices' => array( |
|
90 array ( |
|
91 'label' => 'Yes', |
|
92 'value' => 'Yes' |
|
93 ) |
|
94 ), |
|
95 'std' => '', |
|
96 'rows' => '', |
|
97 'post_type' => '', |
|
98 'taxonomy' => '', |
|
99 'class' => '', |
|
100 'section' => 'general_default' |
|
101 ), |
|
102 array( |
|
103 'label' => 'Colorpicker', |
|
104 'id' => 'my_colorpicker', |
|
105 'type' => 'colorpicker', |
|
106 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
107 'std' => '', |
|
108 'rows' => '', |
|
109 'post_type' => '', |
|
110 'taxonomy' => '', |
|
111 'class' => '', |
|
112 'section' => 'general_default' |
|
113 ), |
|
114 array( |
|
115 'label' => 'CSS', |
|
116 'id' => 'my_css', |
|
117 'type' => 'css', |
|
118 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
119 'std' => '', |
|
120 'rows' => '20', |
|
121 'post_type' => '', |
|
122 'taxonomy' => '', |
|
123 'class' => '', |
|
124 'section' => 'general_default' |
|
125 ), |
|
126 array( |
|
127 'label' => 'Custom Post Type Checkbox', |
|
128 'id' => 'my_custom_post_type_checkbox', |
|
129 'type' => 'custom-post-type-checkbox', |
|
130 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
131 'std' => '', |
|
132 'rows' => '', |
|
133 'post_type' => 'post', |
|
134 'taxonomy' => '', |
|
135 'class' => '', |
|
136 'section' => 'general_default' |
|
137 ), |
|
138 array( |
|
139 'label' => 'Custom Post Type Select', |
|
140 'id' => 'my_custom_post_type_select', |
|
141 'type' => 'custom-post-type-select', |
|
142 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
143 'std' => '', |
|
144 'rows' => '', |
|
145 'post_type' => 'post', |
|
146 'taxonomy' => '', |
|
147 'class' => '', |
|
148 'section' => 'general_default' |
|
149 ), |
|
150 array( |
|
151 'label' => 'List Item', |
|
152 'id' => 'my_list_item', |
|
153 'type' => 'list-item', |
|
154 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
155 'settings' => array( |
|
156 array( |
|
157 'label' => 'Upload', |
|
158 'id' => 'my_list_item_upload', |
|
159 'type' => 'upload', |
|
160 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
161 'std' => '', |
|
162 'rows' => '', |
|
163 'post_type' => '', |
|
164 'taxonomy' => '', |
|
165 'class' => '' |
|
166 ), |
|
167 array( |
|
168 'label' => 'Text', |
|
169 'id' => 'my_list_item_text', |
|
170 'type' => 'text', |
|
171 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
172 'std' => '', |
|
173 'rows' => '', |
|
174 'post_type' => '', |
|
175 'taxonomy' => '', |
|
176 'class' => '' |
|
177 ), |
|
178 array( |
|
179 'label' => 'Textarea Simple', |
|
180 'id' => 'my_list_item_textarea_simple', |
|
181 'type' => 'textarea-simple', |
|
182 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
183 'std' => '', |
|
184 'rows' => '10', |
|
185 'post_type' => '', |
|
186 'taxonomy' => '', |
|
187 'class' => '' |
|
188 ) |
|
189 ), |
|
190 'std' => '', |
|
191 'rows' => '', |
|
192 'post_type' => '', |
|
193 'taxonomy' => '', |
|
194 'class' => '', |
|
195 'section' => 'general_default' |
|
196 ), |
|
197 array( |
|
198 'label' => 'Measurement', |
|
199 'id' => 'my_measurement', |
|
200 'type' => 'measurement', |
|
201 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
202 'std' => '', |
|
203 'rows' => '', |
|
204 'post_type' => '', |
|
205 'taxonomy' => '', |
|
206 'class' => '', |
|
207 'section' => 'general_default' |
|
208 ), |
|
209 array( |
|
210 'label' => 'Page Checkbox', |
|
211 'id' => 'my_page_checkbox', |
|
212 'type' => 'page-checkbox', |
|
213 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
214 'std' => '', |
|
215 'rows' => '', |
|
216 'post_type' => '', |
|
217 'taxonomy' => '', |
|
218 'class' => '', |
|
219 'section' => 'general_default' |
|
220 ), |
|
221 array( |
|
222 'label' => 'Page Select', |
|
223 'id' => 'my_page_select', |
|
224 'type' => 'page-select', |
|
225 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
226 'std' => '', |
|
227 'rows' => '', |
|
228 'post_type' => '', |
|
229 'taxonomy' => '', |
|
230 'class' => '', |
|
231 'section' => 'general_default' |
|
232 ), |
|
233 array( |
|
234 'label' => 'Post Checkbox', |
|
235 'id' => 'my_post_checkbox', |
|
236 'type' => 'post-checkbox', |
|
237 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
238 'std' => '', |
|
239 'rows' => '', |
|
240 'post_type' => '', |
|
241 'taxonomy' => '', |
|
242 'class' => '', |
|
243 'section' => 'general_default' |
|
244 ), |
|
245 array( |
|
246 'label' => 'Post Select', |
|
247 'id' => 'my_post_select', |
|
248 'type' => 'post-select', |
|
249 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
250 'std' => '', |
|
251 'rows' => '', |
|
252 'post_type' => '', |
|
253 'taxonomy' => '', |
|
254 'class' => '', |
|
255 'section' => 'general_default' |
|
256 ), |
|
257 array( |
|
258 'label' => 'Radio', |
|
259 'id' => 'my_radio', |
|
260 'type' => 'radio', |
|
261 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
262 'choices' => array( |
|
263 array( |
|
264 'label' => 'Yes', |
|
265 'value' => 'yes' |
|
266 ), |
|
267 array( |
|
268 'label' => 'No', |
|
269 'value' => 'no' |
|
270 ), |
|
271 array( |
|
272 'label' => 'Maybe', |
|
273 'value' => 'maybe' |
|
274 ) |
|
275 ), |
|
276 'std' => 'yes', |
|
277 'rows' => '', |
|
278 'post_type' => '', |
|
279 'taxonomy' => '', |
|
280 'class' => '', |
|
281 'section' => 'miscellaneous' |
|
282 ), |
|
283 array( |
|
284 'label' => 'Radio Image', |
|
285 'id' => 'my_radio_image', |
|
286 'type' => 'radio-image', |
|
287 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
288 'std' => 'right-sidebar', |
|
289 'rows' => '', |
|
290 'post_type' => '', |
|
291 'taxonomy' => '', |
|
292 'class' => '', |
|
293 'section' => 'miscellaneous' |
|
294 ), |
|
295 array( |
|
296 'label' => 'Select', |
|
297 'id' => 'my_select', |
|
298 'type' => 'select', |
|
299 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
300 'choices' => array( |
|
301 array( |
|
302 'label' => 'Yes', |
|
303 'value' => 'yes' |
|
304 ), |
|
305 array( |
|
306 'label' => 'No', |
|
307 'value' => 'no' |
|
308 ), |
|
309 array( |
|
310 'label' => 'Maybe', |
|
311 'value' => 'maybe' |
|
312 ) |
|
313 ), |
|
314 'std' => 'maybe', |
|
315 'rows' => '', |
|
316 'post_type' => '', |
|
317 'taxonomy' => '', |
|
318 'class' => '', |
|
319 'section' => 'miscellaneous' |
|
320 ), |
|
321 array( |
|
322 'label' => 'Slider', |
|
323 'id' => 'my_slider', |
|
324 'type' => 'slider', |
|
325 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
326 'std' => '', |
|
327 'rows' => '', |
|
328 'post_type' => '', |
|
329 'taxonomy' => '', |
|
330 'class' => '', |
|
331 'section' => 'miscellaneous' |
|
332 ), |
|
333 array( |
|
334 'label' => 'Tag Checkbox', |
|
335 'id' => 'my_tag_checkbox', |
|
336 'type' => 'tag-checkbox', |
|
337 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
338 'std' => '', |
|
339 'rows' => '', |
|
340 'post_type' => '', |
|
341 'taxonomy' => '', |
|
342 'class' => '', |
|
343 'section' => 'miscellaneous' |
|
344 ), |
|
345 array( |
|
346 'label' => 'Tag Select', |
|
347 'id' => 'my_tag_select', |
|
348 'type' => 'tag-select', |
|
349 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
350 'std' => '', |
|
351 'rows' => '', |
|
352 'post_type' => '', |
|
353 'taxonomy' => '', |
|
354 'class' => '', |
|
355 'section' => 'miscellaneous' |
|
356 ), |
|
357 array( |
|
358 'label' => 'Taxonomy Checkbox', |
|
359 'id' => 'my_taxonomy_checkbox', |
|
360 'type' => 'taxonomy-checkbox', |
|
361 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
362 'std' => '', |
|
363 'rows' => '', |
|
364 'post_type' => '', |
|
365 'taxonomy' => 'category,post_tag', |
|
366 'class' => '', |
|
367 'section' => 'miscellaneous' |
|
368 ), |
|
369 array( |
|
370 'label' => 'Taxonomy Select', |
|
371 'id' => 'my_taxonomy_select', |
|
372 'type' => 'taxonomy-select', |
|
373 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
374 'std' => '', |
|
375 'rows' => '', |
|
376 'post_type' => '', |
|
377 'taxonomy' => 'category,post_tag', |
|
378 'class' => '', |
|
379 'section' => 'miscellaneous' |
|
380 ), |
|
381 array( |
|
382 'label' => 'Text', |
|
383 'id' => 'my_text', |
|
384 'type' => 'text', |
|
385 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
386 'std' => '', |
|
387 'rows' => '', |
|
388 'post_type' => '', |
|
389 'taxonomy' => '', |
|
390 'class' => '', |
|
391 'section' => 'miscellaneous' |
|
392 ), |
|
393 array( |
|
394 'label' => 'Textarea', |
|
395 'id' => 'my_textarea', |
|
396 'type' => 'textarea', |
|
397 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
398 'std' => '', |
|
399 'rows' => '15', |
|
400 'post_type' => '', |
|
401 'taxonomy' => '', |
|
402 'class' => '', |
|
403 'section' => 'miscellaneous' |
|
404 ), |
|
405 array( |
|
406 'label' => 'Textarea Simple', |
|
407 'id' => 'my_textarea_simple', |
|
408 'type' => 'textarea-simple', |
|
409 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
410 'std' => '', |
|
411 'rows' => '10', |
|
412 'post_type' => '', |
|
413 'taxonomy' => '', |
|
414 'class' => '', |
|
415 'section' => 'miscellaneous' |
|
416 ), |
|
417 array( |
|
418 'label' => 'Textblock', |
|
419 'id' => 'my_textblock', |
|
420 'type' => 'textblock', |
|
421 'desc' => '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>', |
|
422 'std' => '', |
|
423 'rows' => '', |
|
424 'post_type' => '', |
|
425 'taxonomy' => '', |
|
426 'class' => '', |
|
427 'section' => 'miscellaneous' |
|
428 ), |
|
429 array( |
|
430 'label' => 'Textblock Titled', |
|
431 'id' => 'my_textblock_titled', |
|
432 'type' => 'textblock-titled', |
|
433 'desc' => '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>', |
|
434 'std' => '', |
|
435 'rows' => '', |
|
436 'post_type' => '', |
|
437 'taxonomy' => '', |
|
438 'class' => '', |
|
439 'section' => 'miscellaneous' |
|
440 ), |
|
441 array( |
|
442 'label' => 'Typography', |
|
443 'id' => 'my_typography', |
|
444 'type' => 'typography', |
|
445 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
446 'std' => '', |
|
447 'rows' => '', |
|
448 'post_type' => '', |
|
449 'taxonomy' => '', |
|
450 'class' => '', |
|
451 'section' => 'miscellaneous' |
|
452 ), |
|
453 array( |
|
454 'label' => 'Upload', |
|
455 'id' => 'my_upload', |
|
456 'type' => 'upload', |
|
457 'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', |
|
458 'std' => '', |
|
459 'rows' => '', |
|
460 'post_type' => '', |
|
461 'taxonomy' => '', |
|
462 'class' => '', |
|
463 'section' => 'miscellaneous' |
|
464 ) |
|
465 ) |
|
466 ); |
|
467 |
|
468 /* allow settings to be filtered before saving */ |
|
469 $custom_settings = apply_filters( 'option_tree_settings_args', $custom_settings ); |
|
470 |
|
471 /* settings are not the same update the DB */ |
|
472 if ( $saved_settings !== $custom_settings ) { |
|
473 update_option( 'option_tree_settings', $custom_settings ); |
|
474 } |
|
475 |
|
476 } |