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
|
|
|
$back_disabled = $back_disabled_obj->toCSS( $back_disabled_obj->mode ); |
96
|
|
|
$text_on_back_disabled = ( 60 > $back_disabled_obj->lightness ) ? |
97
|
|
|
$back_disabled_obj->getNew( 'lightness', $back_disabled_obj->lightness + 60 )->toCSS( $back_disabled_obj->mode ) : |
98
|
|
|
$back_disabled_obj->getNew( 'lightness', $back_disabled_obj->lightness - 60 )->toCSS( $back_disabled_obj->mode ); |
99
|
|
|
$border_on_back_disabled = ( 50 < $back_disabled_obj->lightness ) ? |
100
|
|
|
$back_disabled_obj->getNew( 'lightness', $back_disabled_obj->lightness - 4 )->toCSS( $back_disabled_obj->mode ) : |
101
|
|
|
$back_disabled_obj->getNew( 'lightness', $back_disabled_obj->lightness + 4 )->toCSS( $back_disabled_obj->mode ); |
102
|
|
|
} |
103
|
|
|
$accent = ( isset( $config['color_accent'] ) ) ? $config['color_accent'] : false; |
104
|
|
|
$accent_obj = ( $accent ) ? ariColor::newColor( $accent ) : false; |
105
|
|
|
if ( $accent ) { |
106
|
|
|
$text_on_accent = ( 60 > $accent_obj->lightness ) ? |
107
|
|
|
$accent_obj->getNew( 'lightness', $accent_obj->lightness + 60 )->toCSS( $accent_obj->mode ) : |
108
|
|
|
$accent_obj->getNew( 'lightness', $accent_obj->lightness - 60 )->toCSS( $accent_obj->mode ); |
109
|
|
|
$border_on_accent = ( 50 < $accent_obj->lightness ) ? |
110
|
|
|
$accent_obj->getNew( 'lightness', $accent_obj->lightness - 4 )->toCSS( $accent_obj->mode ) : |
111
|
|
|
$accent_obj->getNew( 'lightness', $accent_obj->lightness + 4 )->toCSS( $accent_obj->mode ); |
112
|
|
|
$accent_disabled_obj = ( 35 < $accent_obj->lightness ) ? |
113
|
|
|
$accent_obj->getNew( 'lightness', $accent_obj->lightness - 30 ) : |
114
|
|
|
$accent_obj->getNew( 'lightness', $accent_obj->lightness + 30 ); |
115
|
|
|
$accent_disabled = $accent_disabled_obj->toCSS( $accent_disabled_obj->mode ); |
116
|
|
|
$text_on_accent_disabled = ( 60 > $accent_disabled_obj->lightness ) ? |
117
|
|
|
$accent_disabled_obj->getNew( 'lightness', $accent_disabled_obj->lightness + 60 )->toCSS( $accent_disabled_obj->mode ) : |
118
|
|
|
$accent_disabled_obj->getNew( 'lightness', $accent_disabled_obj->lightness - 60 )->toCSS( $accent_disabled_obj->mode ); |
119
|
|
|
$border_on_accent_disabled = ( 50 < $accent_disabled_obj->lightness ) ? |
120
|
|
|
$accent_disabled_obj->getNew( 'lightness', $accent_disabled_obj->lightness - 4 )->toCSS( $accent_disabled_obj->mode ) : |
121
|
|
|
$accent_disabled_obj->getNew( 'lightness', $accent_disabled_obj->lightness + 4 )->toCSS( $accent_disabled_obj->mode ); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
if ( $back ) { |
125
|
|
|
$elements = array( |
126
|
|
|
'.wp-full-overlay-sidebar', |
127
|
|
|
'#customize-controls .customize-info .accordion-section-title', |
128
|
|
|
'#customize-controls .panel-meta.customize-info .accordion-section-title:hover', |
129
|
|
|
'#customize-theme-controls .accordion-section-title', |
130
|
|
|
'.customize-section-title', |
131
|
|
|
'#customize-theme-controls .control-section-themes .accordion-section-title', |
132
|
|
|
'#customize-theme-controls .control-section-themes .accordion-section-title', |
133
|
|
|
'#customize-theme-controls .control-section-themes .accordion-section-title:hover', |
134
|
|
|
); |
135
|
|
|
|
136
|
|
|
$css .= implode( ',', $elements ) . '{'; |
137
|
|
|
$css .= 'background:' . $back . ';'; |
138
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
|
|
|
|
139
|
|
|
$css .= '}'; |
140
|
|
|
|
141
|
|
|
$elements = array( |
142
|
|
|
'#customize-controls .customize-info .panel-title', |
143
|
|
|
'#customize-controls .customize-pane-child .customize-section-title h3', |
144
|
|
|
'#customize-controls .customize-pane-child h3.customize-section-title', |
145
|
|
|
'.customize-control', |
146
|
|
|
'#customize-controls .description', |
147
|
|
|
); |
148
|
|
|
$css .= implode( ',', $elements ) . '{'; |
149
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
150
|
|
|
$css .= '}'; |
151
|
|
|
|
152
|
|
|
$elements = array( |
153
|
|
|
'#customize-controls .customize-info', |
154
|
|
|
'#customize-header-actions', |
155
|
|
|
'.customize-section-title', |
156
|
|
|
); |
157
|
|
|
$css .= implode( ',', $elements ) . '{'; |
158
|
|
|
$css .= 'border-bottom-color: ' . $border_on_back . ';'; |
|
|
|
|
159
|
|
|
$css .= '}'; |
160
|
|
|
|
161
|
|
|
$elements = array( |
162
|
|
|
'.wp-full-overlay-sidebar .wp-full-overlay-header', |
163
|
|
|
'.customize-controls-close', |
164
|
|
|
'.expanded .wp-full-overlay-footer', |
165
|
|
|
); |
166
|
|
|
$css .= implode( ',', $elements ) . '{'; |
167
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
168
|
|
|
$css .= 'background-color:' . $back_on_back . ';'; |
|
|
|
|
169
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
170
|
|
|
$css .= '}'; |
171
|
|
|
|
172
|
|
|
$elements = array( |
173
|
|
|
'.accordion-section', |
174
|
|
|
'#customize-theme-controls .customize-pane-child.accordion-section-content', |
175
|
|
|
); |
176
|
|
|
$css .= implode( ',', $elements ) . '{'; |
177
|
|
|
$css .= 'background:' . $back_on_back . ';'; |
178
|
|
|
$css .= '}'; |
179
|
|
|
|
180
|
|
|
$elements = array( |
181
|
|
|
'#accordion-section-themes+.control-section', |
182
|
|
|
'#customize-theme-controls .control-section:last-of-type.open', |
183
|
|
|
'#customize-theme-controls .control-section:last-of-type > .accordion-section-title', |
184
|
|
|
'#customize-theme-controls .control-section.open', |
185
|
|
|
); |
186
|
|
|
$css .= implode( ',', $elements ) . '{'; |
187
|
|
|
$css .= 'border-bottom-color:' . $border_on_back . ';'; |
188
|
|
|
$css .= 'border-top-color:' . $border_on_back . ';'; |
189
|
|
|
$css .= '}'; |
190
|
|
|
|
191
|
|
|
$elements = array( |
192
|
|
|
'#customize-theme-controls .accordion-section-title', |
193
|
|
|
); |
194
|
|
|
$css .= implode( ',', $elements ) . '{'; |
195
|
|
|
$css .= 'border-bottom-color:' . $border_on_back . ';'; |
196
|
|
|
$css .= 'border-left-color:' . $border_on_back . ';'; |
197
|
|
|
$css .= '}'; |
198
|
|
|
|
199
|
|
|
$elements = array( |
200
|
|
|
'#customize-theme-controls .control-section-themes .accordion-section-title', |
201
|
|
|
'#customize-theme-controls .control-section-themes .accordion-section-title:hover', |
202
|
|
|
); |
203
|
|
|
$css .= implode( ',', $elements ) . '{'; |
204
|
|
|
$css .= 'border-bottom-color:' . $border_on_back . ';'; |
205
|
|
|
$css .= 'border-top-color:' . $border_on_back . ';'; |
206
|
|
|
$css .= 'border-bottom-color:' . $border_on_back . ';'; |
207
|
|
|
$css .= '}'; |
208
|
|
|
|
209
|
|
|
$elements = array( |
210
|
|
|
'#customize-theme-controls .accordion-section-title:after', |
211
|
|
|
); |
212
|
|
|
$css .= implode( ',', $elements ) . '{'; |
213
|
|
|
$css .= 'color:' . $arrows_on_back . ';'; |
|
|
|
|
214
|
|
|
$css .= '}'; |
215
|
|
|
|
216
|
|
|
$elements = array( |
217
|
|
|
'.wp-core-ui .button', |
218
|
|
|
'.wp-core-ui .button-secondary', |
219
|
|
|
); |
220
|
|
|
$css .= implode( ',', $elements ) . '{'; |
221
|
|
|
$css .= 'background-color:' . $back . ';'; |
222
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
223
|
|
|
$css .= 'box-shadow:0 1px 0 ' . $border_on_back . ';'; |
224
|
|
|
$css .= '-webkit-box-shadow:0 1px 0 ' . $border_on_back . ';'; |
225
|
|
|
$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 . ';'; |
226
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
227
|
|
|
$css .= '}'; |
228
|
|
|
|
229
|
|
|
$css .= '@media screen and (max-width: 640px) {.customize-controls-preview-toggle{'; |
230
|
|
|
$css .= 'background-color:' . $back . ';'; |
231
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
232
|
|
|
$css .= 'box-shadow:0 1px 0 ' . $border_on_back . ';'; |
233
|
|
|
$css .= '-webkit-box-shadow:0 1px 0 ' . $border_on_back . ';'; |
234
|
|
|
$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 . ';'; |
235
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
236
|
|
|
$css .= '}}'; |
237
|
|
|
|
238
|
|
|
$elements = array( |
239
|
|
|
'.wp-core-ui .button.focus', |
240
|
|
|
'.wp-core-ui .button.hover', |
241
|
|
|
'.wp-core-ui .button:focus', |
242
|
|
|
'.wp-core-ui .button:hover', |
243
|
|
|
'.wp-core-ui .button-secondary.focus', |
244
|
|
|
'.wp-core-ui .button-secondary.hover', |
245
|
|
|
'.wp-core-ui .button-secondary:focus', |
246
|
|
|
'.wp-core-ui .button-secondary:hover', |
247
|
|
|
'.customize-panel-back', |
248
|
|
|
'.customize-section-back', |
249
|
|
|
); |
250
|
|
|
$css .= implode( ',', $elements ) . '{'; |
251
|
|
|
$css .= 'background-color:' . $back_on_back . ';'; |
252
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
253
|
|
|
$css .= 'box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
254
|
|
|
$css .= '-webkit-box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
255
|
|
|
$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 . ';'; |
256
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
257
|
|
|
$css .= '}'; |
258
|
|
|
|
259
|
|
|
$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{'; |
260
|
|
|
$css .= 'background-color:' . $back_on_back . ';'; |
261
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
262
|
|
|
$css .= 'box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
263
|
|
|
$css .= '-webkit-box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
264
|
|
|
$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 . ';'; |
265
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
266
|
|
|
$css .= '}}'; |
267
|
|
|
$elements = array( |
268
|
|
|
'.customize-control-kirki-background .background-attachment .buttonset .switch-label', |
269
|
|
|
'.customize-control-kirki-background .background-size .buttonset .switch-label', |
270
|
|
|
'.customize-control-kirki-radio-buttonset .buttonset .switch-label', |
271
|
|
|
); |
272
|
|
|
$css .= implode( ',', $elements ) . '{'; |
273
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
274
|
|
|
$css .= '}'; |
275
|
|
|
|
276
|
|
|
$elements = array( |
277
|
|
|
'.wp-color-result', |
278
|
|
|
); |
279
|
|
|
$css .= implode( ',', $elements ) . '{'; |
280
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
281
|
|
|
$css .= '-webkit-box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
282
|
|
|
$css .= 'box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
283
|
|
|
$css .= '}'; |
284
|
|
|
|
285
|
|
|
$elements = array( |
286
|
|
|
'.wp-color-result:focus', |
287
|
|
|
'.wp-color-result:hover', |
288
|
|
|
); |
289
|
|
|
$css .= implode( ',', $elements ) . '{'; |
290
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
291
|
|
|
$css .= 'background:' . $back_on_back . ';'; |
292
|
|
|
$css .= '}'; |
293
|
|
|
|
294
|
|
|
$elements = array( |
295
|
|
|
'.wp-color-result:after', |
296
|
|
|
); |
297
|
|
|
$css .= implode( ',', $elements ) . '{'; |
298
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
299
|
|
|
$css .= 'background:' . $back . ';'; |
300
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
301
|
|
|
$css .= '}'; |
302
|
|
|
|
303
|
|
|
$elements = array( |
304
|
|
|
'.wp-color-result:focus:after', |
305
|
|
|
'.wp-color-result:hover:after', |
306
|
|
|
); |
307
|
|
|
$css .= implode( ',', $elements ) . '{'; |
308
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
309
|
|
|
$css .= '}'; |
310
|
|
|
|
311
|
|
|
$elements = array( |
312
|
|
|
'.customize-control input[type=tel]', |
313
|
|
|
'.customize-control input[type=url]', |
314
|
|
|
'.customize-control input[type=text]', |
315
|
|
|
'.customize-control input[type=password]', |
316
|
|
|
'.customize-control input[type=email]', |
317
|
|
|
'.customize-control input[type=number]', |
318
|
|
|
'.customize-control input[type=search]', |
319
|
|
|
'.customize-control input[type=radio]', |
320
|
|
|
'.customize-control input[type=checkbox]', |
321
|
|
|
'.customize-control select', |
322
|
|
|
'.select2-container--default .select2-selection--single', |
323
|
|
|
'.select2-container--default .select2-selection--multiple', |
324
|
|
|
); |
325
|
|
|
$css .= implode( ',', $elements ) . '{'; |
326
|
|
|
$css .= 'background:' . $back . ';'; |
327
|
|
|
$css .= 'border-color:' . $border_on_back . ';'; |
328
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
329
|
|
|
$css .= '}'; |
330
|
|
|
|
331
|
|
|
$css .= '.customize-control-kirki-slider input[type=range]::-webkit-slider-thumb{background-color:' . $accent . ';}'; |
332
|
|
|
$css .= '.customize-control-kirki-slider input[type=range]::-moz-range-thumb{background-color:' . $accent . ';}'; |
333
|
|
|
$css .= '.customize-control-kirki-slider input[type=range]::-ms-thumb{background-color:' . $accent . ';}'; |
334
|
|
|
|
335
|
|
|
$css .= '.customize-control-kirki-slider input[type=range]{background:' . $border_on_back . ';}'; |
336
|
|
|
|
337
|
|
|
$elements = array( |
338
|
|
|
'.select2-container--default .select2-selection--single .select2-selection__rendered', |
339
|
|
|
); |
340
|
|
|
$css .= implode( ',', $elements ) . '{'; |
341
|
|
|
$css .= 'color:' . $text_on_back . ';'; |
342
|
|
|
$css .= '}'; |
343
|
|
|
|
344
|
|
|
$elements = array( |
345
|
|
|
'.wp-full-overlay-footer .devices', |
346
|
|
|
); |
347
|
|
|
$css .= implode( ',', $elements ) . '{'; |
348
|
|
|
$css .= 'background: none;'; |
349
|
|
|
$css .= 'background: transparent;'; |
350
|
|
|
$css .= 'box-shadow: none;'; |
351
|
|
|
$css .= '-webkit-box-shadow: none;'; |
352
|
|
|
$css .= '}'; |
353
|
|
|
|
354
|
|
|
$css .= '.kirki-reset-section .dashicons{color:' . $back_on_back . ';}'; |
355
|
|
|
|
356
|
|
|
} // End if(). |
357
|
|
|
|
358
|
|
|
if ( $back || $accent ) { |
359
|
|
|
$elements = array( |
360
|
|
|
'#customize-controls .control-section .accordion-section-title:focus', |
361
|
|
|
'#customize-controls .control-section .accordion-section-title:hover', |
362
|
|
|
'#customize-controls .control-section.open .accordion-section-title', |
363
|
|
|
'#customize-controls .control-section:hover > .accordion-section-title', |
364
|
|
|
'.customize-panel-back:focus', |
365
|
|
|
'.customize-panel-back:hover', |
366
|
|
|
'.customize-section-back:focus', |
367
|
|
|
'.customize-section-back:hover', |
368
|
|
|
); |
369
|
|
|
$css .= implode( ',', $elements ) . '{'; |
370
|
|
|
$css .= ( $back ) ? 'background:' . $hover_on_back . ';' : ''; |
|
|
|
|
371
|
|
|
$css .= ( $accent ) ? 'color:' . $accent . ';border-left-color:' . $accent . ';' : ''; |
372
|
|
|
$css .= '}'; |
373
|
|
|
|
374
|
|
|
$css .= '.customize-controls-close:hover{'; |
375
|
|
|
$css .= ( $back ) ? 'background-color:' . $back . ';' : ''; |
376
|
|
|
$css .= ( $accent ) ? 'color:' . $accent . ';border-color:' . $accent . ';' : ''; |
377
|
|
|
$css .= '}'; |
378
|
|
|
|
379
|
|
|
} |
380
|
|
|
|
381
|
|
|
if ( $accent ) { |
382
|
|
|
$elements = array( |
383
|
|
|
'#customize-theme-controls .control-section .accordion-section-title:focus:after', |
384
|
|
|
'#customize-theme-controls .control-section .accordion-section-title:hover:after', |
385
|
|
|
'#customize-theme-controls .control-section.open .accordion-section-title:after', |
386
|
|
|
'#customize-theme-controls .control-section:hover>.accordion-section-title:after', |
387
|
|
|
); |
388
|
|
|
$css .= implode( ',', $elements ) . '{'; |
389
|
|
|
$css .= 'color:' . $accent . ';'; |
390
|
|
|
$css .= '}'; |
391
|
|
|
|
392
|
|
|
$elements = array( |
393
|
|
|
'.wp-core-ui .button.button-primary', |
394
|
|
|
); |
395
|
|
|
$css .= implode( ',', $elements ) . '{'; |
396
|
|
|
$css .= 'background-color:' . $accent . ';'; |
397
|
|
|
$css .= 'border-color:' . $border_on_accent . ';'; |
|
|
|
|
398
|
|
|
$css .= 'box-shadow:0 1px 0 ' . $border_on_accent . ';'; |
399
|
|
|
$css .= '-webkit-box-shadow:0 1px 0 ' . $border_on_accent . ';'; |
400
|
|
|
$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 . ';'; |
401
|
|
|
$css .= 'color:' . $text_on_accent . ';'; |
|
|
|
|
402
|
|
|
$css .= '}'; |
403
|
|
|
|
404
|
|
|
$elements = array( |
405
|
|
|
'.wp-core-ui .button.button-primary.focus', |
406
|
|
|
'.wp-core-ui .button.button-primary.hover', |
407
|
|
|
'.wp-core-ui .button.button-primary:focus', |
408
|
|
|
'.wp-core-ui .button.button-primary:hover', |
409
|
|
|
); |
410
|
|
|
$css .= implode( ',', $elements ) . '{'; |
411
|
|
|
$css .= 'background-color:' . $accent . ';'; |
412
|
|
|
$css .= 'border-color:' . $border_on_accent . ';'; |
413
|
|
|
$css .= 'box-shadow: 0 1px 0 ' . $border_on_accent . ';'; |
414
|
|
|
$css .= '-webkit-box-shadow: 0 1px 0 ' . $border_on_accent . ';'; |
415
|
|
|
$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 . ';'; |
416
|
|
|
$css .= 'color:' . $text_on_accent . ';'; |
417
|
|
|
$css .= '}'; |
418
|
|
|
|
419
|
|
|
$elements = array( |
420
|
|
|
'.wp-core-ui .button.button-primary-disabled', |
421
|
|
|
'.wp-core-ui .button.button-primary.disabled', |
422
|
|
|
'.wp-core-ui .button.button-primary:disabled', |
423
|
|
|
'.wp-core-ui .button.button-primary[disabled]', |
424
|
|
|
); |
425
|
|
|
$css .= implode( ',', $elements ) . '{'; |
426
|
|
|
$css .= 'background-color:' . $accent_disabled . ' !important;'; |
|
|
|
|
427
|
|
|
$css .= 'border-color: ' . $border_on_accent_disabled . ' !important;'; |
|
|
|
|
428
|
|
|
$css .= 'box-shadow: 0 1px 0 ' . $border_on_accent_disabled . ' !important;'; |
429
|
|
|
$css .= '-webkit-box-shadow: 0 1px 0 ' . $border_on_accent_disabled . ' !important;'; |
430
|
|
|
$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;'; |
431
|
|
|
$css .= 'color:' . $text_on_accent_disabled . ' !important;'; |
|
|
|
|
432
|
|
|
$css .= '}'; |
433
|
|
|
|
434
|
|
|
$elements = array( |
435
|
|
|
'input[type=checkbox]:checked:before', |
436
|
|
|
); |
437
|
|
|
if ( $accent ) { |
438
|
|
|
$css .= implode( ',', $elements ) . '{'; |
439
|
|
|
$css .= 'color:' . $accent . ';'; |
440
|
|
|
$css .= '}'; |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
$elements = array( |
444
|
|
|
'.select2-container--default .select2-results__option--highlighted[aria-selected]', |
445
|
|
|
); |
446
|
|
|
$css .= implode( ',', $elements ) . '{'; |
447
|
|
|
$css .= 'background-color:' . $accent . ';'; |
448
|
|
|
$css .= 'color:' . $text_on_accent . ';'; |
449
|
|
|
$css .= '}'; |
450
|
|
|
|
451
|
|
|
$elements = array( |
452
|
|
|
'.customize-control-kirki-radio-buttonset .buttonset .switch-input:checked + .switch-label', |
453
|
|
|
'.customize-control-kirki-background .background-attachment .buttonset .switch-input:checked + .switch-label', |
454
|
|
|
'.customize-control-kirki-background .background-size .buttonset .switch-input:checked + .switch-label', |
455
|
|
|
); |
456
|
|
|
$css .= implode( ',', $elements ) . '{'; |
457
|
|
|
$css .= 'background-color:' . $accent . ';'; |
458
|
|
|
$css .= 'border-color:' . $border_on_accent . ';'; |
459
|
|
|
$css .= 'color:' . $text_on_accent . ';'; |
460
|
|
|
$css .= '}'; |
461
|
|
|
} // End if(). |
462
|
|
|
|
463
|
|
|
if ( isset( $config['width'] ) ) { |
464
|
|
|
if ( false === strpos( $config['width'], 'calc' ) ) { |
465
|
|
|
$width = esc_attr( $config['width'] ); |
466
|
|
|
$css .= '.wp-full-overlay-sidebar{width:' . $width . ';}'; |
467
|
|
|
$css .= '.expanded .wp-full-overlay-footer{width:' . $width . '}'; |
468
|
|
|
$css .= '.wp-full-overlay.expanded{margin-left:' . $width . ';}'; |
469
|
|
|
$css .= '.wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-left: -' . $width . ';}'; |
470
|
|
|
} |
471
|
|
|
} |
472
|
|
|
|
473
|
|
|
echo '<style>' . $css . '</style>'; // WPCS: XSS ok. |
474
|
|
|
} |
475
|
|
|
} |
476
|
|
|
|
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: