-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme-customizer-demo.php
329 lines (290 loc) · 12.3 KB
/
theme-customizer-demo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
<?php
new theme_customizer();
class theme_customizer
{
public function __construct()
{
add_action ('admin_menu', array(&$this, 'customizer_admin'));
add_action( 'customize_register', array(&$this, 'customize_manager_demo' ));
}
/**
* Add the Customize link to the admin menu
* @return void
*/
public function customizer_admin() {
add_theme_page( 'Customize', 'Customize', 'edit_theme_options', 'customize.php' );
}
/**
* Customizer manager demo
* @param WP_Customizer_Manager $wp_manager
* @return void
*/
public function customize_manager_demo( $wp_manager )
{
$this->demo_section( $wp_manager );
$this->custom_sections( $wp_manager );
}
/**
* A section to show how you use the default customizer controls in WordPress
*
* @param Obj $wp_manager - WP Manager
*
* @return Void
*/
private function demo_section( $wp_manager )
{
$wp_manager->add_section( 'customiser_demo_section', array(
'title' => 'Default Demo Controls',
'priority' => 35,
) );
// Textbox control
$wp_manager->add_setting( 'textbox_setting', array(
'default' => 'Default Value',
) );
$wp_manager->add_control( 'textbox_setting', array(
'label' => 'Text Setting',
'section' => 'customiser_demo_section',
'type' => 'text',
'priority' => 1
) );
// Checkbox control
$wp_manager->add_setting( 'checkbox_setting', array(
'default' => '1',
) );
$wp_manager->add_control( 'checkbox_setting', array(
'label' => 'Checkbox Setting',
'section' => 'customiser_demo_section',
'type' => 'checkbox',
'priority' => 2
) );
// Radio control
$wp_manager->add_setting( 'radio_setting', array(
'default' => '1',
) );
$wp_manager->add_control( 'radio_setting', array(
'label' => 'Radio Setting',
'section' => 'customiser_demo_section',
'type' => 'radio',
'choices' => array("1", "2", "3", "4", "5"),
'priority' => 3
) );
// Select control
$wp_manager->add_setting( 'select_setting', array(
'default' => '1',
) );
$wp_manager->add_control( 'select_setting', array(
'label' => 'Select Dropdown Setting',
'section' => 'customiser_demo_section',
'type' => 'select',
'choices' => array("1", "2", "3", "4", "5"),
'priority' => 4
) );
// Dropdown pages control
$wp_manager->add_setting( 'dropdown_pages_setting', array(
'default' => '1',
) );
$wp_manager->add_control( 'dropdown_pages_setting', array(
'label' => 'Dropdown Pages Setting',
'section' => 'customiser_demo_section',
'type' => 'dropdown-pages',
'priority' => 5
) );
// Color control
$wp_manager->add_setting( 'color_setting', array(
'default' => '#000000',
) );
$wp_manager->add_control( new WP_Customize_Color_Control( $wp_manager, 'color_setting', array(
'label' => 'Color Setting',
'section' => 'customiser_demo_section',
'settings' => 'color_setting',
'priority' => 6
) ) );
// WP_Customize_Upload_Control
$wp_manager->add_setting( 'upload_setting', array(
'default' => '',
) );
$wp_manager->add_control( new WP_Customize_Upload_Control( $wp_manager, 'upload_setting', array(
'label' => 'Upload Setting',
'section' => 'customiser_demo_section',
'settings' => 'upload_setting',
'priority' => 7
) ) );
// WP_Customize_Image_Control
$wp_manager->add_setting( 'image_setting', array(
'default' => '',
) );
$wp_manager->add_control( new WP_Customize_Image_Control( $wp_manager, 'image_setting', array(
'label' => 'Image Setting',
'section' => 'customiser_demo_section',
'settings' => 'image_setting',
'priority' => 8
) ) );
// WP_Customize_Background_Image_Control
$wp_manager->add_setting( 'background_image_setting', array(
'default' => '',
) );
$wp_manager->add_control( new WP_Customize_Image_Control( $wp_manager, 'background_image_setting', array(
'label' => 'Background Image Setting',
'section' => 'customiser_demo_section',
'settings' => 'background_image_setting',
'priority' => 9
) ) );
// WP_Customize_Background_Image_Control
$wp_manager->add_setting( 'background_image_setting', array(
'default' => '',
) );
$wp_manager->add_control( new WP_Customize_Background_Image_Control( $wp_manager, 'background_image_setting', array(
'label' => 'Background Image Setting',
'section' => 'customiser_demo_section',
'settings' => 'background_image_setting',
'priority' => 9
) ) );
}
/**
* Adds a new section to use custom controls in the WordPress customiser
*
* @param Obj $wp_manager - WP Manager
*
* @return Void
*/
private function custom_sections( $wp_manager )
{
$wp_manager->add_section( 'customiser_demo_custom_section', array(
'title' => 'Custom Controls Demo',
'priority' => 36,
) );
// Add A Date Picker
require_once dirname(__FILE__) . '/date/date-picker-custom-control.php';
$wp_manager->add_setting( 'date_picker_setting', array(
'default' => '',
) );
$wp_manager->add_control( new Date_Picker_Custom_Control( $wp_manager, 'date_picker_setting', array(
'label' => 'Date Picker Setting',
'section' => 'customiser_demo_custom_section',
'settings' => 'date_picker_setting',
'priority' => 1
) ) );
// Add A Layout Picker
require_once dirname(__FILE__) . '/layout/layout-picker-custom-control.php';
$wp_manager->add_setting( 'layout_picker_setting', array(
'default' => '',
) );
$wp_manager->add_control( new Layout_Picker_Custom_Control( $wp_manager, 'layout_picker_setting', array(
'label' => 'Layout Picker Setting',
'section' => 'customiser_demo_custom_section',
'settings' => 'layout_picker_setting',
'priority' => 2
) ) );
// Add a category dropdown control
require_once dirname(__FILE__) . '/select/category-dropdown-custom-control.php';
$wp_manager->add_setting( 'category_dropdown_setting', array(
'default' => '',
) );
$wp_manager->add_control( new Category_Dropdown_Custom_Control( $wp_manager, 'category_dropdown_setting', array(
'label' => 'Category Dropdown Setting',
'section' => 'customiser_demo_custom_section',
'settings' => 'category_dropdown_setting',
'priority' => 3
) ) );
// Add a menu dropdown control
require_once dirname(__FILE__) . '/select/menu-dropdown-custom-control.php';
$wp_manager->add_setting( 'menu_dropdown_setting', array(
'default' => '',
) );
$wp_manager->add_control( new Menu_Dropdown_Custom_Control( $wp_manager, 'menu_dropdown_setting', array(
'label' => 'Menu Dropdown Setting',
'section' => 'customiser_demo_custom_section',
'settings' => 'menu_dropdown_setting',
'priority' => 4
) ) );
// Add a post dropdown control
require_once dirname(__FILE__) . '/select/post-dropdown-custom-control.php';
$wp_manager->add_setting( 'post_dropdown_setting', array(
'default' => '',
) );
$wp_manager->add_control( new Post_Dropdown_Custom_Control( $wp_manager, 'post_dropdown_setting', array(
'label' => 'Post Dropdown Setting',
'section' => 'customiser_demo_custom_section',
'settings' => 'post_dropdown_setting',
'priority' => 5
) ) );
// Add a post type dropdown control
require_once dirname(__FILE__) . '/select/post-type-dropdown-custom-control.php';
$wp_manager->add_setting( 'post_type_dropdown_setting', array(
'default' => '',
) );
$wp_manager->add_control( new Post_Type_Dropdown_Custom_Control( $wp_manager, 'post_type_dropdown_setting', array(
'label' => 'Post Type Dropdown Setting',
'section' => 'customiser_demo_custom_section',
'settings' => 'post_type_dropdown_setting',
'priority' => 6
) ) );
// Add a tags dropdown control
require_once dirname(__FILE__) . '/select/tags-dropdown-custom-control.php';
$wp_manager->add_setting( 'tags_dropdown_setting', array(
'default' => '',
) );
$wp_manager->add_control( new Tags_Dropdown_Custom_Control( $wp_manager, 'tags_dropdown_setting', array(
'label' => 'Tags Dropdown Setting',
'section' => 'customiser_demo_custom_section',
'settings' => 'tags_dropdown_setting',
'priority' => 7
) ) );
// Add a taxonomy dropdown control
require_once dirname(__FILE__) . '/select/taxonomy-dropdown-custom-control.php';
$wp_manager->add_setting( 'taxonomy_dropdown_setting', array(
'default' => '',
) );
$wp_manager->add_control( new Taxonomy_Dropdown_Custom_Control( $wp_manager, 'taxonomy_dropdown_setting', array(
'label' => 'Taxonomy Dropdown Setting',
'section' => 'customiser_demo_custom_section',
'settings' => 'taxonomy_dropdown_setting',
'priority' => 8
) ) );
// Add a user dropdown control
require_once dirname(__FILE__) . '/select/user-dropdown-custom-control.php';
$wp_manager->add_setting( 'user_dropdown_setting', array(
'default' => '',
) );
$wp_manager->add_control( new User_Dropdown_Custom_Control( $wp_manager, 'user_dropdown_setting', array(
'label' => 'User Dropdown Setting',
'section' => 'customiser_demo_custom_section',
'settings' => 'user_dropdown_setting',
'priority' => 9
) ) );
// Add a textarea control
require_once dirname(__FILE__) . '/text/textarea-custom-control.php';
$wp_manager->add_setting( 'textarea_text_setting', array(
'default' => '',
) );
$wp_manager->add_control( new Textarea_Custom_Control( $wp_manager, 'textarea_text_setting', array(
'label' => 'Textarea Text Setting',
'section' => 'customiser_demo_custom_section',
'settings' => 'textarea_text_setting',
'priority' => 10
) ) );
// Add a text editor control
require_once dirname(__FILE__) . '/text/text-editor-custom-control.php';
$wp_manager->add_setting( 'text_editor_setting', array(
'default' => '',
) );
$wp_manager->add_control( new Text_Editor_Custom_Control( $wp_manager, 'text_editor_setting', array(
'label' => 'Text Editor Setting',
'section' => 'customiser_demo_custom_section',
'settings' => 'text_editor_setting',
'priority' => 11
) ) );
// Add a Google Font control
require_once dirname(__FILE__) . '/select/google-font-dropdown-custom-control.php';
$wp_manager->add_setting( 'google_font_setting', array(
'default' => '',
) );
$wp_manager->add_control( new Google_Font_Dropdown_Custom_Control( $wp_manager, 'google_font_setting', array(
'label' => 'Google Font Setting',
'section' => 'customiser_demo_custom_section',
'settings' => 'google_font_setting',
'priority' => 12
) ) );
}
}
?>