run:R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
23.8 KB
2026-03-11 16:18:51
R W Run
7.8 KB
2026-03-11 16:18:52
R W Run
36.1 KB
2026-03-11 16:18:51
R W Run
11.9 KB
2026-03-11 16:18:52
R W Run
18.94 KB
2026-03-11 16:18:52
R W Run
7.35 KB
2026-03-11 16:18:52
R W Run
28.6 KB
2026-03-11 16:18:51
R W Run
316 By
2026-03-11 16:18:51
R W Run
12.9 KB
2026-03-11 16:18:51
R W Run
61.02 KB
2026-03-11 16:18:52
R W Run
15 KB
2026-03-11 16:18:51
R W Run
112.05 KB
2026-03-11 16:18:51
R W Run
12.47 KB
2026-03-11 16:18:51
R W Run
15.07 KB
2026-03-11 16:18:52
R W Run
9.84 KB
2026-03-11 16:18:52
R W Run
13.17 KB
2026-03-11 16:18:52
R W Run
33.83 KB
2026-03-11 16:18:51
R W Run
42.63 KB
2026-03-11 16:18:51
R W Run
55.71 KB
2026-03-11 16:18:52
R W Run
12.53 KB
2026-03-11 16:18:51
R W Run
2.55 KB
2026-03-11 16:18:52
R W Run
28.92 KB
2026-03-11 16:18:52
R W Run
539 By
2026-03-11 16:18:51
R W Run
367 By
2026-03-11 16:18:52
R W Run
42.65 KB
2026-03-11 16:18:51
R W Run
401 By
2026-03-11 16:18:51
R W Run
6.61 KB
2026-03-11 16:18:51
R W Run
664 By
2026-03-11 16:18:52
R W Run
20.63 KB
2026-03-11 16:18:51
R W Run
2.18 KB
2026-03-11 16:18:52
R W Run
453 By
2026-03-11 16:18:52
R W Run
457 By
2026-03-11 16:18:51
R W Run
36.83 KB
2026-03-11 16:18:52
R W Run
2.41 KB
2026-03-11 16:18:52
R W Run
8.28 KB
2026-03-11 16:18:51
R W Run
13.89 KB
2026-03-11 16:18:51
R W Run
11.76 KB
2026-03-11 16:18:51
R W Run
2.65 KB
2026-03-11 16:18:51
R W Run
7.43 KB
2026-03-11 16:18:51
R W Run
17.46 KB
2026-03-11 16:18:51
R W Run
5.14 KB
2026-03-11 16:18:52
R W Run
16.7 KB
2026-03-11 16:18:51
R W Run
8.28 KB
2026-03-11 16:18:52
R W Run
2.92 KB
2026-03-11 16:18:52
R W Run
1.32 KB
2026-03-11 16:18:51
R W Run
4.6 KB
2026-03-11 16:18:52
R W Run
11.62 KB
2026-03-11 16:18:52
R W Run
2.5 KB
2026-03-11 16:18:51
R W Run
1.97 KB
2026-03-11 16:18:51
R W Run
11.25 KB
2026-03-11 16:18:52
R W Run
5.32 KB
2026-03-11 16:18:51
R W Run
10.99 KB
2026-03-11 16:18:52
R W Run
68.32 KB
2026-03-11 16:18:51
R W Run
6.34 KB
2026-03-11 16:18:51
R W Run
5.49 KB
2026-03-11 16:18:51
R W Run
1.99 KB
2026-03-11 16:18:52
R W Run
7.02 KB
2026-03-11 16:18:51
R W Run
4.91 KB
2026-03-11 16:18:52
R W Run
16.86 KB
2026-03-11 16:18:51
R W Run
24.23 KB
2026-03-11 16:18:51
R W Run
3.97 KB
2026-03-11 16:18:51
R W Run
47.66 KB
2026-03-11 16:18:51
R W Run
9.22 KB
2026-03-11 16:18:51
R W Run
25.51 KB
2026-03-11 16:18:51
R W Run
198.38 KB
2026-03-11 16:18:52
R W Run
56.65 KB
2026-03-11 16:18:51
R W Run
10.46 KB
2026-03-11 16:18:51
R W Run
10.95 KB
2026-03-11 16:18:52
R W Run
29.26 KB
2026-03-11 16:18:51
R W Run
70.91 KB
2026-03-11 16:18:52
R W Run
35.3 KB
2026-03-11 16:18:52
R W Run
16.61 KB
2026-03-11 16:18:52
R W Run
2.57 KB
2026-03-11 16:18:52
R W Run
39.83 KB
2026-03-11 16:18:51
R W Run
70.64 KB
2026-03-11 16:18:51
R W Run
15.56 KB
2026-03-11 16:18:52
R W Run
7.33 KB
2026-03-11 16:18:52
R W Run
253 By
2026-03-11 16:18:51
R W Run
7.96 KB
2026-03-11 16:18:52
R W Run
3.23 KB
2026-03-11 16:18:52
R W Run
969 By
2026-03-11 16:18:52
R W Run
16.28 KB
2026-03-11 16:18:51
R W Run
7.22 KB
2026-03-11 16:18:51
R W Run
12.95 KB
2026-03-11 16:18:51
R W Run
6.53 KB
2026-03-11 16:18:51
R W Run
3.42 KB
2026-03-11 16:18:52
R W Run
5.84 KB
2026-03-11 16:18:51
R W Run
1.97 KB
2026-03-11 16:18:51
R W Run
4.3 KB
2026-03-11 16:18:52
R W Run
2.91 KB
2026-03-11 16:18:51
R W Run
16.46 KB
2026-03-11 16:18:52
R W Run
40.6 KB
2026-03-11 16:18:51
R W Run
20.22 KB
2026-03-11 16:18:51
R W Run
36.11 KB
2026-03-11 16:18:52
R W Run
17.01 KB
2026-03-11 16:18:51
R W Run
7.27 KB
2026-03-11 16:18:52
R W Run
6.62 KB
2026-03-11 16:18:52
R W Run
16.49 KB
2026-03-11 16:18:52
R W Run
1.79 KB
2026-03-11 16:18:52
R W Run
29.82 KB
2026-03-11 16:18:51
R W Run
6.67 KB
2026-03-11 16:18:52
R W Run
8.98 KB
2026-03-11 16:18:52
R W Run
19.42 KB
2026-03-11 16:18:51
R W Run
12.01 KB
2026-03-11 16:18:51
R W Run
17.11 KB
2026-03-11 16:18:51
R W Run
6.74 KB
2026-03-11 16:18:52
R W Run
30.93 KB
2026-03-11 16:18:51
R W Run
4.99 KB
2026-03-11 16:18:51
R W Run
4.25 KB
2026-03-11 16:18:51
R W Run
24.72 KB
2026-03-11 16:18:51
R W Run
29.96 KB
2026-03-11 16:18:52
R W Run
6.41 KB
2026-03-11 16:18:51
R W Run
160 KB
2026-03-11 16:18:51
R W Run
6.72 KB
2026-03-11 16:18:52
R W Run
10.92 KB
2026-03-11 16:18:51
R W Run
4.77 KB
2026-03-11 16:18:51
R W Run
3.38 KB
2026-03-11 16:18:51
R W Run
11.18 KB
2026-03-11 16:18:51
R W Run
62.19 KB
2026-03-11 16:18:51
R W Run
2.46 KB
2026-03-11 16:18:51
R W Run
9.17 KB
2026-03-11 16:18:51
R W Run
32.15 KB
2026-03-11 16:18:51
R W Run
34.05 KB
2026-03-11 16:18:52
R W Run
7.15 KB
2026-03-11 16:18:51
R W Run
3.47 KB
2026-03-11 16:18:52
R W Run
1.87 KB
2026-03-11 16:18:52
R W Run
30.91 KB
2026-03-11 16:18:51
R W Run
7.29 KB
2026-03-11 16:18:52
R W Run
7.35 KB
2026-03-11 16:18:51
R W Run
12.54 KB
2026-03-11 16:18:51
R W Run
19.12 KB
2026-03-11 16:18:51
R W Run
18.12 KB
2026-03-11 16:18:52
R W Run
39.99 KB
2026-03-11 16:18:52
R W Run
5.17 KB
2026-03-11 16:18:52
R W Run
979 By
2026-03-11 16:18:51
R W Run
18.44 KB
2026-03-11 16:18:52
R W Run
10.24 KB
2026-03-11 16:18:51
R W Run
1.77 KB
2026-03-11 16:18:52
R W Run
34.9 KB
2026-03-11 16:18:51
R W Run
7.19 KB
2026-03-11 16:18:52
R W Run
160.5 KB
2026-03-11 16:18:51
R W Run
64.27 KB
2026-03-11 16:18:51
R W Run
27.95 KB
2026-03-11 16:18:51
R W Run
4.69 KB
2026-03-11 16:18:51
R W Run
2.94 KB
2026-03-11 16:18:51
R W Run
43.13 KB
2026-03-11 16:18:52
R W Run
2.25 KB
2026-03-11 16:18:52
R W Run
22.5 KB
2026-03-11 16:18:51
R W Run
13.01 KB
2026-03-11 16:18:52
R W Run
3.27 KB
2026-03-11 16:18:51
R W Run
18 KB
2026-03-11 16:18:51
R W Run
210.4 KB
2026-03-11 16:18:52
R W Run
25.86 KB
2026-03-11 16:18:52
R W Run
115.85 KB
2026-03-11 16:18:51
R W Run
373 By
2026-03-11 16:18:52
R W Run
343 By
2026-03-11 16:18:52
R W Run
338 By
2026-03-11 16:18:51
R W Run
100.73 KB
2026-03-11 16:18:52
R W Run
130.93 KB
2026-03-11 16:18:51
R W Run
19.1 KB
2026-03-11 16:18:51
R W Run
17.41 KB
2026-03-11 16:18:52
R W Run
41.98 KB
2026-03-11 16:18:52
R W Run
400 By
2026-03-11 16:18:52
R W Run
11.1 KB
2026-03-11 16:18:52
R W Run
37.02 KB
2026-03-11 16:18:51
R W Run
2.24 KB
2026-03-11 16:18:51
R W Run
188.13 KB
2026-03-11 16:18:51
R W Run
338 By
2026-03-11 16:18:51
R W Run
38 KB
2026-03-11 16:18:51
R W Run
4.02 KB
2026-03-11 16:18:52
R W Run
5.38 KB
2026-03-11 16:18:51
R W Run
3.05 KB
2026-03-11 16:18:52
R W Run
2.61 KB
2026-03-11 16:18:51
R W Run
1.16 KB
2026-03-11 16:18:52
R W Run
4.04 KB
2026-03-11 16:18:51
R W Run
3.71 KB
2026-03-11 16:18:51
R W Run
24.6 KB
2026-03-11 16:18:51
R W Run
9.56 KB
2026-03-11 16:18:51
R W Run
346.43 KB
2026-03-11 16:18:52
R W Run
281.84 KB
2026-03-11 16:18:52
R W Run
14.95 KB
2026-03-11 16:18:51
R W Run
8.44 KB
2026-03-11 16:18:52
R W Run
168.95 KB
2026-03-11 16:18:52
R W Run
20.71 KB
2026-03-11 16:18:52
R W Run
25.27 KB
2026-03-11 16:18:51
R W Run
5.72 KB
2026-03-11 16:18:51
R W Run
4.63 KB
2026-03-11 16:18:52
R W Run
81.73 KB
2026-03-11 16:18:51
R W Run
67.18 KB
2026-03-11 16:18:51
R W Run
156.36 KB
2026-03-11 16:18:52
R W Run
55.19 KB
2026-03-11 16:18:51
R W Run
162 By
2026-03-11 16:18:51
R W Run
61.72 KB
2026-03-11 16:18:51
R W Run
216.06 KB
2026-03-11 16:18:52
R W Run
65.09 KB
2026-03-11 16:18:51
R W Run
25.24 KB
2026-03-11 16:18:52
R W Run
4.81 KB
2026-03-11 16:18:51
R W Run
6.48 KB
2026-03-11 16:18:52
R W Run
21.25 KB
2026-03-11 16:18:51
R W Run
2.79 KB
2026-03-11 16:18:52
R W Run
89.69 KB
2026-03-11 16:18:52
R W Run
19.42 KB
2026-03-11 16:18:52
R W Run
3.69 KB
2026-03-11 16:18:52
R W Run
4.11 KB
2026-03-11 16:18:51
R W Run
40.74 KB
2026-03-11 16:18:51
R W Run
25.38 KB
2026-03-11 16:18:51
R W Run
43.31 KB
2026-03-11 16:18:52
R W Run
102.57 KB
2026-03-11 16:18:52
R W Run
6.18 KB
2026-03-11 16:18:51
R W Run
124.47 KB
2026-03-11 16:18:52
R W Run
35.65 KB
2026-03-11 16:18:52
R W Run
6.94 KB
2026-03-11 16:18:52
R W Run
67.04 KB
2026-03-11 16:18:52
R W Run
10.62 KB
2026-03-11 16:18:51
R W Run
289.35 KB
2026-03-11 16:18:52
R W Run
36.23 KB
2026-03-11 16:18:51
R W Run
200 By
2026-03-11 16:18:52
R W Run
200 By
2026-03-11 16:18:52
R W Run
98.29 KB
2026-03-11 16:18:52
R W Run
30.02 KB
2026-03-11 16:18:52
R W Run
19.03 KB
2026-03-11 16:18:52
R W Run
5.06 KB
2026-03-11 16:18:52
R W Run
255 By
2026-03-11 16:18:51
R W Run
22.66 KB
2026-03-11 16:18:52
R W Run
154.63 KB
2026-03-11 16:18:51
R W Run
9.68 KB
2026-03-11 16:18:51
R W Run
258 By
2026-03-11 16:18:51
R W Run
23.49 KB
2026-03-11 16:18:51
R W Run
3.16 KB
2026-03-11 16:18:51
R W Run
8.4 KB
2026-03-11 16:18:52
R W Run
441 By
2026-03-11 16:18:51
R W Run
7.39 KB
2026-03-11 16:18:51
R W Run
173 KB
2026-03-11 16:18:52
R W Run
544 By
2026-03-11 16:18:52
R W Run
4.17 KB
2026-03-11 16:18:51
R W Run
35.97 KB
2026-03-11 16:18:52
R W Run
1.69 KB
2026-03-11 16:18:51
R W Run
2.84 KB
2026-03-11 16:18:52
R W Run
6.09 KB
2026-03-11 16:18:51
R W Run
8.71 KB
2026-03-11 16:18:51
R W Run
131.84 KB
2026-03-11 16:18:51
R W Run
37.45 KB
2026-03-11 16:18:51
R W Run
173.89 KB
2026-03-11 16:18:51
R W Run
7.09 KB
2026-03-11 16:18:51
R W Run
6.41 KB
2026-03-11 16:18:51
R W Run
1.08 KB
2026-03-11 16:18:51
R W Run
69.46 KB
2026-03-11 16:18:52
R W Run
445 By
2026-03-11 16:18:51
R W Run
799 By
2026-03-11 16:18:52
R W Run
error_log
📄class-wp-customize-control.php
1<?php
2/**
3 * WordPress Customize Control classes
4 *
5 * @package WordPress
6 * @subpackage Customize
7 * @since 3.4.0
8 */
9
10// Don't load directly.
11if ( ! defined( 'ABSPATH' ) ) {
12 die( '-1' );
13}
14
15/**
16 * Customize Control class.
17 *
18 * @since 3.4.0
19 */
20#[AllowDynamicProperties]
21class WP_Customize_Control {
22
23 /**
24 * Incremented with each new class instantiation, then stored in $instance_number.
25 *
26 * Used when sorting two instances whose priorities are equal.
27 *
28 * @since 4.1.0
29 * @var int
30 */
31 protected static $instance_count = 0;
32
33 /**
34 * Order in which this instance was created in relation to other instances.
35 *
36 * @since 4.1.0
37 * @var int
38 */
39 public $instance_number;
40
41 /**
42 * Customizer manager.
43 *
44 * @since 3.4.0
45 * @var WP_Customize_Manager
46 */
47 public $manager;
48
49 /**
50 * Control ID.
51 *
52 * @since 3.4.0
53 * @var string
54 */
55 public $id;
56
57 /**
58 * All settings tied to the control.
59 *
60 * @since 3.4.0
61 * @var array
62 */
63 public $settings;
64
65 /**
66 * The primary setting for the control (if there is one).
67 *
68 * @since 3.4.0
69 * @var string|WP_Customize_Setting|null
70 */
71 public $setting = 'default';
72
73 /**
74 * Capability required to use this control.
75 *
76 * Normally this is empty and the capability is derived from the capabilities
77 * of the associated `$settings`.
78 *
79 * @since 4.5.0
80 * @var string
81 */
82 public $capability;
83
84 /**
85 * Order priority to load the control in Customizer.
86 *
87 * @since 3.4.0
88 * @var int
89 */
90 public $priority = 10;
91
92 /**
93 * Section the control belongs to.
94 *
95 * @since 3.4.0
96 * @var string
97 */
98 public $section = '';
99
100 /**
101 * Label for the control.
102 *
103 * @since 3.4.0
104 * @var string
105 */
106 public $label = '';
107
108 /**
109 * Description for the control.
110 *
111 * @since 4.0.0
112 * @var string
113 */
114 public $description = '';
115
116 /**
117 * List of choices for 'radio' or 'select' type controls, where values are the keys, and labels are the values.
118 *
119 * @since 3.4.0
120 * @var array
121 */
122 public $choices = array();
123
124 /**
125 * List of custom input attributes for control output, where attribute names are the keys and values are the values.
126 *
127 * Not used for 'checkbox', 'radio', 'select', or 'dropdown-pages' control types.
128 *
129 * @since 4.0.0
130 * @var array
131 */
132 public $input_attrs = array();
133
134 /**
135 * Show UI for adding new content, currently only used for the dropdown-pages control.
136 *
137 * @since 4.7.0
138 * @var bool
139 */
140 public $allow_addition = false;
141
142 /**
143 * @deprecated It is better to just call the json() method
144 * @since 3.4.0
145 * @var array
146 */
147 public $json = array();
148
149 /**
150 * Control's Type.
151 *
152 * @since 3.4.0
153 * @var string
154 */
155 public $type = 'text';
156
157 /**
158 * Callback.
159 *
160 * @since 4.0.0
161 *
162 * @see WP_Customize_Control::active()
163 *
164 * @var callable Callback is called with one argument, the instance of
165 * WP_Customize_Control, and returns bool to indicate whether
166 * the control is active (such as it relates to the URL
167 * currently being previewed).
168 */
169 public $active_callback = '';
170
171 /**
172 * Constructor.
173 *
174 * Supplied `$args` override class property defaults.
175 *
176 * If `$args['settings']` is not defined, use the `$id` as the setting ID.
177 *
178 * @since 3.4.0
179 *
180 * @param WP_Customize_Manager $manager Customizer bootstrap instance.
181 * @param string $id Control ID.
182 * @param array $args {
183 * Optional. Array of properties for the new Control object. Default empty array.
184 *
185 * @type int $instance_number Order in which this instance was created in relation
186 * to other instances.
187 * @type WP_Customize_Manager $manager Customizer bootstrap instance.
188 * @type string $id Control ID.
189 * @type array $settings All settings tied to the control. If undefined, `$id` will
190 * be used.
191 * @type string $setting The primary setting for the control (if there is one).
192 * Default 'default'.
193 * @type string $capability Capability required to use this control. Normally this is empty
194 * and the capability is derived from `$settings`.
195 * @type int $priority Order priority to load the control. Default 10.
196 * @type string $section Section the control belongs to. Default empty.
197 * @type string $label Label for the control. Default empty.
198 * @type string $description Description for the control. Default empty.
199 * @type array $choices List of choices for 'radio' or 'select' type controls, where
200 * values are the keys, and labels are the values.
201 * Default empty array.
202 * @type array $input_attrs List of custom input attributes for control output, where
203 * attribute names are the keys and values are the values. Not
204 * used for 'checkbox', 'radio', 'select', or 'dropdown-pages'
205 * control types. Default empty array.
206 * @type bool $allow_addition Show UI for adding new content, currently only used for the
207 * dropdown-pages control. Default false.
208 * @type array $json Deprecated. Use WP_Customize_Control::json() instead.
209 * @type string $type Control type. Core controls include 'text', 'checkbox',
210 * 'textarea', 'radio', 'select', and 'dropdown-pages'. Additional
211 * input types such as 'email', 'url', 'number', 'hidden', and
212 * 'date' are supported implicitly. Default 'text'.
213 * @type callable $active_callback Active callback.
214 * }
215 */
216 public function __construct( $manager, $id, $args = array() ) {
217 $keys = array_keys( get_object_vars( $this ) );
218 foreach ( $keys as $key ) {
219 if ( isset( $args[ $key ] ) ) {
220 $this->$key = $args[ $key ];
221 }
222 }
223
224 $this->manager = $manager;
225 $this->id = $id;
226 if ( empty( $this->active_callback ) ) {
227 $this->active_callback = array( $this, 'active_callback' );
228 }
229 self::$instance_count += 1;
230 $this->instance_number = self::$instance_count;
231
232 // Process settings.
233 if ( ! isset( $this->settings ) ) {
234 $this->settings = $id;
235 }
236
237 $settings = array();
238 if ( is_array( $this->settings ) ) {
239 foreach ( $this->settings as $key => $setting ) {
240 $settings[ $key ] = $this->manager->get_setting( $setting );
241 }
242 } elseif ( is_string( $this->settings ) ) {
243 $this->setting = $this->manager->get_setting( $this->settings );
244 $settings['default'] = $this->setting;
245 }
246 $this->settings = $settings;
247 }
248
249 /**
250 * Enqueues control related scripts/styles.
251 *
252 * @since 3.4.0
253 */
254 public function enqueue() {}
255
256 /**
257 * Checks whether control is active to current Customizer preview.
258 *
259 * @since 4.0.0
260 *
261 * @return bool Whether the control is active to the current preview.
262 */
263 final public function active() {
264 $control = $this;
265 $active = call_user_func( $this->active_callback, $this );
266
267 /**
268 * Filters response of WP_Customize_Control::active().
269 *
270 * @since 4.0.0
271 *
272 * @param bool $active Whether the Customizer control is active.
273 * @param WP_Customize_Control $control WP_Customize_Control instance.
274 */
275 $active = apply_filters( 'customize_control_active', $active, $control );
276
277 return $active;
278 }
279
280 /**
281 * Default callback used when invoking WP_Customize_Control::active().
282 *
283 * Subclasses can override this with their specific logic, or they may
284 * provide an 'active_callback' argument to the constructor.
285 *
286 * @since 4.0.0
287 *
288 * @return true Always true.
289 */
290 public function active_callback() {
291 return true;
292 }
293
294 /**
295 * Fetches a setting's value.
296 * Grabs the main setting by default.
297 *
298 * @since 3.4.0
299 *
300 * @param string $setting_key
301 * @return mixed The requested setting's value, if the setting exists.
302 */
303 final public function value( $setting_key = 'default' ) {
304 if ( isset( $this->settings[ $setting_key ] ) ) {
305 return $this->settings[ $setting_key ]->value();
306 }
307 }
308
309 /**
310 * Refreshes the parameters passed to the JavaScript via JSON.
311 *
312 * @since 3.4.0
313 */
314 public function to_json() {
315 $this->json['settings'] = array();
316 foreach ( $this->settings as $key => $setting ) {
317 $this->json['settings'][ $key ] = $setting->id;
318 }
319
320 $this->json['type'] = $this->type;
321 $this->json['priority'] = $this->priority;
322 $this->json['active'] = $this->active();
323 $this->json['section'] = $this->section;
324 $this->json['content'] = $this->get_content();
325 $this->json['label'] = $this->label;
326 $this->json['description'] = $this->description;
327 $this->json['instanceNumber'] = $this->instance_number;
328
329 if ( 'dropdown-pages' === $this->type ) {
330 $this->json['allow_addition'] = $this->allow_addition;
331 }
332 }
333
334 /**
335 * Gets the data to export to the client via JSON.
336 *
337 * @since 4.1.0
338 *
339 * @return array Array of parameters passed to the JavaScript.
340 */
341 public function json() {
342 $this->to_json();
343 return $this->json;
344 }
345
346 /**
347 * Checks if the user can use this control.
348 *
349 * Returns false if the user cannot manipulate one of the associated settings,
350 * or if one of the associated settings does not exist. Also returns false if
351 * the associated section does not exist or if its capability check returns
352 * false.
353 *
354 * @since 3.4.0
355 *
356 * @return bool False if theme doesn't support the control or user doesn't have the required permissions, otherwise true.
357 */
358 final public function check_capabilities() {
359 if ( ! empty( $this->capability ) && ! current_user_can( $this->capability ) ) {
360 return false;
361 }
362
363 foreach ( $this->settings as $setting ) {
364 if ( ! $setting || ! $setting->check_capabilities() ) {
365 return false;
366 }
367 }
368
369 $section = $this->manager->get_section( $this->section );
370 if ( isset( $section ) && ! $section->check_capabilities() ) {
371 return false;
372 }
373
374 return true;
375 }
376
377 /**
378 * Gets the control's content for insertion into the Customizer pane.
379 *
380 * @since 4.1.0
381 *
382 * @return string Contents of the control.
383 */
384 final public function get_content() {
385 ob_start();
386 $this->maybe_render();
387 return trim( ob_get_clean() );
388 }
389
390 /**
391 * Checks capabilities and render the control.
392 *
393 * @since 3.4.0
394 * @uses WP_Customize_Control::render()
395 */
396 final public function maybe_render() {
397 if ( ! $this->check_capabilities() ) {
398 return;
399 }
400
401 /**
402 * Fires just before the current Customizer control is rendered.
403 *
404 * @since 3.4.0
405 *
406 * @param WP_Customize_Control $control WP_Customize_Control instance.
407 */
408 do_action( 'customize_render_control', $this );
409
410 /**
411 * Fires just before a specific Customizer control is rendered.
412 *
413 * The dynamic portion of the hook name, `$this->id`, refers to
414 * the control ID.
415 *
416 * @since 3.4.0
417 *
418 * @param WP_Customize_Control $control WP_Customize_Control instance.
419 */
420 do_action( "customize_render_control_{$this->id}", $this );
421
422 $this->render();
423 }
424
425 /**
426 * Renders the control wrapper and calls $this->render_content() for the internals.
427 *
428 * @since 3.4.0
429 */
430 protected function render() {
431 $id = 'customize-control-' . str_replace( array( '[', ']' ), array( '-', '' ), $this->id );
432 $class = 'customize-control customize-control-' . $this->type;
433
434 printf( '<li id="%s" class="%s">', esc_attr( $id ), esc_attr( $class ) );
435 $this->render_content();
436 echo '</li>';
437 }
438
439 /**
440 * Gets the data link attribute for a setting.
441 *
442 * @since 3.4.0
443 * @since 4.9.0 Return a `data-customize-setting-key-link` attribute if a setting is not registered for the supplied setting key.
444 *
445 * @param string $setting_key
446 * @return string Data link parameter, a `data-customize-setting-link` attribute if the `$setting_key` refers
447 * to a pre-registered setting, and a `data-customize-setting-key-link` attribute if the setting
448 * is not yet registered.
449 */
450 public function get_link( $setting_key = 'default' ) {
451 if ( isset( $this->settings[ $setting_key ] ) && $this->settings[ $setting_key ] instanceof WP_Customize_Setting ) {
452 return 'data-customize-setting-link="' . esc_attr( $this->settings[ $setting_key ]->id ) . '"';
453 } else {
454 return 'data-customize-setting-key-link="' . esc_attr( $setting_key ) . '"';
455 }
456 }
457
458 /**
459 * Renders the data link attribute for the control's input element.
460 *
461 * @since 3.4.0
462 * @uses WP_Customize_Control::get_link()
463 *
464 * @param string $setting_key Default 'default'.
465 */
466 public function link( $setting_key = 'default' ) {
467 echo $this->get_link( $setting_key );
468 }
469
470 /**
471 * Renders the custom attributes for the control's input element.
472 *
473 * @since 4.0.0
474 */
475 public function input_attrs() {
476 foreach ( $this->input_attrs as $attr => $value ) {
477 echo $attr . '="' . esc_attr( $value ) . '" ';
478 }
479 }
480
481 /**
482 * Renders the control's content.
483 *
484 * Allows the content to be overridden without having to rewrite the wrapper in `$this::render()`.
485 *
486 * Supports basic input types `text`, `checkbox`, `textarea`, `radio`, `select` and `dropdown-pages`.
487 * Additional input types such as `email`, `url`, `number`, `hidden` and `date` are supported implicitly.
488 *
489 * Control content can alternately be rendered in JS. See WP_Customize_Control::print_template().
490 *
491 * @since 3.4.0
492 */
493 protected function render_content() {
494 $input_id = '_customize-input-' . $this->id;
495 $description_id = '_customize-description-' . $this->id;
496 $describedby_attr = ( ! empty( $this->description ) ) ? ' aria-describedby="' . esc_attr( $description_id ) . '" ' : '';
497 switch ( $this->type ) {
498 case 'checkbox':
499 ?>
500 <span class="customize-inside-control-row">
501 <input
502 id="<?php echo esc_attr( $input_id ); ?>"
503 <?php echo $describedby_attr; ?>
504 type="checkbox"
505 value="<?php echo esc_attr( $this->value() ); ?>"
506 <?php $this->link(); ?>
507 <?php checked( $this->value() ); ?>
508 />
509 <label for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_html( $this->label ); ?></label>
510 <?php if ( ! empty( $this->description ) ) : ?>
511 <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
512 <?php endif; ?>
513 </span>
514 <?php
515 break;
516 case 'radio':
517 if ( empty( $this->choices ) ) {
518 return;
519 }
520
521 $name = '_customize-radio-' . $this->id;
522 ?>
523 <?php if ( ! empty( $this->label ) ) : ?>
524 <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
525 <?php endif; ?>
526 <?php if ( ! empty( $this->description ) ) : ?>
527 <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
528 <?php endif; ?>
529
530 <?php foreach ( $this->choices as $value => $label ) : ?>
531 <span class="customize-inside-control-row">
532 <input
533 id="<?php echo esc_attr( $input_id . '-radio-' . $value ); ?>"
534 type="radio"
535 <?php echo $describedby_attr; ?>
536 value="<?php echo esc_attr( $value ); ?>"
537 name="<?php echo esc_attr( $name ); ?>"
538 <?php $this->link(); ?>
539 <?php checked( $this->value(), $value ); ?>
540 />
541 <label for="<?php echo esc_attr( $input_id . '-radio-' . $value ); ?>"><?php echo esc_html( $label ); ?></label>
542 </span>
543 <?php endforeach; ?>
544 <?php
545 break;
546 case 'select':
547 if ( empty( $this->choices ) ) {
548 return;
549 }
550
551 ?>
552 <?php if ( ! empty( $this->label ) ) : ?>
553 <label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label>
554 <?php endif; ?>
555 <?php if ( ! empty( $this->description ) ) : ?>
556 <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
557 <?php endif; ?>
558
559 <select id="<?php echo esc_attr( $input_id ); ?>" <?php echo $describedby_attr; ?> <?php $this->link(); ?>>
560 <?php
561 foreach ( $this->choices as $value => $label ) {
562 echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . esc_html( $label ) . '</option>';
563 }
564 ?>
565 </select>
566 <?php
567 break;
568 case 'textarea':
569 if ( ! array_key_exists( 'rows', $this->input_attrs ) ) {
570 $this->input_attrs['rows'] = 5;
571 }
572 ?>
573 <?php if ( ! empty( $this->label ) ) : ?>
574 <label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label>
575 <?php endif; ?>
576 <?php if ( ! empty( $this->description ) ) : ?>
577 <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
578 <?php endif; ?>
579 <textarea
580 id="<?php echo esc_attr( $input_id ); ?>"
581 <?php echo $describedby_attr; ?>
582 <?php $this->input_attrs(); ?>
583 <?php $this->link(); ?>
584 ><?php echo esc_textarea( $this->value() ); ?></textarea>
585 <?php
586 break;
587 case 'dropdown-pages':
588 ?>
589 <?php if ( ! empty( $this->label ) ) : ?>
590 <label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label>
591 <?php endif; ?>
592 <?php if ( ! empty( $this->description ) ) : ?>
593 <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
594 <?php endif; ?>
595
596 <?php
597 $dropdown_name = '_customize-dropdown-pages-' . $this->id;
598 $show_option_none = __( '&mdash; Select &mdash;' );
599 $option_none_value = '0';
600 $dropdown = wp_dropdown_pages(
601 array(
602 'name' => $dropdown_name,
603 'echo' => 0,
604 'show_option_none' => $show_option_none,
605 'option_none_value' => $option_none_value,
606 'selected' => $this->value(),
607 )
608 );
609 if ( empty( $dropdown ) ) {
610 $dropdown = sprintf( '<select id="%1$s" name="%1$s">', esc_attr( $dropdown_name ) );
611 $dropdown .= sprintf( '<option value="%1$s">%2$s</option>', esc_attr( $option_none_value ), esc_html( $show_option_none ) );
612 $dropdown .= '</select>';
613 }
614
615 // Hackily add in the data link parameter.
616 $dropdown = str_replace( '<select', '<select ' . $this->get_link() . ' id="' . esc_attr( $input_id ) . '" ' . $describedby_attr, $dropdown );
617
618 /*
619 * Even more hackily add auto-draft page stubs.
620 * @todo Eventually this should be removed in favor of the pages being injected into the underlying get_pages() call.
621 * See <https://github.com/xwp/wp-customize-posts/pull/250>.
622 */
623 $nav_menus_created_posts_setting = $this->manager->get_setting( 'nav_menus_created_posts' );
624 if ( $nav_menus_created_posts_setting && current_user_can( 'publish_pages' ) ) {
625 $auto_draft_page_options = '';
626 foreach ( $nav_menus_created_posts_setting->value() as $auto_draft_page_id ) {
627 $post = get_post( $auto_draft_page_id );
628 if ( $post && 'page' === $post->post_type ) {
629 $auto_draft_page_options .= sprintf( '<option value="%1$s">%2$s</option>', esc_attr( $post->ID ), esc_html( $post->post_title ) );
630 }
631 }
632 if ( $auto_draft_page_options ) {
633 $dropdown = str_replace( '</select>', $auto_draft_page_options . '</select>', $dropdown );
634 }
635 }
636
637 echo $dropdown;
638 ?>
639 <?php if ( $this->allow_addition && current_user_can( 'publish_pages' ) && current_user_can( 'edit_theme_options' ) ) : // Currently tied to menus functionality. ?>
640 <button type="button" class="button-link add-new-toggle">
641 <?php
642 /* translators: %s: Add Page label. */
643 printf( __( '+ %s' ), get_post_type_object( 'page' )->labels->add_new_item );
644 ?>
645 </button>
646 <div class="new-content-item-wrapper">
647 <label for="create-input-<?php echo esc_attr( $this->id ); ?>"><?php _e( 'New page title' ); ?></label>
648 <div class="new-content-item">
649 <input type="text" id="create-input-<?php echo esc_attr( $this->id ); ?>" class="create-item-input form-required">
650 <button type="button" class="button add-content"><?php _e( 'Add' ); ?></button>
651 </div>
652 <span id="create-input-<?php echo esc_attr( $this->id ); ?>-error" class="create-item-error error-message" style="display: none;"><?php _e( 'Please enter a page title' ); ?></span>
653
654 </div>
655 <?php endif; ?>
656 <?php
657 break;
658 default:
659 ?>
660 <?php if ( ! empty( $this->label ) ) : ?>
661 <label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label>
662 <?php endif; ?>
663 <?php if ( ! empty( $this->description ) ) : ?>
664 <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
665 <?php endif; ?>
666 <input
667 id="<?php echo esc_attr( $input_id ); ?>"
668 type="<?php echo esc_attr( $this->type ); ?>"
669 <?php echo $describedby_attr; ?>
670 <?php $this->input_attrs(); ?>
671 <?php if ( ! isset( $this->input_attrs['value'] ) ) : ?>
672 value="<?php echo esc_attr( $this->value() ); ?>"
673 <?php endif; ?>
674 <?php $this->link(); ?>
675 />
676 <?php
677 break;
678 }
679 }
680
681 /**
682 * Renders the control's JS template.
683 *
684 * This function is only run for control types that have been registered with
685 * WP_Customize_Manager::register_control_type().
686 *
687 * In the future, this will also print the template for the control's container
688 * element and be override-able.
689 *
690 * @since 4.1.0
691 */
692 final public function print_template() {
693 ?>
694 <script type="text/html" id="tmpl-customize-control-<?php echo esc_attr( $this->type ); ?>-content">
695 <?php $this->content_template(); ?>
696 </script>
697 <?php
698 }
699
700 /**
701 * An Underscore (JS) template for this control's content (but not its container).
702 *
703 * Class variables for this control class are available in the `data` JS object;
704 * export custom variables by overriding WP_Customize_Control::to_json().
705 *
706 * @see WP_Customize_Control::print_template()
707 *
708 * @since 4.1.0
709 */
710 protected function content_template() {}
711}
712
713/**
714 * WP_Customize_Color_Control class.
715 */
716require_once ABSPATH . WPINC . '/customize/class-wp-customize-color-control.php';
717
718/**
719 * WP_Customize_Media_Control class.
720 */
721require_once ABSPATH . WPINC . '/customize/class-wp-customize-media-control.php';
722
723/**
724 * WP_Customize_Upload_Control class.
725 */
726require_once ABSPATH . WPINC . '/customize/class-wp-customize-upload-control.php';
727
728/**
729 * WP_Customize_Image_Control class.
730 */
731require_once ABSPATH . WPINC . '/customize/class-wp-customize-image-control.php';
732
733/**
734 * WP_Customize_Background_Image_Control class.
735 */
736require_once ABSPATH . WPINC . '/customize/class-wp-customize-background-image-control.php';
737
738/**
739 * WP_Customize_Background_Position_Control class.
740 */
741require_once ABSPATH . WPINC . '/customize/class-wp-customize-background-position-control.php';
742
743/**
744 * WP_Customize_Cropped_Image_Control class.
745 */
746require_once ABSPATH . WPINC . '/customize/class-wp-customize-cropped-image-control.php';
747
748/**
749 * WP_Customize_Site_Icon_Control class.
750 */
751require_once ABSPATH . WPINC . '/customize/class-wp-customize-site-icon-control.php';
752
753/**
754 * WP_Customize_Header_Image_Control class.
755 */
756require_once ABSPATH . WPINC . '/customize/class-wp-customize-header-image-control.php';
757
758/**
759 * WP_Customize_Theme_Control class.
760 */
761require_once ABSPATH . WPINC . '/customize/class-wp-customize-theme-control.php';
762
763/**
764 * WP_Widget_Area_Customize_Control class.
765 */
766require_once ABSPATH . WPINC . '/customize/class-wp-widget-area-customize-control.php';
767
768/**
769 * WP_Widget_Form_Customize_Control class.
770 */
771require_once ABSPATH . WPINC . '/customize/class-wp-widget-form-customize-control.php';
772
773/**
774 * WP_Customize_Nav_Menu_Control class.
775 */
776require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-control.php';
777
778/**
779 * WP_Customize_Nav_Menu_Item_Control class.
780 */
781require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-control.php';
782
783/**
784 * WP_Customize_Nav_Menu_Location_Control class.
785 */
786require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-location-control.php';
787
788/**
789 * WP_Customize_Nav_Menu_Name_Control class.
790 *
791 * As this file is deprecated, it will trigger a deprecation notice if instantiated. In a subsequent
792 * release, the require_once here will be removed and _deprecated_file() will be called if file is
793 * required at all.
794 *
795 * @deprecated 4.9.0 This file is no longer used due to new menu creation UX.
796 */
797require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-name-control.php';
798
799/**
800 * WP_Customize_Nav_Menu_Locations_Control class.
801 */
802require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-locations-control.php';
803
804/**
805 * WP_Customize_Nav_Menu_Auto_Add_Control class.
806 */
807require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-auto-add-control.php';
808
809/**
810 * WP_Customize_Date_Time_Control class.
811 */
812require_once ABSPATH . WPINC . '/customize/class-wp-customize-date-time-control.php';
813
814/**
815 * WP_Sidebar_Block_Editor_Control class.
816 */
817require_once ABSPATH . WPINC . '/customize/class-wp-sidebar-block-editor-control.php';
818