1
|
|
|
<?php |
|
|
|
|
2
|
|
|
if ( ! class_exists( 'LSX_Customizer_Colour_Body' ) ) { |
|
|
|
|
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* LSX Customizer Colour Body Class |
6
|
|
|
* |
7
|
|
|
* @package LSX Customizer |
8
|
|
|
* @author LightSpeed |
9
|
|
|
* @license GPL3 |
10
|
|
|
* @link |
11
|
|
|
* @copyright 2016 LightSpeed |
12
|
|
|
*/ |
13
|
|
|
class LSX_Customizer_Colour_Body extends LSX_Customizer_Colour { |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Constructor. |
17
|
|
|
* |
18
|
|
|
* @since 1.0.0 |
19
|
|
|
*/ |
20
|
|
|
public function __construct() { |
|
|
|
|
21
|
|
|
add_action( 'after_switch_theme', array( $this, 'set_theme_mod' ) ); |
|
|
|
|
22
|
|
|
add_action( 'customize_save_after', array( $this, 'set_theme_mod' ) ); |
23
|
|
|
|
24
|
|
|
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_css' ), 2999 ); |
25
|
|
|
} |
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Assign CSS to theme mod. |
29
|
|
|
* |
30
|
|
|
* @since 1.0.0 |
31
|
|
|
*/ |
32
|
|
|
public function set_theme_mod() { |
33
|
|
|
$theme_mods = $this->get_theme_mods(); |
34
|
|
|
$styles = $this->get_css( $theme_mods ); |
35
|
|
|
|
36
|
|
|
set_theme_mod( 'lsx_customizer_colour__body_theme_mod', $styles ); |
37
|
|
|
} |
|
|
|
|
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Enqueues front-end CSS. |
41
|
|
|
* |
42
|
|
|
* @since 1.0.0 |
43
|
|
|
*/ |
44
|
|
|
public function enqueue_css() { |
45
|
|
|
$styles_from_theme_mod = get_theme_mod( 'lsx_customizer_colour__body_theme_mod' ); |
46
|
|
|
|
47
|
|
|
if ( is_customize_preview() || false === $styles_from_theme_mod ) { |
|
|
|
|
48
|
|
|
$theme_mods = $this->get_theme_mods(); |
49
|
|
|
$styles = $this->get_css( $theme_mods ); |
50
|
|
|
|
51
|
|
|
if ( false === $styles_from_theme_mod ) { |
|
|
|
|
52
|
|
|
set_theme_mod( 'lsx_customizer_colour__body_theme_mod', $styles ); |
53
|
|
|
} |
54
|
|
|
} else { |
55
|
|
|
$styles = $styles_from_theme_mod; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
wp_add_inline_style( 'lsx-customizer', $styles ); |
59
|
|
|
} |
|
|
|
|
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Get CSS theme mods. |
63
|
|
|
* |
64
|
|
|
* @since 1.0.0 |
65
|
|
|
*/ |
66
|
|
|
public function get_theme_mods() { |
67
|
|
|
$colors = parent::get_color_scheme(); |
68
|
|
|
|
69
|
|
|
$background_color = get_theme_mod( 'background_color', $colors['background_color'] ); |
70
|
|
|
|
71
|
|
|
if ( '#' !== substr( $background_color, 0, 1 ) ) { |
|
|
|
|
72
|
|
|
$background_color = '#' . $background_color; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
return apply_filters( 'lsx_customizer_colours_body', array( |
|
|
|
|
76
|
|
|
'background_color' => $background_color, |
77
|
|
|
'body_line_color' => get_theme_mod( 'body_line_color', $colors['body_line_color'] ), |
|
|
|
|
78
|
|
|
'body_text_heading_color' => get_theme_mod( 'body_text_heading_color', $colors['body_text_heading_color'] ), |
|
|
|
|
79
|
|
|
'body_text_small_color' => get_theme_mod( 'body_text_small_color', $colors['body_text_small_color'] ), |
|
|
|
|
80
|
|
|
'body_text_color' => get_theme_mod( 'body_text_color', $colors['body_text_color'] ), |
|
|
|
|
81
|
|
|
'body_link_color' => get_theme_mod( 'body_link_color', $colors['body_link_color'] ), |
|
|
|
|
82
|
|
|
'body_link_hover_color' => get_theme_mod( 'body_link_hover_color', $colors['body_link_hover_color'] ), |
|
|
|
|
83
|
|
|
'body_section_full_background_color' => get_theme_mod( 'body_section_full_background_color', $colors['body_section_full_background_color'] ), |
|
|
|
|
84
|
|
|
'body_section_full_text_color' => get_theme_mod( 'body_section_full_text_color', $colors['body_section_full_text_color'] ), |
|
|
|
|
85
|
|
|
'body_section_full_link_color' => get_theme_mod( 'body_section_full_link_color', $colors['body_section_full_link_color'] ), |
|
|
|
|
86
|
|
|
'body_section_full_link_hover_color' => get_theme_mod( 'body_section_full_link_hover_color', $colors['body_section_full_link_hover_color'] ), |
|
|
|
|
87
|
|
|
'body_section_full_cta_background_color' => get_theme_mod( 'body_section_full_cta_background_color', $colors['body_section_full_cta_background_color'] ), |
88
|
|
|
'body_section_full_cta_text_color' => get_theme_mod( 'body_section_full_cta_text_color', $colors['body_section_full_cta_text_color'] ), |
|
|
|
|
89
|
|
|
'body_section_full_cta_link_color' => get_theme_mod( 'body_section_full_cta_link_color', $colors['body_section_full_cta_link_color'] ), |
|
|
|
|
90
|
|
|
'body_section_full_cta_link_hover_color' => get_theme_mod( 'body_section_full_cta_link_hover_color', $colors['body_section_full_cta_link_hover_color'] ), |
91
|
|
|
) ); |
|
|
|
|
92
|
|
|
} |
|
|
|
|
93
|
|
|
|
94
|
|
|
/** |
|
|
|
|
95
|
|
|
* Returns CSS. |
96
|
|
|
* |
97
|
|
|
* @since 1.0.0 |
98
|
|
|
*/ |
99
|
|
|
function get_css( $colors ) { |
|
|
|
|
100
|
|
|
global $customizer_colour_names; |
101
|
|
|
|
102
|
|
|
$colors_template = array(); |
103
|
|
|
|
104
|
|
|
foreach ( $customizer_colour_names as $key => $value ) { |
|
|
|
|
105
|
|
|
$colors_template[ $key ] = ''; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
$colors = wp_parse_args( $colors, $colors_template ); |
109
|
|
|
|
110
|
|
|
if ( empty( $colors['background_color'] ) |
|
|
|
|
111
|
|
|
|| empty( $colors['body_line_color'] ) |
112
|
|
|
|| empty( $colors['body_text_heading_color'] ) |
113
|
|
|
|| empty( $colors['body_text_color'] ) |
114
|
|
|
|| empty( $colors['body_link_color'] ) |
115
|
|
|
|| empty( $colors['body_link_hover_color'] ) |
116
|
|
|
|| empty( $colors['body_text_small_color'] ) |
117
|
|
|
|| empty( $colors['body_section_full_background_color'] ) |
118
|
|
|
|| empty( $colors['body_section_full_text_color'] ) |
119
|
|
|
|| empty( $colors['body_section_full_link_color'] ) |
120
|
|
|
|| empty( $colors['body_section_full_link_hover_color'] ) |
121
|
|
|
|| empty( $colors['body_section_full_cta_background_color'] ) |
122
|
|
|
|| empty( $colors['body_section_full_cta_text_color'] ) |
123
|
|
|
|| empty( $colors['body_section_full_cta_link_color'] ) |
124
|
|
|
|| empty( $colors['body_section_full_cta_link_hover_color'] ) ) { |
125
|
|
|
return ''; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
$css = ' |
129
|
|
|
@import "' . get_template_directory() . '/assets/css/scss/global/mixins/content"; |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* LSX Customizer - Body |
133
|
|
|
*/ |
134
|
|
|
@include content-colours ( |
135
|
|
|
$bg: ' . $colors['background_color'] . ', |
136
|
|
|
$breaker: ' . $colors['body_line_color'] . ', |
137
|
|
|
$header: ' . $colors['body_text_heading_color'] . ', |
138
|
|
|
$color: ' . $colors['body_text_color'] . ', |
139
|
|
|
$link: ' . $colors['body_link_color'] . ', |
140
|
|
|
$hover: ' . $colors['body_link_hover_color'] . ', |
141
|
|
|
$small: ' . $colors['body_text_small_color'] . ', |
142
|
|
|
$full-bg: ' . $colors['body_section_full_background_color'] . ', |
143
|
|
|
$full-color: ' . $colors['body_section_full_text_color'] . ', |
144
|
|
|
$full-link: ' . $colors['body_section_full_link_color'] . ', |
145
|
|
|
$full-hover: ' . $colors['body_section_full_link_hover_color'] . ', |
146
|
|
|
$full-cta-bg: ' . $colors['body_section_full_cta_background_color'] . ', |
147
|
|
|
$full-cta-color: ' . $colors['body_section_full_cta_text_color'] . ', |
148
|
|
|
$full-cta-link: ' . $colors['body_section_full_cta_link_color'] . ', |
149
|
|
|
$full-cta-hover: ' . $colors['body_section_full_cta_link_hover_color'] . ' |
150
|
|
|
); |
151
|
|
|
'; |
152
|
|
|
|
153
|
|
|
$css = apply_filters( 'lsx_customizer_colour_selectors_body', $css, $colors ); |
154
|
|
|
$css = parent::scss_to_css( $css ); |
155
|
|
|
|
156
|
|
|
return $css; |
157
|
|
|
} |
|
|
|
|
158
|
|
|
|
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
} |
162
|
|
|
|