Completed
Push — develop ( dbc86e...e0739f )
by Aristeides
02:43 queued 38s
created

example.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * An example file demonstrating how to add all controls.
4
 *
5
 * @package     Kirki
6
 * @category    Core
7
 * @author      Aristeides Stathopoulos
8
 * @copyright   Copyright (c) 2017, Aristeides Stathopoulos
9
 * @license     http://opensource.org/licenses/https://opensource.org/licenses/MIT
10
 * @since       3.0.12
11
 */
12
13
// Exit if accessed directly.
14
if ( ! defined( 'ABSPATH' ) ) {
15
	exit;
16
}
17
18
// Do not proceed if Kirki does not exist.
19
if ( ! class_exists( 'Kirki' ) ) {
20
	return;
21
}
22
23
/**
24
 * First of all, add the config.
25
 *
26
 * @link https://aristath.github.io/kirki/docs/getting-started/config.html
27
 */
28
Kirki::add_config( 'kirki_demo', array(
29
	'capability'  => 'edit_theme_options',
30
	'option_type' => 'theme_mod',
31
) );
32
33
/**
34
 * Add a panel.
35
 *
36
 * @link https://aristath.github.io/kirki/docs/getting-started/panels.html
37
 */
38
Kirki::add_panel( 'kirki_demo_panel', array(
39
	'priority'    => 10,
40
	'title'       => esc_attr__( 'Kirki Demo Panel', 'kirki' ),
41
	'description' => esc_attr__( 'Contains sections for all kirki controls.', 'kirki' ),
42
) );
43
44
/**
45
 * Add Sections.
46
 *
47
 * We'll be doing things a bit differently here, just to demonstrate an example.
48
 * We're going to define 1 section per control-type just to keep things clean and separate.
49
 *
50
 * @link https://aristath.github.io/kirki/docs/getting-started/sections.html
51
 */
52
$sections = array(
53
	'background'      => array( esc_attr__( 'Background', 'kirki' ), '' ),
54
	'code'            => array( esc_attr__( 'Code', 'kirki' ), '' ),
55
	'checkbox'        => array( esc_attr__( 'Checkbox', 'kirki' ), '' ),
56
	'color'           => array( esc_attr__( 'Color', 'kirki' ), '' ),
57
	'color-palette'   => array( esc_attr__( 'Color Palette', 'kirki' ), '' ),
58
	'custom'          => array( esc_attr__( 'Custom', 'kirki' ), '' ),
59
	'dashicons'       => array( esc_attr__( 'Dashicons', 'kirki' ), '' ),
60
	'date'            => array( esc_attr__( 'Date', 'kirki' ), '' ),
61
	'dimension'       => array( esc_attr__( 'Dimension', 'kirki' ), '' ),
62
	'dimensions'      => array( esc_attr__( 'Dimensions', 'kirki' ), '' ),
63
	'editor'          => array( esc_attr__( 'Editor', 'kirki' ), '' ),
64
	'fontawesome'     => array( esc_attr__( 'Font-Awesome', 'kirki' ), '' ),
65
	'generic'         => array( esc_attr__( 'Generic', 'kirki' ), '' ),
66
	'image'           => array( esc_attr__( 'Image', 'kirki' ), '' ),
67
	'multicheck'      => array( esc_attr__( 'Multicheck', 'kirki' ), '' ),
68
	'multicolor'      => array( esc_attr__( 'Multicolor', 'kirki' ), '' ),
69
	'number'          => array( esc_attr__( 'Number', 'kirki' ), '' ),
70
	'palette'         => array( esc_attr__( 'Palette', 'kirki' ), '' ),
71
	'preset'          => array( esc_attr__( 'Preset', 'kirki' ), '' ),
72
	'radio'           => array( esc_attr__( 'Radio', 'kirki' ), esc_attr__( 'A plain Radio control.', 'kirki' ) ),
73
	'radio-buttonset' => array( esc_attr__( 'Radio Buttonset', 'kirki' ), esc_attr__( 'Radio-Buttonset controls are essentially radio controls with some fancy styling to make them look cooler.', 'kirki' ) ),
74
	'radio-image'     => array( esc_attr__( 'Radio Image', 'kirki' ), esc_attr__( 'Radio-Image controls are essentially radio controls with some fancy styles to use images', 'kirki' ) ),
75
	'repeater'        => array( esc_attr__( 'Repeater', 'kirki' ), '' ),
76
	'select'          => array( esc_attr__( 'Select', 'kirki' ), '' ),
77
	'slider'          => array( esc_attr__( 'Slider', 'kirki' ), '' ),
78
	'sortable'        => array( esc_attr__( 'Sortable', 'kirki' ), '' ),
79
	'switch'          => array( esc_attr__( 'Switch', 'kirki' ), '' ),
80
	'toggle'          => array( esc_attr__( 'Toggle', 'kirki' ), '' ),
81
	'typography'      => array( esc_attr__( 'Typography', 'kirki' ), '' ),
82
);
83
foreach ( $sections as $section_id => $section ) {
84
	Kirki::add_section( str_replace( '-', '_', $section_id ) . '_section', array(
85
		'title'       => $section[0],
86
		'description' => $section[1],
87
		'panel'       => 'kirki_demo_panel',
88
	) );
89
}
90
91
/**
92
 * Background Control.
93
 *
94
 * @todo Triggers change on load.
95
 */
96
Kirki::add_field( 'kirki_demo', array(
97
	'type'        => 'background',
98
	'settings'    => 'background_setting',
99
	'label'       => esc_attr__( 'Background Control', 'kirki' ),
100
	'description' => esc_attr__( 'Background conrols are pretty complex! (but useful if properly used)', 'kirki' ),
101
	'section'     => 'background_section',
102
	'default'     => array(
103
		'background-color'      => 'rgba(20,20,20,.8)',
104
		'background-image'      => '',
105
		'background-repeat'     => 'repeat-all',
106
		'background-position'   => 'center center',
107
		'background-size'       => 'cover',
108
		'background-attachment' => 'scroll',
109
	),
110
) );
111
112
/**
113
 * Code control.
114
 *
115
 * @link https://aristath.github.io/kirki/docs/controls/code.html
116
 */
117
Kirki::add_field( 'kirki_demo', array(
118
	'type'        => 'code',
119
	'settings'    => 'code_setting',
120
	'label'       => esc_attr__( 'Code Control', 'kirki' ),
121
	'description' => esc_attr__( 'Description', 'kirki' ),
122
	'section'     => 'code_section',
123
	'default'     => '',
124
	'choices'     => array(
125
		'language' => 'css',
126
		'theme'    => 'monokai',
127
	),
128
) );
129
130
/**
131
 * Checkbox control.
132
 *
133
 * @link https://aristath.github.io/kirki/docs/controls/checkbox.html
134
 */
135
Kirki::add_field( 'kirki_demo', array(
136
	'type'        => 'checkbox',
137
	'settings'    => 'checkbox_setting',
138
	'label'       => esc_attr__( 'Checkbox Control', 'kirki' ),
139
	'description' => esc_attr__( 'Description', 'kirki' ),
140
	'section'     => 'checkbox_section',
141
	'default'     => true,
142
) );
143
144
/**
145
 * Color Controls.
146
 *
147
 * @link https://aristath.github.io/kirki/docs/controls/color.html
148
 */
149
Kirki::add_field( 'kirki_demo', array(
150
	'type'        => 'color',
151
	'settings'    => 'color_setting_hex',
152
	'label'       => __( 'Color Control (hex-only)', 'kirki' ),
153
	'description' => esc_attr__( 'This is a color control - without alpha channel.', 'kirki' ),
154
	'section'     => 'color_section',
155
	'default'     => '#0088CC',
156
) );
157
158
Kirki::add_field( 'kirki_demo', array(
159
	'type'        => 'color',
160
	'settings'    => 'color_setting_rgba',
161
	'label'       => __( 'Color Control (with alpha channel)', 'kirki' ),
162
	'description' => esc_attr__( 'This is a color control - with alpha channel.', 'kirki' ),
163
	'section'     => 'color_section',
164
	'default'     => '#0088CC',
165
	'choices'     => array(
166
		'alpha' => true,
167
	),
168
) );
169
170
/**
171
 * DateTime Control.
172
 */
173
Kirki::add_field( 'kirki_demo', array(
174
	'type'        => 'date',
175
	'settings'    => 'date_setting',
176
	'label'       => esc_attr__( 'Date Control', 'kirki' ),
177
	'description' => esc_attr__( 'This is a date control.', 'kirki' ),
178
	'section'     => 'date_section',
179
	'default'     => '',
180
) );
181
182
/**
183
 * Editor Controls
184
 */
185
Kirki::add_field( 'kirki_demo', array(
186
	'type'        => 'editor',
187
	'settings'    => 'editor_1',
188
	'label'       => esc_attr__( 'First Editor Control', 'kirki' ),
189
	'description' => esc_attr__( 'This is an editor control.', 'kirki' ),
190
	'section'     => 'editor_section',
191
	'default'     => '',
192
) );
193
194
Kirki::add_field( 'kirki_demo', array(
195
	'type'        => 'editor',
196
	'settings'    => 'editor_2',
197
	'label'       => esc_attr__( 'Second Editor Control', 'kirki' ),
198
	'description' => esc_attr__( 'This is a 2nd editor control just to check that we do not have issues with multiple instances.', 'kirki' ),
199
	'section'     => 'editor_section',
200
	'default'     => esc_attr__( 'Default Text', 'kirki' ),
201
) );
202
203
/**
204
 * Color-Palette Controls.
205
 *
206
 * @link https://aristath.github.io/kirki/docs/controls/color-palette.html
207
 */
208
Kirki::add_field( 'kirki_demo', array(
209
	'type'        => 'color-palette',
210
	'settings'    => 'color_palette_setting_0',
211
	'label'       => esc_attr__( 'Color-Palette', 'kirki' ),
212
	'description' => esc_attr__( 'This is a color-palette control', 'kirki' ),
213
	'section'     => 'color_palette_section',
214
	'default'     => '#888888',
215
	'choices'     => array(
216
		'colors' => array( '#000000', '#222222', '#444444', '#666666', '#888888', '#aaaaaa', '#cccccc', '#eeeeee', '#ffffff' ),
217
		'style'  => 'round',
218
	),
219
) );
220
221
Kirki::add_field( 'kirki_demo', array(
222
	'type'        => 'color-palette',
223
	'settings'    => 'color_palette_setting_4',
224
	'label'       => esc_attr__( 'Color-Palette', 'kirki' ),
225
	'description' => esc_attr__( 'Material Design Colors - all', 'kirki' ),
226
	'section'     => 'color_palette_section',
227
	'default'     => '#F44336',
228
	'choices'     => array(
229
		'colors' => Kirki_Helper::get_material_design_colors( 'all' ),
230
		'size'   => 17,
231
	),
232
) );
233
234
Kirki::add_field( 'kirki_demo', array(
235
	'type'        => 'color-palette',
236
	'settings'    => 'color_palette_setting_1',
237
	'label'       => esc_attr__( 'Color-Palette', 'kirki' ),
238
	'description' => esc_attr__( 'Material Design Colors - primary', 'kirki' ),
239
	'section'     => 'color_palette_section',
240
	'default'     => '#000000',
241
	'choices'     => array(
242
		'colors' => Kirki_Helper::get_material_design_colors( 'primary' ),
243
		'size'   => 25,
244
	),
245
) );
246
247
Kirki::add_field( 'kirki_demo', array(
248
	'type'        => 'color-palette',
249
	'settings'    => 'color_palette_setting_2',
250
	'label'       => esc_attr__( 'Color-Palette', 'kirki' ),
251
	'description' => esc_attr__( 'Material Design Colors - red', 'kirki' ),
252
	'section'     => 'color_palette_section',
253
	'default'     => '#FF1744',
254
	'choices'     => array(
255
		'colors' => Kirki_Helper::get_material_design_colors( 'red' ),
256
		'size'   => 16,
257
	),
258
) );
259
260
Kirki::add_field( 'kirki_demo', array(
261
	'type'        => 'color-palette',
262
	'settings'    => 'color_palette_setting_3',
263
	'label'       => esc_attr__( 'Color-Palette', 'kirki' ),
264
	'description' => esc_attr__( 'Material Design Colors - A100', 'kirki' ),
265
	'section'     => 'color_palette_section',
266
	'default'     => '#FF80AB',
267
	'choices'     => array(
268
		'colors' => Kirki_Helper::get_material_design_colors( 'A100' ),
269
		'size'   => 60,
270
		'style'  => 'round',
271
	),
272
) );
273
274
/**
275
 * Dashicons control.
276
 *
277
 * @link https://aristath.github.io/kirki/docs/controls/dashicons.html
278
 */
279
Kirki::add_field( 'kirki_demo', array(
280
	'type'        => 'dashicons',
281
	'settings'    => 'dashicons_setting_0',
282
	'label'       => esc_attr__( 'Dashicons Control', 'kirki' ),
283
	'description' => esc_attr__( 'Using a custom array of dashicons', 'kirki' ),
284
	'section'     => 'dashicons_section',
285
	'default'     => 'menu',
286
	'choices'     => array(
287
		'menu',
288
		'admin-site',
289
		'dashboard',
290
		'admin-post',
291
		'admin-media',
292
		'admin-links',
293
		'admin-page',
294
	),
295
) );
296
297
Kirki::add_field( 'kirki_demo', array(
298
	'type'        => 'dashicons',
299
	'settings'    => 'dashicons_setting_1',
300
	'label'       => esc_attr__( 'All Dashicons', 'kirki' ),
301
	'description' => esc_attr__( 'Showing all dashicons', 'kirki' ),
302
	'section'     => 'dashicons_section',
303
	'default'     => 'menu',
304
) );
305
306
/**
307
 * Dimension Control.
308
 */
309
Kirki::add_field( 'kirki_demo', array(
310
	'type'        => 'dimension',
311
	'settings'    => 'dimension_0',
312
	'label'       => esc_attr__( 'Dimension Control', 'kirki' ),
313
	'description' => esc_attr__( 'Description Here.', 'kirki' ),
314
	'section'     => 'dimension_section',
315
	'default'     => '10px',
316
) );
317
318
/**
319
 * Dimensions Control.
320
 */
321
Kirki::add_field( 'kirki_demo', array(
322
	'type'        => 'dimensions',
323
	'settings'    => 'dimensions_0',
324
	'label'       => esc_attr__( 'Dimension Control', 'kirki' ),
325
	'description' => esc_attr__( 'Description Here.', 'kirki' ),
326
	'section'     => 'dimensions_section',
327
	'default'     => array(
328
		'width'  => '100px',
329
		'height' => '100px',
330
	),
331
) );
332
333
Kirki::add_field( 'kirki_demo', array(
334
	'type'        => 'dimensions',
335
	'settings'    => 'dimensions_1',
336
	'label'       => esc_attr__( 'Dimension Control', 'kirki' ),
337
	'description' => esc_attr__( 'Description Here.', 'kirki' ),
338
	'section'     => 'dimensions_section',
339
	'default'     => array(
340
		'padding-top'    => '1em',
341
		'padding-bottom' => '10rem',
342
		'padding-left'   => '1vh',
343
		'padding-right'  => '10px',
344
	),
345
) );
346
347
/**
348
 * Font-Awesome Control.
349
 */
350
Kirki::add_field( 'kirki_demo', array(
351
	'type'        => 'fontawesome',
352
	'settings'    => 'fontawesome_setting',
353
	'label'       => esc_attr__( 'Font Awesome Control', 'kirki' ),
354
	'description' => esc_attr__( 'Description Here.', 'kirki' ),
355
	'section'     => 'fontawesome_section',
356
	'default'     => 'bath',
357
) );
358
359
/**
360
 * Generic Controls.
361
 */
362
Kirki::add_field( 'kirki_demo', array(
363
	'type'        => 'text',
364
	'settings'    => 'generic_text_setting',
365
	'label'       => esc_attr__( 'Text Control' ),
366
	'description' => esc_attr__( 'Description' ),
367
	'section'     => 'generic_section',
368
	'default'     => '',
369
) );
370
371
Kirki::add_field( 'kirki_demo', array(
372
	'type'        => 'textarea',
373
	'settings'    => 'generic_textarea_setting',
374
	'label'       => esc_attr__( 'Textarea Control' ),
375
	'description' => esc_attr__( 'Description' ),
376
	'section'     => 'generic_section',
377
	'default'     => '',
378
) );
379
380
Kirki::add_field( 'kirki_demo', array(
381
	'type'        => 'generic',
382
	'settings'    => 'generic_custom_setting',
383
	'label'       => esc_attr__( 'Custom input Control.' ),
384
	'description' => esc_attr__( 'The "generic" control allows you to add any input type you want. In this case we use type="password" and define custom styles.', 'kirki' ),
385
	'section'     => 'generic_section',
386
	'default'     => '',
387
	'choices'     => array(
388
		'element'  => 'input',
389
		'type'     => 'password',
390
		'style'    => 'background-color:black;color:red;',
391
		'data-foo' => 'bar',
392
	),
393
) );
394
395
/**
396
 * Image Control.
397
 */
398
Kirki::add_field( 'kirki_demo', array(
399
	'type'        => 'image',
400
	'settings'    => 'image_setting_url',
401
	'label'       => esc_attr__( 'Image Control (URL)', 'kirki' ),
402
	'description' => esc_attr__( 'Description Here.', 'kirki' ),
403
	'section'     => 'image_section',
404
	'default'     => '',
405
) );
406
407
Kirki::add_field( 'kirki_demo', array(
408
	'type'        => 'image',
409
	'settings'    => 'image_setting_id',
410
	'label'       => esc_attr__( 'Image Control (ID)', 'kirki' ),
411
	'description' => esc_attr__( 'Description Here.', 'kirki' ),
412
	'section'     => 'image_section',
413
	'default'     => '',
414
	'choices'     => array(
415
		'save_as' => 'id',
416
	),
417
) );
418
419
Kirki::add_field( 'kirki_demo', array(
420
	'type'        => 'image',
421
	'settings'    => 'image_setting_array',
422
	'label'       => esc_attr__( 'Image Control (array)', 'kirki' ),
423
	'description' => esc_attr__( 'Description Here.', 'kirki' ),
424
	'section'     => 'image_section',
425
	'default'     => '',
426
	'choices'     => array(
427
		'save_as' => 'array',
428
	),
429
) );
430
431
/**
432
 * Multicheck Control.
433
 */
434
Kirki::add_field( 'kirki_demo', array(
435
	'type'        => 'multicheck',
436
	'settings'    => 'multicheck_setting',
437
	'label'       => esc_attr__( 'Multickeck Control', 'kirki' ),
438
	'section'     => 'multicheck_section',
439
	'default'     => array( 'option-1', 'option-3', 'option-4' ),
440
	'priority'    => 10,
441
	'choices'     => array(
442
		'option-1' => esc_attr__( 'Option 1', 'kirki' ),
443
		'option-2' => esc_attr__( 'Option 2', 'kirki' ),
444
		'option-3' => esc_attr__( 'Option 3', 'kirki' ),
445
		'option-4' => esc_attr__( 'Option 4', 'kirki' ),
446
		'option-5' => esc_attr__( 'Option 5', 'kirki' ),
447
	),
448
) );
449
450
/**
451
 * Multicolor Control.
452
 */
453
Kirki::add_field( 'kirki_demo', array(
454
	'type'        => 'multicolor',
455
	'settings'    => 'multicolor_setting',
456
	'label'       => esc_attr__( 'Label', 'kirki' ),
457
	'section'     => 'multicolor_section',
458
	'priority'    => 10,
459
	'choices'     => array(
460
		'link'    => esc_attr__( 'Color', 'kirki' ),
461
		'hover'   => esc_attr__( 'Hover', 'kirki' ),
462
		'active'  => esc_attr__( 'Active', 'kirki' ),
463
	),
464
	'default'     => array(
465
		'link'    => '#0088cc',
466
		'hover'   => '#00aaff',
467
		'active'  => '#00ffff',
468
	),
469
) );
470
471
/**
472
 * Number Control.
473
 */
474
Kirki::add_field( 'kirki_demo', array(
475
	'type'        => 'number',
476
	'settings'    => 'number_setting',
477
	'label'       => esc_attr__( 'Label', 'kirki' ),
478
	'section'     => 'number_section',
479
	'priority'    => 10,
480
	'choices'     => array(
481
		'min'  => -5,
482
		'max'  => 5,
483
		'step' => 1,
484
	),
485
) );
486
487
/**
488
 * Palette Control.
489
 */
490
Kirki::add_field( 'kirki_demo', array(
491
	'type'        => 'palette',
492
	'settings'    => 'palette_setting',
493
	'label'       => esc_attr__( 'Label', 'kirki' ),
494
	'section'     => 'palette_section',
495
	'default'     => 'blue',
496
	'choices'     => array(
497
		'a200'  => Kirki_Helper::get_material_design_colors( 'A200' ),
498
		'blue'  => Kirki_Helper::get_material_design_colors( 'blue' ),
499
		'green' => array( '#E8F5E9', '#C8E6C9', '#A5D6A7', '#81C784', '#66BB6A', '#4CAF50', '#43A047', '#388E3C', '#2E7D32', '#1B5E20', '#B9F6CA', '#69F0AE', '#00E676', '#00C853' ),
500
		'bnw'   => array( '#000000', '#ffffff' ),
501
	),
502
) );
503
504
/**
505
 * Radio Control.
506
 */
507
Kirki::add_field( 'kirki_demo', array(
508
	'type'        => 'radio',
509
	'settings'    => 'radio_setting',
510
	'label'       => esc_attr__( 'Radio Control', 'kirki' ),
511
	'description' => esc_attr__( 'The description here.', 'kirki' ),
512
	'section'     => 'radio_section',
513
	'default'     => 'option-3',
514
	'choices'     => array(
515
		'option-1' => esc_attr__( 'Option 1', 'kirki' ),
516
		'option-2' => esc_attr__( 'Option 2', 'kirki' ),
517
		'option-3' => esc_attr__( 'Option 3', 'kirki' ),
518
		'option-4' => esc_attr__( 'Option 4', 'kirki' ),
519
		'option-5' => esc_attr__( 'Option 5', 'kirki' ),
520
	),
521
) );
522
523
/**
524
 * Radio-Buttonset Control.
525
 */
526
Kirki::add_field( 'kirki_demo', array(
527
	'type'        => 'radio-buttonset',
528
	'settings'    => 'radio_buttonset_setting',
529
	'label'       => esc_attr__( 'Radio-Buttonset Control', 'kirki' ),
530
	'description' => esc_attr__( 'The description here.', 'kirki' ),
531
	'section'     => 'radio_buttonset_section',
532
	'default'     => 'option-2',
533
	'choices'     => array(
534
		'option-1' => esc_attr__( 'Option 1', 'kirki' ),
535
		'option-2' => esc_attr__( 'Option 2', 'kirki' ),
536
		'option-3' => esc_attr__( 'Option 3', 'kirki' ),
537
	),
538
) );
539
540
/**
541
 * Radio-Image Control.
542
 */
543
Kirki::add_field( 'kirki_demo', array(
544
	'type'        => 'radio-image',
545
	'settings'    => 'radio_image_setting',
546
	'label'       => esc_attr__( 'Radio-Image Control', 'kirki' ),
547
	'description' => esc_attr__( 'The description here.', 'kirki' ),
548
	'section'     => 'radio_image_section',
549
	'default'     => 'travel',
550
	'choices'     => array(
551
		'moto'    => 'https://jawordpressorg.github.io/wapuu/wapuu-archive/wapuu-moto.png',
552
		'cossack' => 'https://raw.githubusercontent.com/templatemonster/cossack-wapuula/master/cossack-wapuula.png',
553
		'travel'  => 'https://jawordpressorg.github.io/wapuu/wapuu-archive/wapuu-travel.png',
554
	),
555
) );
556
557
/**
558
 * Select Control.
559
 */
560
Kirki::add_field( 'kirki_demo', array(
561
	'type'        => 'select',
562
	'settings'    => 'select_setting',
563
	'label'       => esc_attr__( 'Select Control', 'kirki' ),
564
	'description' => esc_attr__( 'The description here.', 'kirki' ),
565
	'section'     => 'select_section',
566
	'default'     => 'option-3',
567
	'choices'     => array(
568
		'option-1' => esc_attr__( 'Option 1', 'kirki' ),
569
		'option-2' => esc_attr__( 'Option 2', 'kirki' ),
570
		'option-3' => esc_attr__( 'Option 3', 'kirki' ),
571
		'option-4' => esc_attr__( 'Option 4', 'kirki' ),
572
		'option-5' => esc_attr__( 'Option 5', 'kirki' ),
573
	),
574
) );
575
576
/**
577
 * Slider Control.
578
 */
579
Kirki::add_field( 'kirki_demo', array(
580
	'type'        => 'slider',
581
	'settings'    => 'slider_setting',
582
	'label'       => esc_attr__( 'Slider Control', 'kirki' ),
583
	'description' => esc_attr__( 'The description here.', 'kirki' ),
584
	'section'     => 'slider_section',
585
	'default'     => '10',
586
	'choices'     => array(
587
		'min'  => 0,
588
		'max'  => 20,
589
		'step' => .1,
590
	),
591
) );
592
593
/**
594
 * Sortable control.
595
 */
596
Kirki::add_field( 'kirki_demo', array(
597
	'type'        => 'sortable',
598
	'settings'    => 'sortable_setting',
599
	'label'       => __( 'This is a sortable control.', 'kirki' ),
600
	'section'     => 'sortable_section',
601
	'default'     => array( 'option3', 'option1', 'option4' ),
602
	'choices'     => array(
603
		'option1' => esc_attr__( 'Option 1', 'kirki' ),
604
		'option2' => esc_attr__( 'Option 2', 'kirki' ),
605
		'option3' => esc_attr__( 'Option 3', 'kirki' ),
606
		'option4' => esc_attr__( 'Option 4', 'kirki' ),
607
		'option5' => esc_attr__( 'Option 5', 'kirki' ),
608
		'option6' => esc_attr__( 'Option 6', 'kirki' ),
609
	),
610
) );
611
612
/**
613
 * Switch control.
614
 */
615
Kirki::add_field( 'kirki_demo', array(
616
	'type'        => 'switch',
617
	'settings'    => 'switch_setting',
618
	'label'       => esc_attr__( 'Switch Control', 'kirki' ),
619
	'description' => esc_attr__( 'Description', 'kirki' ),
620
	'section'     => 'switch_section',
621
	'default'     => true,
622
) );
623
624
/**
625
 * Toggle control.
626
 */
627
Kirki::add_field( 'kirki_demo', array(
628
	'type'        => 'toggle',
629
	'settings'    => 'toggle_setting',
630
	'label'       => esc_attr__( 'Toggle Control', 'kirki' ),
631
	'description' => esc_attr__( 'Description', 'kirki' ),
632
	'section'     => 'toggle_section',
633
	'default'     => true,
634
) );
635
636
/**
637
 * Typography Control.
638
 */
639
Kirki::add_field( 'kirki_demo', array(
640
	'type'        => 'typography',
641
	'settings'    => 'typography_setting_0',
642
	'label'       => esc_attr__( 'Typography Control Label', 'kirki' ),
643
	'description' => esc_attr__( 'The full set of options.', 'kirki' ),
644
	'section'     => 'typography_section',
645
	'default'     => array(
646
		'font-family'    => 'Roboto',
647
		'variant'        => 'regular',
648
		'font-size'      => '14px',
649
		'line-height'    => '1.5',
650
		'letter-spacing' => '0',
651
		'subsets'        => array( 'latin-ext' ),
652
		'color'          => '#333333',
653
		'text-transform' => 'none',
654
		'text-align'     => 'left'
0 ignored issues
show
Each line in an array declaration must end in a comma
Loading history...
655
	),
656
	'priority'    => 10,
657
) );
658
659
Kirki::add_field( 'kirki_demo', array(
660
	'type'        => 'typography',
661
	'settings'    => 'typography_setting_1',
662
	'label'       => esc_attr__( 'Typography Control Label', 'kirki' ),
663
	'description' => esc_attr__( 'Just the font-family.', 'Kirki' ),
664
	'section'     => 'typography_section',
665
	'default'     => array(
666
		'font-family'    => 'Roboto',
667
	),
668
) );
669
670
Kirki::add_field( 'kirki_demo', array(
671
	'type'        => 'typography',
672
	'settings'    => 'typography_setting_2',
673
	'label'       => esc_attr__( 'Typography Control Label', 'kirki' ),
674
	'description' => esc_attr__( 'Only font-size, line-height, letter-spacing and color.', 'kirki' ),
675
	'section'     => 'typography_section',
676
	'default'     => array(
677
		'font-size'      => '14px',
678
		'line-height'    => '1.5',
679
		'letter-spacing' => '0',
680
		'color'          => '#333333',
681
	),
682
) );
683