1
|
|
|
<?php |
2
|
|
|
if ( ! defined( 'ABSPATH' ) ) return; // Exit if accessed directly |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Transform SCSS to CSS |
6
|
|
|
*/ |
7
|
|
|
function lsx_customizer_colour__scss_to_css( $scss ) { |
8
|
|
|
$css = ''; |
9
|
|
|
$scssphp_file = get_template_directory() .'/vendor/leafo/scssphp/scss.inc.php'; |
10
|
|
|
|
11
|
|
|
if ( ! empty( $scss ) && file_exists( $scssphp_file ) ) { |
12
|
|
|
require_once $scssphp_file; |
13
|
|
|
|
14
|
|
|
$compiler = new \Leafo\ScssPhp\Compiler(); |
15
|
|
|
$compiler->setFormatter( 'Leafo\ScssPhp\Formatter\Compact' ); |
16
|
|
|
|
17
|
|
|
try { |
18
|
|
|
$css = $compiler->compile( $scss ); |
19
|
|
|
} catch ( Exception $e ) { |
20
|
|
|
$error = $e->getMessage(); |
21
|
|
|
return "/*\n\n\$error:\n\n{$error}\n\n\$scss:\n\n{$scss} */"; |
22
|
|
|
} |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
return $css; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* |
30
|
|
|
*/ |
31
|
|
|
function lsx_customizer_colour__add_footer_styles() { |
32
|
|
|
wp_enqueue_style( 'lsx_customizer_colour', get_stylesheet_uri() ); |
33
|
|
|
} |
34
|
|
|
add_action( 'wp_enqueue_scripts', 'lsx_customizer_colour__add_footer_styles', 999 ); |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Outputs an Underscore template for generating CSS for the color scheme. |
38
|
|
|
*/ |
39
|
|
|
function lsx_customizer_colour__color_scheme_css_template() { |
40
|
|
|
global $customizer_colour_names; |
41
|
|
|
|
42
|
|
|
$colors = array(); |
43
|
|
|
|
44
|
|
|
foreach ( $customizer_colour_names as $key => $value ) { |
45
|
|
|
$colors[$key] = 'unquote("{{ data.'.$key.' }}")'; |
46
|
|
|
} |
47
|
|
|
?> |
48
|
|
|
<script type="text/html" id="tmpl-lsx-color-scheme"> |
49
|
|
|
<?php echo str_replace( '>', '>', esc_html( lsx_customizer_colour__top_menu_get_css( $colors ) ) ); ?> |
50
|
|
|
<?php echo str_replace( '>', '>', esc_html( lsx_customizer_colour__header_get_css( $colors ) ) ); ?> |
51
|
|
|
<?php echo str_replace( '>', '>', esc_html( lsx_customizer_colour__main_menu_get_css( $colors ) ) ); ?> |
52
|
|
|
|
53
|
|
|
<?php echo str_replace( '>', '>', esc_html( lsx_customizer_colour__banner_get_css( $colors ) ) ); ?> |
54
|
|
|
<?php echo str_replace( '>', '>', esc_html( lsx_customizer_colour__body_get_css( $colors ) ) ); ?> |
55
|
|
|
|
56
|
|
|
<?php echo str_replace( '>', '>', esc_html( lsx_customizer_colour__footer_cta_get_css( $colors ) ) ); ?> |
57
|
|
|
<?php echo str_replace( '>', '>', esc_html( lsx_customizer_colour__footer_widgets_get_css( $colors ) ) ); ?> |
58
|
|
|
<?php echo str_replace( '>', '>', esc_html( lsx_customizer_colour__footer_get_css( $colors ) ) ); ?> |
59
|
|
|
|
60
|
|
|
<?php echo str_replace( '>', '>', esc_html( lsx_customizer_colour__button_get_css( $colors ) ) ); ?> |
61
|
|
|
<?php echo str_replace( '>', '>', esc_html( lsx_customizer_colour__button_cta_get_css( $colors ) ) ); ?> |
62
|
|
|
</script> |
63
|
|
|
<?php |
64
|
|
|
} |
65
|
|
|
add_action( 'customize_controls_print_footer_scripts', 'lsx_customizer_colour__color_scheme_css_template' ); |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Retrieves the current color scheme. |
69
|
|
|
*/ |
70
|
|
|
function lsx_customizer_colour__get_color_scheme() { |
71
|
|
|
global $customizer_colour_choices; |
72
|
|
|
|
73
|
|
|
$color_scheme_option = get_theme_mod( 'color_scheme', 'default' ); |
74
|
|
|
$color_schemes = $customizer_colour_choices; |
75
|
|
|
|
76
|
|
|
if ( array_key_exists( $color_scheme_option, $color_schemes ) ) { |
77
|
|
|
return $color_schemes[ $color_scheme_option ]['colors']; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
return $color_schemes['default']['colors']; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Converts a HEX value to RGB. |
85
|
|
|
*/ |
86
|
|
|
function lsx_customizer_colour__hex2rgb( $color ) { |
87
|
|
|
$color = trim( $color, '#' ); |
88
|
|
|
|
89
|
|
|
if ( strlen( $color ) === 3 ) { |
90
|
|
|
$r = hexdec( substr( $color, 0, 1 ).substr( $color, 0, 1 ) ); |
91
|
|
|
$g = hexdec( substr( $color, 1, 1 ).substr( $color, 1, 1 ) ); |
92
|
|
|
$b = hexdec( substr( $color, 2, 1 ).substr( $color, 2, 1 ) ); |
93
|
|
|
} else if ( strlen( $color ) === 6 ) { |
94
|
|
|
$r = hexdec( substr( $color, 0, 2 ) ); |
95
|
|
|
$g = hexdec( substr( $color, 2, 2 ) ); |
96
|
|
|
$b = hexdec( substr( $color, 4, 2 ) ); |
97
|
|
|
} else { |
98
|
|
|
return array(); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
return array( 'red' => $r, 'green' => $g, 'blue' => $b ); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/* ################################################################################# */ |
105
|
|
|
|
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Assign CSS to button theme mod. |
109
|
|
|
*/ |
110
|
|
|
function lsx_customizer_colour__button_set_theme_mod() { |
111
|
|
|
$theme_mods = lsx_customizer_colour__button_get_theme_mods(); |
112
|
|
|
$styles = lsx_customizer_colour__button_get_css( $theme_mods ); |
113
|
|
|
|
114
|
|
|
set_theme_mod( 'lsx_customizer_colour__button_theme_mod', $styles ); |
115
|
|
|
} |
116
|
|
|
add_action( 'after_switch_theme', 'lsx_customizer_colour__button_set_theme_mod' ); |
117
|
|
|
add_action( 'customize_save_after', 'lsx_customizer_colour__button_set_theme_mod' ); |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Enqueues front-end CSS for the button. |
121
|
|
|
*/ |
122
|
|
View Code Duplication |
function lsx_customizer_colour__button_css() { |
|
|
|
|
123
|
|
|
$styles_from_theme_mod = get_theme_mod( 'lsx_customizer_colour__button_theme_mod' ); |
124
|
|
|
|
125
|
|
|
if ( is_customize_preview() || false === $styles_from_theme_mod ) { |
126
|
|
|
$theme_mods = lsx_customizer_colour__button_get_theme_mods(); |
127
|
|
|
$styles = lsx_customizer_colour__button_get_css( $theme_mods ); |
128
|
|
|
|
129
|
|
|
if ( false === $styles_from_theme_mod ) { |
130
|
|
|
set_theme_mod( 'lsx_customizer_colour__button_theme_mod', $styles ); |
131
|
|
|
} |
132
|
|
|
} else { |
133
|
|
|
$styles = $styles_from_theme_mod; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
wp_add_inline_style( 'lsx_customizer_colour', $styles ); |
137
|
|
|
} |
138
|
|
|
add_action( 'wp_enqueue_scripts', 'lsx_customizer_colour__button_css', 9999 ); |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Get button CSS theme mods. |
142
|
|
|
*/ |
143
|
|
|
function lsx_customizer_colour__button_get_theme_mods() { |
144
|
|
|
$colors = lsx_customizer_colour__get_color_scheme(); |
145
|
|
|
|
146
|
|
|
return array( |
147
|
|
|
'button_background_color' => get_theme_mod( 'button_background_color', $colors['button_background_color'] ), |
148
|
|
|
'button_background_hover_color' => get_theme_mod( 'button_background_hover_color', $colors['button_background_hover_color'] ), |
149
|
|
|
'button_text_color' => get_theme_mod( 'button_text_color', $colors['button_text_color'] ), |
150
|
|
|
'button_text_color_hover' => get_theme_mod( 'button_text_color_hover', $colors['button_text_color_hover'] ) |
151
|
|
|
); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* Returns CSS for the button. |
156
|
|
|
*/ |
157
|
|
|
function lsx_customizer_colour__button_get_css( $colors ) { |
158
|
|
|
global $customizer_colour_names; |
159
|
|
|
|
160
|
|
|
$colors_template = array(); |
161
|
|
|
|
162
|
|
|
foreach ( $customizer_colour_names as $key => $value ) { |
163
|
|
|
$colors_template[$key] = ''; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
$colors = wp_parse_args( $colors, $colors_template ); |
167
|
|
|
|
168
|
|
|
$css = <<<CSS |
169
|
|
|
/* |
170
|
|
|
* |
171
|
|
|
* Button |
172
|
|
|
* |
173
|
|
|
*/ |
174
|
|
|
|
175
|
|
|
.btn, |
176
|
|
|
.button, |
177
|
|
|
input[type="submit"], |
178
|
|
|
#searchform .input-group span.input-group-btn button.search-submit, |
179
|
|
|
#respond #submit { |
180
|
|
|
&, |
181
|
|
|
&:visited { |
182
|
|
|
background-color: {$colors['button_background_color']}; |
183
|
|
|
color: {$colors['button_text_color']}; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
&:hover, |
187
|
|
|
&:active, |
188
|
|
|
&:focus { |
189
|
|
|
background-color: {$colors['button_background_hover_color']}; |
190
|
|
|
color: {$colors['button_text_color_hover']}; |
191
|
|
|
} |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
#infinite-handle span { |
195
|
|
|
&, |
196
|
|
|
&:visited { |
197
|
|
|
background-color: {$colors['button_background_color']} !important; |
198
|
|
|
color: {$colors['button_text_color']} !important; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
&:hover, |
202
|
|
|
&:active, |
203
|
|
|
&:focus { |
204
|
|
|
background-color: {$colors['button_background_hover_color']} !important; |
205
|
|
|
color: {$colors['button_text_color_hover']} !important; |
206
|
|
|
} |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
.caldera-grid, |
210
|
|
|
.caldera-clarity-grid, |
211
|
|
|
#footer-widgets .widget { |
212
|
|
|
.btn, |
213
|
|
|
.button-primary, |
214
|
|
|
button { |
215
|
|
|
&, |
216
|
|
|
&:visited { |
217
|
|
|
background-color: {$colors['button_background_color']}; |
218
|
|
|
color: {$colors['button_text_color']}; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
&:hover, |
222
|
|
|
&:active, |
223
|
|
|
&:focus { |
224
|
|
|
background-color: {$colors['button_background_hover_color']}; |
225
|
|
|
color: {$colors['button_text_color_hover']}; |
226
|
|
|
} |
227
|
|
|
} |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
.field-wrap { |
231
|
|
|
input[type="submit"], |
232
|
|
|
input[type="button"], |
233
|
|
|
button { |
234
|
|
|
&, |
235
|
|
|
&:visited { |
236
|
|
|
background-color: {$colors['button_background_color']} !important; |
237
|
|
|
color: {$colors['button_text_color']} !important; |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
&:hover, |
241
|
|
|
&:active, |
242
|
|
|
&:focus { |
243
|
|
|
background-color: {$colors['button_background_hover_color']} !important; |
244
|
|
|
color: {$colors['button_text_color_hover']} !important; |
245
|
|
|
} |
246
|
|
|
} |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
article { |
250
|
|
|
header.entry-header { |
251
|
|
|
h1.entry-title { |
252
|
|
|
a.format-link { |
253
|
|
|
&, |
254
|
|
|
&:visited { |
255
|
|
|
background-color: {$colors['button_background_color']}; |
256
|
|
|
color: {$colors['button_text_color']} !important; |
257
|
|
|
} |
258
|
|
|
} |
259
|
|
|
} |
260
|
|
|
} |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
.button-primary.border-btn, |
264
|
|
|
.btn.border-btn, |
265
|
|
|
button.border-btn, |
266
|
|
|
.wp-pagenavi a, |
267
|
|
|
.lsx-postnav > a { |
268
|
|
|
&, |
269
|
|
|
&:visited { |
270
|
|
|
border-color: {$colors['button_background_color']} !important; |
271
|
|
|
color: {$colors['button_background_color']} !important; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
&:hover, |
275
|
|
|
&:active, |
276
|
|
|
&:focus { |
277
|
|
|
background-color: {$colors['button_background_hover_color']} !important; |
278
|
|
|
border-color: {$colors['button_background_hover_color']} !important; |
279
|
|
|
color: {$colors['button_text_color_hover']} !important; |
280
|
|
|
} |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
.wp-pagenavi span.current, |
284
|
|
|
.lsx-postnav > span { |
285
|
|
|
background-color: {$colors['button_background_color']} !important; |
286
|
|
|
border-color: {$colors['button_background_color']} !important; |
287
|
|
|
color: {$colors['button_text_color']} !important; |
288
|
|
|
} |
289
|
|
|
|
290
|
|
|
input[type="text"], |
291
|
|
|
input[type="search"], |
292
|
|
|
input[type="email"], |
293
|
|
|
input[type="number"], |
294
|
|
|
input[type="password"], |
295
|
|
|
textarea, |
296
|
|
|
select { |
297
|
|
|
&:focus { |
298
|
|
|
border-color: {$colors['button_background_color']} !important; |
299
|
|
|
} |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
/* |
303
|
|
|
* |
304
|
|
|
* Button WooCommerce |
305
|
|
|
* |
306
|
|
|
*/ |
307
|
|
|
|
308
|
|
|
.woocommerce { |
309
|
|
|
a.button, |
310
|
|
|
button.button, |
311
|
|
|
input.button, |
312
|
|
|
input[type="submit"], |
313
|
|
|
#respond input#submit { |
314
|
|
|
&, |
315
|
|
|
&:visited { |
316
|
|
|
background-color: {$colors['button_background_color']} !important; |
317
|
|
|
color: {$colors['button_text_color']} !important; |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
&:hover, |
321
|
|
|
&:active, |
322
|
|
|
&:focus { |
323
|
|
|
background-color: {$colors['button_background_hover_color']} !important; |
324
|
|
|
color: {$colors['button_text_color_hover']} !important; |
325
|
|
|
} |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
table.cart { |
329
|
|
|
td.actions { |
330
|
|
|
.coupon { |
331
|
|
|
.input-text { |
332
|
|
|
&:focus { |
333
|
|
|
border-color: {$colors['button_background_color']} !important; |
334
|
|
|
} |
335
|
|
|
} |
336
|
|
|
} |
337
|
|
|
} |
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
nav.woocommerce-pagination a { |
341
|
|
|
&, |
342
|
|
|
&:visited { |
343
|
|
|
border-color: {$colors['button_background_color']} !important; |
344
|
|
|
color: {$colors['button_background_color']} !important; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
&:hover, |
348
|
|
|
&:active, |
349
|
|
|
&:focus { |
350
|
|
|
background-color: {$colors['button_background_hover_color']} !important; |
351
|
|
|
border-color: {$colors['button_background_hover_color']} !important; |
352
|
|
|
color: {$colors['button_text_color_hover']} !important; |
353
|
|
|
} |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
nav.woocommerce-pagination span.current { |
357
|
|
|
background-color: {$colors['button_background_color']} !important; |
358
|
|
|
border-color: {$colors['button_background_color']} !important; |
359
|
|
|
color: {$colors['button_text_color']} !important; |
360
|
|
|
} |
361
|
|
|
} |
362
|
|
|
CSS; |
363
|
|
|
|
364
|
|
|
$css = apply_filters( 'lsx_customizer_colour_selectors_button', $css, $colors ); |
365
|
|
|
$css = lsx_customizer_colour__scss_to_css( $css ); |
366
|
|
|
return $css; |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
|
370
|
|
|
/* ################################################################################# */ |
371
|
|
|
|
372
|
|
|
|
373
|
|
|
/** |
374
|
|
|
* Assign CSS to button cta theme mod. |
375
|
|
|
*/ |
376
|
|
|
function lsx_customizer_colour__button_cta_set_theme_mod() { |
377
|
|
|
$theme_mods = lsx_customizer_colour__button_cta_get_theme_mods(); |
378
|
|
|
$styles = lsx_customizer_colour__button_cta_get_css( $theme_mods ); |
379
|
|
|
|
380
|
|
|
set_theme_mod( 'lsx_customizer_colour__button_cta_theme_mod', $styles ); |
381
|
|
|
} |
382
|
|
|
add_action( 'after_switch_theme', 'lsx_customizer_colour__button_cta_set_theme_mod' ); |
383
|
|
|
add_action( 'customize_save_after', 'lsx_customizer_colour__button_cta_set_theme_mod' ); |
384
|
|
|
|
385
|
|
|
/** |
386
|
|
|
* Enqueues front-end CSS for the button cta. |
387
|
|
|
*/ |
388
|
|
View Code Duplication |
function lsx_customizer_colour__button_cta_css() { |
|
|
|
|
389
|
|
|
$styles_from_theme_mod = get_theme_mod( 'lsx_customizer_colour__button_cta_theme_mod' ); |
390
|
|
|
|
391
|
|
|
if ( is_customize_preview() || false === $styles_from_theme_mod ) { |
392
|
|
|
$theme_mods = lsx_customizer_colour__button_cta_get_theme_mods(); |
393
|
|
|
$styles = lsx_customizer_colour__button_cta_get_css( $theme_mods ); |
394
|
|
|
|
395
|
|
|
if ( false === $styles_from_theme_mod ) { |
396
|
|
|
set_theme_mod( 'lsx_customizer_colour__button_cta_theme_mod', $styles ); |
397
|
|
|
} |
398
|
|
|
} else { |
399
|
|
|
$styles = $styles_from_theme_mod; |
400
|
|
|
} |
401
|
|
|
|
402
|
|
|
wp_add_inline_style( 'lsx_customizer_colour', $styles ); |
403
|
|
|
} |
404
|
|
|
add_action( 'wp_enqueue_scripts', 'lsx_customizer_colour__button_cta_css', 9999 ); |
405
|
|
|
|
406
|
|
|
/** |
407
|
|
|
* Get button cta CSS theme mods. |
408
|
|
|
*/ |
409
|
|
|
function lsx_customizer_colour__button_cta_get_theme_mods() { |
410
|
|
|
$colors = lsx_customizer_colour__get_color_scheme(); |
411
|
|
|
|
412
|
|
|
return array( |
413
|
|
|
'button_cta_background_color' => get_theme_mod( 'button_cta_background_color', $colors['button_cta_background_color'] ), |
414
|
|
|
'button_cta_background_hover_color' => get_theme_mod( 'button_cta_background_hover_color', $colors['button_cta_background_hover_color'] ), |
415
|
|
|
'button_cta_text_color' => get_theme_mod( 'button_cta_text_color', $colors['button_cta_text_color'] ), |
416
|
|
|
'button_cta_text_color_hover' => get_theme_mod( 'button_cta_text_color_hover', $colors['button_cta_text_color_hover'] ) |
417
|
|
|
); |
418
|
|
|
} |
419
|
|
|
|
420
|
|
|
/** |
421
|
|
|
* Returns CSS for the button cta. |
422
|
|
|
*/ |
423
|
|
|
function lsx_customizer_colour__button_cta_get_css( $colors ) { |
424
|
|
|
global $customizer_colour_names; |
425
|
|
|
|
426
|
|
|
$colors_template = array(); |
427
|
|
|
|
428
|
|
|
foreach ( $customizer_colour_names as $key => $value ) { |
429
|
|
|
$colors_template[$key] = ''; |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
$colors = wp_parse_args( $colors, $colors_template ); |
433
|
|
|
|
434
|
|
|
$css = <<<CSS |
435
|
|
|
/* |
436
|
|
|
* |
437
|
|
|
* Button CTA |
438
|
|
|
* |
439
|
|
|
*/ |
440
|
|
|
|
441
|
|
|
.btn { |
442
|
|
|
&.cta-btn { |
443
|
|
|
&, |
444
|
|
|
&:visited { |
445
|
|
|
background-color: {$colors['button_cta_background_color']} !important; |
446
|
|
|
color: {$colors['button_cta_text_color']} !important; |
447
|
|
|
} |
448
|
|
|
|
449
|
|
|
&:hover, |
450
|
|
|
&:active, |
451
|
|
|
&:focus { |
452
|
|
|
background-color: {$colors['button_cta_background_hover_color']} !important; |
453
|
|
|
color: {$colors['button_cta_text_color_hover']} !important; |
454
|
|
|
} |
455
|
|
|
} |
456
|
|
|
|
457
|
|
|
&.cta-border-btn { |
458
|
|
|
&, |
459
|
|
|
&:visited { |
460
|
|
|
border-color: {$colors['button_cta_background_color']} !important; |
461
|
|
|
color: {$colors['button_cta_background_color']} !important; |
462
|
|
|
} |
463
|
|
|
|
464
|
|
|
&:hover, |
465
|
|
|
&:active, |
466
|
|
|
&:focus { |
467
|
|
|
background-color: {$colors['button_cta_background_hover_color']} !important; |
468
|
|
|
border-color: {$colors['button_cta_background_hover_color']} !important; |
469
|
|
|
color: {$colors['button_cta_text_color_hover']} !important; |
470
|
|
|
} |
471
|
|
|
} |
472
|
|
|
} |
473
|
|
|
|
474
|
|
|
#top-menu { |
475
|
|
|
nav.top-menu { |
476
|
|
|
ul { |
477
|
|
|
li.cta { |
478
|
|
|
a { |
479
|
|
|
&, |
480
|
|
|
&:visited { |
481
|
|
|
background-color: {$colors['button_cta_background_color']} !important; |
482
|
|
|
color: {$colors['button_cta_text_color']} !important; |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
&:hover, |
486
|
|
|
&:active, |
487
|
|
|
&:focus { |
488
|
|
|
background-color: {$colors['button_cta_background_hover_color']} !important; |
489
|
|
|
color: {$colors['button_cta_text_color_hover']} !important; |
490
|
|
|
} |
491
|
|
|
} |
492
|
|
|
} |
493
|
|
|
} |
494
|
|
|
} |
495
|
|
|
} |
496
|
|
|
|
497
|
|
|
nav.primary-navbar { |
498
|
|
|
.nav.navbar-nav { |
499
|
|
|
& > li, |
500
|
|
|
ul.dropdown-menu > li { |
501
|
|
|
&.menu-highlight { |
502
|
|
|
a { |
503
|
|
|
background-color: {$colors['button_cta_background_color']} !important; |
504
|
|
|
color: {$colors['button_cta_text_color']} !important; |
505
|
|
|
|
506
|
|
|
.caret { |
507
|
|
|
border-top-color: {$colors['button_cta_text_color']} !important; |
508
|
|
|
border-bottom-color: {$colors['button_cta_text_color']} !important; |
509
|
|
|
} |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
&:hover { |
513
|
|
|
& > a { |
514
|
|
|
background-color: {$colors['button_cta_background_color']} !important; |
515
|
|
|
color: {$colors['button_cta_text_color']} !important; |
516
|
|
|
} |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
ul.dropdown-menu { |
520
|
|
|
& > li { |
521
|
|
|
& > a { |
522
|
|
|
background-color: {$colors['button_cta_background_color']} !important; |
523
|
|
|
color: {$colors['button_cta_text_color']} !important; |
524
|
|
|
|
525
|
|
|
&:hover { |
526
|
|
|
background-color: {$colors['button_cta_background_hover_color']} !important; |
527
|
|
|
color: {$colors['button_cta_text_color_hover']} !important; |
528
|
|
|
} |
529
|
|
|
} |
530
|
|
|
} |
531
|
|
|
} |
532
|
|
|
} |
533
|
|
|
} |
534
|
|
|
} |
535
|
|
|
} |
536
|
|
|
|
537
|
|
|
/* |
538
|
|
|
* |
539
|
|
|
* Button CTA WooCommerce |
540
|
|
|
* |
541
|
|
|
*/ |
542
|
|
|
|
543
|
|
|
.woocommerce { |
544
|
|
|
a.button, |
545
|
|
|
button.button, |
546
|
|
|
input.button, |
547
|
|
|
input[type="submit"], |
548
|
|
|
#respond input#submit { |
549
|
|
|
&.alt { |
550
|
|
|
&, |
551
|
|
|
&:visited { |
552
|
|
|
background-color: {$colors['button_cta_background_color']} !important; |
553
|
|
|
color: {$colors['button_cta_text_color']} !important; |
554
|
|
|
} |
555
|
|
|
|
556
|
|
|
&:hover, |
557
|
|
|
&:active, |
558
|
|
|
&:focus { |
559
|
|
|
background-color: {$colors['button_cta_background_hover_color']} !important; |
560
|
|
|
color: {$colors['button_cta_text_color_hover']} !important; |
561
|
|
|
} |
562
|
|
|
} |
563
|
|
|
} |
564
|
|
|
} |
565
|
|
|
CSS; |
566
|
|
|
|
567
|
|
|
$css = apply_filters( 'lsx_customizer_colour_selectors_button_cta', $css, $colors ); |
568
|
|
|
$css = lsx_customizer_colour__scss_to_css( $css ); |
569
|
|
|
return $css; |
570
|
|
|
} |
571
|
|
|
|
572
|
|
|
|
573
|
|
|
/* ################################################################################# */ |
574
|
|
|
|
575
|
|
|
|
576
|
|
|
/** |
577
|
|
|
* Assign CSS to top menu theme mod. |
578
|
|
|
*/ |
579
|
|
|
function lsx_customizer_colour__top_menu_set_theme_mod() { |
580
|
|
|
$theme_mods = lsx_customizer_colour__top_menu_get_theme_mods(); |
581
|
|
|
$styles = lsx_customizer_colour__top_menu_get_css( $theme_mods ); |
582
|
|
|
|
583
|
|
|
set_theme_mod( 'lsx_customizer_colour__top_menu_theme_mod', $styles ); |
584
|
|
|
} |
585
|
|
|
add_action( 'after_switch_theme', 'lsx_customizer_colour__top_menu_set_theme_mod' ); |
586
|
|
|
add_action( 'customize_save_after', 'lsx_customizer_colour__top_menu_set_theme_mod' ); |
587
|
|
|
|
588
|
|
|
/** |
589
|
|
|
* Enqueues front-end CSS for the top menu. |
590
|
|
|
*/ |
591
|
|
View Code Duplication |
function lsx_customizer_colour__top_menu_css() { |
|
|
|
|
592
|
|
|
$styles_from_theme_mod = get_theme_mod( 'lsx_customizer_colour__top_menu_theme_mod' ); |
593
|
|
|
|
594
|
|
|
if ( is_customize_preview() || false === $styles_from_theme_mod ) { |
595
|
|
|
$theme_mods = lsx_customizer_colour__top_menu_get_theme_mods(); |
596
|
|
|
$styles = lsx_customizer_colour__top_menu_get_css( $theme_mods ); |
597
|
|
|
|
598
|
|
|
if ( false === $styles_from_theme_mod ) { |
599
|
|
|
set_theme_mod( 'lsx_customizer_colour__top_menu_theme_mod', $styles ); |
600
|
|
|
} |
601
|
|
|
} else { |
602
|
|
|
$styles = $styles_from_theme_mod; |
603
|
|
|
} |
604
|
|
|
|
605
|
|
|
wp_add_inline_style( 'lsx_customizer_colour', $styles ); |
606
|
|
|
} |
607
|
|
|
add_action( 'wp_enqueue_scripts', 'lsx_customizer_colour__top_menu_css', 9999 ); |
608
|
|
|
|
609
|
|
|
/** |
610
|
|
|
* Get top menu CSS theme mods. |
611
|
|
|
*/ |
612
|
|
|
function lsx_customizer_colour__top_menu_get_theme_mods() { |
613
|
|
|
$colors = lsx_customizer_colour__get_color_scheme(); |
614
|
|
|
|
615
|
|
|
return array( |
616
|
|
|
'top_menu_background_color' => get_theme_mod( 'top_menu_background_color', $colors['top_menu_background_color'] ), |
617
|
|
|
'top_menu_text_color' => get_theme_mod( 'top_menu_text_color', $colors['top_menu_text_color'] ), |
618
|
|
|
'top_menu_text_hover_color' => get_theme_mod( 'top_menu_text_hover_color', $colors['top_menu_text_hover_color'] ) |
619
|
|
|
); |
620
|
|
|
} |
621
|
|
|
|
622
|
|
|
/** |
623
|
|
|
* Returns CSS for the top menu. |
624
|
|
|
*/ |
625
|
|
|
function lsx_customizer_colour__top_menu_get_css( $colors ) { |
626
|
|
|
global $customizer_colour_names; |
627
|
|
|
|
628
|
|
|
$colors_template = array(); |
629
|
|
|
|
630
|
|
|
foreach ( $customizer_colour_names as $key => $value ) { |
631
|
|
|
$colors_template[$key] = ''; |
632
|
|
|
} |
633
|
|
|
|
634
|
|
|
$colors = wp_parse_args( $colors, $colors_template ); |
635
|
|
|
|
636
|
|
|
$css = <<<CSS |
637
|
|
|
/* |
638
|
|
|
* |
639
|
|
|
* Top Menu |
640
|
|
|
* |
641
|
|
|
*/ |
642
|
|
|
|
643
|
|
|
#top-menu { |
644
|
|
|
background-color: {$colors['top_menu_background_color']}; |
645
|
|
|
|
646
|
|
|
nav.top-menu { |
647
|
|
|
ul { |
648
|
|
|
li { |
649
|
|
|
a { |
650
|
|
|
&, |
651
|
|
|
&:visited { |
652
|
|
|
color: {$colors['top_menu_text_color']}; |
653
|
|
|
} |
654
|
|
|
|
655
|
|
|
&:before { |
656
|
|
|
color: {$colors['top_menu_text_hover_color']}; |
657
|
|
|
} |
658
|
|
|
|
659
|
|
|
&:hover, |
660
|
|
|
&:active, |
661
|
|
|
&:focus { |
662
|
|
|
&, |
663
|
|
|
&:before { |
664
|
|
|
color: {$colors['top_menu_text_hover_color']}; |
665
|
|
|
} |
666
|
|
|
} |
667
|
|
|
} |
668
|
|
|
} |
669
|
|
|
|
670
|
|
|
&.submenu-languages { |
671
|
|
|
& > li { |
672
|
|
|
a { |
673
|
|
|
&, |
674
|
|
|
&:visited { |
675
|
|
|
background-color: {$colors['top_menu_background_color']}; |
676
|
|
|
color: {$colors['top_menu_text_color']}; |
677
|
|
|
} |
678
|
|
|
|
679
|
|
|
&:hover, |
680
|
|
|
&:active, |
681
|
|
|
&:focus { |
682
|
|
|
background-color: {$colors['top_menu_background_color']}; |
683
|
|
|
color: {$colors['top_menu_text_hover_color']}; |
684
|
|
|
} |
685
|
|
|
} |
686
|
|
|
} |
687
|
|
|
} |
688
|
|
|
} |
689
|
|
|
} |
690
|
|
|
} |
691
|
|
|
CSS; |
692
|
|
|
|
693
|
|
|
$css = apply_filters( 'lsx_customizer_colour_selectors_top_menu', $css, $colors ); |
694
|
|
|
$css = lsx_customizer_colour__scss_to_css( $css ); |
695
|
|
|
return $css; |
696
|
|
|
} |
697
|
|
|
|
698
|
|
|
|
699
|
|
|
/* ################################################################################# */ |
700
|
|
|
|
701
|
|
|
|
702
|
|
|
/** |
703
|
|
|
* Assign CSS to header theme mod. |
704
|
|
|
*/ |
705
|
|
|
function lsx_customizer_colour__header_set_theme_mod() { |
706
|
|
|
$theme_mods = lsx_customizer_colour__header_get_theme_mods(); |
707
|
|
|
$styles = lsx_customizer_colour__header_get_css( $theme_mods ); |
708
|
|
|
|
709
|
|
|
set_theme_mod( 'lsx_customizer_colour__header_theme_mod', $styles ); |
710
|
|
|
} |
711
|
|
|
add_action( 'after_switch_theme', 'lsx_customizer_colour__header_set_theme_mod' ); |
712
|
|
|
add_action( 'customize_save_after', 'lsx_customizer_colour__header_set_theme_mod' ); |
713
|
|
|
|
714
|
|
|
/** |
715
|
|
|
* Enqueues front-end CSS for the header. |
716
|
|
|
*/ |
717
|
|
View Code Duplication |
function lsx_customizer_colour__header_css() { |
|
|
|
|
718
|
|
|
$styles_from_theme_mod = get_theme_mod( 'lsx_customizer_colour__header_theme_mod' ); |
719
|
|
|
|
720
|
|
|
if ( is_customize_preview() || false === $styles_from_theme_mod ) { |
721
|
|
|
$theme_mods = lsx_customizer_colour__header_get_theme_mods(); |
722
|
|
|
$styles = lsx_customizer_colour__header_get_css( $theme_mods ); |
723
|
|
|
|
724
|
|
|
if ( false === $styles_from_theme_mod ) { |
725
|
|
|
set_theme_mod( 'lsx_customizer_colour__header_theme_mod', $styles ); |
726
|
|
|
} |
727
|
|
|
} else { |
728
|
|
|
$styles = $styles_from_theme_mod; |
729
|
|
|
} |
730
|
|
|
|
731
|
|
|
wp_add_inline_style( 'lsx_customizer_colour', $styles ); |
732
|
|
|
} |
733
|
|
|
add_action( 'wp_enqueue_scripts', 'lsx_customizer_colour__header_css', 9999 ); |
734
|
|
|
|
735
|
|
|
/** |
736
|
|
|
* Get header CSS theme mods. |
737
|
|
|
*/ |
738
|
|
|
function lsx_customizer_colour__header_get_theme_mods() { |
739
|
|
|
$colors = lsx_customizer_colour__get_color_scheme(); |
740
|
|
|
|
741
|
|
|
return array( |
742
|
|
|
'header_background_color' => get_theme_mod( 'header_background_color', $colors['header_background_color'] ), |
743
|
|
|
'header_title_color' => get_theme_mod( 'header_title_color', $colors['header_title_color'] ), |
744
|
|
|
'header_title_hover_color' => get_theme_mod( 'header_title_hover_color', $colors['header_title_hover_color'] ), |
745
|
|
|
'header_description_color' => get_theme_mod( 'header_description_color', $colors['header_description_color'] ) |
746
|
|
|
); |
747
|
|
|
} |
748
|
|
|
|
749
|
|
|
/** |
750
|
|
|
* Returns CSS for the header. |
751
|
|
|
*/ |
752
|
|
|
function lsx_customizer_colour__header_get_css( $colors ) { |
753
|
|
|
global $customizer_colour_names; |
754
|
|
|
|
755
|
|
|
$colors_template = array(); |
756
|
|
|
|
757
|
|
|
foreach ( $customizer_colour_names as $key => $value ) { |
758
|
|
|
$colors_template[$key] = ''; |
759
|
|
|
} |
760
|
|
|
|
761
|
|
|
$colors = wp_parse_args( $colors, $colors_template ); |
762
|
|
|
|
763
|
|
|
$css = <<<CSS |
764
|
|
|
/* |
765
|
|
|
* |
766
|
|
|
* Header |
767
|
|
|
* |
768
|
|
|
*/ |
769
|
|
|
|
770
|
|
|
header.banner { |
771
|
|
|
background-color: {$colors['header_background_color']}; |
772
|
|
|
|
773
|
|
|
.site-branding { |
774
|
|
|
.site-title { |
775
|
|
|
color: {$colors['header_title_color']}; |
776
|
|
|
|
777
|
|
|
a { |
778
|
|
|
&, |
779
|
|
|
&:visited { |
780
|
|
|
color: {$colors['header_title_color']}; |
781
|
|
|
} |
782
|
|
|
|
783
|
|
|
&:hover, |
784
|
|
|
&:active, |
785
|
|
|
&:focus { |
786
|
|
|
color: {$colors['header_title_hover_color']}; |
787
|
|
|
} |
788
|
|
|
} |
789
|
|
|
} |
790
|
|
|
|
791
|
|
|
.site-description { |
792
|
|
|
color: {$colors['header_description_color']}; |
793
|
|
|
} |
794
|
|
|
} |
795
|
|
|
} |
796
|
|
|
CSS; |
797
|
|
|
|
798
|
|
|
$css = apply_filters( 'lsx_customizer_colour_selectors_header', $css, $colors ); |
799
|
|
|
$css = lsx_customizer_colour__scss_to_css( $css ); |
800
|
|
|
return $css; |
801
|
|
|
} |
802
|
|
|
|
803
|
|
|
|
804
|
|
|
/* ################################################################################# */ |
805
|
|
|
|
806
|
|
|
|
807
|
|
|
/** |
808
|
|
|
* Assign CSS to main menu theme mod. |
809
|
|
|
*/ |
810
|
|
|
function lsx_customizer_colour__main_menu_set_theme_mod() { |
811
|
|
|
$theme_mods = lsx_customizer_colour__main_menu_get_theme_mods(); |
812
|
|
|
$styles = lsx_customizer_colour__main_menu_get_css( $theme_mods ); |
813
|
|
|
|
814
|
|
|
set_theme_mod( 'lsx_customizer_colour__main_menu_theme_mod', $styles ); |
815
|
|
|
} |
816
|
|
|
add_action( 'after_switch_theme', 'lsx_customizer_colour__main_menu_set_theme_mod' ); |
817
|
|
|
add_action( 'customize_save_after', 'lsx_customizer_colour__main_menu_set_theme_mod' ); |
818
|
|
|
|
819
|
|
|
/** |
820
|
|
|
* Enqueues front-end CSS for the main menu. |
821
|
|
|
*/ |
822
|
|
View Code Duplication |
function lsx_customizer_colour__main_menu_css() { |
|
|
|
|
823
|
|
|
$styles_from_theme_mod = get_theme_mod( 'lsx_customizer_colour__main_menu_theme_mod' ); |
824
|
|
|
|
825
|
|
|
if ( is_customize_preview() || false === $styles_from_theme_mod ) { |
826
|
|
|
$theme_mods = lsx_customizer_colour__main_menu_get_theme_mods(); |
827
|
|
|
$styles = lsx_customizer_colour__main_menu_get_css( $theme_mods ); |
828
|
|
|
|
829
|
|
|
if ( false === $styles_from_theme_mod ) { |
830
|
|
|
set_theme_mod( 'lsx_customizer_colour__main_menu_theme_mod', $styles ); |
831
|
|
|
} |
832
|
|
|
} else { |
833
|
|
|
$styles = $styles_from_theme_mod; |
834
|
|
|
} |
835
|
|
|
|
836
|
|
|
wp_add_inline_style( 'lsx_customizer_colour', $styles ); |
837
|
|
|
} |
838
|
|
|
add_action( 'wp_enqueue_scripts', 'lsx_customizer_colour__main_menu_css', 9999 ); |
839
|
|
|
|
840
|
|
|
/** |
841
|
|
|
* Get main menu CSS theme mods. |
842
|
|
|
*/ |
843
|
|
|
function lsx_customizer_colour__main_menu_get_theme_mods() { |
844
|
|
|
$colors = lsx_customizer_colour__get_color_scheme(); |
845
|
|
|
|
846
|
|
|
return array( |
847
|
|
|
'main_menu_background_hover1_color' => get_theme_mod( 'main_menu_background_hover1_color', $colors['main_menu_background_hover1_color'] ), |
848
|
|
|
'main_menu_background_hover2_color' => get_theme_mod( 'main_menu_background_hover2_color', $colors['main_menu_background_hover2_color'] ), |
849
|
|
|
'main_menu_text_color' => get_theme_mod( 'main_menu_text_color', $colors['main_menu_text_color'] ), |
850
|
|
|
'main_menu_text_hover1_color' => get_theme_mod( 'main_menu_text_hover1_color', $colors['main_menu_text_hover1_color'] ), |
851
|
|
|
'main_menu_text_hover2_color' => get_theme_mod( 'main_menu_text_hover2_color', $colors['main_menu_text_hover2_color'] ) |
852
|
|
|
); |
853
|
|
|
} |
854
|
|
|
|
855
|
|
|
/** |
856
|
|
|
* Returns CSS for the main menu. |
857
|
|
|
*/ |
858
|
|
|
function lsx_customizer_colour__main_menu_get_css( $colors ) { |
859
|
|
|
global $customizer_colour_names; |
860
|
|
|
|
861
|
|
|
$colors_template = array(); |
862
|
|
|
|
863
|
|
|
foreach ( $customizer_colour_names as $key => $value ) { |
864
|
|
|
$colors_template[$key] = ''; |
865
|
|
|
} |
866
|
|
|
|
867
|
|
|
$colors = wp_parse_args( $colors, $colors_template ); |
868
|
|
|
|
869
|
|
|
$css = <<<CSS |
870
|
|
|
/* |
871
|
|
|
* |
872
|
|
|
* Main Menu |
873
|
|
|
* |
874
|
|
|
*/ |
875
|
|
|
|
876
|
|
|
nav.primary-navbar { |
877
|
|
|
.nav.navbar-nav { |
878
|
|
|
& > li, |
879
|
|
|
ul.dropdown-menu > li { |
880
|
|
|
& > a, |
881
|
|
|
ul.dropdown-menu > li > a { |
882
|
|
|
color: {$colors['main_menu_text_color']}; |
883
|
|
|
} |
884
|
|
|
|
885
|
|
|
&:hover, |
886
|
|
|
&.open, |
887
|
|
|
&.active { |
888
|
|
|
& > a { |
889
|
|
|
background-color: {$colors['main_menu_background_hover1_color']}; |
890
|
|
|
color: {$colors['main_menu_text_hover1_color']}; |
891
|
|
|
|
892
|
|
|
.caret { |
893
|
|
|
border-top-color: {$colors['main_menu_text_hover1_color']}; |
894
|
|
|
border-bottom-color: {$colors['main_menu_text_hover1_color']}; |
895
|
|
|
} |
896
|
|
|
} |
897
|
|
|
} |
898
|
|
|
|
899
|
|
|
ul.dropdown-menu { |
900
|
|
|
background-color: {$colors['main_menu_background_hover1_color']}; |
901
|
|
|
|
902
|
|
|
& > li { |
903
|
|
|
& > a { |
904
|
|
|
color: {$colors['main_menu_text_hover1_color']}; |
905
|
|
|
|
906
|
|
|
&:hover { |
907
|
|
|
background-color: {$colors['main_menu_background_hover2_color']}; |
908
|
|
|
color: {$colors['main_menu_text_hover2_color']}; |
909
|
|
|
} |
910
|
|
|
} |
911
|
|
|
} |
912
|
|
|
} |
913
|
|
|
|
914
|
|
|
&.active { |
915
|
|
|
& li.active a { |
916
|
|
|
background-color: {$colors['main_menu_background_hover2_color']} !important; |
917
|
|
|
color: {$colors['main_menu_text_hover2_color']}; |
918
|
|
|
} |
919
|
|
|
} |
920
|
|
|
} |
921
|
|
|
} |
922
|
|
|
} |
923
|
|
|
|
924
|
|
|
.navbar-default { |
925
|
|
|
.navbar-toggle { |
926
|
|
|
&, |
927
|
|
|
&:visited, |
928
|
|
|
&:focus, |
929
|
|
|
&:hover, |
930
|
|
|
&:active { |
931
|
|
|
border-color: {$colors['main_menu_background_hover1_color']}; |
932
|
|
|
background-color: {$colors['main_menu_background_hover1_color']}; |
933
|
|
|
} |
934
|
|
|
|
935
|
|
|
.icon-bar { |
936
|
|
|
background-color: {$colors['main_menu_text_hover1_color']}; |
937
|
|
|
} |
938
|
|
|
} |
939
|
|
|
} |
940
|
|
|
|
941
|
|
|
header.banner { |
942
|
|
|
.search-submit { |
943
|
|
|
&, |
944
|
|
|
&:visited { |
945
|
|
|
color: {$colors['main_menu_text_color']} !important; |
946
|
|
|
} |
947
|
|
|
|
948
|
|
|
&:hover, |
949
|
|
|
&:active, |
950
|
|
|
&:focus { |
951
|
|
|
color: #333 !important; /* @TODO */ |
952
|
|
|
} |
953
|
|
|
} |
954
|
|
|
} |
955
|
|
|
CSS; |
956
|
|
|
|
957
|
|
|
$css = apply_filters( 'lsx_customizer_colour_selectors_main_menu', $css, $colors ); |
958
|
|
|
$css = lsx_customizer_colour__scss_to_css( $css ); |
959
|
|
|
return $css; |
960
|
|
|
} |
961
|
|
|
|
962
|
|
|
|
963
|
|
|
/* ################################################################################# */ |
964
|
|
|
|
965
|
|
|
|
966
|
|
|
/** |
967
|
|
|
* Assign CSS to banner theme mod. |
968
|
|
|
*/ |
969
|
|
|
function lsx_customizer_colour__banner_set_theme_mod() { |
970
|
|
|
$theme_mods = lsx_customizer_colour__banner_get_theme_mods(); |
971
|
|
|
$styles = lsx_customizer_colour__banner_get_css( $theme_mods ); |
972
|
|
|
|
973
|
|
|
set_theme_mod( 'lsx_customizer_colour__banner_theme_mod', $styles ); |
974
|
|
|
} |
975
|
|
|
add_action( 'after_switch_theme', 'lsx_customizer_colour__banner_set_theme_mod' ); |
976
|
|
|
add_action( 'customize_save_after', 'lsx_customizer_colour__banner_set_theme_mod' ); |
977
|
|
|
|
978
|
|
|
/** |
979
|
|
|
* Enqueues front-end CSS for the banner. |
980
|
|
|
*/ |
981
|
|
View Code Duplication |
function lsx_customizer_colour__banner_css() { |
|
|
|
|
982
|
|
|
$styles_from_theme_mod = get_theme_mod( 'lsx_customizer_colour__banner_theme_mod' ); |
983
|
|
|
|
984
|
|
|
if ( is_customize_preview() || false === $styles_from_theme_mod ) { |
985
|
|
|
$theme_mods = lsx_customizer_colour__banner_get_theme_mods(); |
986
|
|
|
$styles = lsx_customizer_colour__banner_get_css( $theme_mods ); |
987
|
|
|
|
988
|
|
|
if ( false === $styles_from_theme_mod ) { |
989
|
|
|
set_theme_mod( 'lsx_customizer_colour__banner_theme_mod', $styles ); |
990
|
|
|
} |
991
|
|
|
} else { |
992
|
|
|
$styles = $styles_from_theme_mod; |
993
|
|
|
} |
994
|
|
|
|
995
|
|
|
wp_add_inline_style( 'lsx_customizer_colour', $styles ); |
996
|
|
|
} |
997
|
|
|
add_action( 'wp_enqueue_scripts', 'lsx_customizer_colour__banner_css', 9999 ); |
998
|
|
|
|
999
|
|
|
/** |
1000
|
|
|
* Get banner CSS theme mods. |
1001
|
|
|
*/ |
1002
|
|
|
function lsx_customizer_colour__banner_get_theme_mods() { |
1003
|
|
|
$colors = lsx_customizer_colour__get_color_scheme(); |
1004
|
|
|
|
1005
|
|
|
return array( |
1006
|
|
|
'banner_background_color' => get_theme_mod( 'banner_background_color', $colors['banner_background_color'] ), |
1007
|
|
|
'banner_text_color' => get_theme_mod( 'banner_text_color', $colors['banner_text_color'] ), |
1008
|
|
|
'banner_text_image_color' => get_theme_mod( 'banner_text_image_color', $colors['banner_text_image_color'] ) |
1009
|
|
|
); |
1010
|
|
|
} |
1011
|
|
|
|
1012
|
|
|
/** |
1013
|
|
|
* Returns CSS for the banner. |
1014
|
|
|
*/ |
1015
|
|
|
function lsx_customizer_colour__banner_get_css( $colors ) { |
1016
|
|
|
global $customizer_colour_names; |
1017
|
|
|
|
1018
|
|
|
$colors_template = array(); |
1019
|
|
|
|
1020
|
|
|
foreach ( $customizer_colour_names as $key => $value ) { |
1021
|
|
|
$colors_template[$key] = ''; |
1022
|
|
|
} |
1023
|
|
|
|
1024
|
|
|
$colors = wp_parse_args( $colors, $colors_template ); |
1025
|
|
|
|
1026
|
|
|
$css = <<<CSS |
1027
|
|
|
/* |
1028
|
|
|
* |
1029
|
|
|
* Banner |
1030
|
|
|
* |
1031
|
|
|
*/ |
1032
|
|
|
|
1033
|
|
|
.wrap { |
1034
|
|
|
.archive-header { |
1035
|
|
|
background-color: {$colors['banner_background_color']} !important; |
1036
|
|
|
|
1037
|
|
|
.archive-title, |
1038
|
|
|
h1 { |
1039
|
|
|
color: {$colors['banner_text_color']} !important; |
1040
|
|
|
} |
1041
|
|
|
} |
1042
|
|
|
} |
1043
|
|
|
|
1044
|
|
|
body.page-has-banner { |
1045
|
|
|
.page-banner { |
1046
|
|
|
h1.page-title { |
1047
|
|
|
color: {$colors['banner_text_image_color']} !important; |
1048
|
|
|
} |
1049
|
|
|
} |
1050
|
|
|
} |
1051
|
|
|
CSS; |
1052
|
|
|
|
1053
|
|
|
$css = apply_filters( 'lsx_customizer_colour_selectors_banner', $css, $colors ); |
1054
|
|
|
$css = lsx_customizer_colour__scss_to_css( $css ); |
1055
|
|
|
return $css; |
1056
|
|
|
} |
1057
|
|
|
|
1058
|
|
|
|
1059
|
|
|
/* ################################################################################# */ |
1060
|
|
|
|
1061
|
|
|
|
1062
|
|
|
/** |
1063
|
|
|
* Assign CSS to body theme mod. |
1064
|
|
|
*/ |
1065
|
|
|
function lsx_customizer_colour__body_set_theme_mod() { |
1066
|
|
|
$theme_mods = lsx_customizer_colour__body_get_theme_mods(); |
1067
|
|
|
$styles = lsx_customizer_colour__body_get_css( $theme_mods ); |
1068
|
|
|
|
1069
|
|
|
set_theme_mod( 'lsx_customizer_colour__body_theme_mod', $styles ); |
1070
|
|
|
} |
1071
|
|
|
add_action( 'after_switch_theme', 'lsx_customizer_colour__body_set_theme_mod' ); |
1072
|
|
|
add_action( 'customize_save_after', 'lsx_customizer_colour__body_set_theme_mod' ); |
1073
|
|
|
|
1074
|
|
|
/** |
1075
|
|
|
* Enqueues front-end CSS for the body. |
1076
|
|
|
*/ |
1077
|
|
View Code Duplication |
function lsx_customizer_colour__body_css() { |
|
|
|
|
1078
|
|
|
$styles_from_theme_mod = get_theme_mod( 'lsx_customizer_colour__body_theme_mod' ); |
1079
|
|
|
|
1080
|
|
|
if ( is_customize_preview() || false === $styles_from_theme_mod ) { |
1081
|
|
|
$theme_mods = lsx_customizer_colour__body_get_theme_mods(); |
1082
|
|
|
$styles = lsx_customizer_colour__body_get_css( $theme_mods ); |
1083
|
|
|
|
1084
|
|
|
if ( false === $styles_from_theme_mod ) { |
1085
|
|
|
set_theme_mod( 'lsx_customizer_colour__body_theme_mod', $styles ); |
1086
|
|
|
} |
1087
|
|
|
} else { |
1088
|
|
|
$styles = $styles_from_theme_mod; |
1089
|
|
|
} |
1090
|
|
|
|
1091
|
|
|
wp_add_inline_style( 'lsx_customizer_colour', $styles ); |
1092
|
|
|
} |
1093
|
|
|
add_action( 'wp_enqueue_scripts', 'lsx_customizer_colour__body_css', 9999 ); |
1094
|
|
|
|
1095
|
|
|
/** |
1096
|
|
|
* Get body CSS theme mods. |
1097
|
|
|
*/ |
1098
|
|
|
function lsx_customizer_colour__body_get_theme_mods() { |
1099
|
|
|
$colors = lsx_customizer_colour__get_color_scheme(); |
1100
|
|
|
|
1101
|
|
|
$background_color = get_theme_mod( 'background_color', $colors['background_color'] ); |
1102
|
|
|
|
1103
|
|
|
if ( '#' !== substr( $background_color, 0, 1 ) ) { |
1104
|
|
|
$background_color = '#' . $background_color; |
1105
|
|
|
} |
1106
|
|
|
|
1107
|
|
|
return array( |
1108
|
|
|
'background_color' => $background_color, |
1109
|
|
|
'body_line_color' => get_theme_mod( 'body_line_color', $colors['body_line_color'] ), |
1110
|
|
|
'body_text_heading_color' => get_theme_mod( 'body_text_heading_color', $colors['body_text_heading_color'] ), |
1111
|
|
|
'body_text_color' => get_theme_mod( 'body_text_color', $colors['body_text_color'] ), |
1112
|
|
|
'body_link_color' => get_theme_mod( 'body_link_color', $colors['body_link_color'] ), |
1113
|
|
|
'body_link_hover_color' => get_theme_mod( 'body_link_hover_color', $colors['body_link_hover_color'] ), |
1114
|
|
|
'body_section_full_background_color' => get_theme_mod( 'body_section_full_background_color', $colors['body_section_full_background_color'] ), |
1115
|
|
|
'body_section_full_text_color' => get_theme_mod( 'body_section_full_text_color', $colors['body_section_full_text_color'] ), |
1116
|
|
|
'body_section_full_cta_background_color' => get_theme_mod( 'body_section_full_cta_background_color', $colors['body_section_full_cta_background_color'] ), |
1117
|
|
|
'body_section_full_cta_text_color' => get_theme_mod( 'body_section_full_cta_text_color', $colors['body_section_full_cta_text_color'] ) |
1118
|
|
|
); |
1119
|
|
|
} |
1120
|
|
|
|
1121
|
|
|
/** |
1122
|
|
|
* Returns CSS for the body. |
1123
|
|
|
*/ |
1124
|
|
|
function lsx_customizer_colour__body_get_css( $colors ) { |
1125
|
|
|
global $customizer_colour_names; |
1126
|
|
|
|
1127
|
|
|
foreach ( $customizer_colour_names as $key => $value ) { |
1128
|
|
|
$colors_template[$key] = ''; |
|
|
|
|
1129
|
|
|
} |
1130
|
|
|
|
1131
|
|
|
$colors = wp_parse_args( $colors, $colors_template ); |
|
|
|
|
1132
|
|
|
|
1133
|
|
|
$rgb = lsx_customizer_colour__hex2rgb( $colors['body_line_color'] ); |
1134
|
|
|
$colors['body_line_color_rgba'] = "rgba({$rgb['red']}, {$rgb['green']}, {$rgb['blue']}, 0.5)"; |
1135
|
|
|
|
1136
|
|
|
$css = <<<CSS |
1137
|
|
|
/* |
1138
|
|
|
* |
1139
|
|
|
* Body |
1140
|
|
|
* |
1141
|
|
|
*/ |
1142
|
|
|
|
1143
|
|
|
body { |
1144
|
|
|
color: {$colors['body_text_color']}; |
1145
|
|
|
|
1146
|
|
|
&.archive.author, |
1147
|
|
|
&.archive.category, |
1148
|
|
|
&.archive.date, |
1149
|
|
|
&.archive.tag, |
1150
|
|
|
&.archive.tax-post_format, |
1151
|
|
|
&.blog, |
1152
|
|
|
&.search { |
1153
|
|
|
.wrap { |
1154
|
|
|
#primary { |
1155
|
|
|
#main { |
1156
|
|
|
& > article { |
1157
|
|
|
-webkit-box-shadow: 1px 1px 3px 0 {$colors['body_line_color_rgba']}; |
1158
|
|
|
box-shadow: 1px 1px 3px 0 {$colors['body_line_color_rgba']}; |
1159
|
|
|
border-color: {$colors['body_line_color']}; |
1160
|
|
|
} |
1161
|
|
|
} |
1162
|
|
|
} |
1163
|
|
|
} |
1164
|
|
|
} |
1165
|
|
|
|
1166
|
|
|
&.single-post { |
1167
|
|
|
.wrap { |
1168
|
|
|
#primary { |
1169
|
|
|
#main { |
1170
|
|
|
& > article { |
1171
|
|
|
.post-tags-wrapper { |
1172
|
|
|
border-top-color: {$colors['body_line_color']}; |
1173
|
|
|
border-bottom-color: {$colors['body_line_color']}; |
1174
|
|
|
} |
1175
|
|
|
} |
1176
|
|
|
} |
1177
|
|
|
|
1178
|
|
|
.post-navigation { |
1179
|
|
|
.pager { |
1180
|
|
|
a { |
1181
|
|
|
&, |
1182
|
|
|
&:visited { |
1183
|
|
|
div { |
1184
|
|
|
h3 { |
1185
|
|
|
color: {$colors['body_text_heading_color']}; |
1186
|
|
|
} |
1187
|
|
|
} |
1188
|
|
|
} |
1189
|
|
|
|
1190
|
|
|
&:hover, |
1191
|
|
|
&:active, |
1192
|
|
|
&:focus { |
1193
|
|
|
div { |
1194
|
|
|
h3 { |
1195
|
|
|
color: {$colors['body_link_hover_color']}; |
1196
|
|
|
} |
1197
|
|
|
} |
1198
|
|
|
} |
1199
|
|
|
} |
1200
|
|
|
} |
1201
|
|
|
} |
1202
|
|
|
} |
1203
|
|
|
} |
1204
|
|
|
} |
1205
|
|
|
} |
1206
|
|
|
|
1207
|
|
|
.wrap { |
1208
|
|
|
background-color: {$colors['background_color']}; |
1209
|
|
|
} |
1210
|
|
|
|
1211
|
|
|
h1, h2, h3, h4, h5, h6 { |
1212
|
|
|
color: {$colors['body_text_heading_color']}; |
1213
|
|
|
|
1214
|
|
|
a { |
1215
|
|
|
&, |
1216
|
|
|
&:visited { |
1217
|
|
|
color: {$colors['body_text_heading_color']}; |
1218
|
|
|
} |
1219
|
|
|
|
1220
|
|
|
&:hover, |
1221
|
|
|
&:active, |
1222
|
|
|
&:focus { |
1223
|
|
|
color: {$colors['body_link_hover_color']}; |
1224
|
|
|
} |
1225
|
|
|
} |
1226
|
|
|
} |
1227
|
|
|
|
1228
|
|
|
article { |
1229
|
|
|
header.entry-header { |
1230
|
|
|
h1.entry-title { |
1231
|
|
|
a { |
1232
|
|
|
&, |
1233
|
|
|
&:visited { |
1234
|
|
|
color: {$colors['body_text_heading_color']} !important; |
1235
|
|
|
} |
1236
|
|
|
|
1237
|
|
|
&:hover, |
1238
|
|
|
&:active, |
1239
|
|
|
&:focus { |
1240
|
|
|
color: {$colors['body_link_hover_color']} !important; |
1241
|
|
|
} |
1242
|
|
|
} |
1243
|
|
|
} |
1244
|
|
|
} |
1245
|
|
|
|
1246
|
|
|
.entry-content, |
1247
|
|
|
.entry-summary { |
1248
|
|
|
color: {$colors['body_text_color']} !important; |
1249
|
|
|
} |
1250
|
|
|
} |
1251
|
|
|
|
1252
|
|
|
.sharedaddy { |
1253
|
|
|
.sd-sharing { |
1254
|
|
|
border-top-color: {$colors['body_line_color']}; |
1255
|
|
|
|
1256
|
|
|
.sd-title { |
1257
|
|
|
&, |
1258
|
|
|
&:before { |
1259
|
|
|
color: {$colors['body_text_color']} !important; |
1260
|
|
|
} |
1261
|
|
|
} |
1262
|
|
|
} |
1263
|
|
|
} |
1264
|
|
|
|
1265
|
|
|
.entry-meta { |
1266
|
|
|
.post-meta { |
1267
|
|
|
color: {$colors['body_text_color']} !important; |
1268
|
|
|
} |
1269
|
|
|
} |
1270
|
|
|
|
1271
|
|
|
.nav-links-description { |
1272
|
|
|
color: {$colors['body_text_color']} !important; |
1273
|
|
|
|
1274
|
|
|
&:after, |
1275
|
|
|
&:before { |
1276
|
|
|
color: {$colors['body_text_color']} !important; |
1277
|
|
|
} |
1278
|
|
|
} |
1279
|
|
|
|
1280
|
|
|
.post-meta-author, |
1281
|
|
|
.post-meta-categories, |
1282
|
|
|
.post-meta-time, |
1283
|
|
|
.post-comments { |
1284
|
|
|
&:before { |
1285
|
|
|
color: {$colors['body_text_color']} !important; |
1286
|
|
|
} |
1287
|
|
|
|
1288
|
|
|
a { |
1289
|
|
|
&, |
1290
|
|
|
&:visited { |
1291
|
|
|
color: {$colors['body_link_color']} !important; |
1292
|
|
|
} |
1293
|
|
|
|
1294
|
|
|
&:hover, |
1295
|
|
|
&:active, |
1296
|
|
|
&:focus { |
1297
|
|
|
color: {$colors['body_link_hover_color']} !important; |
1298
|
|
|
} |
1299
|
|
|
} |
1300
|
|
|
} |
1301
|
|
|
|
1302
|
|
|
.post-meta-link { |
1303
|
|
|
&:before { |
1304
|
|
|
color: {$colors['body_text_color']} !important; |
1305
|
|
|
} |
1306
|
|
|
|
1307
|
|
|
&, |
1308
|
|
|
&:visited { |
1309
|
|
|
color: {$colors['body_link_color']} !important; |
1310
|
|
|
} |
1311
|
|
|
|
1312
|
|
|
&:hover, |
1313
|
|
|
&:active, |
1314
|
|
|
&:focus { |
1315
|
|
|
color: {$colors['body_link_hover_color']} !important; |
1316
|
|
|
} |
1317
|
|
|
} |
1318
|
|
|
|
1319
|
|
|
.post-tags, |
1320
|
|
|
#reply-title { |
1321
|
|
|
&:before { |
1322
|
|
|
color: {$colors['body_text_color']} !important; |
1323
|
|
|
} |
1324
|
|
|
} |
1325
|
|
|
|
1326
|
|
|
a { |
1327
|
|
|
&, |
1328
|
|
|
.entry-content &:not(.btn), |
1329
|
|
|
.entry-summary &:not(.btn) { |
1330
|
|
|
&, |
1331
|
|
|
&:visited { |
1332
|
|
|
color: {$colors['body_link_color']}; |
1333
|
|
|
} |
1334
|
|
|
|
1335
|
|
|
&:hover, |
1336
|
|
|
&:active, |
1337
|
|
|
&:focus { |
1338
|
|
|
color: {$colors['body_link_hover_color']}; |
1339
|
|
|
} |
1340
|
|
|
} |
1341
|
|
|
} |
1342
|
|
|
|
1343
|
|
|
.facetwp-alpha { |
1344
|
|
|
&.available, |
1345
|
|
|
&.selected { |
1346
|
|
|
color: {$colors['body_link_color']} !important; |
1347
|
|
|
|
1348
|
|
|
&:hover { |
1349
|
|
|
color: {$colors['body_link_hover_color']} !important; |
1350
|
|
|
} |
1351
|
|
|
} |
1352
|
|
|
} |
1353
|
|
|
|
1354
|
|
|
figure.wp-caption { |
1355
|
|
|
border-color: {$colors['body_line_color']}; |
1356
|
|
|
|
1357
|
|
|
figcaption.wp-caption-text { |
1358
|
|
|
border-top-color: {$colors['body_line_color']}; |
1359
|
|
|
} |
1360
|
|
|
} |
1361
|
|
|
|
1362
|
|
|
.page-header { |
1363
|
|
|
border-bottom-color: {$colors['body_line_color']}; |
1364
|
|
|
} |
1365
|
|
|
|
1366
|
|
|
#main { |
1367
|
|
|
.lsx-full-width { |
1368
|
|
|
background-color: {$colors['body_section_full_background_color']}; |
1369
|
|
|
color: {$colors['body_section_full_text_color']}; |
1370
|
|
|
|
1371
|
|
|
h1, h2, h3, h4, h5, h6, |
1372
|
|
|
a, .lsx-hero-unit { |
1373
|
|
|
color: {$colors['body_section_full_text_color']}; |
1374
|
|
|
} |
1375
|
|
|
|
1376
|
|
|
.lsx-border-button { |
1377
|
|
|
color: {$colors['body_section_full_text_color']} !important; |
1378
|
|
|
border-color: {$colors['body_section_full_text_color']} !important; |
1379
|
|
|
|
1380
|
|
|
&:hover, |
1381
|
|
|
&:active, |
1382
|
|
|
&focus { |
1383
|
|
|
color: {$colors['body_section_full_background_color']} !important; |
1384
|
|
|
background-color: {$colors['body_section_full_text_color']} !important; |
1385
|
|
|
} |
1386
|
|
|
} |
1387
|
|
|
} |
1388
|
|
|
|
1389
|
|
|
.lsx-full-width-alt { |
1390
|
|
|
background-color: {$colors['body_section_full_cta_background_color']}; |
1391
|
|
|
color: {$colors['body_section_full_cta_text_color']}; |
1392
|
|
|
|
1393
|
|
|
h1, h2, h3, h4, h5, h6, |
1394
|
|
|
a, .lsx-hero-unit { |
1395
|
|
|
color: {$colors['body_section_full_cta_text_color']}; |
1396
|
|
|
} |
1397
|
|
|
|
1398
|
|
|
.lsx-border-button { |
1399
|
|
|
color: {$colors['body_section_full_cta_text_color']} !important; |
1400
|
|
|
border-color: {$colors['body_section_full_cta_text_color']} !important; |
1401
|
|
|
|
1402
|
|
|
&:hover, |
1403
|
|
|
&:active, |
1404
|
|
|
&focus { |
1405
|
|
|
color: {$colors['body_section_full_cta_background_color']} !important; |
1406
|
|
|
background-color: {$colors['body_section_full_cta_text_color']} !important; |
1407
|
|
|
} |
1408
|
|
|
} |
1409
|
|
|
} |
1410
|
|
|
} |
1411
|
|
|
CSS; |
1412
|
|
|
|
1413
|
|
|
$css = apply_filters( 'lsx_customizer_colour_selectors_body', $css, $colors ); |
1414
|
|
|
$css = lsx_customizer_colour__scss_to_css( $css ); |
1415
|
|
|
|
1416
|
|
|
return $css; |
1417
|
|
|
} |
1418
|
|
|
|
1419
|
|
|
|
1420
|
|
|
/* ################################################################################# */ |
1421
|
|
|
|
1422
|
|
|
|
1423
|
|
|
/** |
1424
|
|
|
* Assign CSS to footer cta theme mod. |
1425
|
|
|
*/ |
1426
|
|
|
function lsx_customizer_colour__footer_cta_set_theme_mod() { |
1427
|
|
|
$theme_mods = lsx_customizer_colour__footer_cta_get_theme_mods(); |
1428
|
|
|
$styles = lsx_customizer_colour__footer_cta_get_css( $theme_mods ); |
1429
|
|
|
|
1430
|
|
|
set_theme_mod( 'lsx_customizer_colour__footer_cta_theme_mod', $styles ); |
1431
|
|
|
} |
1432
|
|
|
add_action( 'after_switch_theme', 'lsx_customizer_colour__footer_cta_set_theme_mod' ); |
1433
|
|
|
add_action( 'customize_save_after', 'lsx_customizer_colour__footer_cta_set_theme_mod' ); |
1434
|
|
|
|
1435
|
|
|
/** |
1436
|
|
|
* Enqueues front-end CSS for the footer cta. |
1437
|
|
|
*/ |
1438
|
|
View Code Duplication |
function lsx_customizer_colour__footer_cta_css() { |
|
|
|
|
1439
|
|
|
$styles_from_theme_mod = get_theme_mod( 'lsx_customizer_colour__footer_cta_theme_mod' ); |
1440
|
|
|
|
1441
|
|
|
if ( is_customize_preview() || false === $styles_from_theme_mod ) { |
1442
|
|
|
$theme_mods = lsx_customizer_colour__footer_cta_get_theme_mods(); |
1443
|
|
|
$styles = lsx_customizer_colour__footer_cta_get_css( $theme_mods ); |
1444
|
|
|
|
1445
|
|
|
if ( false === $styles_from_theme_mod ) { |
1446
|
|
|
set_theme_mod( 'lsx_customizer_colour__footer_cta_theme_mod', $styles ); |
1447
|
|
|
} |
1448
|
|
|
} else { |
1449
|
|
|
$styles = $styles_from_theme_mod; |
1450
|
|
|
} |
1451
|
|
|
|
1452
|
|
|
wp_add_inline_style( 'lsx_customizer_colour', $styles ); |
1453
|
|
|
} |
1454
|
|
|
add_action( 'wp_enqueue_scripts', 'lsx_customizer_colour__footer_cta_css', 9999 ); |
1455
|
|
|
|
1456
|
|
|
/** |
1457
|
|
|
* Get footer cta CSS theme mods. |
1458
|
|
|
*/ |
1459
|
|
|
function lsx_customizer_colour__footer_cta_get_theme_mods() { |
1460
|
|
|
$colors = lsx_customizer_colour__get_color_scheme(); |
1461
|
|
|
|
1462
|
|
|
return array( |
1463
|
|
|
'footer_cta_background_color' => get_theme_mod( 'footer_cta_background_color', $colors['footer_cta_background_color'] ), |
1464
|
|
|
'footer_cta_text_color' => get_theme_mod( 'footer_cta_text_color', $colors['footer_cta_text_color'] ), |
1465
|
|
|
'footer_cta_link_color' => get_theme_mod( 'footer_cta_link_color', $colors['footer_cta_link_color'] ), |
1466
|
|
|
'footer_cta_link_hover_color' => get_theme_mod( 'footer_cta_link_hover_color', $colors['footer_cta_link_hover_color'] ) |
1467
|
|
|
); |
1468
|
|
|
} |
1469
|
|
|
|
1470
|
|
|
/** |
1471
|
|
|
* Returns CSS for the footer cta. |
1472
|
|
|
*/ |
1473
|
|
|
function lsx_customizer_colour__footer_cta_get_css( $colors ) { |
1474
|
|
|
global $customizer_colour_names; |
1475
|
|
|
|
1476
|
|
|
$colors_template = array(); |
1477
|
|
|
|
1478
|
|
|
foreach ( $customizer_colour_names as $key => $value ) { |
1479
|
|
|
$colors_template[$key] = ''; |
1480
|
|
|
} |
1481
|
|
|
|
1482
|
|
|
$colors = wp_parse_args( $colors, $colors_template ); |
1483
|
|
|
|
1484
|
|
|
$css = <<<CSS |
1485
|
|
|
/* |
1486
|
|
|
* |
1487
|
|
|
* Footer CTA |
1488
|
|
|
* |
1489
|
|
|
*/ |
1490
|
|
|
|
1491
|
|
|
#footer-cta { |
1492
|
|
|
&, |
1493
|
|
|
.lsx-full-width { |
1494
|
|
|
background-color: {$colors['footer_cta_background_color']}; |
1495
|
|
|
} |
1496
|
|
|
|
1497
|
|
|
h1, h2, h3, h4, h5, h6, |
1498
|
|
|
.textwidget { |
1499
|
|
|
color: {$colors['footer_cta_text_color']}; |
1500
|
|
|
|
1501
|
|
|
a { |
1502
|
|
|
&, |
1503
|
|
|
&:visited { |
1504
|
|
|
color: {$colors['footer_cta_link_color']}; |
1505
|
|
|
} |
1506
|
|
|
|
1507
|
|
|
&:hover, |
1508
|
|
|
&:active, |
1509
|
|
|
&:focus { |
1510
|
|
|
color: {$colors['footer_cta_link_hover_color']}; |
1511
|
|
|
} |
1512
|
|
|
} |
1513
|
|
|
} |
1514
|
|
|
} |
1515
|
|
|
CSS; |
1516
|
|
|
|
1517
|
|
|
$css = apply_filters( 'lsx_customizer_colour_selectors_footer_cta', $css, $colors ); |
1518
|
|
|
$css = lsx_customizer_colour__scss_to_css( $css ); |
1519
|
|
|
return $css; |
1520
|
|
|
} |
1521
|
|
|
|
1522
|
|
|
|
1523
|
|
|
/* ################################################################################# */ |
1524
|
|
|
|
1525
|
|
|
/** |
1526
|
|
|
* Assign CSS to footer widgets theme mod. |
1527
|
|
|
*/ |
1528
|
|
|
function lsx_customizer_colour__footer_widgets_set_theme_mod() { |
1529
|
|
|
$theme_mods = lsx_customizer_colour__footer_widgets_get_theme_mods(); |
1530
|
|
|
$styles = lsx_customizer_colour__footer_widgets_get_css( $theme_mods ); |
1531
|
|
|
|
1532
|
|
|
set_theme_mod( 'lsx_customizer_colour__footer_widgets_theme_mod', $styles ); |
1533
|
|
|
} |
1534
|
|
|
add_action( 'after_switch_theme', 'lsx_customizer_colour__footer_widgets_set_theme_mod' ); |
1535
|
|
|
add_action( 'customize_save_after', 'lsx_customizer_colour__footer_widgets_set_theme_mod' ); |
1536
|
|
|
|
1537
|
|
|
/** |
1538
|
|
|
* Enqueues front-end CSS for the footer widgets. |
1539
|
|
|
*/ |
1540
|
|
View Code Duplication |
function lsx_customizer_colour__footer_widgets_css() { |
|
|
|
|
1541
|
|
|
$styles_from_theme_mod = get_theme_mod( 'lsx_customizer_colour__footer_widgets_theme_mod' ); |
1542
|
|
|
|
1543
|
|
|
if ( is_customize_preview() || false === $styles_from_theme_mod ) { |
1544
|
|
|
$theme_mods = lsx_customizer_colour__footer_widgets_get_theme_mods(); |
1545
|
|
|
$styles = lsx_customizer_colour__footer_widgets_get_css( $theme_mods ); |
1546
|
|
|
|
1547
|
|
|
if ( false === $styles_from_theme_mod ) { |
1548
|
|
|
set_theme_mod( 'lsx_customizer_colour__footer_widgets_theme_mod', $styles ); |
1549
|
|
|
} |
1550
|
|
|
} else { |
1551
|
|
|
$styles = $styles_from_theme_mod; |
1552
|
|
|
} |
1553
|
|
|
|
1554
|
|
|
wp_add_inline_style( 'lsx_customizer_colour', $styles ); |
1555
|
|
|
} |
1556
|
|
|
add_action( 'wp_enqueue_scripts', 'lsx_customizer_colour__footer_widgets_css', 9999 ); |
1557
|
|
|
|
1558
|
|
|
/** |
1559
|
|
|
* Get footer widgets CSS theme mods. |
1560
|
|
|
*/ |
1561
|
|
|
function lsx_customizer_colour__footer_widgets_get_theme_mods() { |
1562
|
|
|
$colors = lsx_customizer_colour__get_color_scheme(); |
1563
|
|
|
|
1564
|
|
|
return array( |
1565
|
|
|
'footer_widgets_background_color' => get_theme_mod( 'footer_widgets_background_color', $colors['footer_widgets_background_color'] ), |
1566
|
|
|
'footer_widgets_text_color' => get_theme_mod( 'footer_widgets_text_color', $colors['footer_widgets_text_color'] ), |
1567
|
|
|
'footer_widgets_link_color' => get_theme_mod( 'footer_widgets_link_color', $colors['footer_widgets_link_color'] ), |
1568
|
|
|
'footer_widgets_link_hover_color' => get_theme_mod( 'footer_widgets_link_hover_color', $colors['footer_widgets_link_hover_color'] ) |
1569
|
|
|
); |
1570
|
|
|
} |
1571
|
|
|
|
1572
|
|
|
/** |
1573
|
|
|
* Returns CSS for the footer widgets. |
1574
|
|
|
*/ |
1575
|
|
|
function lsx_customizer_colour__footer_widgets_get_css( $colors ) { |
1576
|
|
|
global $customizer_colour_names; |
1577
|
|
|
|
1578
|
|
|
$colors_template = array(); |
1579
|
|
|
|
1580
|
|
|
foreach ( $customizer_colour_names as $key => $value ) { |
1581
|
|
|
$colors_template[$key] = ''; |
1582
|
|
|
} |
1583
|
|
|
|
1584
|
|
|
$colors = wp_parse_args( $colors, $colors_template ); |
1585
|
|
|
|
1586
|
|
|
$css = <<<CSS |
1587
|
|
|
/* |
1588
|
|
|
* |
1589
|
|
|
* Footer Widgets |
1590
|
|
|
* |
1591
|
|
|
*/ |
1592
|
|
|
|
1593
|
|
|
#footer-widgets { |
1594
|
|
|
background-color: {$colors['footer_widgets_background_color']}; |
1595
|
|
|
|
1596
|
|
|
&, |
1597
|
|
|
.widget, |
1598
|
|
|
.widget h3.widget-title { |
1599
|
|
|
color: {$colors['footer_widgets_text_color']}; |
1600
|
|
|
|
1601
|
|
|
a:not(.btn) { |
1602
|
|
|
&, |
1603
|
|
|
&:visited { |
1604
|
|
|
color: {$colors['footer_widgets_link_color']}; |
1605
|
|
|
} |
1606
|
|
|
|
1607
|
|
|
&:hover, |
1608
|
|
|
&:active, |
1609
|
|
|
&:focus { |
1610
|
|
|
color: {$colors['footer_widgets_link_hover_color']}; |
1611
|
|
|
} |
1612
|
|
|
} |
1613
|
|
|
} |
1614
|
|
|
|
1615
|
|
|
.widget { |
1616
|
|
|
h3.widget-title { |
1617
|
|
|
border-bottom-color: {$colors['footer_widgets_text_color']}; |
1618
|
|
|
} |
1619
|
|
|
} |
1620
|
|
|
} |
1621
|
|
|
CSS; |
1622
|
|
|
|
1623
|
|
|
$css = apply_filters( 'lsx_customizer_colour_selectors_footer_widgets', $css, $colors ); |
1624
|
|
|
$css = lsx_customizer_colour__scss_to_css( $css ); |
1625
|
|
|
return $css; |
1626
|
|
|
} |
1627
|
|
|
|
1628
|
|
|
|
1629
|
|
|
/* ################################################################################# */ |
1630
|
|
|
|
1631
|
|
|
/** |
1632
|
|
|
* Assign CSS to footer theme mod. |
1633
|
|
|
*/ |
1634
|
|
|
function lsx_customizer_colour__footer_set_theme_mod() { |
1635
|
|
|
$theme_mods = lsx_customizer_colour__footer_get_theme_mods(); |
1636
|
|
|
$styles = lsx_customizer_colour__footer_get_css( $theme_mods ); |
1637
|
|
|
|
1638
|
|
|
set_theme_mod( 'lsx_customizer_colour__footer_theme_mod', $styles ); |
1639
|
|
|
} |
1640
|
|
|
add_action( 'after_switch_theme', 'lsx_customizer_colour__footer_set_theme_mod' ); |
1641
|
|
|
add_action( 'customize_save_after', 'lsx_customizer_colour__footer_set_theme_mod' ); |
1642
|
|
|
|
1643
|
|
|
/** |
1644
|
|
|
* Enqueues front-end CSS for the footer. |
1645
|
|
|
*/ |
1646
|
|
View Code Duplication |
function lsx_customizer_colour__footer_css() { |
|
|
|
|
1647
|
|
|
$styles_from_theme_mod = get_theme_mod( 'lsx_customizer_colour__footer_theme_mod' ); |
1648
|
|
|
|
1649
|
|
|
if ( is_customize_preview() || false === $styles_from_theme_mod ) { |
1650
|
|
|
$theme_mods = lsx_customizer_colour__footer_get_theme_mods(); |
1651
|
|
|
$styles = lsx_customizer_colour__footer_get_css( $theme_mods ); |
1652
|
|
|
|
1653
|
|
|
if ( false === $styles_from_theme_mod ) { |
1654
|
|
|
set_theme_mod( 'lsx_customizer_colour__footer_theme_mod', $styles ); |
1655
|
|
|
} |
1656
|
|
|
} else { |
1657
|
|
|
$styles = $styles_from_theme_mod; |
1658
|
|
|
} |
1659
|
|
|
|
1660
|
|
|
wp_add_inline_style( 'lsx_customizer_colour', $styles ); |
1661
|
|
|
} |
1662
|
|
|
add_action( 'wp_enqueue_scripts', 'lsx_customizer_colour__footer_css', 9999 ); |
1663
|
|
|
|
1664
|
|
|
/** |
1665
|
|
|
* Get footer CSS theme mods. |
1666
|
|
|
*/ |
1667
|
|
|
function lsx_customizer_colour__footer_get_theme_mods() { |
1668
|
|
|
$colors = lsx_customizer_colour__get_color_scheme(); |
1669
|
|
|
|
1670
|
|
|
return array( |
1671
|
|
|
'footer_background_color' => get_theme_mod( 'footer_background_color', $colors['footer_background_color'] ), |
1672
|
|
|
'footer_text_color' => get_theme_mod( 'footer_text_color', $colors['footer_text_color'] ), |
1673
|
|
|
'footer_link_color' => get_theme_mod( 'footer_link_color', $colors['footer_link_color'] ), |
1674
|
|
|
'footer_link_hover_color' => get_theme_mod( 'footer_link_hover_color', $colors['footer_link_hover_color'] ) |
1675
|
|
|
); |
1676
|
|
|
} |
1677
|
|
|
|
1678
|
|
|
/** |
1679
|
|
|
* Returns CSS for the footer. |
1680
|
|
|
*/ |
1681
|
|
|
function lsx_customizer_colour__footer_get_css( $colors ) { |
1682
|
|
|
global $customizer_colour_names; |
1683
|
|
|
|
1684
|
|
|
$colors_template = array(); |
1685
|
|
|
|
1686
|
|
|
foreach ( $customizer_colour_names as $key => $value ) { |
1687
|
|
|
$colors_template[$key] = ''; |
1688
|
|
|
} |
1689
|
|
|
|
1690
|
|
|
$colors = wp_parse_args( $colors, $colors_template ); |
1691
|
|
|
|
1692
|
|
|
$css = <<<CSS |
1693
|
|
|
/* |
1694
|
|
|
* |
1695
|
|
|
* Footer |
1696
|
|
|
* |
1697
|
|
|
*/ |
1698
|
|
|
|
1699
|
|
|
footer.content-info { |
1700
|
|
|
background-color: {$colors['footer_background_color']}; |
1701
|
|
|
|
1702
|
|
|
&, |
1703
|
|
|
& .credit { |
1704
|
|
|
color: {$colors['footer_text_color']}; |
1705
|
|
|
} |
1706
|
|
|
|
1707
|
|
|
a { |
1708
|
|
|
&, |
1709
|
|
|
&:visited { |
1710
|
|
|
color: {$colors['footer_link_color']}; |
1711
|
|
|
} |
1712
|
|
|
|
1713
|
|
|
&:hover, |
1714
|
|
|
&:active, |
1715
|
|
|
&:focus { |
1716
|
|
|
color: {$colors['footer_link_hover_color']}; |
1717
|
|
|
} |
1718
|
|
|
} |
1719
|
|
|
} |
1720
|
|
|
|
1721
|
|
|
nav#footer-navigation { |
1722
|
|
|
ul { |
1723
|
|
|
li { |
1724
|
|
|
border-right-color: {$colors['footer_link_color']}; |
1725
|
|
|
} |
1726
|
|
|
} |
1727
|
|
|
} |
1728
|
|
|
CSS; |
1729
|
|
|
|
1730
|
|
|
$css = apply_filters( 'lsx_customizer_colour_selectors_footer', $css, $colors ); |
1731
|
|
|
$css = lsx_customizer_colour__scss_to_css( $css ); |
1732
|
|
|
return $css; |
1733
|
|
|
} |
1734
|
|
|
|
1735
|
|
|
|
1736
|
|
|
/* ################################################################################# */ |
1737
|
|
|
|
1738
|
|
|
|
1739
|
|
|
/** |
1740
|
|
|
* Customize Colour Control Class |
1741
|
|
|
*/ |
1742
|
|
|
|
1743
|
|
|
if ( ! class_exists( 'WP_Customize_Control' ) ) { |
1744
|
|
|
return; |
1745
|
|
|
} |
1746
|
|
|
|
1747
|
|
|
class LSX_Customize_Colour_Control extends WP_Customize_Control { |
1748
|
|
|
|
1749
|
|
|
/** |
1750
|
|
|
* Enqueue control related scripts/styles. |
1751
|
|
|
*/ |
1752
|
|
|
public function enqueue() { |
1753
|
|
|
wp_enqueue_script( 'lsx-colour-control', get_template_directory_uri() .'/js/customizer-colour.js', array( 'customize-controls', 'iris', 'underscore', 'wp-util' ), null, true ); |
1754
|
|
|
wp_localize_script( 'lsx-colour-control', 'colorScheme', $this->choices ); |
1755
|
|
|
|
1756
|
|
|
global $customizer_colour_names; |
1757
|
|
|
$colors = array(); |
1758
|
|
|
foreach ( $customizer_colour_names as $key => $value ) { |
1759
|
|
|
$colors[] = $key; |
1760
|
|
|
} |
1761
|
|
|
wp_localize_script( 'lsx-colour-control', 'colorSchemeKeys', $colors ); |
1762
|
|
|
} |
1763
|
|
|
|
1764
|
|
|
/** |
1765
|
|
|
* Render the control's content. |
1766
|
|
|
*/ |
1767
|
|
|
public function render_content() { |
1768
|
|
|
if ( empty( $this->choices ) ) { |
1769
|
|
|
return; |
1770
|
|
|
} |
1771
|
|
|
|
1772
|
|
|
?> |
1773
|
|
|
<label> |
1774
|
|
|
<?php if ( ! empty( $this->label ) ) { ?> |
1775
|
|
|
<span class="customize-control-title"><?php echo esc_html( $this->label ) ?></span> |
1776
|
|
|
<?php } |
1777
|
|
|
if ( ! empty( $this->description ) ) { ?> |
1778
|
|
|
<span class="description customize-control-description"><?php echo esc_html( $this->description ) ?></span> |
1779
|
|
|
<?php } ?> |
1780
|
|
|
<select <?php $this->link() ?>> |
1781
|
|
|
<?php |
1782
|
|
|
foreach ( $this->choices as $value => $label ) { |
1783
|
|
|
echo '<option value="'. esc_attr( $value ) .'"'. selected( $this->value(), $value, false ) .'>'. esc_html( $label['label'] ) .'</option>'; |
1784
|
|
|
} |
1785
|
|
|
?> |
1786
|
|
|
</select> |
1787
|
|
|
</label> |
1788
|
|
|
<?php |
1789
|
|
|
} |
1790
|
|
|
|
1791
|
|
|
} |
1792
|
|
|
|
1793
|
|
|
?> |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.