1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Changes the styling of the customizer |
4
|
|
|
* based on the settings set using the kirki/config filter. |
5
|
|
|
* For documentation please see |
6
|
|
|
* https://github.com/aristath/kirki/wiki/Styling-the-Customizer |
7
|
|
|
* |
8
|
|
|
* @package Kirki |
9
|
|
|
* @category Modules |
10
|
|
|
* @author Aristeides Stathopoulos |
11
|
|
|
* @copyright Copyright (c) 2017, Aristeides Stathopoulos |
12
|
|
|
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT |
13
|
|
|
* @since 3.0.0 |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
// Exit if accessed directly. |
17
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
18
|
|
|
exit; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Adds styles to the customizer. |
23
|
|
|
*/ |
24
|
|
|
class Kirki_Modules_Customizer_Styling { |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* The object instance. |
28
|
|
|
* |
29
|
|
|
* @static |
30
|
|
|
* @access private |
31
|
|
|
* @since 3.0.0 |
32
|
|
|
* @var object |
33
|
|
|
*/ |
34
|
|
|
private static $instance; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Constructor. |
38
|
|
|
* |
39
|
|
|
* @access protected |
40
|
|
|
*/ |
41
|
|
|
protected function __construct() { |
42
|
|
|
add_action( 'customize_controls_print_styles', array( $this, 'custom_css' ), 99 ); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Gets an instance of this object. |
47
|
|
|
* Prevents duplicate instances which avoid artefacts and improves performance. |
48
|
|
|
* |
49
|
|
|
* @static |
50
|
|
|
* @access public |
51
|
|
|
* @since 3.0.0 |
52
|
|
|
* @return object |
53
|
|
|
*/ |
54
|
|
|
public static function get_instance() { |
55
|
|
|
if ( ! self::$instance ) { |
56
|
|
|
self::$instance = new self(); |
57
|
|
|
} |
58
|
|
|
return self::$instance; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Add custom CSS rules to the head, applying our custom styles. |
63
|
|
|
* |
64
|
|
|
* @access public |
65
|
|
|
*/ |
66
|
|
|
public function custom_css() { |
67
|
|
|
|
68
|
|
|
$css = ''; |
69
|
|
|
|
70
|
|
|
$config = apply_filters( 'kirki/config', array() ); |
71
|
|
|
if ( ! isset( $config['color_accent'] ) && ! isset( $config['color_back'] ) ) { |
72
|
|
|
return; |
73
|
|
|
} |
74
|
|
|
$back = isset( $config['color_back'] ) ? $config['color_back'] : false; |
75
|
|
|
$back_obj = ( $back ) ? ariColor::newColor( $back ) : false; |
76
|
|
|
if ( $back ) { |
77
|
|
|
$text_on_back = ( 60 > $back_obj->lightness ) ? |
78
|
|
|
$back_obj->getNew( 'lightness', $back_obj->lightness + 60 )->toCSS( $back_obj->mode ) : |
79
|
|
|
$back_obj->getNew( 'lightness', $back_obj->lightness - 60 )->toCSS( $back_obj->mode ); |
80
|
|
|
$border_on_back = ( 80 < $back_obj->lightness ) ? |
81
|
|
|
$back_obj->getNew( 'lightness', $back_obj->lightness - 13 )->toCSS( $back_obj->mode ) : |
82
|
|
|
$back_obj->getNew( 'lightness', $back_obj->lightness + 13 )->toCSS( $back_obj->mode ); |
83
|
|
|
$back_on_back = ( 90 < $back_obj->lightness ) ? |
84
|
|
|
$back_obj->getNew( 'lightness', $back_obj->lightness - 6 )->toCSS( $back_obj->mode ) : |
85
|
|
|
$back_obj->getNew( 'lightness', $back_obj->lightness + 11 )->toCSS( $back_obj->mode ); |
86
|
|
|
$hover_on_back = ( 90 < $back_obj->lightness ) ? |
87
|
|
|
$back_obj->getNew( 'lightness', $back_obj->lightness - 3 )->toCSS( $back_obj->mode ) : |
88
|
|
|
$back_obj->getNew( 'lightness', $back_obj->lightness + 3 )->toCSS( $back_obj->mode ); |
89
|
|
|
$arrows_on_back = ( 50 > $back_obj->lightness ) ? |
90
|
|
|
$back_obj->getNew( 'lightness', $back_obj->lightness + 30 )->toCSS( $back_obj->mode ) : |
91
|
|
|
$back_obj->getNew( 'lightness', $back_obj->lightness - 30 )->toCSS( $back_obj->mode ); |
92
|
|
|
$back_disabled_obj = ( 35 < $back_obj->lightness ) ? |
93
|
|
|
$back_obj->getNew( 'lightness', $back_obj->lightness - 30 ) : |
94
|
|
|
$back_obj->getNew( 'lightness', $back_obj->lightness + 30 ); |
95
|
|
|
} |
96
|
|
|
$accent = ( isset( $config['color_accent'] ) ) ? $config['color_accent'] : false; |
97
|
|
|
$accent_obj = ( $accent ) ? ariColor::newColor( $accent ) : false; |
98
|
|
|
if ( $accent ) { |
99
|
|
|
$text_on_accent = ( 60 > $accent_obj->lightness ) ? |
100
|
|
|
$accent_obj->getNew( 'lightness', $accent_obj->lightness + 60 )->toCSS( $accent_obj->mode ) : |
101
|
|
|
$accent_obj->getNew( 'lightness', $accent_obj->lightness - 60 )->toCSS( $accent_obj->mode ); |
102
|
|
|
$border_on_accent = ( 50 < $accent_obj->lightness ) ? |
103
|
|
|
$accent_obj->getNew( 'lightness', $accent_obj->lightness - 4 )->toCSS( $accent_obj->mode ) : |
104
|
|
|
$accent_obj->getNew( 'lightness', $accent_obj->lightness + 4 )->toCSS( $accent_obj->mode ); |
105
|
|
|
$accent_disabled_obj = ( 35 < $accent_obj->lightness ) ? |
106
|
|
|
$accent_obj->getNew( 'lightness', $accent_obj->lightness - 30 ) : |
107
|
|
|
$accent_obj->getNew( 'lightness', $accent_obj->lightness + 30 ); |
108
|
|
|
$accent_disabled = $accent_disabled_obj->toCSS( $accent_disabled_obj->mode ); |
109
|
|
|
$text_on_accent_disabled = ( 60 > $accent_disabled_obj->lightness ) ? |
110
|
|
|
$accent_disabled_obj->getNew( 'lightness', $accent_disabled_obj->lightness + 60 )->toCSS( $accent_disabled_obj->mode ) : |
111
|
|
|
$accent_disabled_obj->getNew( 'lightness', $accent_disabled_obj->lightness - 60 )->toCSS( $accent_disabled_obj->mode ); |
112
|
|
|
$border_on_accent_disabled = ( 50 < $accent_disabled_obj->lightness ) ? |
113
|
|
|
$accent_disabled_obj->getNew( 'lightness', $accent_disabled_obj->lightness - 4 )->toCSS( $accent_disabled_obj->mode ) : |
114
|
|
|
$accent_disabled_obj->getNew( 'lightness', $accent_disabled_obj->lightness + 4 )->toCSS( $accent_disabled_obj->mode ); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
if ( $back ) { |
118
|
|
|
$elements = array( |
119
|
|
|
'.wp-full-overlay-sidebar', |
120
|
|
|
'#customize-controls .customize-info .accordion-section-title', |
121
|
|
|
'#customize-controls .panel-meta.customize-info .accordion-section-title:hover', |
122
|
|
|
'#customize-theme-controls .accordion-section-title', |
123
|
|
|
'.customize-section-title', |
124
|
|
|
'#customize-theme-controls .control-section-themes .accordion-section-title', |
125
|
|
|
'#customize-theme-controls .control-section-themes .accordion-section-title', |
126
|
|
|
'#customize-theme-controls .control-section-themes .accordion-section-title:hover', |
127
|
|
|
); |
128
|
|
|
|
129
|
|
|
$css .= implode( ',', $elements ) . '{'; |
130
|
|
|
$css .= 'background:' . $back . ';'; |
131
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
|
|
|
|
132
|
|
|
$css .= '}'; |
133
|
|
|
|
134
|
|
|
$elements = array( |
135
|
|
|
'#customize-controls .customize-info .panel-title', |
136
|
|
|
'#customize-controls .customize-pane-child .customize-section-title h3', |
137
|
|
|
'#customize-controls .customize-pane-child h3.customize-section-title', |
138
|
|
|
'.customize-control', |
139
|
|
|
'#customize-controls .description', |
140
|
|
|
); |
141
|
|
|
$css .= implode( ',', $elements ) . '{'; |
142
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
143
|
|
|
$css .= '}'; |
144
|
|
|
|
145
|
|
|
$elements = array( |
146
|
|
|
'#customize-controls .customize-info', |
147
|
|
|
'#customize-header-actions', |
148
|
|
|
'.customize-section-title', |
149
|
|
|
); |
150
|
|
|
$css .= implode( ',', $elements ) . '{'; |
151
|
|
|
$css .= 'border-bottom-color: ' . $border_on_back . ';'; |
|
|
|
|
152
|
|
|
$css .= '}'; |
153
|
|
|
|
154
|
|
|
$elements = array( |
155
|
|
|
'.wp-full-overlay-sidebar .wp-full-overlay-header', |
156
|
|
|
'.customize-controls-close', |
157
|
|
|
'.expanded .wp-full-overlay-footer', |
158
|
|
|
); |
159
|
|
|
$css .= implode( ',', $elements ) . '{'; |
160
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
161
|
|
|
$css .= 'background-color:' . $back_on_back . ';'; |
|
|
|
|
162
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
163
|
|
|
$css .= '}'; |
164
|
|
|
|
165
|
|
|
$elements = array( |
166
|
|
|
'.accordion-section', |
167
|
|
|
'#customize-theme-controls .customize-pane-child.accordion-section-content', |
168
|
|
|
); |
169
|
|
|
$css .= implode( ',', $elements ) . '{'; |
170
|
|
|
$css .= 'background:' . $back_on_back . ';'; |
171
|
|
|
$css .= '}'; |
172
|
|
|
|
173
|
|
|
$elements = array( |
174
|
|
|
'#accordion-section-themes+.control-section', |
175
|
|
|
'#customize-theme-controls .control-section:last-of-type.open', |
176
|
|
|
'#customize-theme-controls .control-section:last-of-type > .accordion-section-title', |
177
|
|
|
'#customize-theme-controls .control-section.open', |
178
|
|
|
); |
179
|
|
|
$css .= implode( ',', $elements ) . '{'; |
180
|
|
|
$css .= 'border-bottom-color:' . $border_on_back . ';'; |
181
|
|
|
$css .= 'border-top-color:' . $border_on_back . ';'; |
182
|
|
|
$css .= '}'; |
183
|
|
|
|
184
|
|
|
$elements = array( |
185
|
|
|
'#customize-theme-controls .accordion-section-title', |
186
|
|
|
); |
187
|
|
|
$css .= implode( ',', $elements ) . '{'; |
188
|
|
|
$css .= 'border-bottom-color:' . $border_on_back . ';'; |
189
|
|
|
$css .= 'border-left-color:' . $border_on_back . ';'; |
190
|
|
|
$css .= '}'; |
191
|
|
|
|
192
|
|
|
$elements = array( |
193
|
|
|
'#customize-theme-controls .control-section-themes .accordion-section-title', |
194
|
|
|
'#customize-theme-controls .control-section-themes .accordion-section-title:hover', |
195
|
|
|
); |
196
|
|
|
$css .= implode( ',', $elements ) . '{'; |
197
|
|
|
$css .= 'border-bottom-color:' . $border_on_back . ';'; |
198
|
|
|
$css .= 'border-top-color:' . $border_on_back . ';'; |
199
|
|
|
$css .= 'border-bottom-color:' . $border_on_back . ';'; |
200
|
|
|
$css .= '}'; |
201
|
|
|
|
202
|
|
|
$elements = array( |
203
|
|
|
'#customize-theme-controls .accordion-section-title:after', |
204
|
|
|
); |
205
|
|
|
$css .= implode( ',', $elements ) . '{'; |
206
|
|
|
$css .= 'color:' . $arrows_on_back . ';'; |
|
|
|
|
207
|
|
|
$css .= '}'; |
208
|
|
|
|
209
|
|
|
$elements = array( |
210
|
|
|
'.wp-core-ui .button', |
211
|
|
|
'.wp-core-ui .button-secondary', |
212
|
|
|
); |
213
|
|
|
$css .= implode( ',', $elements ) . '{'; |
214
|
|
|
$css .= 'background-color:' . $back . ';'; |
215
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
216
|
|
|
$css .= 'box-shadow:0 1px 0 ' . $border_on_back . ';'; |
217
|
|
|
$css .= '-webkit-box-shadow:0 1px 0 ' . $border_on_back . ';'; |
218
|
|
|
$css .= 'text-shadow:0 -1px 1px ' . $border_on_back . ', 1px 0 1px ' . $border_on_back . ', 0 1px 1px ' . $border_on_back . ', -1px 0 1px ' . $border_on_back . ';'; |
219
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
220
|
|
|
$css .= '}'; |
221
|
|
|
|
222
|
|
|
$css .= '@media screen and (max-width: 640px) {.customize-controls-preview-toggle{'; |
223
|
|
|
$css .= 'background-color:' . $back . ';'; |
224
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
225
|
|
|
$css .= 'box-shadow:0 1px 0 ' . $border_on_back . ';'; |
226
|
|
|
$css .= '-webkit-box-shadow:0 1px 0 ' . $border_on_back . ';'; |
227
|
|
|
$css .= 'text-shadow:0 -1px 1px ' . $border_on_back . ', 1px 0 1px ' . $border_on_back . ', 0 1px 1px ' . $border_on_back . ', -1px 0 1px ' . $border_on_back . ';'; |
228
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
229
|
|
|
$css .= '}}'; |
230
|
|
|
|
231
|
|
|
$elements = array( |
232
|
|
|
'.wp-core-ui .button.focus', |
233
|
|
|
'.wp-core-ui .button.hover', |
234
|
|
|
'.wp-core-ui .button:focus', |
235
|
|
|
'.wp-core-ui .button:hover', |
236
|
|
|
'.wp-core-ui .button-secondary.focus', |
237
|
|
|
'.wp-core-ui .button-secondary.hover', |
238
|
|
|
'.wp-core-ui .button-secondary:focus', |
239
|
|
|
'.wp-core-ui .button-secondary:hover', |
240
|
|
|
'.customize-panel-back', |
241
|
|
|
'.customize-section-back', |
242
|
|
|
); |
243
|
|
|
$css .= implode( ',', $elements ) . '{'; |
244
|
|
|
$css .= 'background-color:' . $back_on_back . ';'; |
245
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
246
|
|
|
$css .= 'box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
247
|
|
|
$css .= '-webkit-box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
248
|
|
|
$css .= 'text-shadow: 0 -1px 1px ' . $border_on_back . ', 1px 0 1px ' . $border_on_back . ', 0 1px 1px ' . $border_on_back . ', -1px 0 1px ' . $border_on_back . ';'; |
249
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
250
|
|
|
$css .= '}'; |
251
|
|
|
|
252
|
|
|
$css .= '@media screen and (max-width: 640px) {.customize-controls-preview-toggle.focus,.customize-controls-preview-toggle.hover,.customize-controls-preview-toggle:focus,.customize-controls-preview-toggle:hover{'; |
253
|
|
|
$css .= 'background-color:' . $back_on_back . ';'; |
254
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
255
|
|
|
$css .= 'box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
256
|
|
|
$css .= '-webkit-box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
257
|
|
|
$css .= 'text-shadow: 0 -1px 1px ' . $border_on_back . ', 1px 0 1px ' . $border_on_back . ', 0 1px 1px ' . $border_on_back . ', -1px 0 1px ' . $border_on_back . ';'; |
258
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
259
|
|
|
$css .= '}}'; |
260
|
|
|
$elements = array( |
261
|
|
|
'.customize-control-kirki-background .background-attachment .buttonset .switch-label', |
262
|
|
|
'.customize-control-kirki-background .background-size .buttonset .switch-label', |
263
|
|
|
'.customize-control-kirki-radio-buttonset .buttonset .switch-label', |
264
|
|
|
); |
265
|
|
|
$css .= implode( ',', $elements ) . '{'; |
266
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
267
|
|
|
$css .= '}'; |
268
|
|
|
|
269
|
|
|
$elements = array( |
270
|
|
|
'.wp-color-result', |
271
|
|
|
); |
272
|
|
|
$css .= implode( ',', $elements ) . '{'; |
273
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
274
|
|
|
$css .= '-webkit-box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
275
|
|
|
$css .= 'box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
276
|
|
|
$css .= '}'; |
277
|
|
|
|
278
|
|
|
$elements = array( |
279
|
|
|
'.wp-color-result:focus', |
280
|
|
|
'.wp-color-result:hover', |
281
|
|
|
); |
282
|
|
|
$css .= implode( ',', $elements ) . '{'; |
283
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
284
|
|
|
$css .= 'background:' . $back_on_back . ';'; |
285
|
|
|
$css .= '}'; |
286
|
|
|
|
287
|
|
|
$elements = array( |
288
|
|
|
'.wp-color-result:after', |
289
|
|
|
); |
290
|
|
|
$css .= implode( ',', $elements ) . '{'; |
291
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
292
|
|
|
$css .= 'background:' . $back . ';'; |
293
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
294
|
|
|
$css .= '}'; |
295
|
|
|
|
296
|
|
|
$elements = array( |
297
|
|
|
'.wp-color-result:focus:after', |
298
|
|
|
'.wp-color-result:hover:after', |
299
|
|
|
); |
300
|
|
|
$css .= implode( ',', $elements ) . '{'; |
301
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
302
|
|
|
$css .= '}'; |
303
|
|
|
|
304
|
|
|
$elements = array( |
305
|
|
|
'.customize-control input[type=tel]', |
306
|
|
|
'.customize-control input[type=url]', |
307
|
|
|
'.customize-control input[type=text]', |
308
|
|
|
'.customize-control input[type=password]', |
309
|
|
|
'.customize-control input[type=email]', |
310
|
|
|
'.customize-control input[type=number]', |
311
|
|
|
'.customize-control input[type=search]', |
312
|
|
|
'.customize-control input[type=radio]', |
313
|
|
|
'.customize-control input[type=checkbox]', |
314
|
|
|
'.customize-control select', |
315
|
|
|
'.select2-container--default .select2-selection--single', |
316
|
|
|
'.select2-container--default .select2-selection--multiple', |
317
|
|
|
); |
318
|
|
|
$css .= implode( ',', $elements ) . '{'; |
319
|
|
|
$css .= 'background:' . $back . ';'; |
320
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
321
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
322
|
|
|
$css .= '}'; |
323
|
|
|
|
324
|
|
|
$css .= '.customize-control-kirki-slider input[type=range]::-webkit-slider-thumb{background-color:' . $accent . ';}'; |
325
|
|
|
$css .= '.customize-control-kirki-slider input[type=range]::-moz-range-thumb{background-color:' . $accent . ';}'; |
326
|
|
|
$css .= '.customize-control-kirki-slider input[type=range]::-ms-thumb{background-color:' . $accent . ';}'; |
327
|
|
|
|
328
|
|
|
$css .= '.customize-control-kirki-slider input[type=range]{background:' . $border_on_back . ';}'; |
329
|
|
|
|
330
|
|
|
$elements = array( |
331
|
|
|
'.select2-container--default .select2-selection--single .select2-selection__rendered', |
332
|
|
|
); |
333
|
|
|
$css .= implode( ',', $elements ) . '{'; |
334
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
335
|
|
|
$css .= '}'; |
336
|
|
|
|
337
|
|
|
$elements = array( |
338
|
|
|
'.wp-full-overlay-footer .devices', |
339
|
|
|
); |
340
|
|
|
$css .= implode( ',', $elements ) . '{'; |
341
|
|
|
$css .= 'background: none;'; |
342
|
|
|
$css .= 'background: transparent;'; |
343
|
|
|
$css .= 'box-shadow: none;'; |
344
|
|
|
$css .= '-webkit-box-shadow: none;'; |
345
|
|
|
$css .= '}'; |
346
|
|
|
|
347
|
|
|
$css .= '.kirki-reset-section .dashicons{color:' . $back_on_back . ';}'; |
348
|
|
|
|
349
|
|
|
} // End if(). |
350
|
|
|
|
351
|
|
|
if ( $back || $accent ) { |
352
|
|
|
$elements = array( |
353
|
|
|
'#customize-controls .control-section .accordion-section-title:focus', |
354
|
|
|
'#customize-controls .control-section .accordion-section-title:hover', |
355
|
|
|
'#customize-controls .control-section.open .accordion-section-title', |
356
|
|
|
'#customize-controls .control-section:hover > .accordion-section-title', |
357
|
|
|
'.customize-panel-back:focus', |
358
|
|
|
'.customize-panel-back:hover', |
359
|
|
|
'.customize-section-back:focus', |
360
|
|
|
'.customize-section-back:hover', |
361
|
|
|
); |
362
|
|
|
$css .= implode( ',', $elements ) . '{'; |
363
|
|
|
$css .= ( $back ) ? 'background:' . $hover_on_back . ';' : ''; |
|
|
|
|
364
|
|
|
$css .= ( $accent ) ? 'color:' . $accent . ';border-left-color:' . $accent . ';' : ''; |
365
|
|
|
$css .= '}'; |
366
|
|
|
|
367
|
|
|
$css .= '.customize-controls-close:hover{'; |
368
|
|
|
$css .= ( $back ) ? 'background-color:' . $back . ';' : ''; |
369
|
|
|
$css .= ( $accent ) ? 'color:' . $accent . ';border-color:' . $accent . ';' : ''; |
370
|
|
|
$css .= '}'; |
371
|
|
|
|
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
if ( $accent ) { |
375
|
|
|
$elements = array( |
376
|
|
|
'#customize-theme-controls .control-section .accordion-section-title:focus:after', |
377
|
|
|
'#customize-theme-controls .control-section .accordion-section-title:hover:after', |
378
|
|
|
'#customize-theme-controls .control-section.open .accordion-section-title:after', |
379
|
|
|
'#customize-theme-controls .control-section:hover>.accordion-section-title:after', |
380
|
|
|
); |
381
|
|
|
$css .= implode( ',', $elements ) . '{'; |
382
|
|
|
$css .= 'color:' . $accent . ';'; |
383
|
|
|
$css .= '}'; |
384
|
|
|
|
385
|
|
|
$elements = array( |
386
|
|
|
'.wp-core-ui .button.button-primary', |
387
|
|
|
); |
388
|
|
|
$css .= implode( ',', $elements ) . '{'; |
389
|
|
|
$css .= 'background-color:' . $accent . ';'; |
390
|
|
|
$css .= 'border-color:' . $border_on_accent . ';'; |
|
|
|
|
391
|
|
|
$css .= 'box-shadow:0 1px 0 ' . $border_on_accent . ';'; |
392
|
|
|
$css .= '-webkit-box-shadow:0 1px 0 ' . $border_on_accent . ';'; |
393
|
|
|
$css .= 'text-shadow:0 -1px 1px ' . $border_on_accent . ', 1px 0 1px ' . $border_on_accent . ', 0 1px 1px ' . $border_on_accent . ', -1px 0 1px ' . $border_on_accent . ';'; |
394
|
|
|
$css .= 'color:' . $text_on_accent . ';'; |
|
|
|
|
395
|
|
|
$css .= '}'; |
396
|
|
|
|
397
|
|
|
$elements = array( |
398
|
|
|
'.wp-core-ui .button.button-primary.focus', |
399
|
|
|
'.wp-core-ui .button.button-primary.hover', |
400
|
|
|
'.wp-core-ui .button.button-primary:focus', |
401
|
|
|
'.wp-core-ui .button.button-primary:hover', |
402
|
|
|
); |
403
|
|
|
$css .= implode( ',', $elements ) . '{'; |
404
|
|
|
$css .= 'background-color:' . $accent . ';'; |
405
|
|
|
$css .= 'border-color:' . $border_on_accent . ';'; |
406
|
|
|
$css .= 'box-shadow: 0 1px 0 ' . $border_on_accent . ';'; |
407
|
|
|
$css .= '-webkit-box-shadow: 0 1px 0 ' . $border_on_accent . ';'; |
408
|
|
|
$css .= 'text-shadow: 0 -1px 1px ' . $border_on_accent . ', 1px 0 1px ' . $border_on_accent . ', 0 1px 1px ' . $border_on_accent . ', -1px 0 1px ' . $border_on_accent . ';'; |
409
|
|
|
$css .= 'color:' . $text_on_accent . ';'; |
410
|
|
|
$css .= '}'; |
411
|
|
|
|
412
|
|
|
$elements = array( |
413
|
|
|
'.wp-core-ui .button.button-primary-disabled', |
414
|
|
|
'.wp-core-ui .button.button-primary.disabled', |
415
|
|
|
'.wp-core-ui .button.button-primary:disabled', |
416
|
|
|
'.wp-core-ui .button.button-primary[disabled]', |
417
|
|
|
); |
418
|
|
|
$css .= implode( ',', $elements ) . '{'; |
419
|
|
|
$css .= 'background-color:' . $accent_disabled . ' !important;'; |
|
|
|
|
420
|
|
|
$css .= 'border-color: ' . $border_on_accent_disabled . ' !important;'; |
|
|
|
|
421
|
|
|
$css .= 'box-shadow: 0 1px 0 ' . $border_on_accent_disabled . ' !important;'; |
422
|
|
|
$css .= '-webkit-box-shadow: 0 1px 0 ' . $border_on_accent_disabled . ' !important;'; |
423
|
|
|
$css .= 'text-shadow: 0 -1px 1px ' . $border_on_accent_disabled . ', 1px 0 1px ' . $border_on_accent_disabled . ', 0 1px 1px ' . $border_on_accent_disabled . ', -1px 0 1px ' . $border_on_accent_disabled . ' !important;'; |
424
|
|
|
$css .= 'color:' . $text_on_accent_disabled . ' !important;'; |
|
|
|
|
425
|
|
|
$css .= '}'; |
426
|
|
|
|
427
|
|
|
$elements = array( |
428
|
|
|
'input[type=checkbox]:checked:before', |
429
|
|
|
); |
430
|
|
|
if ( $accent ) { |
431
|
|
|
$css .= implode( ',', $elements ) . '{'; |
432
|
|
|
$css .= 'color:' . $accent . ';'; |
433
|
|
|
$css .= '}'; |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
$elements = array( |
437
|
|
|
'.select2-container--default .select2-results__option--highlighted[aria-selected]', |
438
|
|
|
); |
439
|
|
|
$css .= implode( ',', $elements ) . '{'; |
440
|
|
|
$css .= 'background-color:' . $accent . ';'; |
441
|
|
|
$css .= 'color:' . $text_on_accent . ';'; |
442
|
|
|
$css .= '}'; |
443
|
|
|
|
444
|
|
|
$elements = array( |
445
|
|
|
'.customize-control-kirki-radio-buttonset .buttonset .switch-input:checked + .switch-label', |
446
|
|
|
'.customize-control-kirki-background .background-attachment .buttonset .switch-input:checked + .switch-label', |
447
|
|
|
'.customize-control-kirki-background .background-size .buttonset .switch-input:checked + .switch-label', |
448
|
|
|
); |
449
|
|
|
$css .= implode( ',', $elements ) . '{'; |
450
|
|
|
$css .= 'background-color:' . $accent . ';'; |
451
|
|
|
$css .= 'border-color:' . $border_on_accent . ';'; |
452
|
|
|
$css .= 'color:' . $text_on_accent . ';'; |
453
|
|
|
$css .= '}'; |
454
|
|
|
} // End if(). |
455
|
|
|
|
456
|
|
|
if ( isset( $config['width'] ) ) { |
457
|
|
|
if ( false === strpos( $config['width'], 'calc' ) ) { |
458
|
|
|
$width = esc_attr( $config['width'] ); |
459
|
|
|
$css .= '.wp-full-overlay-sidebar{width:' . $width . ';}'; |
460
|
|
|
$css .= '.expanded .wp-full-overlay-footer{width:' . $width . '}'; |
461
|
|
|
$css .= '.wp-full-overlay.expanded{margin-left:' . $width . ';}'; |
462
|
|
|
$css .= '.wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-left: -' . $width . ';}'; |
463
|
|
|
} |
464
|
|
|
} |
465
|
|
|
|
466
|
|
|
echo '<style>' . $css . '</style>'; // WPCS: XSS ok. |
467
|
|
|
} |
468
|
|
|
} |
469
|
|
|
|
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: