6
6
*/
7
7
8
8
function decode_add_customize_controls ( $ wp_customize ) {
9
- /* Adds Textarea Control (Required until WP 4.4) */
9
+ /**
10
+ * Adds Textarea Control (Required until WP 4.4)
11
+ */
10
12
class Decode_Customize_Textarea_Control extends WP_Customize_Control {
11
13
public $ type = 'textarea ' ;
12
14
@@ -20,10 +22,64 @@ public function render_content() {
20
22
}
21
23
}
22
24
23
- /* Adds a favicon image uploader control that only allows .ico and .png files to be uploaded */
25
+ /**
26
+ * Adds a favicon image uploader control that only allows .ico and .png files to be uploaded.
27
+ */
24
28
class Decode_Customize_Favicon_Image_Control extends WP_Customize_Image_Control {
25
29
public $ extensions = array ( 'png ' , 'ico ' , 'image/x-icon ' );
26
30
}
31
+
32
+ /**
33
+ * Slider Control
34
+ */
35
+ class Decode_Customize_Slider_Control extends WP_Customize_Control {
36
+
37
+ public $ type = 'slider ' ;
38
+
39
+ public function enqueue () {
40
+ wp_enqueue_script ( 'jquery-ui ' );
41
+ wp_enqueue_script ( 'jquery-ui-slider ' );
42
+ wp_enqueue_style ( 'decode-customize-slider-controle ' , get_template_directory_uri () . '/inc/customizer/assets/css/slider-control/slider-control.css ' );
43
+ }
44
+
45
+ public function render_content () { ?>
46
+ <label>
47
+
48
+ <span class="customize-control-title">
49
+ <?php echo esc_attr ( $ this ->label ); ?>
50
+ <?php if ( ! empty ( $ this ->description ) ) : ?>
51
+ <span class="description customize-control-description"><?php echo esc_html ( $ this ->description ); ?> </span>
52
+ <?php endif ; ?>
53
+ </span>
54
+
55
+ <input type="text" class="rl-slider" id="input_<?php echo $ this ->id ; ?> " value="<?php echo esc_attr ( $ this ->value () ); ?> " <?php $ this ->link (); ?> />
56
+
57
+ </label>
58
+
59
+ <div id="slider_<?php echo $ this ->id ; ?> " class="ss-slider"></div>
60
+ <script>
61
+ jQuery(document).ready(function($) {
62
+ $( '[id="slider_<?php echo $ this ->id ; ?> "]' ).slider({
63
+ value : <?php echo esc_attr ( $ this ->value () ); ?> ,
64
+ min : <?php echo $ this ->choices ['min ' ]; ?> ,
65
+ max : <?php echo $ this ->choices ['max ' ]; ?> ,
66
+ step : <?php echo $ this ->choices ['step ' ]; ?> ,
67
+ slide : function( event, ui ) { $( '[id="input_<?php echo $ this ->id ; ?> "]' ).val(ui.value).keyup(); }
68
+ });
69
+ $( '[id="input_<?php echo $ this ->id ; ?> "]' ).val( $( '[id="slider_<?php echo $ this ->id ; ?> "]' ).slider( "value" ) );
70
+
71
+ $( '[id="input_<?php echo $ this ->id ; ?> "]' ).change(function() {
72
+ $( '[id="slider_<?php echo $ this ->id ; ?> "]' ).slider({
73
+ value : $( this ).val()
74
+ });
75
+ });
76
+
77
+ });
78
+ </script>
79
+ <?php
80
+
81
+ }
82
+ }
27
83
}
28
84
add_action ( 'customize_register ' , 'decode_add_customize_controls ' );
29
85
@@ -1306,6 +1362,11 @@ public static function decode_customize_register( $wp_customize ) {
1306
1362
'sanitize_callback ' => 'decode_sanitize_boolean ' ,
1307
1363
) );
1308
1364
1365
+ $ wp_customize ->add_setting ( 'content_width ' , array (
1366
+ 'default ' => 792 ,
1367
+ 'sanitize_callback ' => 'absint '
1368
+ ) );
1369
+
1309
1370
$ wp_customize ->add_setting ( 'site_colophon ' , array (
1310
1371
'default ' => '' ,
1311
1372
'sanitize_callback ' => 'decode_sanitize_html ' ,
@@ -1428,6 +1489,19 @@ public static function decode_customize_register( $wp_customize ) {
1428
1489
'type ' => 'checkbox ' ,
1429
1490
'priority ' => 16 ,
1430
1491
) );
1492
+
1493
+ $ wp_customize ->add_control (
1494
+ new Decode_Customize_Slider_Control (
1495
+ $ wp_customize , 'content_width ' , array (
1496
+ 'label ' => esc_html__ ( 'Content Width ' , 'decode ' ),
1497
+ 'choices ' => array (
1498
+ 'min ' => 640 ,
1499
+ 'max ' => 792 ,
1500
+ 'step ' => 1
1501
+ ),
1502
+ 'section ' => 'decode_content_options ' ,
1503
+ 'priority ' => 17 ,
1504
+ ) ) );
1431
1505
1432
1506
$ wp_customize ->add_control (
1433
1507
new Decode_Customize_Textarea_Control (
@@ -1436,7 +1510,7 @@ public static function decode_customize_register( $wp_customize ) {
1436
1510
'section ' => 'decode_content_options ' ,
1437
1511
'settings ' => 'site_colophon ' ,
1438
1512
'type ' => 'textarea ' ,
1439
- 'priority ' => 16 ,
1513
+ 'priority ' => 18 ,
1440
1514
) ) );
1441
1515
1442
1516
0 commit comments