@@ -18,58 +18,58 @@ |
||
18 | 18 | */ |
19 | 19 | class Background_Position extends Property { |
20 | 20 | |
21 | - /** |
|
22 | - * Modifies the value. |
|
23 | - * |
|
24 | - * @access protected |
|
25 | - */ |
|
26 | - protected function process_value() { |
|
27 | - $this->value = trim( $this->value ); |
|
21 | + /** |
|
22 | + * Modifies the value. |
|
23 | + * |
|
24 | + * @access protected |
|
25 | + */ |
|
26 | + protected function process_value() { |
|
27 | + $this->value = trim( $this->value ); |
|
28 | 28 | |
29 | - // If you use calc() there, I suppose you know what you're doing. |
|
30 | - // No need to process this any further, just exit. |
|
31 | - if ( false !== strpos( $this->value, 'calc' ) ) { |
|
32 | - return; |
|
33 | - } |
|
29 | + // If you use calc() there, I suppose you know what you're doing. |
|
30 | + // No need to process this any further, just exit. |
|
31 | + if ( false !== strpos( $this->value, 'calc' ) ) { |
|
32 | + return; |
|
33 | + } |
|
34 | 34 | |
35 | - // If the value is initial or inherit, we don't need to do anything. |
|
36 | - // Just exit. |
|
37 | - if ( 'initial' === $this->value || 'inherit' === $this->value ) { |
|
38 | - return; |
|
39 | - } |
|
35 | + // If the value is initial or inherit, we don't need to do anything. |
|
36 | + // Just exit. |
|
37 | + if ( 'initial' === $this->value || 'inherit' === $this->value ) { |
|
38 | + return; |
|
39 | + } |
|
40 | 40 | |
41 | - $x_dimensions = [ 'left', 'center', 'right' ]; |
|
42 | - $y_dimensions = [ 'top', 'center', 'bottom' ]; |
|
41 | + $x_dimensions = [ 'left', 'center', 'right' ]; |
|
42 | + $y_dimensions = [ 'top', 'center', 'bottom' ]; |
|
43 | 43 | |
44 | - // If there's a space, we have an X and a Y value. |
|
45 | - if ( false !== strpos( $this->value, ' ' ) ) { |
|
46 | - $xy = explode( ' ', $this->value ); |
|
44 | + // If there's a space, we have an X and a Y value. |
|
45 | + if ( false !== strpos( $this->value, ' ' ) ) { |
|
46 | + $xy = explode( ' ', $this->value ); |
|
47 | 47 | |
48 | - $x = trim( $xy[0] ); |
|
49 | - $y = trim( $xy[1] ); |
|
48 | + $x = trim( $xy[0] ); |
|
49 | + $y = trim( $xy[1] ); |
|
50 | 50 | |
51 | - // If x is not left/center/right, we need to sanitize it. |
|
52 | - if ( ! in_array( $x, $x_dimensions, true ) ) { |
|
53 | - $x = sanitize_text_field( $x ); |
|
54 | - } |
|
55 | - if ( ! in_array( $y, $y_dimensions, true ) ) { |
|
56 | - $y = sanitize_text_field( $y ); |
|
57 | - } |
|
58 | - $this->value = $x . ' ' . $y; |
|
59 | - return; |
|
60 | - } |
|
61 | - $x = 'center'; |
|
62 | - foreach ( $x_dimensions as $x_dimension ) { |
|
63 | - if ( false !== strpos( $this->value, $x_dimension ) ) { |
|
64 | - $x = $x_dimension; |
|
65 | - } |
|
66 | - } |
|
67 | - $y = 'center'; |
|
68 | - foreach ( $y_dimensions as $y_dimension ) { |
|
69 | - if ( false !== strpos( $this->value, $y_dimension ) ) { |
|
70 | - $y = $y_dimension; |
|
71 | - } |
|
72 | - } |
|
73 | - $this->value = $x . ' ' . $y; |
|
74 | - } |
|
51 | + // If x is not left/center/right, we need to sanitize it. |
|
52 | + if ( ! in_array( $x, $x_dimensions, true ) ) { |
|
53 | + $x = sanitize_text_field( $x ); |
|
54 | + } |
|
55 | + if ( ! in_array( $y, $y_dimensions, true ) ) { |
|
56 | + $y = sanitize_text_field( $y ); |
|
57 | + } |
|
58 | + $this->value = $x . ' ' . $y; |
|
59 | + return; |
|
60 | + } |
|
61 | + $x = 'center'; |
|
62 | + foreach ( $x_dimensions as $x_dimension ) { |
|
63 | + if ( false !== strpos( $this->value, $x_dimension ) ) { |
|
64 | + $x = $x_dimension; |
|
65 | + } |
|
66 | + } |
|
67 | + $y = 'center'; |
|
68 | + foreach ( $y_dimensions as $y_dimension ) { |
|
69 | + if ( false !== strpos( $this->value, $y_dimension ) ) { |
|
70 | + $y = $y_dimension; |
|
71 | + } |
|
72 | + } |
|
73 | + $this->value = $x . ' ' . $y; |
|
74 | + } |
|
75 | 75 | } |
@@ -24,49 +24,49 @@ |
||
24 | 24 | * @access protected |
25 | 25 | */ |
26 | 26 | protected function process_value() { |
27 | - $this->value = trim( $this->value ); |
|
27 | + $this->value = trim($this->value); |
|
28 | 28 | |
29 | 29 | // If you use calc() there, I suppose you know what you're doing. |
30 | 30 | // No need to process this any further, just exit. |
31 | - if ( false !== strpos( $this->value, 'calc' ) ) { |
|
31 | + if (false !== strpos($this->value, 'calc')) { |
|
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | 35 | // If the value is initial or inherit, we don't need to do anything. |
36 | 36 | // Just exit. |
37 | - if ( 'initial' === $this->value || 'inherit' === $this->value ) { |
|
37 | + if ('initial' === $this->value || 'inherit' === $this->value) { |
|
38 | 38 | return; |
39 | 39 | } |
40 | 40 | |
41 | - $x_dimensions = [ 'left', 'center', 'right' ]; |
|
42 | - $y_dimensions = [ 'top', 'center', 'bottom' ]; |
|
41 | + $x_dimensions = ['left', 'center', 'right']; |
|
42 | + $y_dimensions = ['top', 'center', 'bottom']; |
|
43 | 43 | |
44 | 44 | // If there's a space, we have an X and a Y value. |
45 | - if ( false !== strpos( $this->value, ' ' ) ) { |
|
46 | - $xy = explode( ' ', $this->value ); |
|
45 | + if (false !== strpos($this->value, ' ')) { |
|
46 | + $xy = explode(' ', $this->value); |
|
47 | 47 | |
48 | - $x = trim( $xy[0] ); |
|
49 | - $y = trim( $xy[1] ); |
|
48 | + $x = trim($xy[0]); |
|
49 | + $y = trim($xy[1]); |
|
50 | 50 | |
51 | 51 | // If x is not left/center/right, we need to sanitize it. |
52 | - if ( ! in_array( $x, $x_dimensions, true ) ) { |
|
53 | - $x = sanitize_text_field( $x ); |
|
52 | + if (!in_array($x, $x_dimensions, true)) { |
|
53 | + $x = sanitize_text_field($x); |
|
54 | 54 | } |
55 | - if ( ! in_array( $y, $y_dimensions, true ) ) { |
|
56 | - $y = sanitize_text_field( $y ); |
|
55 | + if (!in_array($y, $y_dimensions, true)) { |
|
56 | + $y = sanitize_text_field($y); |
|
57 | 57 | } |
58 | 58 | $this->value = $x . ' ' . $y; |
59 | 59 | return; |
60 | 60 | } |
61 | 61 | $x = 'center'; |
62 | - foreach ( $x_dimensions as $x_dimension ) { |
|
63 | - if ( false !== strpos( $this->value, $x_dimension ) ) { |
|
62 | + foreach ($x_dimensions as $x_dimension) { |
|
63 | + if (false !== strpos($this->value, $x_dimension)) { |
|
64 | 64 | $x = $x_dimension; |
65 | 65 | } |
66 | 66 | } |
67 | 67 | $y = 'center'; |
68 | - foreach ( $y_dimensions as $y_dimension ) { |
|
69 | - if ( false !== strpos( $this->value, $y_dimension ) ) { |
|
68 | + foreach ($y_dimensions as $y_dimension) { |
|
69 | + if (false !== strpos($this->value, $y_dimension)) { |
|
70 | 70 | $y = $y_dimension; |
71 | 71 | } |
72 | 72 | } |
@@ -19,29 +19,29 @@ |
||
19 | 19 | */ |
20 | 20 | class Font_Family extends Property { |
21 | 21 | |
22 | - /** |
|
23 | - * Modifies the value. |
|
24 | - * |
|
25 | - * @access protected |
|
26 | - */ |
|
27 | - protected function process_value() { |
|
28 | - $google_fonts_array = Fonts::get_google_fonts(); |
|
29 | - |
|
30 | - $family = $this->value; |
|
31 | - |
|
32 | - // Make sure the value is a string. |
|
33 | - // If not, then early exit. |
|
34 | - if ( ! is_string( $family ) ) { |
|
35 | - return; |
|
36 | - } |
|
37 | - |
|
38 | - // Hack for standard fonts. |
|
39 | - $family = str_replace( '"', '"', $family ); |
|
40 | - |
|
41 | - // Add double quotes if needed. |
|
42 | - if ( false !== strpos( $family, ' ' ) && false === strpos( $family, '"' ) ) { |
|
43 | - $this->value = '"' . $family . '"'; |
|
44 | - } |
|
45 | - $this->value = html_entity_decode( $family, ENT_QUOTES ); |
|
46 | - } |
|
22 | + /** |
|
23 | + * Modifies the value. |
|
24 | + * |
|
25 | + * @access protected |
|
26 | + */ |
|
27 | + protected function process_value() { |
|
28 | + $google_fonts_array = Fonts::get_google_fonts(); |
|
29 | + |
|
30 | + $family = $this->value; |
|
31 | + |
|
32 | + // Make sure the value is a string. |
|
33 | + // If not, then early exit. |
|
34 | + if ( ! is_string( $family ) ) { |
|
35 | + return; |
|
36 | + } |
|
37 | + |
|
38 | + // Hack for standard fonts. |
|
39 | + $family = str_replace( '"', '"', $family ); |
|
40 | + |
|
41 | + // Add double quotes if needed. |
|
42 | + if ( false !== strpos( $family, ' ' ) && false === strpos( $family, '"' ) ) { |
|
43 | + $this->value = '"' . $family . '"'; |
|
44 | + } |
|
45 | + $this->value = html_entity_decode( $family, ENT_QUOTES ); |
|
46 | + } |
|
47 | 47 | } |
@@ -31,17 +31,17 @@ |
||
31 | 31 | |
32 | 32 | // Make sure the value is a string. |
33 | 33 | // If not, then early exit. |
34 | - if ( ! is_string( $family ) ) { |
|
34 | + if (!is_string($family)) { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | // Hack for standard fonts. |
39 | - $family = str_replace( '"', '"', $family ); |
|
39 | + $family = str_replace('"', '"', $family); |
|
40 | 40 | |
41 | 41 | // Add double quotes if needed. |
42 | - if ( false !== strpos( $family, ' ' ) && false === strpos( $family, '"' ) ) { |
|
42 | + if (false !== strpos($family, ' ') && false === strpos($family, '"')) { |
|
43 | 43 | $this->value = '"' . $family . '"'; |
44 | 44 | } |
45 | - $this->value = html_entity_decode( $family, ENT_QUOTES ); |
|
45 | + $this->value = html_entity_decode($family, ENT_QUOTES); |
|
46 | 46 | } |
47 | 47 | } |
@@ -22,441 +22,441 @@ |
||
22 | 22 | */ |
23 | 23 | class CSS { |
24 | 24 | |
25 | - /** |
|
26 | - * The CSS array |
|
27 | - * |
|
28 | - * @access public |
|
29 | - * @var array |
|
30 | - */ |
|
31 | - public static $css_array = array(); |
|
32 | - |
|
33 | - /** |
|
34 | - * An array of fields to be processed. |
|
35 | - * |
|
36 | - * @static |
|
37 | - * @access protected |
|
38 | - * @since 1.0 |
|
39 | - * @var array |
|
40 | - */ |
|
41 | - protected static $fields = array(); |
|
42 | - |
|
43 | - /** |
|
44 | - * Field option types. |
|
45 | - * |
|
46 | - * @static |
|
47 | - * @access protected |
|
48 | - * @since 1.0 |
|
49 | - * @var array |
|
50 | - */ |
|
51 | - protected static $field_option_types = array(); |
|
52 | - |
|
53 | - /** |
|
54 | - * The default handle for kirki's styles enqueue. |
|
55 | - * |
|
56 | - * @since 4.0 |
|
57 | - * @access private |
|
58 | - * @static |
|
59 | - * |
|
60 | - * @var string |
|
61 | - */ |
|
62 | - private static $css_handle = 'kirki-styles'; |
|
63 | - |
|
64 | - /** |
|
65 | - * The default id for kirki's inline style tag. |
|
66 | - * |
|
67 | - * @since 4.0.23 |
|
68 | - * @access private |
|
69 | - * @static |
|
70 | - * |
|
71 | - * @var string |
|
72 | - */ |
|
73 | - private static $inline_styles_id = 'kirki-inline-styles'; |
|
74 | - |
|
75 | - /** |
|
76 | - * Constructor |
|
77 | - * |
|
78 | - * @access public |
|
79 | - */ |
|
80 | - public function __construct() { |
|
81 | - |
|
82 | - add_action( 'kirki_field_init', array( $this, 'field_init' ), 10, 2 ); |
|
83 | - add_action( 'init', array( $this, 'init' ) ); |
|
84 | - |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Init. |
|
89 | - * |
|
90 | - * @access public |
|
91 | - */ |
|
92 | - public function init() { |
|
93 | - |
|
94 | - new \Kirki\Module\Webfonts(); |
|
95 | - |
|
96 | - add_action( 'wp', array( $this, 'print_styles_action' ) ); |
|
97 | - |
|
98 | - if ( ! apply_filters( 'kirki_output_inline_styles', true ) ) { |
|
99 | - $config = apply_filters( 'kirki_config', array() ); |
|
100 | - $priority = 999; |
|
101 | - |
|
102 | - if ( isset( $config['styles_priority'] ) ) { |
|
103 | - $priority = absint( $config['styles_priority'] ); |
|
104 | - } |
|
105 | - |
|
106 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ), $priority ); |
|
107 | - } else { |
|
108 | - add_action( 'wp_head', array( $this, 'print_styles_inline' ), 999 ); |
|
109 | - } |
|
110 | - |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Runs when a field gets added. |
|
115 | - * Adds fields to this object so their styles can later be generated. |
|
116 | - * |
|
117 | - * @access public |
|
118 | - * @since 1.0 |
|
119 | - * @param array $args The field args. |
|
120 | - * @param Object $object The field object. |
|
121 | - * @return void |
|
122 | - */ |
|
123 | - public function field_init( $args, $object ) { |
|
124 | - |
|
125 | - if ( ! isset( $args['output'] ) ) { |
|
126 | - $args['output'] = array(); |
|
127 | - } |
|
128 | - |
|
129 | - self::$field_option_types[ $args['settings'] ] = isset( $args['option_type'] ) ? $args['option_type'] : 'theme_mod'; |
|
130 | - |
|
131 | - if ( ! is_array( $args['output'] ) ) { |
|
132 | - /* translators: The field ID where the error occurs. */ |
|
133 | - _doing_it_wrong( __METHOD__, sprintf( esc_html__( '"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki' ), esc_html( $args['settings'] ) ), '3.0.10' ); |
|
134 | - $args['output'] = array( |
|
135 | - array( |
|
136 | - 'element' => $args['output'], |
|
137 | - ), |
|
138 | - ); |
|
139 | - } |
|
140 | - |
|
141 | - // Convert to array of arrays if needed. |
|
142 | - if ( isset( $args['output']['element'] ) ) { |
|
143 | - /* translators: The field ID where the error occurs. */ |
|
144 | - _doing_it_wrong( __METHOD__, sprintf( esc_html__( '"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki' ), esc_html( $args['settings'] ) ), '3.0.10' ); |
|
145 | - $args['output'] = array( $args['output'] ); |
|
146 | - } |
|
147 | - |
|
148 | - if ( empty( $args['output'] ) ) { |
|
149 | - return; |
|
150 | - } |
|
151 | - |
|
152 | - foreach ( $args['output'] as $key => $output ) { |
|
153 | - if ( empty( $output ) || ! isset( $output['element'] ) ) { |
|
154 | - unset( $args['output'][ $key ] ); |
|
155 | - continue; |
|
156 | - } |
|
157 | - if ( ! isset( $output['sanitize_callback'] ) && isset( $output['callback'] ) ) { |
|
158 | - $args['output'][ $key ]['sanitize_callback'] = $output['callback']; |
|
159 | - } |
|
160 | - |
|
161 | - // Convert element arrays to strings. |
|
162 | - if ( isset( $output['element'] ) && is_array( $output['element'] ) ) { |
|
163 | - $args['output'][ $key ]['element'] = array_unique( $args['output'][ $key ]['element'] ); |
|
164 | - sort( $args['output'][ $key ]['element'] ); |
|
165 | - |
|
166 | - // Trim each element in the array. |
|
167 | - foreach ( $args['output'][ $key ]['element'] as $index => $element ) { |
|
168 | - $args['output'][ $key ]['element'][ $index ] = trim( $element ); |
|
169 | - } |
|
170 | - $args['output'][ $key ]['element'] = implode( ',', $args['output'][ $key ]['element'] ); |
|
171 | - } |
|
172 | - |
|
173 | - // Fix for https://github.com/aristath/kirki/issues/1659#issuecomment-346229751. |
|
174 | - $args['output'][ $key ]['element'] = str_replace( array( "\t", "\n", "\r", "\0", "\x0B" ), ' ', $args['output'][ $key ]['element'] ); |
|
175 | - $args['output'][ $key ]['element'] = trim( preg_replace( '/\s+/', ' ', $args['output'][ $key ]['element'] ) ); |
|
176 | - } |
|
177 | - |
|
178 | - if ( ! isset( $args['type'] ) && isset( $object->type ) ) { |
|
179 | - $args['type'] = $object->type; |
|
180 | - } |
|
181 | - |
|
182 | - self::$fields[] = $args; |
|
183 | - |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * Print styles inline. |
|
188 | - * |
|
189 | - * @access public |
|
190 | - * @since 3.0.36 |
|
191 | - * @return void |
|
192 | - */ |
|
193 | - public function print_styles_inline() { |
|
194 | - |
|
195 | - $should_print = true; |
|
196 | - |
|
197 | - if ( defined( 'KIRKI_NO_OUTPUT' ) && true === KIRKI_NO_OUTPUT ) { |
|
198 | - $should_print = false; |
|
199 | - } |
|
200 | - |
|
201 | - ob_start(); |
|
202 | - $this->print_styles(); |
|
203 | - $inline_styles = ob_get_clean(); |
|
204 | - |
|
205 | - /** |
|
206 | - * If KIRKI_NO_OUTPUT constant is defined (and is true), but typography field is defined, then print it. |
|
207 | - * Otherwise, the typography field might be broken (missing font-family) if the font-face is not outputted. |
|
208 | - */ |
|
209 | - if ( ! $should_print && false !== stripos($inline_styles, '@font-face') ) { |
|
210 | - $should_print = true; |
|
211 | - } |
|
212 | - |
|
213 | - if ( ! $should_print ) { |
|
214 | - return; |
|
215 | - } |
|
216 | - |
|
217 | - $inline_styles_id = apply_filters( 'kirki_inline_styles_id', self::$inline_styles_id ); |
|
218 | - |
|
219 | - echo '<style id="' . esc_attr( $inline_styles_id ) . '">'; |
|
220 | - echo $inline_styles; |
|
221 | - echo '</style>'; |
|
222 | - |
|
223 | - } |
|
224 | - |
|
225 | - /** |
|
226 | - * Enqueue the styles. |
|
227 | - * |
|
228 | - * @access public |
|
229 | - * @since 3.0.36 |
|
230 | - * @return void |
|
231 | - */ |
|
232 | - public function enqueue_styles() { |
|
233 | - |
|
234 | - $args = array( |
|
235 | - 'action' => apply_filters( 'kirki_styles_action_handle', self::$css_handle ), |
|
236 | - ); |
|
237 | - |
|
238 | - if ( is_admin() ) { |
|
239 | - global $current_screen; |
|
240 | - |
|
241 | - /** |
|
242 | - * This `enqueue_styles` method is also hooked into `enqueue_block_editor_assets`. |
|
243 | - * It needs to be excluded from customize control page. |
|
244 | - * |
|
245 | - * Why not simply excluding all admin area except gutenberg editing interface? |
|
246 | - * Because it would be nice to let the possibility open |
|
247 | - * if a 3rd party plugin will output gutenberg syles somewhere in admin area. |
|
248 | - * |
|
249 | - * Example of possibility: |
|
250 | - * In the future, Ultimate Dashboard Pro's admin page feature might supports Gutenberg. |
|
251 | - */ |
|
252 | - if ( is_object( $current_screen ) && property_exists( $current_screen, 'id' ) && 'customize' === $current_screen->id ) { |
|
253 | - return; |
|
254 | - } |
|
255 | - |
|
256 | - if ( property_exists( $current_screen, 'is_block_editor' ) && 1 === (int) $current_screen->is_block_editor ) { |
|
257 | - $args['editor'] = '1'; |
|
258 | - } |
|
259 | - } |
|
260 | - |
|
261 | - // Enqueue the dynamic stylesheet. |
|
262 | - wp_enqueue_style( |
|
263 | - self::$css_handle, |
|
264 | - add_query_arg( $args, home_url() ), |
|
265 | - array(), |
|
266 | - '4.0' |
|
267 | - ); |
|
268 | - |
|
269 | - } |
|
270 | - |
|
271 | - /** |
|
272 | - * Prints the styles as an enqueued file. |
|
273 | - * |
|
274 | - * @access public |
|
275 | - * @since 3.0.36 |
|
276 | - * @return void |
|
277 | - */ |
|
278 | - public function print_styles_action() { |
|
279 | - |
|
280 | - /** |
|
281 | - * Note to code reviewers: |
|
282 | - * There is no need for a nonce check here, we're only checking if this is a valid request or not. |
|
283 | - */ |
|
284 | - |
|
285 | - // phpcs:ignore WordPress.Security.NonceVerification |
|
286 | - if ( empty( $_GET['action'] ) || apply_filters( 'kirki_styles_action_handle', self::$css_handle ) !== $_GET['action'] ) { |
|
287 | - return; |
|
288 | - } |
|
289 | - |
|
290 | - // This is a stylesheet. |
|
291 | - header( 'Content-type: text/css' ); |
|
292 | - $this->print_styles(); |
|
293 | - exit; |
|
294 | - |
|
295 | - } |
|
296 | - |
|
297 | - /** |
|
298 | - * Prints the styles. |
|
299 | - * |
|
300 | - * @access public |
|
301 | - */ |
|
302 | - public function print_styles() { |
|
303 | - |
|
304 | - // Go through all configs. |
|
305 | - $configs = Kirki::$config; |
|
306 | - |
|
307 | - foreach ( $configs as $config_id => $args ) { |
|
308 | - if ( defined( 'KIRKI_NO_OUTPUT' ) && true === KIRKI_NO_OUTPUT ) { |
|
309 | - continue; |
|
310 | - } |
|
311 | - |
|
312 | - if ( isset( $args['disable_output'] ) && true === $args['disable_output'] ) { |
|
313 | - continue; |
|
314 | - } |
|
315 | - |
|
316 | - $styles = self::loop_controls( $config_id ); |
|
317 | - $styles = apply_filters( "kirki_{$config_id}_dynamic_css", $styles ); |
|
318 | - |
|
319 | - if ( ! empty( $styles ) ) { |
|
320 | - /** |
|
321 | - * Note to code reviewers: |
|
322 | - * |
|
323 | - * Though all output should be run through an escaping function, this is pure CSS. |
|
324 | - * |
|
325 | - * When used in the print_styles_action() method the PHP header() call makes the browser interpret it as such. |
|
326 | - * No code, script or anything else can be executed from inside a stylesheet. |
|
327 | - * |
|
328 | - * When using in the print_styles_inline() method the wp_strip_all_tags call we use below |
|
329 | - * strips anything that has the possibility to be malicious, and since this is inslide a <style> tag |
|
330 | - * it can only be interpreted by the browser as such. |
|
331 | - * wp_strip_all_tags() excludes the possibility of someone closing the <style> tag and then opening something else. |
|
332 | - */ |
|
333 | - echo wp_strip_all_tags( $styles ); // phpcs:ignore WordPress.Security.EscapeOutput |
|
334 | - } |
|
335 | - } |
|
336 | - |
|
337 | - do_action( 'kirki_dynamic_css' ); |
|
338 | - |
|
339 | - } |
|
340 | - |
|
341 | - /** |
|
342 | - * Loop through all fields and create an array of style definitions. |
|
343 | - * |
|
344 | - * @static |
|
345 | - * @access public |
|
346 | - * @param string $config_id The configuration ID. |
|
347 | - */ |
|
348 | - public static function loop_controls( $config_id ) { |
|
349 | - |
|
350 | - // Get an instance of the Generator class. |
|
351 | - // This will make sure google fonts and backup fonts are loaded. |
|
352 | - Generator::get_instance(); |
|
353 | - |
|
354 | - $fields = self::get_fields_by_config( $config_id ); |
|
355 | - |
|
356 | - // Compatibility with v3 API. |
|
357 | - if ( class_exists( '\Kirki\Compatibility\Kirki' ) ) { |
|
358 | - $fields = array_merge( \Kirki\Compatibility\Kirki::$fields, $fields ); |
|
359 | - } |
|
360 | - |
|
361 | - $css = array(); |
|
362 | - |
|
363 | - // Early exit if no fields are found. |
|
364 | - if ( empty( $fields ) ) { |
|
365 | - return; |
|
366 | - } |
|
367 | - |
|
368 | - foreach ( $fields as $field ) { |
|
369 | - |
|
370 | - // Only process fields that belong to $config_id. |
|
371 | - if ( isset( $field['kirki_config'] ) && $config_id !== $field['kirki_config'] ) { |
|
372 | - continue; |
|
373 | - } |
|
374 | - |
|
375 | - if ( true === apply_filters( "kirki_{$config_id}_css_skip_hidden", true ) ) { |
|
376 | - |
|
377 | - // Only continue if field dependencies are met. |
|
378 | - if ( ( isset( $field['required'] ) && ! empty( $field['required'] ) ) || ( isset( $field['active_callback'] ) && ! empty( $field['active_callback'] ) ) ) { |
|
379 | - $valid = true; |
|
380 | - |
|
381 | - // If $field is using active_callback instead of required. |
|
382 | - if ( ! isset( $field['required'] ) || empty( $field['required'] ) ) { |
|
383 | - if ( isset( $field['active_callback'] ) && ! empty( $field['active_callback'] ) ) { |
|
384 | - // The "active_callback" or "required" accepts array or callable as the value. |
|
385 | - if ( is_array( $field['active_callback'] ) || is_callable( $field['active_callback'] ) ) { |
|
386 | - $field['required'] = $field['active_callback']; |
|
387 | - } |
|
388 | - } |
|
389 | - } |
|
390 | - |
|
391 | - // At this point, we know that the "required" is set and is not empty. |
|
392 | - if ( is_array( $field['required'] ) ) { |
|
393 | - foreach ( $field['required'] as $requirement ) { |
|
394 | - if ( isset( $requirement['setting'] ) && isset( $requirement['value'] ) && isset( $requirement['operator'] ) && isset( self::$field_option_types[ $requirement['setting'] ] ) ) { |
|
395 | - $controller_value = Values::get_value( $config_id, $requirement['setting'] ); |
|
396 | - |
|
397 | - if ( ! Helper::compare_values( $controller_value, $requirement['value'], $requirement['operator'] ) ) { |
|
398 | - $valid = false; |
|
399 | - } |
|
400 | - } |
|
401 | - } |
|
402 | - } elseif ( is_string( $field['required'] ) ) { |
|
403 | - $valid = '__return_true' === $field['required'] ? true : false; |
|
404 | - } elseif ( is_callable( $field['required'] ) ) { |
|
405 | - $valid = call_user_func( $field['required'] ); |
|
406 | - } |
|
407 | - |
|
408 | - if ( ! $valid ) { |
|
409 | - continue; |
|
410 | - } |
|
411 | - } |
|
412 | - } |
|
413 | - |
|
414 | - // Only continue if $field['output'] is set. |
|
415 | - if ( isset( $field['output'] ) && ! empty( $field['output'] ) ) { |
|
416 | - $css = Helper::array_replace_recursive( $css, Generator::css( $field ) ); |
|
417 | - |
|
418 | - // Add the globals. |
|
419 | - if ( isset( self::$css_array[ $config_id ] ) && ! empty( self::$css_array[ $config_id ] ) ) { |
|
420 | - Helper::array_replace_recursive( $css, self::$css_array[ $config_id ] ); |
|
421 | - } |
|
422 | - } |
|
423 | - } |
|
424 | - |
|
425 | - $css = apply_filters( "kirki_{$config_id}_styles", $css ); |
|
426 | - |
|
427 | - if ( is_array( $css ) ) { |
|
428 | - return Generator::styles_parse( Generator::add_prefixes( $css ) ); |
|
429 | - } |
|
430 | - |
|
431 | - } |
|
432 | - |
|
433 | - /** |
|
434 | - * Gets fields from self::$fields by config-id. |
|
435 | - * |
|
436 | - * @static |
|
437 | - * @access private |
|
438 | - * @since 1.0 |
|
439 | - * @param string $config_id The config-ID. |
|
440 | - * @return array |
|
441 | - */ |
|
442 | - private static function get_fields_by_config( $config_id ) { |
|
443 | - |
|
444 | - $fields = array(); |
|
445 | - |
|
446 | - foreach ( self::$fields as $field ) { |
|
447 | - if ( |
|
448 | - ( isset( $field['kirki_config'] ) && $config_id === $field['kirki_config'] ) || |
|
449 | - ( |
|
450 | - ( 'global' === $config_id || ! $config_id ) && |
|
451 | - ( ! isset( $field['kirki_config'] ) || 'global' === $field['kirki_config'] || ! $field['kirki_config'] ) |
|
452 | - ) |
|
453 | - ) { |
|
454 | - $fields[] = $field; |
|
455 | - } |
|
456 | - } |
|
457 | - |
|
458 | - return $fields; |
|
459 | - |
|
460 | - } |
|
25 | + /** |
|
26 | + * The CSS array |
|
27 | + * |
|
28 | + * @access public |
|
29 | + * @var array |
|
30 | + */ |
|
31 | + public static $css_array = array(); |
|
32 | + |
|
33 | + /** |
|
34 | + * An array of fields to be processed. |
|
35 | + * |
|
36 | + * @static |
|
37 | + * @access protected |
|
38 | + * @since 1.0 |
|
39 | + * @var array |
|
40 | + */ |
|
41 | + protected static $fields = array(); |
|
42 | + |
|
43 | + /** |
|
44 | + * Field option types. |
|
45 | + * |
|
46 | + * @static |
|
47 | + * @access protected |
|
48 | + * @since 1.0 |
|
49 | + * @var array |
|
50 | + */ |
|
51 | + protected static $field_option_types = array(); |
|
52 | + |
|
53 | + /** |
|
54 | + * The default handle for kirki's styles enqueue. |
|
55 | + * |
|
56 | + * @since 4.0 |
|
57 | + * @access private |
|
58 | + * @static |
|
59 | + * |
|
60 | + * @var string |
|
61 | + */ |
|
62 | + private static $css_handle = 'kirki-styles'; |
|
63 | + |
|
64 | + /** |
|
65 | + * The default id for kirki's inline style tag. |
|
66 | + * |
|
67 | + * @since 4.0.23 |
|
68 | + * @access private |
|
69 | + * @static |
|
70 | + * |
|
71 | + * @var string |
|
72 | + */ |
|
73 | + private static $inline_styles_id = 'kirki-inline-styles'; |
|
74 | + |
|
75 | + /** |
|
76 | + * Constructor |
|
77 | + * |
|
78 | + * @access public |
|
79 | + */ |
|
80 | + public function __construct() { |
|
81 | + |
|
82 | + add_action( 'kirki_field_init', array( $this, 'field_init' ), 10, 2 ); |
|
83 | + add_action( 'init', array( $this, 'init' ) ); |
|
84 | + |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Init. |
|
89 | + * |
|
90 | + * @access public |
|
91 | + */ |
|
92 | + public function init() { |
|
93 | + |
|
94 | + new \Kirki\Module\Webfonts(); |
|
95 | + |
|
96 | + add_action( 'wp', array( $this, 'print_styles_action' ) ); |
|
97 | + |
|
98 | + if ( ! apply_filters( 'kirki_output_inline_styles', true ) ) { |
|
99 | + $config = apply_filters( 'kirki_config', array() ); |
|
100 | + $priority = 999; |
|
101 | + |
|
102 | + if ( isset( $config['styles_priority'] ) ) { |
|
103 | + $priority = absint( $config['styles_priority'] ); |
|
104 | + } |
|
105 | + |
|
106 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ), $priority ); |
|
107 | + } else { |
|
108 | + add_action( 'wp_head', array( $this, 'print_styles_inline' ), 999 ); |
|
109 | + } |
|
110 | + |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Runs when a field gets added. |
|
115 | + * Adds fields to this object so their styles can later be generated. |
|
116 | + * |
|
117 | + * @access public |
|
118 | + * @since 1.0 |
|
119 | + * @param array $args The field args. |
|
120 | + * @param Object $object The field object. |
|
121 | + * @return void |
|
122 | + */ |
|
123 | + public function field_init( $args, $object ) { |
|
124 | + |
|
125 | + if ( ! isset( $args['output'] ) ) { |
|
126 | + $args['output'] = array(); |
|
127 | + } |
|
128 | + |
|
129 | + self::$field_option_types[ $args['settings'] ] = isset( $args['option_type'] ) ? $args['option_type'] : 'theme_mod'; |
|
130 | + |
|
131 | + if ( ! is_array( $args['output'] ) ) { |
|
132 | + /* translators: The field ID where the error occurs. */ |
|
133 | + _doing_it_wrong( __METHOD__, sprintf( esc_html__( '"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki' ), esc_html( $args['settings'] ) ), '3.0.10' ); |
|
134 | + $args['output'] = array( |
|
135 | + array( |
|
136 | + 'element' => $args['output'], |
|
137 | + ), |
|
138 | + ); |
|
139 | + } |
|
140 | + |
|
141 | + // Convert to array of arrays if needed. |
|
142 | + if ( isset( $args['output']['element'] ) ) { |
|
143 | + /* translators: The field ID where the error occurs. */ |
|
144 | + _doing_it_wrong( __METHOD__, sprintf( esc_html__( '"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki' ), esc_html( $args['settings'] ) ), '3.0.10' ); |
|
145 | + $args['output'] = array( $args['output'] ); |
|
146 | + } |
|
147 | + |
|
148 | + if ( empty( $args['output'] ) ) { |
|
149 | + return; |
|
150 | + } |
|
151 | + |
|
152 | + foreach ( $args['output'] as $key => $output ) { |
|
153 | + if ( empty( $output ) || ! isset( $output['element'] ) ) { |
|
154 | + unset( $args['output'][ $key ] ); |
|
155 | + continue; |
|
156 | + } |
|
157 | + if ( ! isset( $output['sanitize_callback'] ) && isset( $output['callback'] ) ) { |
|
158 | + $args['output'][ $key ]['sanitize_callback'] = $output['callback']; |
|
159 | + } |
|
160 | + |
|
161 | + // Convert element arrays to strings. |
|
162 | + if ( isset( $output['element'] ) && is_array( $output['element'] ) ) { |
|
163 | + $args['output'][ $key ]['element'] = array_unique( $args['output'][ $key ]['element'] ); |
|
164 | + sort( $args['output'][ $key ]['element'] ); |
|
165 | + |
|
166 | + // Trim each element in the array. |
|
167 | + foreach ( $args['output'][ $key ]['element'] as $index => $element ) { |
|
168 | + $args['output'][ $key ]['element'][ $index ] = trim( $element ); |
|
169 | + } |
|
170 | + $args['output'][ $key ]['element'] = implode( ',', $args['output'][ $key ]['element'] ); |
|
171 | + } |
|
172 | + |
|
173 | + // Fix for https://github.com/aristath/kirki/issues/1659#issuecomment-346229751. |
|
174 | + $args['output'][ $key ]['element'] = str_replace( array( "\t", "\n", "\r", "\0", "\x0B" ), ' ', $args['output'][ $key ]['element'] ); |
|
175 | + $args['output'][ $key ]['element'] = trim( preg_replace( '/\s+/', ' ', $args['output'][ $key ]['element'] ) ); |
|
176 | + } |
|
177 | + |
|
178 | + if ( ! isset( $args['type'] ) && isset( $object->type ) ) { |
|
179 | + $args['type'] = $object->type; |
|
180 | + } |
|
181 | + |
|
182 | + self::$fields[] = $args; |
|
183 | + |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * Print styles inline. |
|
188 | + * |
|
189 | + * @access public |
|
190 | + * @since 3.0.36 |
|
191 | + * @return void |
|
192 | + */ |
|
193 | + public function print_styles_inline() { |
|
194 | + |
|
195 | + $should_print = true; |
|
196 | + |
|
197 | + if ( defined( 'KIRKI_NO_OUTPUT' ) && true === KIRKI_NO_OUTPUT ) { |
|
198 | + $should_print = false; |
|
199 | + } |
|
200 | + |
|
201 | + ob_start(); |
|
202 | + $this->print_styles(); |
|
203 | + $inline_styles = ob_get_clean(); |
|
204 | + |
|
205 | + /** |
|
206 | + * If KIRKI_NO_OUTPUT constant is defined (and is true), but typography field is defined, then print it. |
|
207 | + * Otherwise, the typography field might be broken (missing font-family) if the font-face is not outputted. |
|
208 | + */ |
|
209 | + if ( ! $should_print && false !== stripos($inline_styles, '@font-face') ) { |
|
210 | + $should_print = true; |
|
211 | + } |
|
212 | + |
|
213 | + if ( ! $should_print ) { |
|
214 | + return; |
|
215 | + } |
|
216 | + |
|
217 | + $inline_styles_id = apply_filters( 'kirki_inline_styles_id', self::$inline_styles_id ); |
|
218 | + |
|
219 | + echo '<style id="' . esc_attr( $inline_styles_id ) . '">'; |
|
220 | + echo $inline_styles; |
|
221 | + echo '</style>'; |
|
222 | + |
|
223 | + } |
|
224 | + |
|
225 | + /** |
|
226 | + * Enqueue the styles. |
|
227 | + * |
|
228 | + * @access public |
|
229 | + * @since 3.0.36 |
|
230 | + * @return void |
|
231 | + */ |
|
232 | + public function enqueue_styles() { |
|
233 | + |
|
234 | + $args = array( |
|
235 | + 'action' => apply_filters( 'kirki_styles_action_handle', self::$css_handle ), |
|
236 | + ); |
|
237 | + |
|
238 | + if ( is_admin() ) { |
|
239 | + global $current_screen; |
|
240 | + |
|
241 | + /** |
|
242 | + * This `enqueue_styles` method is also hooked into `enqueue_block_editor_assets`. |
|
243 | + * It needs to be excluded from customize control page. |
|
244 | + * |
|
245 | + * Why not simply excluding all admin area except gutenberg editing interface? |
|
246 | + * Because it would be nice to let the possibility open |
|
247 | + * if a 3rd party plugin will output gutenberg syles somewhere in admin area. |
|
248 | + * |
|
249 | + * Example of possibility: |
|
250 | + * In the future, Ultimate Dashboard Pro's admin page feature might supports Gutenberg. |
|
251 | + */ |
|
252 | + if ( is_object( $current_screen ) && property_exists( $current_screen, 'id' ) && 'customize' === $current_screen->id ) { |
|
253 | + return; |
|
254 | + } |
|
255 | + |
|
256 | + if ( property_exists( $current_screen, 'is_block_editor' ) && 1 === (int) $current_screen->is_block_editor ) { |
|
257 | + $args['editor'] = '1'; |
|
258 | + } |
|
259 | + } |
|
260 | + |
|
261 | + // Enqueue the dynamic stylesheet. |
|
262 | + wp_enqueue_style( |
|
263 | + self::$css_handle, |
|
264 | + add_query_arg( $args, home_url() ), |
|
265 | + array(), |
|
266 | + '4.0' |
|
267 | + ); |
|
268 | + |
|
269 | + } |
|
270 | + |
|
271 | + /** |
|
272 | + * Prints the styles as an enqueued file. |
|
273 | + * |
|
274 | + * @access public |
|
275 | + * @since 3.0.36 |
|
276 | + * @return void |
|
277 | + */ |
|
278 | + public function print_styles_action() { |
|
279 | + |
|
280 | + /** |
|
281 | + * Note to code reviewers: |
|
282 | + * There is no need for a nonce check here, we're only checking if this is a valid request or not. |
|
283 | + */ |
|
284 | + |
|
285 | + // phpcs:ignore WordPress.Security.NonceVerification |
|
286 | + if ( empty( $_GET['action'] ) || apply_filters( 'kirki_styles_action_handle', self::$css_handle ) !== $_GET['action'] ) { |
|
287 | + return; |
|
288 | + } |
|
289 | + |
|
290 | + // This is a stylesheet. |
|
291 | + header( 'Content-type: text/css' ); |
|
292 | + $this->print_styles(); |
|
293 | + exit; |
|
294 | + |
|
295 | + } |
|
296 | + |
|
297 | + /** |
|
298 | + * Prints the styles. |
|
299 | + * |
|
300 | + * @access public |
|
301 | + */ |
|
302 | + public function print_styles() { |
|
303 | + |
|
304 | + // Go through all configs. |
|
305 | + $configs = Kirki::$config; |
|
306 | + |
|
307 | + foreach ( $configs as $config_id => $args ) { |
|
308 | + if ( defined( 'KIRKI_NO_OUTPUT' ) && true === KIRKI_NO_OUTPUT ) { |
|
309 | + continue; |
|
310 | + } |
|
311 | + |
|
312 | + if ( isset( $args['disable_output'] ) && true === $args['disable_output'] ) { |
|
313 | + continue; |
|
314 | + } |
|
315 | + |
|
316 | + $styles = self::loop_controls( $config_id ); |
|
317 | + $styles = apply_filters( "kirki_{$config_id}_dynamic_css", $styles ); |
|
318 | + |
|
319 | + if ( ! empty( $styles ) ) { |
|
320 | + /** |
|
321 | + * Note to code reviewers: |
|
322 | + * |
|
323 | + * Though all output should be run through an escaping function, this is pure CSS. |
|
324 | + * |
|
325 | + * When used in the print_styles_action() method the PHP header() call makes the browser interpret it as such. |
|
326 | + * No code, script or anything else can be executed from inside a stylesheet. |
|
327 | + * |
|
328 | + * When using in the print_styles_inline() method the wp_strip_all_tags call we use below |
|
329 | + * strips anything that has the possibility to be malicious, and since this is inslide a <style> tag |
|
330 | + * it can only be interpreted by the browser as such. |
|
331 | + * wp_strip_all_tags() excludes the possibility of someone closing the <style> tag and then opening something else. |
|
332 | + */ |
|
333 | + echo wp_strip_all_tags( $styles ); // phpcs:ignore WordPress.Security.EscapeOutput |
|
334 | + } |
|
335 | + } |
|
336 | + |
|
337 | + do_action( 'kirki_dynamic_css' ); |
|
338 | + |
|
339 | + } |
|
340 | + |
|
341 | + /** |
|
342 | + * Loop through all fields and create an array of style definitions. |
|
343 | + * |
|
344 | + * @static |
|
345 | + * @access public |
|
346 | + * @param string $config_id The configuration ID. |
|
347 | + */ |
|
348 | + public static function loop_controls( $config_id ) { |
|
349 | + |
|
350 | + // Get an instance of the Generator class. |
|
351 | + // This will make sure google fonts and backup fonts are loaded. |
|
352 | + Generator::get_instance(); |
|
353 | + |
|
354 | + $fields = self::get_fields_by_config( $config_id ); |
|
355 | + |
|
356 | + // Compatibility with v3 API. |
|
357 | + if ( class_exists( '\Kirki\Compatibility\Kirki' ) ) { |
|
358 | + $fields = array_merge( \Kirki\Compatibility\Kirki::$fields, $fields ); |
|
359 | + } |
|
360 | + |
|
361 | + $css = array(); |
|
362 | + |
|
363 | + // Early exit if no fields are found. |
|
364 | + if ( empty( $fields ) ) { |
|
365 | + return; |
|
366 | + } |
|
367 | + |
|
368 | + foreach ( $fields as $field ) { |
|
369 | + |
|
370 | + // Only process fields that belong to $config_id. |
|
371 | + if ( isset( $field['kirki_config'] ) && $config_id !== $field['kirki_config'] ) { |
|
372 | + continue; |
|
373 | + } |
|
374 | + |
|
375 | + if ( true === apply_filters( "kirki_{$config_id}_css_skip_hidden", true ) ) { |
|
376 | + |
|
377 | + // Only continue if field dependencies are met. |
|
378 | + if ( ( isset( $field['required'] ) && ! empty( $field['required'] ) ) || ( isset( $field['active_callback'] ) && ! empty( $field['active_callback'] ) ) ) { |
|
379 | + $valid = true; |
|
380 | + |
|
381 | + // If $field is using active_callback instead of required. |
|
382 | + if ( ! isset( $field['required'] ) || empty( $field['required'] ) ) { |
|
383 | + if ( isset( $field['active_callback'] ) && ! empty( $field['active_callback'] ) ) { |
|
384 | + // The "active_callback" or "required" accepts array or callable as the value. |
|
385 | + if ( is_array( $field['active_callback'] ) || is_callable( $field['active_callback'] ) ) { |
|
386 | + $field['required'] = $field['active_callback']; |
|
387 | + } |
|
388 | + } |
|
389 | + } |
|
390 | + |
|
391 | + // At this point, we know that the "required" is set and is not empty. |
|
392 | + if ( is_array( $field['required'] ) ) { |
|
393 | + foreach ( $field['required'] as $requirement ) { |
|
394 | + if ( isset( $requirement['setting'] ) && isset( $requirement['value'] ) && isset( $requirement['operator'] ) && isset( self::$field_option_types[ $requirement['setting'] ] ) ) { |
|
395 | + $controller_value = Values::get_value( $config_id, $requirement['setting'] ); |
|
396 | + |
|
397 | + if ( ! Helper::compare_values( $controller_value, $requirement['value'], $requirement['operator'] ) ) { |
|
398 | + $valid = false; |
|
399 | + } |
|
400 | + } |
|
401 | + } |
|
402 | + } elseif ( is_string( $field['required'] ) ) { |
|
403 | + $valid = '__return_true' === $field['required'] ? true : false; |
|
404 | + } elseif ( is_callable( $field['required'] ) ) { |
|
405 | + $valid = call_user_func( $field['required'] ); |
|
406 | + } |
|
407 | + |
|
408 | + if ( ! $valid ) { |
|
409 | + continue; |
|
410 | + } |
|
411 | + } |
|
412 | + } |
|
413 | + |
|
414 | + // Only continue if $field['output'] is set. |
|
415 | + if ( isset( $field['output'] ) && ! empty( $field['output'] ) ) { |
|
416 | + $css = Helper::array_replace_recursive( $css, Generator::css( $field ) ); |
|
417 | + |
|
418 | + // Add the globals. |
|
419 | + if ( isset( self::$css_array[ $config_id ] ) && ! empty( self::$css_array[ $config_id ] ) ) { |
|
420 | + Helper::array_replace_recursive( $css, self::$css_array[ $config_id ] ); |
|
421 | + } |
|
422 | + } |
|
423 | + } |
|
424 | + |
|
425 | + $css = apply_filters( "kirki_{$config_id}_styles", $css ); |
|
426 | + |
|
427 | + if ( is_array( $css ) ) { |
|
428 | + return Generator::styles_parse( Generator::add_prefixes( $css ) ); |
|
429 | + } |
|
430 | + |
|
431 | + } |
|
432 | + |
|
433 | + /** |
|
434 | + * Gets fields from self::$fields by config-id. |
|
435 | + * |
|
436 | + * @static |
|
437 | + * @access private |
|
438 | + * @since 1.0 |
|
439 | + * @param string $config_id The config-ID. |
|
440 | + * @return array |
|
441 | + */ |
|
442 | + private static function get_fields_by_config( $config_id ) { |
|
443 | + |
|
444 | + $fields = array(); |
|
445 | + |
|
446 | + foreach ( self::$fields as $field ) { |
|
447 | + if ( |
|
448 | + ( isset( $field['kirki_config'] ) && $config_id === $field['kirki_config'] ) || |
|
449 | + ( |
|
450 | + ( 'global' === $config_id || ! $config_id ) && |
|
451 | + ( ! isset( $field['kirki_config'] ) || 'global' === $field['kirki_config'] || ! $field['kirki_config'] ) |
|
452 | + ) |
|
453 | + ) { |
|
454 | + $fields[] = $field; |
|
455 | + } |
|
456 | + } |
|
457 | + |
|
458 | + return $fields; |
|
459 | + |
|
460 | + } |
|
461 | 461 | |
462 | 462 | } |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function __construct() { |
81 | 81 | |
82 | - add_action( 'kirki_field_init', array( $this, 'field_init' ), 10, 2 ); |
|
83 | - add_action( 'init', array( $this, 'init' ) ); |
|
82 | + add_action('kirki_field_init', array($this, 'field_init'), 10, 2); |
|
83 | + add_action('init', array($this, 'init')); |
|
84 | 84 | |
85 | 85 | } |
86 | 86 | |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | |
94 | 94 | new \Kirki\Module\Webfonts(); |
95 | 95 | |
96 | - add_action( 'wp', array( $this, 'print_styles_action' ) ); |
|
96 | + add_action('wp', array($this, 'print_styles_action')); |
|
97 | 97 | |
98 | - if ( ! apply_filters( 'kirki_output_inline_styles', true ) ) { |
|
99 | - $config = apply_filters( 'kirki_config', array() ); |
|
98 | + if (!apply_filters('kirki_output_inline_styles', true)) { |
|
99 | + $config = apply_filters('kirki_config', array()); |
|
100 | 100 | $priority = 999; |
101 | 101 | |
102 | - if ( isset( $config['styles_priority'] ) ) { |
|
103 | - $priority = absint( $config['styles_priority'] ); |
|
102 | + if (isset($config['styles_priority'])) { |
|
103 | + $priority = absint($config['styles_priority']); |
|
104 | 104 | } |
105 | 105 | |
106 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ), $priority ); |
|
106 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'), $priority); |
|
107 | 107 | } else { |
108 | - add_action( 'wp_head', array( $this, 'print_styles_inline' ), 999 ); |
|
108 | + add_action('wp_head', array($this, 'print_styles_inline'), 999); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | } |
@@ -120,17 +120,17 @@ discard block |
||
120 | 120 | * @param Object $object The field object. |
121 | 121 | * @return void |
122 | 122 | */ |
123 | - public function field_init( $args, $object ) { |
|
123 | + public function field_init($args, $object) { |
|
124 | 124 | |
125 | - if ( ! isset( $args['output'] ) ) { |
|
125 | + if (!isset($args['output'])) { |
|
126 | 126 | $args['output'] = array(); |
127 | 127 | } |
128 | 128 | |
129 | - self::$field_option_types[ $args['settings'] ] = isset( $args['option_type'] ) ? $args['option_type'] : 'theme_mod'; |
|
129 | + self::$field_option_types[$args['settings']] = isset($args['option_type']) ? $args['option_type'] : 'theme_mod'; |
|
130 | 130 | |
131 | - if ( ! is_array( $args['output'] ) ) { |
|
131 | + if (!is_array($args['output'])) { |
|
132 | 132 | /* translators: The field ID where the error occurs. */ |
133 | - _doing_it_wrong( __METHOD__, sprintf( esc_html__( '"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki' ), esc_html( $args['settings'] ) ), '3.0.10' ); |
|
133 | + _doing_it_wrong(__METHOD__, sprintf(esc_html__('"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki'), esc_html($args['settings'])), '3.0.10'); |
|
134 | 134 | $args['output'] = array( |
135 | 135 | array( |
136 | 136 | 'element' => $args['output'], |
@@ -139,43 +139,43 @@ discard block |
||
139 | 139 | } |
140 | 140 | |
141 | 141 | // Convert to array of arrays if needed. |
142 | - if ( isset( $args['output']['element'] ) ) { |
|
142 | + if (isset($args['output']['element'])) { |
|
143 | 143 | /* translators: The field ID where the error occurs. */ |
144 | - _doing_it_wrong( __METHOD__, sprintf( esc_html__( '"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki' ), esc_html( $args['settings'] ) ), '3.0.10' ); |
|
145 | - $args['output'] = array( $args['output'] ); |
|
144 | + _doing_it_wrong(__METHOD__, sprintf(esc_html__('"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki'), esc_html($args['settings'])), '3.0.10'); |
|
145 | + $args['output'] = array($args['output']); |
|
146 | 146 | } |
147 | 147 | |
148 | - if ( empty( $args['output'] ) ) { |
|
148 | + if (empty($args['output'])) { |
|
149 | 149 | return; |
150 | 150 | } |
151 | 151 | |
152 | - foreach ( $args['output'] as $key => $output ) { |
|
153 | - if ( empty( $output ) || ! isset( $output['element'] ) ) { |
|
154 | - unset( $args['output'][ $key ] ); |
|
152 | + foreach ($args['output'] as $key => $output) { |
|
153 | + if (empty($output) || !isset($output['element'])) { |
|
154 | + unset($args['output'][$key]); |
|
155 | 155 | continue; |
156 | 156 | } |
157 | - if ( ! isset( $output['sanitize_callback'] ) && isset( $output['callback'] ) ) { |
|
158 | - $args['output'][ $key ]['sanitize_callback'] = $output['callback']; |
|
157 | + if (!isset($output['sanitize_callback']) && isset($output['callback'])) { |
|
158 | + $args['output'][$key]['sanitize_callback'] = $output['callback']; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | // Convert element arrays to strings. |
162 | - if ( isset( $output['element'] ) && is_array( $output['element'] ) ) { |
|
163 | - $args['output'][ $key ]['element'] = array_unique( $args['output'][ $key ]['element'] ); |
|
164 | - sort( $args['output'][ $key ]['element'] ); |
|
162 | + if (isset($output['element']) && is_array($output['element'])) { |
|
163 | + $args['output'][$key]['element'] = array_unique($args['output'][$key]['element']); |
|
164 | + sort($args['output'][$key]['element']); |
|
165 | 165 | |
166 | 166 | // Trim each element in the array. |
167 | - foreach ( $args['output'][ $key ]['element'] as $index => $element ) { |
|
168 | - $args['output'][ $key ]['element'][ $index ] = trim( $element ); |
|
167 | + foreach ($args['output'][$key]['element'] as $index => $element) { |
|
168 | + $args['output'][$key]['element'][$index] = trim($element); |
|
169 | 169 | } |
170 | - $args['output'][ $key ]['element'] = implode( ',', $args['output'][ $key ]['element'] ); |
|
170 | + $args['output'][$key]['element'] = implode(',', $args['output'][$key]['element']); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // Fix for https://github.com/aristath/kirki/issues/1659#issuecomment-346229751. |
174 | - $args['output'][ $key ]['element'] = str_replace( array( "\t", "\n", "\r", "\0", "\x0B" ), ' ', $args['output'][ $key ]['element'] ); |
|
175 | - $args['output'][ $key ]['element'] = trim( preg_replace( '/\s+/', ' ', $args['output'][ $key ]['element'] ) ); |
|
174 | + $args['output'][$key]['element'] = str_replace(array("\t", "\n", "\r", "\0", "\x0B"), ' ', $args['output'][$key]['element']); |
|
175 | + $args['output'][$key]['element'] = trim(preg_replace('/\s+/', ' ', $args['output'][$key]['element'])); |
|
176 | 176 | } |
177 | 177 | |
178 | - if ( ! isset( $args['type'] ) && isset( $object->type ) ) { |
|
178 | + if (!isset($args['type']) && isset($object->type)) { |
|
179 | 179 | $args['type'] = $object->type; |
180 | 180 | } |
181 | 181 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | $should_print = true; |
196 | 196 | |
197 | - if ( defined( 'KIRKI_NO_OUTPUT' ) && true === KIRKI_NO_OUTPUT ) { |
|
197 | + if (defined('KIRKI_NO_OUTPUT') && true === KIRKI_NO_OUTPUT) { |
|
198 | 198 | $should_print = false; |
199 | 199 | } |
200 | 200 | |
@@ -206,17 +206,17 @@ discard block |
||
206 | 206 | * If KIRKI_NO_OUTPUT constant is defined (and is true), but typography field is defined, then print it. |
207 | 207 | * Otherwise, the typography field might be broken (missing font-family) if the font-face is not outputted. |
208 | 208 | */ |
209 | - if ( ! $should_print && false !== stripos($inline_styles, '@font-face') ) { |
|
209 | + if (!$should_print && false !== stripos($inline_styles, '@font-face')) { |
|
210 | 210 | $should_print = true; |
211 | 211 | } |
212 | 212 | |
213 | - if ( ! $should_print ) { |
|
213 | + if (!$should_print) { |
|
214 | 214 | return; |
215 | 215 | } |
216 | 216 | |
217 | - $inline_styles_id = apply_filters( 'kirki_inline_styles_id', self::$inline_styles_id ); |
|
217 | + $inline_styles_id = apply_filters('kirki_inline_styles_id', self::$inline_styles_id); |
|
218 | 218 | |
219 | - echo '<style id="' . esc_attr( $inline_styles_id ) . '">'; |
|
219 | + echo '<style id="' . esc_attr($inline_styles_id) . '">'; |
|
220 | 220 | echo $inline_styles; |
221 | 221 | echo '</style>'; |
222 | 222 | |
@@ -232,10 +232,10 @@ discard block |
||
232 | 232 | public function enqueue_styles() { |
233 | 233 | |
234 | 234 | $args = array( |
235 | - 'action' => apply_filters( 'kirki_styles_action_handle', self::$css_handle ), |
|
235 | + 'action' => apply_filters('kirki_styles_action_handle', self::$css_handle), |
|
236 | 236 | ); |
237 | 237 | |
238 | - if ( is_admin() ) { |
|
238 | + if (is_admin()) { |
|
239 | 239 | global $current_screen; |
240 | 240 | |
241 | 241 | /** |
@@ -249,11 +249,11 @@ discard block |
||
249 | 249 | * Example of possibility: |
250 | 250 | * In the future, Ultimate Dashboard Pro's admin page feature might supports Gutenberg. |
251 | 251 | */ |
252 | - if ( is_object( $current_screen ) && property_exists( $current_screen, 'id' ) && 'customize' === $current_screen->id ) { |
|
252 | + if (is_object($current_screen) && property_exists($current_screen, 'id') && 'customize' === $current_screen->id) { |
|
253 | 253 | return; |
254 | 254 | } |
255 | 255 | |
256 | - if ( property_exists( $current_screen, 'is_block_editor' ) && 1 === (int) $current_screen->is_block_editor ) { |
|
256 | + if (property_exists($current_screen, 'is_block_editor') && 1 === (int) $current_screen->is_block_editor) { |
|
257 | 257 | $args['editor'] = '1'; |
258 | 258 | } |
259 | 259 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | // Enqueue the dynamic stylesheet. |
262 | 262 | wp_enqueue_style( |
263 | 263 | self::$css_handle, |
264 | - add_query_arg( $args, home_url() ), |
|
264 | + add_query_arg($args, home_url()), |
|
265 | 265 | array(), |
266 | 266 | '4.0' |
267 | 267 | ); |
@@ -283,12 +283,12 @@ discard block |
||
283 | 283 | */ |
284 | 284 | |
285 | 285 | // phpcs:ignore WordPress.Security.NonceVerification |
286 | - if ( empty( $_GET['action'] ) || apply_filters( 'kirki_styles_action_handle', self::$css_handle ) !== $_GET['action'] ) { |
|
286 | + if (empty($_GET['action']) || apply_filters('kirki_styles_action_handle', self::$css_handle) !== $_GET['action']) { |
|
287 | 287 | return; |
288 | 288 | } |
289 | 289 | |
290 | 290 | // This is a stylesheet. |
291 | - header( 'Content-type: text/css' ); |
|
291 | + header('Content-type: text/css'); |
|
292 | 292 | $this->print_styles(); |
293 | 293 | exit; |
294 | 294 | |
@@ -304,19 +304,19 @@ discard block |
||
304 | 304 | // Go through all configs. |
305 | 305 | $configs = Kirki::$config; |
306 | 306 | |
307 | - foreach ( $configs as $config_id => $args ) { |
|
308 | - if ( defined( 'KIRKI_NO_OUTPUT' ) && true === KIRKI_NO_OUTPUT ) { |
|
307 | + foreach ($configs as $config_id => $args) { |
|
308 | + if (defined('KIRKI_NO_OUTPUT') && true === KIRKI_NO_OUTPUT) { |
|
309 | 309 | continue; |
310 | 310 | } |
311 | 311 | |
312 | - if ( isset( $args['disable_output'] ) && true === $args['disable_output'] ) { |
|
312 | + if (isset($args['disable_output']) && true === $args['disable_output']) { |
|
313 | 313 | continue; |
314 | 314 | } |
315 | 315 | |
316 | - $styles = self::loop_controls( $config_id ); |
|
317 | - $styles = apply_filters( "kirki_{$config_id}_dynamic_css", $styles ); |
|
316 | + $styles = self::loop_controls($config_id); |
|
317 | + $styles = apply_filters("kirki_{$config_id}_dynamic_css", $styles); |
|
318 | 318 | |
319 | - if ( ! empty( $styles ) ) { |
|
319 | + if (!empty($styles)) { |
|
320 | 320 | /** |
321 | 321 | * Note to code reviewers: |
322 | 322 | * |
@@ -330,11 +330,11 @@ discard block |
||
330 | 330 | * it can only be interpreted by the browser as such. |
331 | 331 | * wp_strip_all_tags() excludes the possibility of someone closing the <style> tag and then opening something else. |
332 | 332 | */ |
333 | - echo wp_strip_all_tags( $styles ); // phpcs:ignore WordPress.Security.EscapeOutput |
|
333 | + echo wp_strip_all_tags($styles); // phpcs:ignore WordPress.Security.EscapeOutput |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | |
337 | - do_action( 'kirki_dynamic_css' ); |
|
337 | + do_action('kirki_dynamic_css'); |
|
338 | 338 | |
339 | 339 | } |
340 | 340 | |
@@ -345,87 +345,87 @@ discard block |
||
345 | 345 | * @access public |
346 | 346 | * @param string $config_id The configuration ID. |
347 | 347 | */ |
348 | - public static function loop_controls( $config_id ) { |
|
348 | + public static function loop_controls($config_id) { |
|
349 | 349 | |
350 | 350 | // Get an instance of the Generator class. |
351 | 351 | // This will make sure google fonts and backup fonts are loaded. |
352 | 352 | Generator::get_instance(); |
353 | 353 | |
354 | - $fields = self::get_fields_by_config( $config_id ); |
|
354 | + $fields = self::get_fields_by_config($config_id); |
|
355 | 355 | |
356 | 356 | // Compatibility with v3 API. |
357 | - if ( class_exists( '\Kirki\Compatibility\Kirki' ) ) { |
|
358 | - $fields = array_merge( \Kirki\Compatibility\Kirki::$fields, $fields ); |
|
357 | + if (class_exists('\Kirki\Compatibility\Kirki')) { |
|
358 | + $fields = array_merge(\Kirki\Compatibility\Kirki::$fields, $fields); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | $css = array(); |
362 | 362 | |
363 | 363 | // Early exit if no fields are found. |
364 | - if ( empty( $fields ) ) { |
|
364 | + if (empty($fields)) { |
|
365 | 365 | return; |
366 | 366 | } |
367 | 367 | |
368 | - foreach ( $fields as $field ) { |
|
368 | + foreach ($fields as $field) { |
|
369 | 369 | |
370 | 370 | // Only process fields that belong to $config_id. |
371 | - if ( isset( $field['kirki_config'] ) && $config_id !== $field['kirki_config'] ) { |
|
371 | + if (isset($field['kirki_config']) && $config_id !== $field['kirki_config']) { |
|
372 | 372 | continue; |
373 | 373 | } |
374 | 374 | |
375 | - if ( true === apply_filters( "kirki_{$config_id}_css_skip_hidden", true ) ) { |
|
375 | + if (true === apply_filters("kirki_{$config_id}_css_skip_hidden", true)) { |
|
376 | 376 | |
377 | 377 | // Only continue if field dependencies are met. |
378 | - if ( ( isset( $field['required'] ) && ! empty( $field['required'] ) ) || ( isset( $field['active_callback'] ) && ! empty( $field['active_callback'] ) ) ) { |
|
378 | + if ((isset($field['required']) && !empty($field['required'])) || (isset($field['active_callback']) && !empty($field['active_callback']))) { |
|
379 | 379 | $valid = true; |
380 | 380 | |
381 | 381 | // If $field is using active_callback instead of required. |
382 | - if ( ! isset( $field['required'] ) || empty( $field['required'] ) ) { |
|
383 | - if ( isset( $field['active_callback'] ) && ! empty( $field['active_callback'] ) ) { |
|
382 | + if (!isset($field['required']) || empty($field['required'])) { |
|
383 | + if (isset($field['active_callback']) && !empty($field['active_callback'])) { |
|
384 | 384 | // The "active_callback" or "required" accepts array or callable as the value. |
385 | - if ( is_array( $field['active_callback'] ) || is_callable( $field['active_callback'] ) ) { |
|
385 | + if (is_array($field['active_callback']) || is_callable($field['active_callback'])) { |
|
386 | 386 | $field['required'] = $field['active_callback']; |
387 | 387 | } |
388 | 388 | } |
389 | 389 | } |
390 | 390 | |
391 | 391 | // At this point, we know that the "required" is set and is not empty. |
392 | - if ( is_array( $field['required'] ) ) { |
|
393 | - foreach ( $field['required'] as $requirement ) { |
|
394 | - if ( isset( $requirement['setting'] ) && isset( $requirement['value'] ) && isset( $requirement['operator'] ) && isset( self::$field_option_types[ $requirement['setting'] ] ) ) { |
|
395 | - $controller_value = Values::get_value( $config_id, $requirement['setting'] ); |
|
392 | + if (is_array($field['required'])) { |
|
393 | + foreach ($field['required'] as $requirement) { |
|
394 | + if (isset($requirement['setting']) && isset($requirement['value']) && isset($requirement['operator']) && isset(self::$field_option_types[$requirement['setting']])) { |
|
395 | + $controller_value = Values::get_value($config_id, $requirement['setting']); |
|
396 | 396 | |
397 | - if ( ! Helper::compare_values( $controller_value, $requirement['value'], $requirement['operator'] ) ) { |
|
397 | + if (!Helper::compare_values($controller_value, $requirement['value'], $requirement['operator'])) { |
|
398 | 398 | $valid = false; |
399 | 399 | } |
400 | 400 | } |
401 | 401 | } |
402 | - } elseif ( is_string( $field['required'] ) ) { |
|
402 | + } elseif (is_string($field['required'])) { |
|
403 | 403 | $valid = '__return_true' === $field['required'] ? true : false; |
404 | - } elseif ( is_callable( $field['required'] ) ) { |
|
405 | - $valid = call_user_func( $field['required'] ); |
|
404 | + } elseif (is_callable($field['required'])) { |
|
405 | + $valid = call_user_func($field['required']); |
|
406 | 406 | } |
407 | 407 | |
408 | - if ( ! $valid ) { |
|
408 | + if (!$valid) { |
|
409 | 409 | continue; |
410 | 410 | } |
411 | 411 | } |
412 | 412 | } |
413 | 413 | |
414 | 414 | // Only continue if $field['output'] is set. |
415 | - if ( isset( $field['output'] ) && ! empty( $field['output'] ) ) { |
|
416 | - $css = Helper::array_replace_recursive( $css, Generator::css( $field ) ); |
|
415 | + if (isset($field['output']) && !empty($field['output'])) { |
|
416 | + $css = Helper::array_replace_recursive($css, Generator::css($field)); |
|
417 | 417 | |
418 | 418 | // Add the globals. |
419 | - if ( isset( self::$css_array[ $config_id ] ) && ! empty( self::$css_array[ $config_id ] ) ) { |
|
420 | - Helper::array_replace_recursive( $css, self::$css_array[ $config_id ] ); |
|
419 | + if (isset(self::$css_array[$config_id]) && !empty(self::$css_array[$config_id])) { |
|
420 | + Helper::array_replace_recursive($css, self::$css_array[$config_id]); |
|
421 | 421 | } |
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
425 | - $css = apply_filters( "kirki_{$config_id}_styles", $css ); |
|
425 | + $css = apply_filters("kirki_{$config_id}_styles", $css); |
|
426 | 426 | |
427 | - if ( is_array( $css ) ) { |
|
428 | - return Generator::styles_parse( Generator::add_prefixes( $css ) ); |
|
427 | + if (is_array($css)) { |
|
428 | + return Generator::styles_parse(Generator::add_prefixes($css)); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | } |
@@ -439,16 +439,16 @@ discard block |
||
439 | 439 | * @param string $config_id The config-ID. |
440 | 440 | * @return array |
441 | 441 | */ |
442 | - private static function get_fields_by_config( $config_id ) { |
|
442 | + private static function get_fields_by_config($config_id) { |
|
443 | 443 | |
444 | 444 | $fields = array(); |
445 | 445 | |
446 | - foreach ( self::$fields as $field ) { |
|
446 | + foreach (self::$fields as $field) { |
|
447 | 447 | if ( |
448 | - ( isset( $field['kirki_config'] ) && $config_id === $field['kirki_config'] ) || |
|
448 | + (isset($field['kirki_config']) && $config_id === $field['kirki_config']) || |
|
449 | 449 | ( |
450 | - ( 'global' === $config_id || ! $config_id ) && |
|
451 | - ( ! isset( $field['kirki_config'] ) || 'global' === $field['kirki_config'] || ! $field['kirki_config'] ) |
|
450 | + ('global' === $config_id || !$config_id) && |
|
451 | + (!isset($field['kirki_config']) || 'global' === $field['kirki_config'] || !$field['kirki_config']) |
|
452 | 452 | ) |
453 | 453 | ) { |
454 | 454 | $fields[] = $field; |
@@ -17,32 +17,32 @@ |
||
17 | 17 | */ |
18 | 18 | class FontAwesome extends Select { |
19 | 19 | |
20 | - /** |
|
21 | - * Filter arguments before creating the control. |
|
22 | - * |
|
23 | - * @access public |
|
24 | - * @since 0.1 |
|
25 | - * @param array $args The field arguments. |
|
26 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
27 | - * @return array |
|
28 | - */ |
|
29 | - public function filter_control_args( $args, $wp_customize ) { |
|
30 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
31 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
20 | + /** |
|
21 | + * Filter arguments before creating the control. |
|
22 | + * |
|
23 | + * @access public |
|
24 | + * @since 0.1 |
|
25 | + * @param array $args The field arguments. |
|
26 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
27 | + * @return array |
|
28 | + */ |
|
29 | + public function filter_control_args( $args, $wp_customize ) { |
|
30 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
31 | + $args = parent::filter_control_args( $args, $wp_customize ); |
|
32 | 32 | |
33 | - ob_start(); |
|
34 | - include 'fontawesome.json'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
|
35 | - $font_awesome_json = ob_get_clean(); |
|
33 | + ob_start(); |
|
34 | + include 'fontawesome.json'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
|
35 | + $font_awesome_json = ob_get_clean(); |
|
36 | 36 | |
37 | - $fa_array = (array) json_decode( $font_awesome_json, true ); |
|
38 | - $args['choices'] = []; |
|
39 | - foreach ( $fa_array['icons'] as $icon ) { |
|
40 | - if ( ! isset( $icon['id'] ) || ! isset( $icon['name'] ) ) { |
|
41 | - continue; |
|
42 | - } |
|
43 | - $args['choices'][ $icon['id'] ] = $icon['name']; |
|
44 | - } |
|
45 | - } |
|
46 | - return $args; |
|
47 | - } |
|
37 | + $fa_array = (array) json_decode( $font_awesome_json, true ); |
|
38 | + $args['choices'] = []; |
|
39 | + foreach ( $fa_array['icons'] as $icon ) { |
|
40 | + if ( ! isset( $icon['id'] ) || ! isset( $icon['name'] ) ) { |
|
41 | + continue; |
|
42 | + } |
|
43 | + $args['choices'][ $icon['id'] ] = $icon['name']; |
|
44 | + } |
|
45 | + } |
|
46 | + return $args; |
|
47 | + } |
|
48 | 48 | } |
@@ -26,21 +26,21 @@ |
||
26 | 26 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
27 | 27 | * @return array |
28 | 28 | */ |
29 | - public function filter_control_args( $args, $wp_customize ) { |
|
30 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
31 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
29 | + public function filter_control_args($args, $wp_customize) { |
|
30 | + if ($args['settings'] === $this->args['settings']) { |
|
31 | + $args = parent::filter_control_args($args, $wp_customize); |
|
32 | 32 | |
33 | 33 | ob_start(); |
34 | 34 | include 'fontawesome.json'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
35 | 35 | $font_awesome_json = ob_get_clean(); |
36 | 36 | |
37 | - $fa_array = (array) json_decode( $font_awesome_json, true ); |
|
37 | + $fa_array = (array) json_decode($font_awesome_json, true); |
|
38 | 38 | $args['choices'] = []; |
39 | - foreach ( $fa_array['icons'] as $icon ) { |
|
40 | - if ( ! isset( $icon['id'] ) || ! isset( $icon['name'] ) ) { |
|
39 | + foreach ($fa_array['icons'] as $icon) { |
|
40 | + if (!isset($icon['id']) || !isset($icon['name'])) { |
|
41 | 41 | continue; |
42 | 42 | } |
43 | - $args['choices'][ $icon['id'] ] = $icon['name']; |
|
43 | + $args['choices'][$icon['id']] = $icon['name']; |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | return $args; |
@@ -17,165 +17,165 @@ |
||
17 | 17 | */ |
18 | 18 | class Option { |
19 | 19 | |
20 | - /** |
|
21 | - * Constructor. |
|
22 | - * |
|
23 | - * @access public |
|
24 | - * @since 1.0 |
|
25 | - */ |
|
26 | - public function __construct() { |
|
27 | - add_filter( 'kirki_field_add_setting_args', [ $this, 'add_setting_args' ], 20, 2 ); |
|
28 | - add_filter( 'kirki_field_add_control_args', [ $this, 'add_control_args' ], 20, 2 ); |
|
29 | - add_filter( 'kirki_get_value', [ $this, 'kirki_get_value' ], 10, 4 ); |
|
30 | - } |
|
31 | - |
|
32 | - /** |
|
33 | - * Filters the value for an option. |
|
34 | - * |
|
35 | - * @access public |
|
36 | - * @since 4.0 |
|
37 | - * @param mixed $value The value. |
|
38 | - * @param string $option The field-name. |
|
39 | - * @param mixed $default The default value. |
|
40 | - * @param string $type The option-type (theme_mod, option etc). |
|
41 | - * @return mixed Returns the field value. |
|
42 | - */ |
|
43 | - public function kirki_get_value( $value = '', $option = '', $default = '', $type = 'theme_mod' ) { |
|
44 | - |
|
45 | - if ( 'option' === $type ) { |
|
46 | - |
|
47 | - /** |
|
48 | - * If the option doesn't contain a '[', then it's not a sub-item |
|
49 | - * of another option. Get the option value and return it. |
|
50 | - */ |
|
51 | - if ( false === strpos( $option, '[' ) ) { |
|
52 | - return get_option( $option, $default ); |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * If we got here then this is part of an option array. |
|
57 | - * We need to get the 1st level, and then find the item inside that array. |
|
58 | - */ |
|
59 | - $parts = \explode( '[', $option ); |
|
60 | - $value = get_option( $parts[0], [] ); |
|
61 | - |
|
62 | - // If there's no value, return the default. |
|
63 | - if ( empty( $value ) ) { |
|
64 | - return $default; |
|
65 | - } |
|
66 | - |
|
67 | - foreach ( $parts as $key => $part ) { |
|
68 | - /** |
|
69 | - * Skip the 1st item, it's already been dealt with |
|
70 | - * when we got the value initially right before this loop. |
|
71 | - */ |
|
72 | - if ( 0 === $key ) { |
|
73 | - continue; |
|
74 | - } |
|
75 | - |
|
76 | - $part = str_replace( ']', '', $part ); |
|
77 | - |
|
78 | - /** |
|
79 | - * If the item exists in the value, then change $value to the item. |
|
80 | - * This runs recursively for all parts until we get to the end. |
|
81 | - */ |
|
82 | - if ( is_array( $value ) && isset( $value[ $part ] ) ) { |
|
83 | - $value = $value[ $part ]; |
|
84 | - continue; |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * If we got here, the item was not found in the value. |
|
89 | - * We need to change the value accordingly depending on whether |
|
90 | - * this is the last item in the loop or not. |
|
91 | - */ |
|
92 | - $value = ( isset( $parts[ $key + 1 ] ) ) ? [] : ''; |
|
93 | - } |
|
94 | - } |
|
95 | - |
|
96 | - return $value; |
|
97 | - |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Allow filtering the arguments. |
|
102 | - * |
|
103 | - * @since 0.1 |
|
104 | - * @param array $args The arguments. |
|
105 | - * @param WP_Customize_Manager $customizer The customizer instance. |
|
106 | - * @return array Return the arguments. |
|
107 | - */ |
|
108 | - public function add_setting_args( $args, $customizer ) { |
|
109 | - |
|
110 | - // If this is not an option, early exit. |
|
111 | - if ( ! isset( $args['option_type'] ) || 'option' !== $args['option_type'] ) { |
|
112 | - return $args; |
|
113 | - } |
|
114 | - |
|
115 | - // Set "type" argument to option. |
|
116 | - $args['type'] = 'option'; |
|
117 | - return $this->maybe_change_settings( $args ); |
|
118 | - |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Allow filtering the arguments. |
|
123 | - * |
|
124 | - * @since 0.1 |
|
125 | - * @param array $args The arguments. |
|
126 | - * @param WP_Customize_Manager $customizer The customizer instance. |
|
127 | - * @return array Return the arguments. |
|
128 | - */ |
|
129 | - public function add_control_args( $args, $customizer ) { |
|
130 | - |
|
131 | - // If this is not an option, early exit. |
|
132 | - if ( ! isset( $args['option_type'] ) || 'option' !== $args['option_type'] ) { |
|
133 | - return $args; |
|
134 | - } |
|
135 | - |
|
136 | - return $this->maybe_change_settings( $args ); |
|
137 | - |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * Change the settings argument. |
|
142 | - * |
|
143 | - * @access private |
|
144 | - * @since 1.0 |
|
145 | - * @param array $args The arguments. |
|
146 | - * @return array Returns modified array with tweaks to the [settings] argument if needed. |
|
147 | - */ |
|
148 | - private function maybe_change_settings( $args ) { |
|
149 | - |
|
150 | - // Check if we have an option-name defined. |
|
151 | - if ( isset( $args['option_name'] ) ) { |
|
152 | - if ( empty( $args['option_name'] ) ) { |
|
153 | - return $args; |
|
154 | - } |
|
155 | - |
|
156 | - if ( isset( $args['settings'] ) && $args['settings'] && false !== strpos( $args['settings'], $args['option_name'] . '[' ) ) { |
|
157 | - return $args; |
|
158 | - } |
|
159 | - |
|
160 | - if ( false === strpos( $args['settings'], '[' ) ) { |
|
161 | - // ? Bagus: in line above, it's obvious that '[' is not found in $args['settings']. But why do we explode it using '[' here? |
|
162 | - $parts = explode( '[', $args['settings'] ); |
|
163 | - $final_parts = [ $args['option_name'] ]; |
|
164 | - |
|
165 | - foreach ( $parts as $part ) { |
|
166 | - $final_parts[] = $part; |
|
167 | - } |
|
168 | - |
|
169 | - $args['settings'] = \implode( '][', $final_parts ) . ']'; |
|
170 | - $args['settings'] = str_replace( |
|
171 | - $args['option_name'] . '][', |
|
172 | - $args['option_name'] . '[', |
|
173 | - $args['settings'] |
|
174 | - ); |
|
175 | - } |
|
176 | - } |
|
177 | - |
|
178 | - return $args; |
|
179 | - |
|
180 | - } |
|
20 | + /** |
|
21 | + * Constructor. |
|
22 | + * |
|
23 | + * @access public |
|
24 | + * @since 1.0 |
|
25 | + */ |
|
26 | + public function __construct() { |
|
27 | + add_filter( 'kirki_field_add_setting_args', [ $this, 'add_setting_args' ], 20, 2 ); |
|
28 | + add_filter( 'kirki_field_add_control_args', [ $this, 'add_control_args' ], 20, 2 ); |
|
29 | + add_filter( 'kirki_get_value', [ $this, 'kirki_get_value' ], 10, 4 ); |
|
30 | + } |
|
31 | + |
|
32 | + /** |
|
33 | + * Filters the value for an option. |
|
34 | + * |
|
35 | + * @access public |
|
36 | + * @since 4.0 |
|
37 | + * @param mixed $value The value. |
|
38 | + * @param string $option The field-name. |
|
39 | + * @param mixed $default The default value. |
|
40 | + * @param string $type The option-type (theme_mod, option etc). |
|
41 | + * @return mixed Returns the field value. |
|
42 | + */ |
|
43 | + public function kirki_get_value( $value = '', $option = '', $default = '', $type = 'theme_mod' ) { |
|
44 | + |
|
45 | + if ( 'option' === $type ) { |
|
46 | + |
|
47 | + /** |
|
48 | + * If the option doesn't contain a '[', then it's not a sub-item |
|
49 | + * of another option. Get the option value and return it. |
|
50 | + */ |
|
51 | + if ( false === strpos( $option, '[' ) ) { |
|
52 | + return get_option( $option, $default ); |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * If we got here then this is part of an option array. |
|
57 | + * We need to get the 1st level, and then find the item inside that array. |
|
58 | + */ |
|
59 | + $parts = \explode( '[', $option ); |
|
60 | + $value = get_option( $parts[0], [] ); |
|
61 | + |
|
62 | + // If there's no value, return the default. |
|
63 | + if ( empty( $value ) ) { |
|
64 | + return $default; |
|
65 | + } |
|
66 | + |
|
67 | + foreach ( $parts as $key => $part ) { |
|
68 | + /** |
|
69 | + * Skip the 1st item, it's already been dealt with |
|
70 | + * when we got the value initially right before this loop. |
|
71 | + */ |
|
72 | + if ( 0 === $key ) { |
|
73 | + continue; |
|
74 | + } |
|
75 | + |
|
76 | + $part = str_replace( ']', '', $part ); |
|
77 | + |
|
78 | + /** |
|
79 | + * If the item exists in the value, then change $value to the item. |
|
80 | + * This runs recursively for all parts until we get to the end. |
|
81 | + */ |
|
82 | + if ( is_array( $value ) && isset( $value[ $part ] ) ) { |
|
83 | + $value = $value[ $part ]; |
|
84 | + continue; |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * If we got here, the item was not found in the value. |
|
89 | + * We need to change the value accordingly depending on whether |
|
90 | + * this is the last item in the loop or not. |
|
91 | + */ |
|
92 | + $value = ( isset( $parts[ $key + 1 ] ) ) ? [] : ''; |
|
93 | + } |
|
94 | + } |
|
95 | + |
|
96 | + return $value; |
|
97 | + |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Allow filtering the arguments. |
|
102 | + * |
|
103 | + * @since 0.1 |
|
104 | + * @param array $args The arguments. |
|
105 | + * @param WP_Customize_Manager $customizer The customizer instance. |
|
106 | + * @return array Return the arguments. |
|
107 | + */ |
|
108 | + public function add_setting_args( $args, $customizer ) { |
|
109 | + |
|
110 | + // If this is not an option, early exit. |
|
111 | + if ( ! isset( $args['option_type'] ) || 'option' !== $args['option_type'] ) { |
|
112 | + return $args; |
|
113 | + } |
|
114 | + |
|
115 | + // Set "type" argument to option. |
|
116 | + $args['type'] = 'option'; |
|
117 | + return $this->maybe_change_settings( $args ); |
|
118 | + |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Allow filtering the arguments. |
|
123 | + * |
|
124 | + * @since 0.1 |
|
125 | + * @param array $args The arguments. |
|
126 | + * @param WP_Customize_Manager $customizer The customizer instance. |
|
127 | + * @return array Return the arguments. |
|
128 | + */ |
|
129 | + public function add_control_args( $args, $customizer ) { |
|
130 | + |
|
131 | + // If this is not an option, early exit. |
|
132 | + if ( ! isset( $args['option_type'] ) || 'option' !== $args['option_type'] ) { |
|
133 | + return $args; |
|
134 | + } |
|
135 | + |
|
136 | + return $this->maybe_change_settings( $args ); |
|
137 | + |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * Change the settings argument. |
|
142 | + * |
|
143 | + * @access private |
|
144 | + * @since 1.0 |
|
145 | + * @param array $args The arguments. |
|
146 | + * @return array Returns modified array with tweaks to the [settings] argument if needed. |
|
147 | + */ |
|
148 | + private function maybe_change_settings( $args ) { |
|
149 | + |
|
150 | + // Check if we have an option-name defined. |
|
151 | + if ( isset( $args['option_name'] ) ) { |
|
152 | + if ( empty( $args['option_name'] ) ) { |
|
153 | + return $args; |
|
154 | + } |
|
155 | + |
|
156 | + if ( isset( $args['settings'] ) && $args['settings'] && false !== strpos( $args['settings'], $args['option_name'] . '[' ) ) { |
|
157 | + return $args; |
|
158 | + } |
|
159 | + |
|
160 | + if ( false === strpos( $args['settings'], '[' ) ) { |
|
161 | + // ? Bagus: in line above, it's obvious that '[' is not found in $args['settings']. But why do we explode it using '[' here? |
|
162 | + $parts = explode( '[', $args['settings'] ); |
|
163 | + $final_parts = [ $args['option_name'] ]; |
|
164 | + |
|
165 | + foreach ( $parts as $part ) { |
|
166 | + $final_parts[] = $part; |
|
167 | + } |
|
168 | + |
|
169 | + $args['settings'] = \implode( '][', $final_parts ) . ']'; |
|
170 | + $args['settings'] = str_replace( |
|
171 | + $args['option_name'] . '][', |
|
172 | + $args['option_name'] . '[', |
|
173 | + $args['settings'] |
|
174 | + ); |
|
175 | + } |
|
176 | + } |
|
177 | + |
|
178 | + return $args; |
|
179 | + |
|
180 | + } |
|
181 | 181 | } |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | * @since 1.0 |
25 | 25 | */ |
26 | 26 | public function __construct() { |
27 | - add_filter( 'kirki_field_add_setting_args', [ $this, 'add_setting_args' ], 20, 2 ); |
|
28 | - add_filter( 'kirki_field_add_control_args', [ $this, 'add_control_args' ], 20, 2 ); |
|
29 | - add_filter( 'kirki_get_value', [ $this, 'kirki_get_value' ], 10, 4 ); |
|
27 | + add_filter('kirki_field_add_setting_args', [$this, 'add_setting_args'], 20, 2); |
|
28 | + add_filter('kirki_field_add_control_args', [$this, 'add_control_args'], 20, 2); |
|
29 | + add_filter('kirki_get_value', [$this, 'kirki_get_value'], 10, 4); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -40,47 +40,47 @@ discard block |
||
40 | 40 | * @param string $type The option-type (theme_mod, option etc). |
41 | 41 | * @return mixed Returns the field value. |
42 | 42 | */ |
43 | - public function kirki_get_value( $value = '', $option = '', $default = '', $type = 'theme_mod' ) { |
|
43 | + public function kirki_get_value($value = '', $option = '', $default = '', $type = 'theme_mod') { |
|
44 | 44 | |
45 | - if ( 'option' === $type ) { |
|
45 | + if ('option' === $type) { |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * If the option doesn't contain a '[', then it's not a sub-item |
49 | 49 | * of another option. Get the option value and return it. |
50 | 50 | */ |
51 | - if ( false === strpos( $option, '[' ) ) { |
|
52 | - return get_option( $option, $default ); |
|
51 | + if (false === strpos($option, '[')) { |
|
52 | + return get_option($option, $default); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | 56 | * If we got here then this is part of an option array. |
57 | 57 | * We need to get the 1st level, and then find the item inside that array. |
58 | 58 | */ |
59 | - $parts = \explode( '[', $option ); |
|
60 | - $value = get_option( $parts[0], [] ); |
|
59 | + $parts = \explode('[', $option); |
|
60 | + $value = get_option($parts[0], []); |
|
61 | 61 | |
62 | 62 | // If there's no value, return the default. |
63 | - if ( empty( $value ) ) { |
|
63 | + if (empty($value)) { |
|
64 | 64 | return $default; |
65 | 65 | } |
66 | 66 | |
67 | - foreach ( $parts as $key => $part ) { |
|
67 | + foreach ($parts as $key => $part) { |
|
68 | 68 | /** |
69 | 69 | * Skip the 1st item, it's already been dealt with |
70 | 70 | * when we got the value initially right before this loop. |
71 | 71 | */ |
72 | - if ( 0 === $key ) { |
|
72 | + if (0 === $key) { |
|
73 | 73 | continue; |
74 | 74 | } |
75 | 75 | |
76 | - $part = str_replace( ']', '', $part ); |
|
76 | + $part = str_replace(']', '', $part); |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * If the item exists in the value, then change $value to the item. |
80 | 80 | * This runs recursively for all parts until we get to the end. |
81 | 81 | */ |
82 | - if ( is_array( $value ) && isset( $value[ $part ] ) ) { |
|
83 | - $value = $value[ $part ]; |
|
82 | + if (is_array($value) && isset($value[$part])) { |
|
83 | + $value = $value[$part]; |
|
84 | 84 | continue; |
85 | 85 | } |
86 | 86 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * We need to change the value accordingly depending on whether |
90 | 90 | * this is the last item in the loop or not. |
91 | 91 | */ |
92 | - $value = ( isset( $parts[ $key + 1 ] ) ) ? [] : ''; |
|
92 | + $value = (isset($parts[$key + 1])) ? [] : ''; |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -105,16 +105,16 @@ discard block |
||
105 | 105 | * @param WP_Customize_Manager $customizer The customizer instance. |
106 | 106 | * @return array Return the arguments. |
107 | 107 | */ |
108 | - public function add_setting_args( $args, $customizer ) { |
|
108 | + public function add_setting_args($args, $customizer) { |
|
109 | 109 | |
110 | 110 | // If this is not an option, early exit. |
111 | - if ( ! isset( $args['option_type'] ) || 'option' !== $args['option_type'] ) { |
|
111 | + if (!isset($args['option_type']) || 'option' !== $args['option_type']) { |
|
112 | 112 | return $args; |
113 | 113 | } |
114 | 114 | |
115 | 115 | // Set "type" argument to option. |
116 | 116 | $args['type'] = 'option'; |
117 | - return $this->maybe_change_settings( $args ); |
|
117 | + return $this->maybe_change_settings($args); |
|
118 | 118 | |
119 | 119 | } |
120 | 120 | |
@@ -126,14 +126,14 @@ discard block |
||
126 | 126 | * @param WP_Customize_Manager $customizer The customizer instance. |
127 | 127 | * @return array Return the arguments. |
128 | 128 | */ |
129 | - public function add_control_args( $args, $customizer ) { |
|
129 | + public function add_control_args($args, $customizer) { |
|
130 | 130 | |
131 | 131 | // If this is not an option, early exit. |
132 | - if ( ! isset( $args['option_type'] ) || 'option' !== $args['option_type'] ) { |
|
132 | + if (!isset($args['option_type']) || 'option' !== $args['option_type']) { |
|
133 | 133 | return $args; |
134 | 134 | } |
135 | 135 | |
136 | - return $this->maybe_change_settings( $args ); |
|
136 | + return $this->maybe_change_settings($args); |
|
137 | 137 | |
138 | 138 | } |
139 | 139 | |
@@ -145,28 +145,28 @@ discard block |
||
145 | 145 | * @param array $args The arguments. |
146 | 146 | * @return array Returns modified array with tweaks to the [settings] argument if needed. |
147 | 147 | */ |
148 | - private function maybe_change_settings( $args ) { |
|
148 | + private function maybe_change_settings($args) { |
|
149 | 149 | |
150 | 150 | // Check if we have an option-name defined. |
151 | - if ( isset( $args['option_name'] ) ) { |
|
152 | - if ( empty( $args['option_name'] ) ) { |
|
151 | + if (isset($args['option_name'])) { |
|
152 | + if (empty($args['option_name'])) { |
|
153 | 153 | return $args; |
154 | 154 | } |
155 | 155 | |
156 | - if ( isset( $args['settings'] ) && $args['settings'] && false !== strpos( $args['settings'], $args['option_name'] . '[' ) ) { |
|
156 | + if (isset($args['settings']) && $args['settings'] && false !== strpos($args['settings'], $args['option_name'] . '[')) { |
|
157 | 157 | return $args; |
158 | 158 | } |
159 | 159 | |
160 | - if ( false === strpos( $args['settings'], '[' ) ) { |
|
160 | + if (false === strpos($args['settings'], '[')) { |
|
161 | 161 | // ? Bagus: in line above, it's obvious that '[' is not found in $args['settings']. But why do we explode it using '[' here? |
162 | - $parts = explode( '[', $args['settings'] ); |
|
163 | - $final_parts = [ $args['option_name'] ]; |
|
162 | + $parts = explode('[', $args['settings']); |
|
163 | + $final_parts = [$args['option_name']]; |
|
164 | 164 | |
165 | - foreach ( $parts as $part ) { |
|
165 | + foreach ($parts as $part) { |
|
166 | 166 | $final_parts[] = $part; |
167 | 167 | } |
168 | 168 | |
169 | - $args['settings'] = \implode( '][', $final_parts ) . ']'; |
|
169 | + $args['settings'] = \implode('][', $final_parts) . ']'; |
|
170 | 170 | $args['settings'] = str_replace( |
171 | 171 | $args['option_name'] . '][', |
172 | 172 | $args['option_name'] . '[', |
@@ -17,68 +17,68 @@ |
||
17 | 17 | */ |
18 | 18 | class Editor extends Field { |
19 | 19 | |
20 | - /** |
|
21 | - * The field type. |
|
22 | - * |
|
23 | - * @access public |
|
24 | - * @since 1.0 |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - public $type = 'kirki-editor'; |
|
20 | + /** |
|
21 | + * The field type. |
|
22 | + * |
|
23 | + * @access public |
|
24 | + * @since 1.0 |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + public $type = 'kirki-editor'; |
|
28 | 28 | |
29 | - /** |
|
30 | - * The control class-name. |
|
31 | - * |
|
32 | - * @access protected |
|
33 | - * @since 0.1 |
|
34 | - * @var string |
|
35 | - */ |
|
36 | - protected $control_class = '\Kirki\Control\Editor'; |
|
29 | + /** |
|
30 | + * The control class-name. |
|
31 | + * |
|
32 | + * @access protected |
|
33 | + * @since 0.1 |
|
34 | + * @var string |
|
35 | + */ |
|
36 | + protected $control_class = '\Kirki\Control\Editor'; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Whether we should register the control class for JS-templating or not. |
|
40 | - * |
|
41 | - * @access protected |
|
42 | - * @since 0.1 |
|
43 | - * @var bool |
|
44 | - */ |
|
45 | - protected $control_has_js_template = true; |
|
38 | + /** |
|
39 | + * Whether we should register the control class for JS-templating or not. |
|
40 | + * |
|
41 | + * @access protected |
|
42 | + * @since 0.1 |
|
43 | + * @var bool |
|
44 | + */ |
|
45 | + protected $control_has_js_template = true; |
|
46 | 46 | |
47 | - /** |
|
48 | - * Filter arguments before creating the setting. |
|
49 | - * |
|
50 | - * @access public |
|
51 | - * @since 0.1 |
|
52 | - * @param array $args The field arguments. |
|
53 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
54 | - * @return array |
|
55 | - */ |
|
56 | - public function filter_setting_args( $args, $wp_customize ) { |
|
57 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
58 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
47 | + /** |
|
48 | + * Filter arguments before creating the setting. |
|
49 | + * |
|
50 | + * @access public |
|
51 | + * @since 0.1 |
|
52 | + * @param array $args The field arguments. |
|
53 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
54 | + * @return array |
|
55 | + */ |
|
56 | + public function filter_setting_args( $args, $wp_customize ) { |
|
57 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
58 | + $args = parent::filter_setting_args( $args, $wp_customize ); |
|
59 | 59 | |
60 | - // Set the sanitize-callback if none is defined. |
|
61 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
62 | - $args['sanitize_callback'] = 'wp_kses_post'; |
|
63 | - } |
|
64 | - } |
|
65 | - return $args; |
|
66 | - } |
|
60 | + // Set the sanitize-callback if none is defined. |
|
61 | + if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
62 | + $args['sanitize_callback'] = 'wp_kses_post'; |
|
63 | + } |
|
64 | + } |
|
65 | + return $args; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Filter arguments before creating the control. |
|
70 | - * |
|
71 | - * @access public |
|
72 | - * @since 0.1 |
|
73 | - * @param array $args The field arguments. |
|
74 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
75 | - * @return array |
|
76 | - */ |
|
77 | - public function filter_control_args( $args, $wp_customize ) { |
|
78 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
79 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
80 | - $args['type'] = 'kirki-editor'; |
|
81 | - } |
|
82 | - return $args; |
|
83 | - } |
|
68 | + /** |
|
69 | + * Filter arguments before creating the control. |
|
70 | + * |
|
71 | + * @access public |
|
72 | + * @since 0.1 |
|
73 | + * @param array $args The field arguments. |
|
74 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
75 | + * @return array |
|
76 | + */ |
|
77 | + public function filter_control_args( $args, $wp_customize ) { |
|
78 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
79 | + $args = parent::filter_control_args( $args, $wp_customize ); |
|
80 | + $args['type'] = 'kirki-editor'; |
|
81 | + } |
|
82 | + return $args; |
|
83 | + } |
|
84 | 84 | } |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
54 | 54 | * @return array |
55 | 55 | */ |
56 | - public function filter_setting_args( $args, $wp_customize ) { |
|
57 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
58 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
56 | + public function filter_setting_args($args, $wp_customize) { |
|
57 | + if ($args['settings'] === $this->args['settings']) { |
|
58 | + $args = parent::filter_setting_args($args, $wp_customize); |
|
59 | 59 | |
60 | 60 | // Set the sanitize-callback if none is defined. |
61 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
61 | + if (!isset($args['sanitize_callback']) || !$args['sanitize_callback']) { |
|
62 | 62 | $args['sanitize_callback'] = 'wp_kses_post'; |
63 | 63 | } |
64 | 64 | } |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
75 | 75 | * @return array |
76 | 76 | */ |
77 | - public function filter_control_args( $args, $wp_customize ) { |
|
78 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
79 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
77 | + public function filter_control_args($args, $wp_customize) { |
|
78 | + if ($args['settings'] === $this->args['settings']) { |
|
79 | + $args = parent::filter_control_args($args, $wp_customize); |
|
80 | 80 | $args['type'] = 'kirki-editor'; |
81 | 81 | } |
82 | 82 | return $args; |
@@ -22,86 +22,86 @@ |
||
22 | 22 | */ |
23 | 23 | class Editor extends Base { |
24 | 24 | |
25 | - /** |
|
26 | - * The control type. |
|
27 | - * |
|
28 | - * @access public |
|
29 | - * @since 1.0 |
|
30 | - * @var string |
|
31 | - */ |
|
32 | - public $type = 'kirki-editor'; |
|
25 | + /** |
|
26 | + * The control type. |
|
27 | + * |
|
28 | + * @access public |
|
29 | + * @since 1.0 |
|
30 | + * @var string |
|
31 | + */ |
|
32 | + public $type = 'kirki-editor'; |
|
33 | 33 | |
34 | - /** |
|
35 | - * The version. Used in scripts & styles for cache-busting. |
|
36 | - * |
|
37 | - * @static |
|
38 | - * @access public |
|
39 | - * @since 1.0 |
|
40 | - * @var string |
|
41 | - */ |
|
42 | - public static $control_ver = '1.0'; |
|
34 | + /** |
|
35 | + * The version. Used in scripts & styles for cache-busting. |
|
36 | + * |
|
37 | + * @static |
|
38 | + * @access public |
|
39 | + * @since 1.0 |
|
40 | + * @var string |
|
41 | + */ |
|
42 | + public static $control_ver = '1.0'; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Args to pass to TinyMCE. |
|
46 | - * |
|
47 | - * @access public |
|
48 | - * @since 1.0 |
|
49 | - * @var bool |
|
50 | - */ |
|
51 | - public $choices = []; |
|
44 | + /** |
|
45 | + * Args to pass to TinyMCE. |
|
46 | + * |
|
47 | + * @access public |
|
48 | + * @since 1.0 |
|
49 | + * @var bool |
|
50 | + */ |
|
51 | + public $choices = []; |
|
52 | 52 | |
53 | - /** |
|
54 | - * Enqueue control related scripts/styles. |
|
55 | - * |
|
56 | - * @access public |
|
57 | - * @since 1.0 |
|
58 | - * @return void |
|
59 | - */ |
|
60 | - public function enqueue() { |
|
61 | - parent::enqueue(); |
|
53 | + /** |
|
54 | + * Enqueue control related scripts/styles. |
|
55 | + * |
|
56 | + * @access public |
|
57 | + * @since 1.0 |
|
58 | + * @return void |
|
59 | + */ |
|
60 | + public function enqueue() { |
|
61 | + parent::enqueue(); |
|
62 | 62 | |
63 | - // Enqueue the script. |
|
64 | - wp_enqueue_script( 'kirki-control-editor', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'kirki-control-base' ], self::$control_ver, false ); |
|
63 | + // Enqueue the script. |
|
64 | + wp_enqueue_script( 'kirki-control-editor', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'kirki-control-base' ], self::$control_ver, false ); |
|
65 | 65 | |
66 | - // Enqueue the style. |
|
67 | - wp_enqueue_style( 'kirki-control-editor-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver ); |
|
68 | - } |
|
66 | + // Enqueue the style. |
|
67 | + wp_enqueue_style( 'kirki-control-editor-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver ); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Refresh the parameters passed to the JavaScript via JSON. |
|
72 | - * |
|
73 | - * @access public |
|
74 | - * @since 1.0 |
|
75 | - * @return void |
|
76 | - */ |
|
77 | - public function to_json() { |
|
78 | - parent::to_json(); |
|
79 | - $this->json['choices'] = $this->choices; |
|
80 | - } |
|
70 | + /** |
|
71 | + * Refresh the parameters passed to the JavaScript via JSON. |
|
72 | + * |
|
73 | + * @access public |
|
74 | + * @since 1.0 |
|
75 | + * @return void |
|
76 | + */ |
|
77 | + public function to_json() { |
|
78 | + parent::to_json(); |
|
79 | + $this->json['choices'] = $this->choices; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * An Underscore (JS) template for this control's content (but not its container). |
|
84 | - * |
|
85 | - * Class variables for this control class are available in the `data` JS object; |
|
86 | - * export custom variables by overriding {@see WP_Customize_Control::to_json()}. |
|
87 | - * |
|
88 | - * The actual editor is added from the \Kirki\Field\Editor class. |
|
89 | - * All this template contains is a button that triggers the global editor on/off |
|
90 | - * and a hidden textarea element that is used to mirror save the options. |
|
91 | - * |
|
92 | - * @see WP_Customize_Control::print_template() |
|
93 | - * |
|
94 | - * @access protected |
|
95 | - * @since 1.0 |
|
96 | - * @return void |
|
97 | - */ |
|
98 | - protected function content_template() { |
|
99 | - ?> |
|
82 | + /** |
|
83 | + * An Underscore (JS) template for this control's content (but not its container). |
|
84 | + * |
|
85 | + * Class variables for this control class are available in the `data` JS object; |
|
86 | + * export custom variables by overriding {@see WP_Customize_Control::to_json()}. |
|
87 | + * |
|
88 | + * The actual editor is added from the \Kirki\Field\Editor class. |
|
89 | + * All this template contains is a button that triggers the global editor on/off |
|
90 | + * and a hidden textarea element that is used to mirror save the options. |
|
91 | + * |
|
92 | + * @see WP_Customize_Control::print_template() |
|
93 | + * |
|
94 | + * @access protected |
|
95 | + * @since 1.0 |
|
96 | + * @return void |
|
97 | + */ |
|
98 | + protected function content_template() { |
|
99 | + ?> |
|
100 | 100 | <label> |
101 | 101 | <# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #> |
102 | 102 | <# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #> |
103 | 103 | </label> |
104 | 104 | <textarea id="kirki-editor-{{{ data.id.replace( '[', '' ).replace( ']', '' ) }}}" {{{ data.inputAttrs }}} {{{ data.link }}}>{{ data.value }}</textarea> |
105 | 105 | <?php |
106 | - } |
|
106 | + } |
|
107 | 107 | } |
@@ -61,10 +61,10 @@ |
||
61 | 61 | parent::enqueue(); |
62 | 62 | |
63 | 63 | // Enqueue the script. |
64 | - wp_enqueue_script( 'kirki-control-editor', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'kirki-control-base' ], self::$control_ver, false ); |
|
64 | + wp_enqueue_script('kirki-control-editor', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.js'), ['jquery', 'customize-base', 'kirki-control-base'], self::$control_ver, false); |
|
65 | 65 | |
66 | 66 | // Enqueue the style. |
67 | - wp_enqueue_style( 'kirki-control-editor-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver ); |
|
67 | + wp_enqueue_style('kirki-control-editor-style', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.css'), [], self::$control_ver); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -19,68 +19,68 @@ |
||
19 | 19 | */ |
20 | 20 | class Date extends Field { |
21 | 21 | |
22 | - /** |
|
23 | - * The field type. |
|
24 | - * |
|
25 | - * @access public |
|
26 | - * @since 1.0 |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - public $type = 'kirki-date'; |
|
22 | + /** |
|
23 | + * The field type. |
|
24 | + * |
|
25 | + * @access public |
|
26 | + * @since 1.0 |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + public $type = 'kirki-date'; |
|
30 | 30 | |
31 | - /** |
|
32 | - * The control class-name. |
|
33 | - * |
|
34 | - * @access protected |
|
35 | - * @since 0.1 |
|
36 | - * @var string |
|
37 | - */ |
|
38 | - protected $control_class = '\Kirki\Control\Date'; |
|
31 | + /** |
|
32 | + * The control class-name. |
|
33 | + * |
|
34 | + * @access protected |
|
35 | + * @since 0.1 |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + protected $control_class = '\Kirki\Control\Date'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Whether we should register the control class for JS-templating or not. |
|
42 | - * |
|
43 | - * @access protected |
|
44 | - * @since 0.1 |
|
45 | - * @var bool |
|
46 | - */ |
|
47 | - protected $control_has_js_template = true; |
|
40 | + /** |
|
41 | + * Whether we should register the control class for JS-templating or not. |
|
42 | + * |
|
43 | + * @access protected |
|
44 | + * @since 0.1 |
|
45 | + * @var bool |
|
46 | + */ |
|
47 | + protected $control_has_js_template = true; |
|
48 | 48 | |
49 | - /** |
|
50 | - * Filter arguments before creating the setting. |
|
51 | - * |
|
52 | - * @access public |
|
53 | - * @since 0.1 |
|
54 | - * @param array $args The field arguments. |
|
55 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - public function filter_setting_args( $args, $wp_customize ) { |
|
59 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
60 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
49 | + /** |
|
50 | + * Filter arguments before creating the setting. |
|
51 | + * |
|
52 | + * @access public |
|
53 | + * @since 0.1 |
|
54 | + * @param array $args The field arguments. |
|
55 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + public function filter_setting_args( $args, $wp_customize ) { |
|
59 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
60 | + $args = parent::filter_setting_args( $args, $wp_customize ); |
|
61 | 61 | |
62 | - // Set the sanitize-callback if none is defined. |
|
63 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
64 | - $args['sanitize_callback'] = 'sanitize_text_field'; |
|
65 | - } |
|
66 | - } |
|
67 | - return $args; |
|
68 | - } |
|
62 | + // Set the sanitize-callback if none is defined. |
|
63 | + if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
64 | + $args['sanitize_callback'] = 'sanitize_text_field'; |
|
65 | + } |
|
66 | + } |
|
67 | + return $args; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Filter arguments before creating the control. |
|
72 | - * |
|
73 | - * @access public |
|
74 | - * @since 0.1 |
|
75 | - * @param array $args The field arguments. |
|
76 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
77 | - * @return array |
|
78 | - */ |
|
79 | - public function filter_control_args( $args, $wp_customize ) { |
|
80 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
81 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
82 | - $args['type'] = 'kirki-date'; |
|
83 | - } |
|
84 | - return $args; |
|
85 | - } |
|
70 | + /** |
|
71 | + * Filter arguments before creating the control. |
|
72 | + * |
|
73 | + * @access public |
|
74 | + * @since 0.1 |
|
75 | + * @param array $args The field arguments. |
|
76 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
77 | + * @return array |
|
78 | + */ |
|
79 | + public function filter_control_args( $args, $wp_customize ) { |
|
80 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
81 | + $args = parent::filter_control_args( $args, $wp_customize ); |
|
82 | + $args['type'] = 'kirki-date'; |
|
83 | + } |
|
84 | + return $args; |
|
85 | + } |
|
86 | 86 | } |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
56 | 56 | * @return array |
57 | 57 | */ |
58 | - public function filter_setting_args( $args, $wp_customize ) { |
|
59 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
60 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
58 | + public function filter_setting_args($args, $wp_customize) { |
|
59 | + if ($args['settings'] === $this->args['settings']) { |
|
60 | + $args = parent::filter_setting_args($args, $wp_customize); |
|
61 | 61 | |
62 | 62 | // Set the sanitize-callback if none is defined. |
63 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
63 | + if (!isset($args['sanitize_callback']) || !$args['sanitize_callback']) { |
|
64 | 64 | $args['sanitize_callback'] = 'sanitize_text_field'; |
65 | 65 | } |
66 | 66 | } |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
77 | 77 | * @return array |
78 | 78 | */ |
79 | - public function filter_control_args( $args, $wp_customize ) { |
|
80 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
81 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
79 | + public function filter_control_args($args, $wp_customize) { |
|
80 | + if ($args['settings'] === $this->args['settings']) { |
|
81 | + $args = parent::filter_control_args($args, $wp_customize); |
|
82 | 82 | $args['type'] = 'kirki-date'; |
83 | 83 | } |
84 | 84 | return $args; |
@@ -20,56 +20,56 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class Date extends Base { |
22 | 22 | |
23 | - /** |
|
24 | - * The control type. |
|
25 | - * |
|
26 | - * @access public |
|
27 | - * @since 1.0 |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - public $type = 'kirki-date'; |
|
23 | + /** |
|
24 | + * The control type. |
|
25 | + * |
|
26 | + * @access public |
|
27 | + * @since 1.0 |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + public $type = 'kirki-date'; |
|
31 | 31 | |
32 | - /** |
|
33 | - * The version. Used in scripts & styles for cache-busting. |
|
34 | - * |
|
35 | - * @static |
|
36 | - * @access public |
|
37 | - * @since 1.0 |
|
38 | - * @var string |
|
39 | - */ |
|
40 | - public static $control_ver = '1.0'; |
|
32 | + /** |
|
33 | + * The version. Used in scripts & styles for cache-busting. |
|
34 | + * |
|
35 | + * @static |
|
36 | + * @access public |
|
37 | + * @since 1.0 |
|
38 | + * @var string |
|
39 | + */ |
|
40 | + public static $control_ver = '1.0'; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Enqueue control related scripts/styles. |
|
44 | - * |
|
45 | - * @access public |
|
46 | - * @since 1.0 |
|
47 | - * @return void |
|
48 | - */ |
|
49 | - public function enqueue() { |
|
50 | - parent::enqueue(); |
|
42 | + /** |
|
43 | + * Enqueue control related scripts/styles. |
|
44 | + * |
|
45 | + * @access public |
|
46 | + * @since 1.0 |
|
47 | + * @return void |
|
48 | + */ |
|
49 | + public function enqueue() { |
|
50 | + parent::enqueue(); |
|
51 | 51 | |
52 | - // Enqueue the script. |
|
53 | - wp_enqueue_script( 'kirki-control-date', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'kirki-control-base', 'jquery-ui-datepicker' ], self::$control_ver, false ); |
|
52 | + // Enqueue the script. |
|
53 | + wp_enqueue_script( 'kirki-control-date', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'kirki-control-base', 'jquery-ui-datepicker' ], self::$control_ver, false ); |
|
54 | 54 | |
55 | - // Enqueue the style. |
|
56 | - wp_enqueue_style( 'kirki-control-date-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver ); |
|
57 | - } |
|
55 | + // Enqueue the style. |
|
56 | + wp_enqueue_style( 'kirki-control-date-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver ); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * An Underscore (JS) template for this control's content (but not its container). |
|
61 | - * |
|
62 | - * Class variables for this control class are available in the `data` JS object; |
|
63 | - * export custom variables by overriding {@see WP_Customize_Control::to_json()}. |
|
64 | - * |
|
65 | - * @see WP_Customize_Control::print_template() |
|
66 | - * |
|
67 | - * @access protected |
|
68 | - * @since 1.0 |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - protected function content_template() { |
|
72 | - ?> |
|
59 | + /** |
|
60 | + * An Underscore (JS) template for this control's content (but not its container). |
|
61 | + * |
|
62 | + * Class variables for this control class are available in the `data` JS object; |
|
63 | + * export custom variables by overriding {@see WP_Customize_Control::to_json()}. |
|
64 | + * |
|
65 | + * @see WP_Customize_Control::print_template() |
|
66 | + * |
|
67 | + * @access protected |
|
68 | + * @since 1.0 |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + protected function content_template() { |
|
72 | + ?> |
|
73 | 73 | <label> |
74 | 74 | <# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #> |
75 | 75 | <# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #> |
@@ -78,5 +78,5 @@ discard block |
||
78 | 78 | </div> |
79 | 79 | </label> |
80 | 80 | <?php |
81 | - } |
|
81 | + } |
|
82 | 82 | } |
@@ -50,10 +50,10 @@ |
||
50 | 50 | parent::enqueue(); |
51 | 51 | |
52 | 52 | // Enqueue the script. |
53 | - wp_enqueue_script( 'kirki-control-date', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'kirki-control-base', 'jquery-ui-datepicker' ], self::$control_ver, false ); |
|
53 | + wp_enqueue_script('kirki-control-date', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.js'), ['jquery', 'customize-base', 'kirki-control-base', 'jquery-ui-datepicker'], self::$control_ver, false); |
|
54 | 54 | |
55 | 55 | // Enqueue the style. |
56 | - wp_enqueue_style( 'kirki-control-date-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver ); |
|
56 | + wp_enqueue_style('kirki-control-date-style', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.css'), [], self::$control_ver); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |