@@ -1,526 +1,526 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! class_exists( 'LSX_Customizer_Login' ) ) { |
3 | 3 | |
4 | - /** |
|
5 | - * LSX Customizer Login Class |
|
6 | - * |
|
7 | - * @package LSX Customizer |
|
8 | - * @author LightSpeed |
|
9 | - * @license GPL3 |
|
10 | - * @link |
|
11 | - * @copyright 2019 LightSpeed |
|
12 | - */ |
|
13 | - class LSX_Customizer_Login extends LSX_Customizer { |
|
14 | - |
|
15 | - /** |
|
16 | - * Constructor. |
|
17 | - * |
|
18 | - * @since 1.0.0 |
|
19 | - */ |
|
20 | - public function __construct() { |
|
21 | - add_action( 'customize_register', array( $this, 'register_general' ), 20 ); |
|
22 | - add_action( 'customize_register', array( $this, 'register_form' ), 30 ); |
|
23 | - add_action( 'customize_register', array( $this, 'register_background' ), 40 ); |
|
24 | - |
|
25 | - add_action( 'after_switch_theme', array( $this, 'set_theme_mod' ) ); |
|
26 | - add_action( 'customize_save_after', array( $this, 'set_theme_mod' ) ); |
|
27 | - add_action( 'login_enqueue_scripts', array( $this, 'enqueue_css' ), 2999 ); |
|
28 | - } |
|
29 | - |
|
30 | - /** |
|
31 | - * Customizer Controls and Settings. |
|
32 | - * |
|
33 | - * @param WP_Customize_Manager $wp_customize Theme Customizer object. |
|
34 | - * @since 1.0.0 |
|
35 | - */ |
|
36 | - public function register_general( $wp_customize ) { |
|
37 | - /** |
|
38 | - * Register the main panel |
|
39 | - */ |
|
40 | - $wp_customize->add_panel( |
|
41 | - 'login', |
|
42 | - array( |
|
43 | - 'title' => esc_html__( 'WP Login Screen', 'lsx-customizer' ), |
|
44 | - 'priority' => 60, |
|
45 | - ) |
|
46 | - ); |
|
47 | - |
|
48 | - /** |
|
49 | - * Reigster the Form section |
|
50 | - */ |
|
51 | - $wp_customize->add_section( |
|
52 | - 'login-general', |
|
53 | - array( |
|
54 | - 'title' => esc_html__( 'General', 'lsx-customizer' ), |
|
55 | - 'priority' => 1, |
|
56 | - 'panel' => 'login', |
|
57 | - ) |
|
58 | - ); |
|
59 | - |
|
60 | - /** |
|
61 | - * Select the background repeat. |
|
62 | - */ |
|
63 | - $wp_customize->add_setting( |
|
64 | - 'lsx_login_logo', |
|
65 | - array( |
|
66 | - 'default' => '', |
|
67 | - 'type' => 'theme_mod', |
|
68 | - 'transport' => 'postMessage', |
|
69 | - ) |
|
70 | - ); |
|
71 | - |
|
72 | - $wp_customize->add_control( |
|
73 | - new WP_Customize_Image_Control( |
|
74 | - $wp_customize, |
|
75 | - 'lsx_login_logo', |
|
76 | - array( |
|
77 | - 'label' => __( 'Upload a logo', 'lsx-customizer' ), |
|
78 | - 'section' => 'login-general', |
|
79 | - 'settings' => 'lsx_login_logo', |
|
80 | - ) |
|
81 | - ) |
|
82 | - ); |
|
83 | - |
|
84 | - /** |
|
85 | - * Link Colour |
|
86 | - */ |
|
87 | - $wp_customize->add_setting( |
|
88 | - 'lsx_login_link_colour', |
|
89 | - array( |
|
90 | - 'default' => '0085ba', |
|
91 | - 'type' => 'theme_mod', |
|
92 | - 'transport' => 'postMessage', |
|
93 | - ) |
|
94 | - ); |
|
95 | - $wp_customize->add_control( |
|
96 | - new WP_Customize_Color_Control( |
|
97 | - $wp_customize, |
|
98 | - 'lsx_login_link_colour', |
|
99 | - array( |
|
100 | - 'label' => __( 'Link Colour', 'lsx-customizer' ), |
|
101 | - 'section' => 'login-general', |
|
102 | - 'settings' => 'lsx_login_link_colour', |
|
103 | - ) |
|
104 | - ) |
|
105 | - ); |
|
106 | - |
|
107 | - /** |
|
108 | - * Link Hover Colour |
|
109 | - */ |
|
110 | - $wp_customize->add_setting( |
|
111 | - 'lsx_login_link_hover_colour', |
|
112 | - array( |
|
113 | - 'default' => '000000', |
|
114 | - 'type' => 'theme_mod', |
|
115 | - 'transport' => 'postMessage', |
|
116 | - ) |
|
117 | - ); |
|
118 | - $wp_customize->add_control( |
|
119 | - new WP_Customize_Color_Control( |
|
120 | - $wp_customize, |
|
121 | - 'lsx_login_link_hover_colour', |
|
122 | - array( |
|
123 | - 'label' => __( 'Link Hover Colour', 'lsx-customizer' ), |
|
124 | - 'section' => 'login-general', |
|
125 | - 'settings' => 'lsx_login_link_hover_colour', |
|
126 | - ) |
|
127 | - ) |
|
128 | - ); |
|
129 | - |
|
130 | - /** |
|
131 | - * Add in the custom CSS. |
|
132 | - */ |
|
133 | - $wp_customize->add_setting( |
|
134 | - 'lsx_login_custom_css', |
|
135 | - array( |
|
136 | - 'default' => '', |
|
137 | - 'type' => 'theme_mod', |
|
138 | - 'transport' => 'postMessage', |
|
139 | - ) |
|
140 | - ); |
|
141 | - $wp_customize->add_control( |
|
142 | - new WP_Customize_Control( |
|
143 | - $wp_customize, |
|
144 | - 'lsx_login_custom_css', |
|
145 | - array( |
|
146 | - 'label' => __( 'Custom CSS', 'lsx-customizer' ), |
|
147 | - 'section' => 'login-general', |
|
148 | - 'settings' => 'lsx_login_custom_css', |
|
149 | - 'type' => 'textarea', |
|
150 | - ) |
|
151 | - ) |
|
152 | - ); |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * Customizer Controls and Settings. |
|
157 | - * |
|
158 | - * @param WP_Customize_Manager $wp_customize Theme Customizer object. |
|
159 | - * @since 1.0.0 |
|
160 | - */ |
|
161 | - public function register_form( $wp_customize ) { |
|
162 | - /** |
|
163 | - * Reigster the Form section |
|
164 | - */ |
|
165 | - $wp_customize->add_section( |
|
166 | - 'login-form', |
|
167 | - array( |
|
168 | - 'title' => esc_html__( 'Form', 'lsx-customizer' ), |
|
169 | - 'priority' => 1, |
|
170 | - 'panel' => 'login', |
|
171 | - ) |
|
172 | - ); |
|
173 | - |
|
174 | - /** |
|
175 | - * Form Background Colour |
|
176 | - */ |
|
177 | - $wp_customize->add_setting( |
|
178 | - 'lsx_login_form_colour', |
|
179 | - array( |
|
180 | - 'default' => 'ffffff', |
|
181 | - 'type' => 'theme_mod', |
|
182 | - 'transport' => 'postMessage', |
|
183 | - ) |
|
184 | - ); |
|
185 | - $wp_customize->add_control( |
|
186 | - new WP_Customize_Color_Control( |
|
187 | - $wp_customize, |
|
188 | - 'lsx_login_form_colour', |
|
189 | - array( |
|
190 | - 'label' => __( 'Form Background Colour', 'lsx-customizer' ), |
|
191 | - 'section' => 'login-form', |
|
192 | - 'settings' => 'lsx_login_form_colour', |
|
193 | - ) |
|
194 | - ) |
|
195 | - ); |
|
196 | - |
|
197 | - /** |
|
198 | - * Form Label Colour |
|
199 | - */ |
|
200 | - $wp_customize->add_setting( |
|
201 | - 'lsx_login_form_label_colour', |
|
202 | - array( |
|
203 | - 'default' => 'ffffff', |
|
204 | - 'type' => 'theme_mod', |
|
205 | - 'transport' => 'postMessage', |
|
206 | - ) |
|
207 | - ); |
|
208 | - $wp_customize->add_control( |
|
209 | - new WP_Customize_Color_Control( |
|
210 | - $wp_customize, |
|
211 | - 'lsx_login_form_label_colour', |
|
212 | - array( |
|
213 | - 'label' => __( 'Form Label Colour', 'lsx-customizer' ), |
|
214 | - 'section' => 'login-form', |
|
215 | - 'settings' => 'lsx_login_form_label_colour', |
|
216 | - ) |
|
217 | - ) |
|
218 | - ); |
|
219 | - |
|
220 | - /** |
|
221 | - * Button Colour |
|
222 | - */ |
|
223 | - $wp_customize->add_setting( |
|
224 | - 'lsx_login_button_colour', |
|
225 | - array( |
|
226 | - 'default' => '000000', |
|
227 | - 'type' => 'theme_mod', |
|
228 | - 'transport' => 'postMessage', |
|
229 | - ) |
|
230 | - ); |
|
231 | - $wp_customize->add_control( |
|
232 | - new WP_Customize_Color_Control( |
|
233 | - $wp_customize, |
|
234 | - 'lsx_login_button_colour', |
|
235 | - array( |
|
236 | - 'label' => __( 'Button Colour', 'lsx-customizer' ), |
|
237 | - 'section' => 'login-form', |
|
238 | - 'settings' => 'lsx_login_button_colour', |
|
239 | - ) |
|
240 | - ) |
|
241 | - ); |
|
242 | - |
|
243 | - /** |
|
244 | - * Button Shadow Colour |
|
245 | - */ |
|
246 | - $wp_customize->add_setting( |
|
247 | - 'lsx_login_button_shadow_colour', |
|
248 | - array( |
|
249 | - 'default' => '015d82', |
|
250 | - 'type' => 'theme_mod', |
|
251 | - 'transport' => 'postMessage', |
|
252 | - ) |
|
253 | - ); |
|
254 | - $wp_customize->add_control( |
|
255 | - new WP_Customize_Color_Control( |
|
256 | - $wp_customize, |
|
257 | - 'lsx_login_button_shadow_colour', |
|
258 | - array( |
|
259 | - 'label' => __( 'Button Shadow Colour', 'lsx-customizer' ), |
|
260 | - 'section' => 'login-form', |
|
261 | - 'settings' => 'lsx_login_button_shadow_colour', |
|
262 | - ) |
|
263 | - ) |
|
264 | - ); |
|
265 | - |
|
266 | - /** |
|
267 | - * Button Hover Colour |
|
268 | - */ |
|
269 | - $wp_customize->add_setting( |
|
270 | - 'lsx_login_button_hover_colour', |
|
271 | - array( |
|
272 | - 'default' => '000000', |
|
273 | - 'type' => 'theme_mod', |
|
274 | - 'transport' => 'postMessage', |
|
275 | - ) |
|
276 | - ); |
|
277 | - $wp_customize->add_control( |
|
278 | - new WP_Customize_Color_Control( |
|
279 | - $wp_customize, |
|
280 | - 'lsx_login_button_hover_colour', |
|
281 | - array( |
|
282 | - 'label' => __( 'Button Hover Colour', 'lsx-customizer' ), |
|
283 | - 'section' => 'login-form', |
|
284 | - 'settings' => 'lsx_login_button_hover_colour', |
|
285 | - ) |
|
286 | - ) |
|
287 | - ); |
|
288 | - |
|
289 | - /** |
|
290 | - * Button Text Colour |
|
291 | - */ |
|
292 | - $wp_customize->add_setting( |
|
293 | - 'lsx_login_button_text_colour', |
|
294 | - array( |
|
295 | - 'default' => '0085ba', |
|
296 | - 'type' => 'theme_mod', |
|
297 | - 'transport' => 'postMessage', |
|
298 | - ) |
|
299 | - ); |
|
300 | - $wp_customize->add_control( |
|
301 | - new WP_Customize_Color_Control( |
|
302 | - $wp_customize, |
|
303 | - 'lsx_login_button_text_colour', |
|
304 | - array( |
|
305 | - 'label' => __( 'Button Text Colour', 'lsx-customizer' ), |
|
306 | - 'section' => 'login-form', |
|
307 | - 'settings' => 'lsx_login_button_text_colour', |
|
308 | - ) |
|
309 | - ) |
|
310 | - ); |
|
311 | - |
|
312 | - } |
|
313 | - |
|
314 | - /** |
|
315 | - * Customizer Controls and Settings. |
|
316 | - * |
|
317 | - * @param WP_Customize_Manager $wp_customize Theme Customizer object. |
|
318 | - * @since 1.0.0 |
|
319 | - */ |
|
320 | - public function register_background( $wp_customize ) { |
|
321 | - $wp_customize->add_section( |
|
322 | - 'login-background', |
|
323 | - array( |
|
324 | - 'title' => esc_html__( 'Background', 'lsx-customizer' ), |
|
325 | - 'priority' => 1, |
|
326 | - 'panel' => 'login', |
|
327 | - ) |
|
328 | - ); |
|
329 | - /** |
|
330 | - * Background Colour |
|
331 | - */ |
|
332 | - $wp_customize->add_setting( |
|
333 | - 'lsx_login_bg_colour', |
|
334 | - array( |
|
335 | - 'default' => 'ffffff', |
|
336 | - 'type' => 'theme_mod', |
|
337 | - 'transport' => 'postMessage', |
|
338 | - ) |
|
339 | - ); |
|
340 | - $wp_customize->add_control( |
|
341 | - new WP_Customize_Color_Control( |
|
342 | - $wp_customize, |
|
343 | - 'lsx_login_bg_colour', |
|
344 | - array( |
|
345 | - 'label' => __( 'Background Colour', 'lsx-customizer' ), |
|
346 | - 'section' => 'login-background', |
|
347 | - 'settings' => 'lsx_login_bg_colour', |
|
348 | - ) |
|
349 | - ) |
|
350 | - ); |
|
351 | - |
|
352 | - /** |
|
353 | - * Upload a Background Image |
|
354 | - */ |
|
355 | - $wp_customize->add_setting( |
|
356 | - 'lsx_login_bg_image', |
|
357 | - array( |
|
358 | - 'default' => '', |
|
359 | - 'type' => 'theme_mod', |
|
360 | - 'transport' => 'postMessage', |
|
361 | - ) |
|
362 | - ); |
|
363 | - |
|
364 | - $wp_customize->add_control( |
|
365 | - new WP_Customize_Image_Control( |
|
366 | - $wp_customize, |
|
367 | - 'lsx_login_bg_image', |
|
368 | - array( |
|
369 | - 'label' => __( 'Background Image', 'lsx-customizer' ), |
|
370 | - 'section' => 'login-background', |
|
371 | - 'settings' => 'lsx_login_bg_image', |
|
372 | - ) |
|
373 | - ) |
|
374 | - ); |
|
375 | - |
|
376 | - /** |
|
377 | - * Select the background repeat. |
|
378 | - */ |
|
379 | - $wp_customize->add_setting( |
|
380 | - 'lsx_login_bg_repeat', |
|
381 | - array( |
|
382 | - 'default' => 'no-repeat', |
|
383 | - 'type' => 'theme_mod', |
|
384 | - 'transport' => 'postMessage', |
|
385 | - ) |
|
386 | - ); |
|
387 | - $wp_customize->add_control( |
|
388 | - new WP_Customize_Control( |
|
389 | - $wp_customize, |
|
390 | - 'lsx_login_bg_repeat', |
|
391 | - array( |
|
392 | - 'label' => __( 'Background Repeat', 'lsx-customizer' ), |
|
393 | - 'section' => 'login-background', |
|
394 | - 'settings' => 'lsx_login_bg_repeat', |
|
395 | - 'type' => 'select', |
|
396 | - 'choices' => array( |
|
397 | - 'no-repeat' => __( 'No Repeat', 'lsx-customizer' ), |
|
398 | - 'repeat' => __( 'Repeat', 'lsx-customizer' ), |
|
399 | - 'repeat-x' => __( 'Repeat Horizontally', 'lsx-customizer' ), |
|
400 | - 'repeat-y' => __( 'Repeat Vertically', 'lsx-customizer' ), |
|
401 | - ), |
|
402 | - ) |
|
403 | - ) |
|
404 | - ); |
|
405 | - |
|
406 | - /** |
|
407 | - * Select the background repeat. |
|
408 | - */ |
|
409 | - $wp_customize->add_setting( |
|
410 | - 'lsx_login_bg_size', |
|
411 | - array( |
|
412 | - 'default' => 'none', |
|
413 | - 'type' => 'theme_mod', |
|
414 | - 'transport' => 'postMessage', |
|
415 | - ) |
|
416 | - ); |
|
417 | - $wp_customize->add_control( |
|
418 | - new WP_Customize_Control( |
|
419 | - $wp_customize, |
|
420 | - 'lsx_login_bg_size', |
|
421 | - array( |
|
422 | - 'label' => __( 'Background Size', 'lsx-customizer' ), |
|
423 | - 'section' => 'login-background', |
|
424 | - 'settings' => 'lsx_login_bg_size', |
|
425 | - 'type' => 'select', |
|
426 | - 'choices' => array( |
|
427 | - 'initial' => __( 'None', 'lsx-customizer' ), |
|
428 | - 'cover' => __( 'Cover', 'lsx-customizer' ), |
|
429 | - 'contain' => __( 'Contain', 'lsx-customizer' ), |
|
430 | - ), |
|
431 | - ) |
|
432 | - ) |
|
433 | - ); |
|
434 | - } |
|
435 | - |
|
436 | - /** |
|
437 | - * Assign CSS to theme mod. |
|
438 | - * |
|
439 | - * @since 1.0.0 |
|
440 | - */ |
|
441 | - public function set_theme_mod() { |
|
442 | - $theme_mods = $this->get_theme_mods(); |
|
443 | - $styles = $this->get_css( $theme_mods ); |
|
444 | - |
|
445 | - set_theme_mod( 'lsx_customizer_login_styles', $styles ); |
|
446 | - } |
|
447 | - |
|
448 | - /** |
|
449 | - * Enqueues front-end CSS. |
|
450 | - * |
|
451 | - * @since 1.0.0 |
|
452 | - */ |
|
453 | - public function enqueue_css() { |
|
454 | - $styles_from_theme_mod = get_theme_mod( 'lsx_customizer_login_styles' ); |
|
455 | - if ( is_customize_preview() || false === $styles_from_theme_mod ) { |
|
456 | - $theme_mods = $this->get_theme_mods(); |
|
457 | - $styles = $this->get_css( $theme_mods ); |
|
458 | - |
|
459 | - if ( false === $styles_from_theme_mod ) { |
|
460 | - set_theme_mod( 'lsx_customizer_login_styles', $styles ); |
|
461 | - } |
|
462 | - } else { |
|
463 | - $styles = $styles_from_theme_mod; |
|
464 | - } |
|
465 | - echo wp_kses( |
|
466 | - $styles, |
|
467 | - array( |
|
468 | - 'style' => array(), |
|
469 | - ) |
|
470 | - ); |
|
471 | - } |
|
472 | - |
|
473 | - /** |
|
474 | - * Get CSS theme mods. |
|
475 | - * |
|
476 | - * @since 1.0.0 |
|
477 | - */ |
|
478 | - public function get_theme_mods() { |
|
479 | - $mods = apply_filters( |
|
480 | - 'lsx_customizer_login_styles', |
|
481 | - array( |
|
482 | - 'logo' => get_theme_mod( 'lsx_login_logo', '' ), |
|
483 | - 'link_colour' => get_theme_mod( 'lsx_login_link_colour', '#0085ba' ), |
|
484 | - 'link_hover_colour' => get_theme_mod( 'lsx_login_link_hover_colour', '#0085ba' ), |
|
485 | - 'button_colour' => get_theme_mod( 'lsx_login_button_colour', '#0085ba' ), |
|
486 | - 'button_shadow_colour' => get_theme_mod( 'lsx_login_button_shadow_colour', '#015d82' ), |
|
487 | - 'button_hover_colour' => get_theme_mod( 'lsx_login_button_hover_colour', '#015d82' ), |
|
488 | - 'button_text_colour' => get_theme_mod( 'lsx_login_button_text_colour', '#ffffff' ), |
|
489 | - 'login_form_colour' => get_theme_mod( 'lsx_login_form_colour', '#ffffff' ), |
|
490 | - 'login_form_label_colour' => get_theme_mod( 'lsx_login_form_label_colour', '#333333' ), |
|
491 | - 'background_colour' => get_theme_mod( 'lsx_login_bg_colour', '#f2f2f2' ), |
|
492 | - 'background_image' => get_theme_mod( 'lsx_login_bg_image', '' ), |
|
493 | - 'background_repeat' => get_theme_mod( 'lsx_login_bg_repeat', 'no-repeat' ), |
|
494 | - 'background_size' => get_theme_mod( 'lsx_login_bg_size', 'initial' ), |
|
495 | - 'custom_css' => get_theme_mod( 'lsx_login_custom_css', '' ), |
|
496 | - ) |
|
497 | - ); |
|
498 | - return $mods; |
|
499 | - } |
|
500 | - |
|
501 | - /** |
|
502 | - * Returns CSS. |
|
503 | - * |
|
504 | - * @since 1.0.0 |
|
505 | - */ |
|
506 | - public function get_css( $theme_mods ) { |
|
507 | - $css = '<style>'; |
|
508 | - |
|
509 | - $css .= "body.login #backtoblog a, body.login #nav a { color: {$theme_mods['link_colour']}; }"; |
|
510 | - $css .= "body.login #nav a:hover, .login h1 a:hover, body.login #backtoblog a:hover { color: {$theme_mods['link_hover_colour']}; }"; |
|
511 | - $css .= "body.login.wp-core-ui .button-primary { background-color: {$theme_mods['button_colour']}; }"; |
|
512 | - $css .= "body.login.wp-core-ui .button-primary { border-color: {$theme_mods['button_colour']}; }"; |
|
513 | - $css .= "body.login.wp-core-ui .button-primary:hover { background-color: {$theme_mods['button_hover_colour']}; }"; |
|
514 | - $css .= "body.login.wp-core-ui .button-primary:hover { border-color: {$theme_mods['button_hover_colour']}; }"; |
|
515 | - $css .= "body.login .button-primary { box-shadow: 0 1px 0 {$theme_mods['button_shadow_colour']}; }"; |
|
516 | - $css .= "body.login .button-primary:active { box-shadow: 0 2px 0 {$theme_mods['button_shadow_colour']}; }"; |
|
517 | - $css .= "body.login .button-primary { color: {$theme_mods['button_text_colour']} ; }"; |
|
518 | - $css .= 'body.login .button-primary { text-shadow: none; }'; |
|
519 | - $css .= "body.login form { background: {$theme_mods['login_form_colour']}; }"; |
|
520 | - $css .= "body.login label { color: {$theme_mods['login_form_label_colour']}; }"; |
|
521 | - |
|
522 | - if ( isset( $theme_mods['logo'] ) && '' !== $theme_mods['logo'] ) { |
|
523 | - $css .= " |
|
4 | + /** |
|
5 | + * LSX Customizer Login Class |
|
6 | + * |
|
7 | + * @package LSX Customizer |
|
8 | + * @author LightSpeed |
|
9 | + * @license GPL3 |
|
10 | + * @link |
|
11 | + * @copyright 2019 LightSpeed |
|
12 | + */ |
|
13 | + class LSX_Customizer_Login extends LSX_Customizer { |
|
14 | + |
|
15 | + /** |
|
16 | + * Constructor. |
|
17 | + * |
|
18 | + * @since 1.0.0 |
|
19 | + */ |
|
20 | + public function __construct() { |
|
21 | + add_action( 'customize_register', array( $this, 'register_general' ), 20 ); |
|
22 | + add_action( 'customize_register', array( $this, 'register_form' ), 30 ); |
|
23 | + add_action( 'customize_register', array( $this, 'register_background' ), 40 ); |
|
24 | + |
|
25 | + add_action( 'after_switch_theme', array( $this, 'set_theme_mod' ) ); |
|
26 | + add_action( 'customize_save_after', array( $this, 'set_theme_mod' ) ); |
|
27 | + add_action( 'login_enqueue_scripts', array( $this, 'enqueue_css' ), 2999 ); |
|
28 | + } |
|
29 | + |
|
30 | + /** |
|
31 | + * Customizer Controls and Settings. |
|
32 | + * |
|
33 | + * @param WP_Customize_Manager $wp_customize Theme Customizer object. |
|
34 | + * @since 1.0.0 |
|
35 | + */ |
|
36 | + public function register_general( $wp_customize ) { |
|
37 | + /** |
|
38 | + * Register the main panel |
|
39 | + */ |
|
40 | + $wp_customize->add_panel( |
|
41 | + 'login', |
|
42 | + array( |
|
43 | + 'title' => esc_html__( 'WP Login Screen', 'lsx-customizer' ), |
|
44 | + 'priority' => 60, |
|
45 | + ) |
|
46 | + ); |
|
47 | + |
|
48 | + /** |
|
49 | + * Reigster the Form section |
|
50 | + */ |
|
51 | + $wp_customize->add_section( |
|
52 | + 'login-general', |
|
53 | + array( |
|
54 | + 'title' => esc_html__( 'General', 'lsx-customizer' ), |
|
55 | + 'priority' => 1, |
|
56 | + 'panel' => 'login', |
|
57 | + ) |
|
58 | + ); |
|
59 | + |
|
60 | + /** |
|
61 | + * Select the background repeat. |
|
62 | + */ |
|
63 | + $wp_customize->add_setting( |
|
64 | + 'lsx_login_logo', |
|
65 | + array( |
|
66 | + 'default' => '', |
|
67 | + 'type' => 'theme_mod', |
|
68 | + 'transport' => 'postMessage', |
|
69 | + ) |
|
70 | + ); |
|
71 | + |
|
72 | + $wp_customize->add_control( |
|
73 | + new WP_Customize_Image_Control( |
|
74 | + $wp_customize, |
|
75 | + 'lsx_login_logo', |
|
76 | + array( |
|
77 | + 'label' => __( 'Upload a logo', 'lsx-customizer' ), |
|
78 | + 'section' => 'login-general', |
|
79 | + 'settings' => 'lsx_login_logo', |
|
80 | + ) |
|
81 | + ) |
|
82 | + ); |
|
83 | + |
|
84 | + /** |
|
85 | + * Link Colour |
|
86 | + */ |
|
87 | + $wp_customize->add_setting( |
|
88 | + 'lsx_login_link_colour', |
|
89 | + array( |
|
90 | + 'default' => '0085ba', |
|
91 | + 'type' => 'theme_mod', |
|
92 | + 'transport' => 'postMessage', |
|
93 | + ) |
|
94 | + ); |
|
95 | + $wp_customize->add_control( |
|
96 | + new WP_Customize_Color_Control( |
|
97 | + $wp_customize, |
|
98 | + 'lsx_login_link_colour', |
|
99 | + array( |
|
100 | + 'label' => __( 'Link Colour', 'lsx-customizer' ), |
|
101 | + 'section' => 'login-general', |
|
102 | + 'settings' => 'lsx_login_link_colour', |
|
103 | + ) |
|
104 | + ) |
|
105 | + ); |
|
106 | + |
|
107 | + /** |
|
108 | + * Link Hover Colour |
|
109 | + */ |
|
110 | + $wp_customize->add_setting( |
|
111 | + 'lsx_login_link_hover_colour', |
|
112 | + array( |
|
113 | + 'default' => '000000', |
|
114 | + 'type' => 'theme_mod', |
|
115 | + 'transport' => 'postMessage', |
|
116 | + ) |
|
117 | + ); |
|
118 | + $wp_customize->add_control( |
|
119 | + new WP_Customize_Color_Control( |
|
120 | + $wp_customize, |
|
121 | + 'lsx_login_link_hover_colour', |
|
122 | + array( |
|
123 | + 'label' => __( 'Link Hover Colour', 'lsx-customizer' ), |
|
124 | + 'section' => 'login-general', |
|
125 | + 'settings' => 'lsx_login_link_hover_colour', |
|
126 | + ) |
|
127 | + ) |
|
128 | + ); |
|
129 | + |
|
130 | + /** |
|
131 | + * Add in the custom CSS. |
|
132 | + */ |
|
133 | + $wp_customize->add_setting( |
|
134 | + 'lsx_login_custom_css', |
|
135 | + array( |
|
136 | + 'default' => '', |
|
137 | + 'type' => 'theme_mod', |
|
138 | + 'transport' => 'postMessage', |
|
139 | + ) |
|
140 | + ); |
|
141 | + $wp_customize->add_control( |
|
142 | + new WP_Customize_Control( |
|
143 | + $wp_customize, |
|
144 | + 'lsx_login_custom_css', |
|
145 | + array( |
|
146 | + 'label' => __( 'Custom CSS', 'lsx-customizer' ), |
|
147 | + 'section' => 'login-general', |
|
148 | + 'settings' => 'lsx_login_custom_css', |
|
149 | + 'type' => 'textarea', |
|
150 | + ) |
|
151 | + ) |
|
152 | + ); |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * Customizer Controls and Settings. |
|
157 | + * |
|
158 | + * @param WP_Customize_Manager $wp_customize Theme Customizer object. |
|
159 | + * @since 1.0.0 |
|
160 | + */ |
|
161 | + public function register_form( $wp_customize ) { |
|
162 | + /** |
|
163 | + * Reigster the Form section |
|
164 | + */ |
|
165 | + $wp_customize->add_section( |
|
166 | + 'login-form', |
|
167 | + array( |
|
168 | + 'title' => esc_html__( 'Form', 'lsx-customizer' ), |
|
169 | + 'priority' => 1, |
|
170 | + 'panel' => 'login', |
|
171 | + ) |
|
172 | + ); |
|
173 | + |
|
174 | + /** |
|
175 | + * Form Background Colour |
|
176 | + */ |
|
177 | + $wp_customize->add_setting( |
|
178 | + 'lsx_login_form_colour', |
|
179 | + array( |
|
180 | + 'default' => 'ffffff', |
|
181 | + 'type' => 'theme_mod', |
|
182 | + 'transport' => 'postMessage', |
|
183 | + ) |
|
184 | + ); |
|
185 | + $wp_customize->add_control( |
|
186 | + new WP_Customize_Color_Control( |
|
187 | + $wp_customize, |
|
188 | + 'lsx_login_form_colour', |
|
189 | + array( |
|
190 | + 'label' => __( 'Form Background Colour', 'lsx-customizer' ), |
|
191 | + 'section' => 'login-form', |
|
192 | + 'settings' => 'lsx_login_form_colour', |
|
193 | + ) |
|
194 | + ) |
|
195 | + ); |
|
196 | + |
|
197 | + /** |
|
198 | + * Form Label Colour |
|
199 | + */ |
|
200 | + $wp_customize->add_setting( |
|
201 | + 'lsx_login_form_label_colour', |
|
202 | + array( |
|
203 | + 'default' => 'ffffff', |
|
204 | + 'type' => 'theme_mod', |
|
205 | + 'transport' => 'postMessage', |
|
206 | + ) |
|
207 | + ); |
|
208 | + $wp_customize->add_control( |
|
209 | + new WP_Customize_Color_Control( |
|
210 | + $wp_customize, |
|
211 | + 'lsx_login_form_label_colour', |
|
212 | + array( |
|
213 | + 'label' => __( 'Form Label Colour', 'lsx-customizer' ), |
|
214 | + 'section' => 'login-form', |
|
215 | + 'settings' => 'lsx_login_form_label_colour', |
|
216 | + ) |
|
217 | + ) |
|
218 | + ); |
|
219 | + |
|
220 | + /** |
|
221 | + * Button Colour |
|
222 | + */ |
|
223 | + $wp_customize->add_setting( |
|
224 | + 'lsx_login_button_colour', |
|
225 | + array( |
|
226 | + 'default' => '000000', |
|
227 | + 'type' => 'theme_mod', |
|
228 | + 'transport' => 'postMessage', |
|
229 | + ) |
|
230 | + ); |
|
231 | + $wp_customize->add_control( |
|
232 | + new WP_Customize_Color_Control( |
|
233 | + $wp_customize, |
|
234 | + 'lsx_login_button_colour', |
|
235 | + array( |
|
236 | + 'label' => __( 'Button Colour', 'lsx-customizer' ), |
|
237 | + 'section' => 'login-form', |
|
238 | + 'settings' => 'lsx_login_button_colour', |
|
239 | + ) |
|
240 | + ) |
|
241 | + ); |
|
242 | + |
|
243 | + /** |
|
244 | + * Button Shadow Colour |
|
245 | + */ |
|
246 | + $wp_customize->add_setting( |
|
247 | + 'lsx_login_button_shadow_colour', |
|
248 | + array( |
|
249 | + 'default' => '015d82', |
|
250 | + 'type' => 'theme_mod', |
|
251 | + 'transport' => 'postMessage', |
|
252 | + ) |
|
253 | + ); |
|
254 | + $wp_customize->add_control( |
|
255 | + new WP_Customize_Color_Control( |
|
256 | + $wp_customize, |
|
257 | + 'lsx_login_button_shadow_colour', |
|
258 | + array( |
|
259 | + 'label' => __( 'Button Shadow Colour', 'lsx-customizer' ), |
|
260 | + 'section' => 'login-form', |
|
261 | + 'settings' => 'lsx_login_button_shadow_colour', |
|
262 | + ) |
|
263 | + ) |
|
264 | + ); |
|
265 | + |
|
266 | + /** |
|
267 | + * Button Hover Colour |
|
268 | + */ |
|
269 | + $wp_customize->add_setting( |
|
270 | + 'lsx_login_button_hover_colour', |
|
271 | + array( |
|
272 | + 'default' => '000000', |
|
273 | + 'type' => 'theme_mod', |
|
274 | + 'transport' => 'postMessage', |
|
275 | + ) |
|
276 | + ); |
|
277 | + $wp_customize->add_control( |
|
278 | + new WP_Customize_Color_Control( |
|
279 | + $wp_customize, |
|
280 | + 'lsx_login_button_hover_colour', |
|
281 | + array( |
|
282 | + 'label' => __( 'Button Hover Colour', 'lsx-customizer' ), |
|
283 | + 'section' => 'login-form', |
|
284 | + 'settings' => 'lsx_login_button_hover_colour', |
|
285 | + ) |
|
286 | + ) |
|
287 | + ); |
|
288 | + |
|
289 | + /** |
|
290 | + * Button Text Colour |
|
291 | + */ |
|
292 | + $wp_customize->add_setting( |
|
293 | + 'lsx_login_button_text_colour', |
|
294 | + array( |
|
295 | + 'default' => '0085ba', |
|
296 | + 'type' => 'theme_mod', |
|
297 | + 'transport' => 'postMessage', |
|
298 | + ) |
|
299 | + ); |
|
300 | + $wp_customize->add_control( |
|
301 | + new WP_Customize_Color_Control( |
|
302 | + $wp_customize, |
|
303 | + 'lsx_login_button_text_colour', |
|
304 | + array( |
|
305 | + 'label' => __( 'Button Text Colour', 'lsx-customizer' ), |
|
306 | + 'section' => 'login-form', |
|
307 | + 'settings' => 'lsx_login_button_text_colour', |
|
308 | + ) |
|
309 | + ) |
|
310 | + ); |
|
311 | + |
|
312 | + } |
|
313 | + |
|
314 | + /** |
|
315 | + * Customizer Controls and Settings. |
|
316 | + * |
|
317 | + * @param WP_Customize_Manager $wp_customize Theme Customizer object. |
|
318 | + * @since 1.0.0 |
|
319 | + */ |
|
320 | + public function register_background( $wp_customize ) { |
|
321 | + $wp_customize->add_section( |
|
322 | + 'login-background', |
|
323 | + array( |
|
324 | + 'title' => esc_html__( 'Background', 'lsx-customizer' ), |
|
325 | + 'priority' => 1, |
|
326 | + 'panel' => 'login', |
|
327 | + ) |
|
328 | + ); |
|
329 | + /** |
|
330 | + * Background Colour |
|
331 | + */ |
|
332 | + $wp_customize->add_setting( |
|
333 | + 'lsx_login_bg_colour', |
|
334 | + array( |
|
335 | + 'default' => 'ffffff', |
|
336 | + 'type' => 'theme_mod', |
|
337 | + 'transport' => 'postMessage', |
|
338 | + ) |
|
339 | + ); |
|
340 | + $wp_customize->add_control( |
|
341 | + new WP_Customize_Color_Control( |
|
342 | + $wp_customize, |
|
343 | + 'lsx_login_bg_colour', |
|
344 | + array( |
|
345 | + 'label' => __( 'Background Colour', 'lsx-customizer' ), |
|
346 | + 'section' => 'login-background', |
|
347 | + 'settings' => 'lsx_login_bg_colour', |
|
348 | + ) |
|
349 | + ) |
|
350 | + ); |
|
351 | + |
|
352 | + /** |
|
353 | + * Upload a Background Image |
|
354 | + */ |
|
355 | + $wp_customize->add_setting( |
|
356 | + 'lsx_login_bg_image', |
|
357 | + array( |
|
358 | + 'default' => '', |
|
359 | + 'type' => 'theme_mod', |
|
360 | + 'transport' => 'postMessage', |
|
361 | + ) |
|
362 | + ); |
|
363 | + |
|
364 | + $wp_customize->add_control( |
|
365 | + new WP_Customize_Image_Control( |
|
366 | + $wp_customize, |
|
367 | + 'lsx_login_bg_image', |
|
368 | + array( |
|
369 | + 'label' => __( 'Background Image', 'lsx-customizer' ), |
|
370 | + 'section' => 'login-background', |
|
371 | + 'settings' => 'lsx_login_bg_image', |
|
372 | + ) |
|
373 | + ) |
|
374 | + ); |
|
375 | + |
|
376 | + /** |
|
377 | + * Select the background repeat. |
|
378 | + */ |
|
379 | + $wp_customize->add_setting( |
|
380 | + 'lsx_login_bg_repeat', |
|
381 | + array( |
|
382 | + 'default' => 'no-repeat', |
|
383 | + 'type' => 'theme_mod', |
|
384 | + 'transport' => 'postMessage', |
|
385 | + ) |
|
386 | + ); |
|
387 | + $wp_customize->add_control( |
|
388 | + new WP_Customize_Control( |
|
389 | + $wp_customize, |
|
390 | + 'lsx_login_bg_repeat', |
|
391 | + array( |
|
392 | + 'label' => __( 'Background Repeat', 'lsx-customizer' ), |
|
393 | + 'section' => 'login-background', |
|
394 | + 'settings' => 'lsx_login_bg_repeat', |
|
395 | + 'type' => 'select', |
|
396 | + 'choices' => array( |
|
397 | + 'no-repeat' => __( 'No Repeat', 'lsx-customizer' ), |
|
398 | + 'repeat' => __( 'Repeat', 'lsx-customizer' ), |
|
399 | + 'repeat-x' => __( 'Repeat Horizontally', 'lsx-customizer' ), |
|
400 | + 'repeat-y' => __( 'Repeat Vertically', 'lsx-customizer' ), |
|
401 | + ), |
|
402 | + ) |
|
403 | + ) |
|
404 | + ); |
|
405 | + |
|
406 | + /** |
|
407 | + * Select the background repeat. |
|
408 | + */ |
|
409 | + $wp_customize->add_setting( |
|
410 | + 'lsx_login_bg_size', |
|
411 | + array( |
|
412 | + 'default' => 'none', |
|
413 | + 'type' => 'theme_mod', |
|
414 | + 'transport' => 'postMessage', |
|
415 | + ) |
|
416 | + ); |
|
417 | + $wp_customize->add_control( |
|
418 | + new WP_Customize_Control( |
|
419 | + $wp_customize, |
|
420 | + 'lsx_login_bg_size', |
|
421 | + array( |
|
422 | + 'label' => __( 'Background Size', 'lsx-customizer' ), |
|
423 | + 'section' => 'login-background', |
|
424 | + 'settings' => 'lsx_login_bg_size', |
|
425 | + 'type' => 'select', |
|
426 | + 'choices' => array( |
|
427 | + 'initial' => __( 'None', 'lsx-customizer' ), |
|
428 | + 'cover' => __( 'Cover', 'lsx-customizer' ), |
|
429 | + 'contain' => __( 'Contain', 'lsx-customizer' ), |
|
430 | + ), |
|
431 | + ) |
|
432 | + ) |
|
433 | + ); |
|
434 | + } |
|
435 | + |
|
436 | + /** |
|
437 | + * Assign CSS to theme mod. |
|
438 | + * |
|
439 | + * @since 1.0.0 |
|
440 | + */ |
|
441 | + public function set_theme_mod() { |
|
442 | + $theme_mods = $this->get_theme_mods(); |
|
443 | + $styles = $this->get_css( $theme_mods ); |
|
444 | + |
|
445 | + set_theme_mod( 'lsx_customizer_login_styles', $styles ); |
|
446 | + } |
|
447 | + |
|
448 | + /** |
|
449 | + * Enqueues front-end CSS. |
|
450 | + * |
|
451 | + * @since 1.0.0 |
|
452 | + */ |
|
453 | + public function enqueue_css() { |
|
454 | + $styles_from_theme_mod = get_theme_mod( 'lsx_customizer_login_styles' ); |
|
455 | + if ( is_customize_preview() || false === $styles_from_theme_mod ) { |
|
456 | + $theme_mods = $this->get_theme_mods(); |
|
457 | + $styles = $this->get_css( $theme_mods ); |
|
458 | + |
|
459 | + if ( false === $styles_from_theme_mod ) { |
|
460 | + set_theme_mod( 'lsx_customizer_login_styles', $styles ); |
|
461 | + } |
|
462 | + } else { |
|
463 | + $styles = $styles_from_theme_mod; |
|
464 | + } |
|
465 | + echo wp_kses( |
|
466 | + $styles, |
|
467 | + array( |
|
468 | + 'style' => array(), |
|
469 | + ) |
|
470 | + ); |
|
471 | + } |
|
472 | + |
|
473 | + /** |
|
474 | + * Get CSS theme mods. |
|
475 | + * |
|
476 | + * @since 1.0.0 |
|
477 | + */ |
|
478 | + public function get_theme_mods() { |
|
479 | + $mods = apply_filters( |
|
480 | + 'lsx_customizer_login_styles', |
|
481 | + array( |
|
482 | + 'logo' => get_theme_mod( 'lsx_login_logo', '' ), |
|
483 | + 'link_colour' => get_theme_mod( 'lsx_login_link_colour', '#0085ba' ), |
|
484 | + 'link_hover_colour' => get_theme_mod( 'lsx_login_link_hover_colour', '#0085ba' ), |
|
485 | + 'button_colour' => get_theme_mod( 'lsx_login_button_colour', '#0085ba' ), |
|
486 | + 'button_shadow_colour' => get_theme_mod( 'lsx_login_button_shadow_colour', '#015d82' ), |
|
487 | + 'button_hover_colour' => get_theme_mod( 'lsx_login_button_hover_colour', '#015d82' ), |
|
488 | + 'button_text_colour' => get_theme_mod( 'lsx_login_button_text_colour', '#ffffff' ), |
|
489 | + 'login_form_colour' => get_theme_mod( 'lsx_login_form_colour', '#ffffff' ), |
|
490 | + 'login_form_label_colour' => get_theme_mod( 'lsx_login_form_label_colour', '#333333' ), |
|
491 | + 'background_colour' => get_theme_mod( 'lsx_login_bg_colour', '#f2f2f2' ), |
|
492 | + 'background_image' => get_theme_mod( 'lsx_login_bg_image', '' ), |
|
493 | + 'background_repeat' => get_theme_mod( 'lsx_login_bg_repeat', 'no-repeat' ), |
|
494 | + 'background_size' => get_theme_mod( 'lsx_login_bg_size', 'initial' ), |
|
495 | + 'custom_css' => get_theme_mod( 'lsx_login_custom_css', '' ), |
|
496 | + ) |
|
497 | + ); |
|
498 | + return $mods; |
|
499 | + } |
|
500 | + |
|
501 | + /** |
|
502 | + * Returns CSS. |
|
503 | + * |
|
504 | + * @since 1.0.0 |
|
505 | + */ |
|
506 | + public function get_css( $theme_mods ) { |
|
507 | + $css = '<style>'; |
|
508 | + |
|
509 | + $css .= "body.login #backtoblog a, body.login #nav a { color: {$theme_mods['link_colour']}; }"; |
|
510 | + $css .= "body.login #nav a:hover, .login h1 a:hover, body.login #backtoblog a:hover { color: {$theme_mods['link_hover_colour']}; }"; |
|
511 | + $css .= "body.login.wp-core-ui .button-primary { background-color: {$theme_mods['button_colour']}; }"; |
|
512 | + $css .= "body.login.wp-core-ui .button-primary { border-color: {$theme_mods['button_colour']}; }"; |
|
513 | + $css .= "body.login.wp-core-ui .button-primary:hover { background-color: {$theme_mods['button_hover_colour']}; }"; |
|
514 | + $css .= "body.login.wp-core-ui .button-primary:hover { border-color: {$theme_mods['button_hover_colour']}; }"; |
|
515 | + $css .= "body.login .button-primary { box-shadow: 0 1px 0 {$theme_mods['button_shadow_colour']}; }"; |
|
516 | + $css .= "body.login .button-primary:active { box-shadow: 0 2px 0 {$theme_mods['button_shadow_colour']}; }"; |
|
517 | + $css .= "body.login .button-primary { color: {$theme_mods['button_text_colour']} ; }"; |
|
518 | + $css .= 'body.login .button-primary { text-shadow: none; }'; |
|
519 | + $css .= "body.login form { background: {$theme_mods['login_form_colour']}; }"; |
|
520 | + $css .= "body.login label { color: {$theme_mods['login_form_label_colour']}; }"; |
|
521 | + |
|
522 | + if ( isset( $theme_mods['logo'] ) && '' !== $theme_mods['logo'] ) { |
|
523 | + $css .= " |
|
524 | 524 | #login h1 a, .login h1 a { |
525 | 525 | background-image: url('" . $theme_mods['logo'] . "'); |
526 | 526 | max-height: 150px; |
@@ -529,22 +529,22 @@ discard block |
||
529 | 529 | background-repeat: no-repeat; |
530 | 530 | } |
531 | 531 | "; |
532 | - } |
|
533 | - |
|
534 | - // Add in the background image options. |
|
535 | - $background_image = ''; |
|
536 | - if ( isset( $theme_mods['background_image'] ) && '' !== $theme_mods['background_image'] ) { |
|
537 | - $background_image = "background-image:url('{$theme_mods['background_image']}');"; |
|
538 | - } |
|
539 | - $background_repeat = ''; |
|
540 | - if ( isset( $theme_mods['background_repeat'] ) && '' !== $theme_mods['background_repeat'] ) { |
|
541 | - $background_repeat = "background-repeat:{$theme_mods['background_repeat']};"; |
|
542 | - } |
|
543 | - $background_size = ''; |
|
544 | - if ( isset( $theme_mods['background_size'] ) && '' !== $theme_mods['background_size'] ) { |
|
545 | - $background_size = "background-size:{$theme_mods['background_size']};"; |
|
546 | - } |
|
547 | - $css .= " |
|
532 | + } |
|
533 | + |
|
534 | + // Add in the background image options. |
|
535 | + $background_image = ''; |
|
536 | + if ( isset( $theme_mods['background_image'] ) && '' !== $theme_mods['background_image'] ) { |
|
537 | + $background_image = "background-image:url('{$theme_mods['background_image']}');"; |
|
538 | + } |
|
539 | + $background_repeat = ''; |
|
540 | + if ( isset( $theme_mods['background_repeat'] ) && '' !== $theme_mods['background_repeat'] ) { |
|
541 | + $background_repeat = "background-repeat:{$theme_mods['background_repeat']};"; |
|
542 | + } |
|
543 | + $background_size = ''; |
|
544 | + if ( isset( $theme_mods['background_size'] ) && '' !== $theme_mods['background_size'] ) { |
|
545 | + $background_size = "background-size:{$theme_mods['background_size']};"; |
|
546 | + } |
|
547 | + $css .= " |
|
548 | 548 | .login { |
549 | 549 | background:{$theme_mods['background_colour']}; |
550 | 550 | {$background_image} |
@@ -555,15 +555,15 @@ discard block |
||
555 | 555 | transition:0.4s; |
556 | 556 | }"; |
557 | 557 | |
558 | - // Add in the custom css |
|
559 | - if ( isset( $theme_mods['custom_css'] ) && '' !== $theme_mods['custom_css'] ) { |
|
560 | - $css .= $theme_mods['custom_css']; |
|
561 | - } |
|
562 | - |
|
563 | - $css .= '</style>'; |
|
564 | - $css = apply_filters( 'lsx_customizer_login_styles', $css ); |
|
565 | - return $css; |
|
566 | - } |
|
567 | - } |
|
568 | - new LSX_Customizer_Login(); |
|
558 | + // Add in the custom css |
|
559 | + if ( isset( $theme_mods['custom_css'] ) && '' !== $theme_mods['custom_css'] ) { |
|
560 | + $css .= $theme_mods['custom_css']; |
|
561 | + } |
|
562 | + |
|
563 | + $css .= '</style>'; |
|
564 | + $css = apply_filters( 'lsx_customizer_login_styles', $css ); |
|
565 | + return $css; |
|
566 | + } |
|
567 | + } |
|
568 | + new LSX_Customizer_Login(); |
|
569 | 569 | } |
@@ -1,375 +1,375 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! class_exists( 'LSX_Customizer_Colour' ) ) { |
3 | 3 | |
4 | - /** |
|
5 | - * LSX Customizer Colour Class |
|
6 | - * |
|
7 | - * @package LSX Customizer |
|
8 | - * @author LightSpeed |
|
9 | - * @license GPL3 |
|
10 | - * @link |
|
11 | - * @copyright 2016 LightSpeed |
|
12 | - */ |
|
13 | - class LSX_Customizer_Colour extends LSX_Customizer { |
|
14 | - |
|
15 | - /** |
|
16 | - * Button customizer instance. |
|
17 | - * |
|
18 | - * @var string |
|
19 | - * @since 1.0.0 |
|
20 | - */ |
|
21 | - public $button; |
|
22 | - |
|
23 | - /** |
|
24 | - * Button CTA customizer instance. |
|
25 | - * |
|
26 | - * @var string |
|
27 | - * @since 1.0.0 |
|
28 | - */ |
|
29 | - public $button_cta; |
|
30 | - |
|
31 | - /** |
|
32 | - * Button secondary customizer instance. |
|
33 | - * |
|
34 | - * @var string |
|
35 | - * @since 1.1.0 |
|
36 | - */ |
|
37 | - public $button_secondary; |
|
38 | - |
|
39 | - /** |
|
40 | - * Button tertiary customizer instance. |
|
41 | - * |
|
42 | - * @var string |
|
43 | - * @since 1.1.0 |
|
44 | - */ |
|
45 | - public $button_tertiary; |
|
46 | - |
|
47 | - /** |
|
48 | - * Top Menu customizer instance. |
|
49 | - * |
|
50 | - * @var string |
|
51 | - * @since 1.0.0 |
|
52 | - */ |
|
53 | - public $top_menu; |
|
54 | - |
|
55 | - /** |
|
56 | - * Header customizer instance. |
|
57 | - * |
|
58 | - * @var string |
|
59 | - * @since 1.0.0 |
|
60 | - */ |
|
61 | - public $header; |
|
62 | - |
|
63 | - /** |
|
64 | - * Main menu customizer instance. |
|
65 | - * |
|
66 | - * @var string |
|
67 | - * @since 1.0.0 |
|
68 | - */ |
|
69 | - public $main_menu; |
|
70 | - |
|
71 | - /** |
|
72 | - * Banner customizer instance. |
|
73 | - * |
|
74 | - * @var string |
|
75 | - * @since 1.0.0 |
|
76 | - */ |
|
77 | - public $banner; |
|
78 | - |
|
79 | - /** |
|
80 | - * Body customizer instance. |
|
81 | - * |
|
82 | - * @var string |
|
83 | - * @since 1.0.0 |
|
84 | - */ |
|
85 | - public $body; |
|
86 | - |
|
87 | - /** |
|
88 | - * Footer CTA customizer instance. |
|
89 | - * |
|
90 | - * @var string |
|
91 | - * @since 1.0.0 |
|
92 | - */ |
|
93 | - public $footer_cta; |
|
94 | - |
|
95 | - /** |
|
96 | - * Footer Widgets customizer instance. |
|
97 | - * |
|
98 | - * @var string |
|
99 | - * @since 1.0.0 |
|
100 | - */ |
|
101 | - public $footer_widgets; |
|
102 | - |
|
103 | - /** |
|
104 | - * Footer customizer instance. |
|
105 | - * |
|
106 | - * @var string |
|
107 | - * @since 1.0.0 |
|
108 | - */ |
|
109 | - public $footer; |
|
110 | - |
|
111 | - /** |
|
112 | - * Constructor. |
|
113 | - * |
|
114 | - * @since 1.0.0 |
|
115 | - */ |
|
116 | - public function __construct() { |
|
117 | - add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ), 20 ); |
|
118 | - add_action( 'customize_register', array( $this, 'customize_register' ), 20 ); |
|
119 | - add_action( 'customize_controls_print_footer_scripts', array( $this, 'colour_scheme_css_template' ) ); |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Customizer Controls and Settings. |
|
124 | - * |
|
125 | - * @param WP_Customize_Manager $wp_customize Theme Customizer object. |
|
126 | - * @since 1.0.0 |
|
127 | - */ |
|
128 | - public function after_setup_theme() { |
|
129 | - require_once( LSX_CUSTOMIZER_PATH . 'includes/lsx-customizer-colour-options.php' ); |
|
130 | - require_once( LSX_CUSTOMIZER_PATH . 'includes/lsx-customizer-colour-deprecated.php' ); |
|
131 | - require_once( LSX_CUSTOMIZER_PATH . 'includes/lsx-customizer-templates.php' ); |
|
132 | - |
|
133 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-button.php' ); |
|
134 | - $this->button = new LSX_Customizer_Colour_Button(); |
|
135 | - |
|
136 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-button-cta.php' ); |
|
137 | - $this->button_cta = new LSX_Customizer_Colour_Button_CTA(); |
|
138 | - |
|
139 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-button-secondary.php' ); |
|
140 | - $this->button_secondary = new LSX_Customizer_Colour_Button_Secondary(); |
|
141 | - |
|
142 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-button-tertiary.php' ); |
|
143 | - $this->button_tertiary = new LSX_Customizer_Colour_Button_Tertiary(); |
|
144 | - |
|
145 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-top-menu.php' ); |
|
146 | - $this->top_menu = new LSX_Customizer_Colour_Top_Menu(); |
|
147 | - |
|
148 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-header.php' ); |
|
149 | - $this->header = new LSX_Customizer_Colour_Header(); |
|
150 | - |
|
151 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-main-menu.php' ); |
|
152 | - $this->main_menu = new LSX_Customizer_Colour_Main_Menu(); |
|
153 | - |
|
154 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-banner.php' ); |
|
155 | - $this->banner = new LSX_Customizer_Colour_Banner(); |
|
156 | - |
|
157 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-body.php' ); |
|
158 | - $this->body = new LSX_Customizer_Colour_Body(); |
|
159 | - |
|
160 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-footer-cta.php' ); |
|
161 | - $this->footer_cta = new LSX_Customizer_Colour_Footer_CTA(); |
|
162 | - |
|
163 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-footer-widgets.php' ); |
|
164 | - $this->footer_widgets = new LSX_Customizer_Colour_Footer_Widgets(); |
|
165 | - |
|
166 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-footer.php' ); |
|
167 | - $this->footer = new LSX_Customizer_Colour_Footer(); |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Customizer Controls and Settings. |
|
172 | - * |
|
173 | - * @param WP_Customize_Manager $wp_customize Theme Customizer object. |
|
174 | - * @since 1.0.0 |
|
175 | - */ |
|
176 | - public function customize_register( $wp_customize ) { |
|
177 | - global $customizer_colour_names; |
|
178 | - global $customizer_colour_choices; |
|
179 | - |
|
180 | - /** |
|
181 | - * Colors |
|
182 | - */ |
|
183 | - $wp_customize->add_panel( 'colors', array( |
|
184 | - 'title' => esc_html__( 'Site Design', 'lsx-customizer' ), |
|
185 | - 'priority' => 60, |
|
186 | - ) ); |
|
187 | - |
|
188 | - $wp_customize->add_section( 'colors-palette', array( |
|
189 | - 'title' => esc_html__( 'Block Editor', 'lsx-customizer' ), |
|
190 | - 'description' => esc_html__( 'Define the block editor colour pallette.', 'lsx-customizer' ), |
|
191 | - 'priority' => 2, |
|
192 | - 'panel' => 'colors', |
|
193 | - ) ); |
|
194 | - |
|
195 | - $wp_customize->add_section( 'colors-button', array( |
|
196 | - 'title' => esc_html__( 'Button', 'lsx-customizer' ), |
|
197 | - 'priority' => 3, |
|
198 | - 'panel' => 'colors', |
|
199 | - ) ); |
|
200 | - |
|
201 | - $wp_customize->add_section( 'colors-button-cta', array( |
|
202 | - 'title' => esc_html__( 'Button CTA', 'lsx-customizer' ), |
|
203 | - 'priority' => 4, |
|
204 | - 'panel' => 'colors', |
|
205 | - ) ); |
|
206 | - |
|
207 | - $wp_customize->add_section( 'colors-button-secondary', array( |
|
208 | - 'title' => esc_html__( 'Button Secondary', 'lsx-customizer' ), |
|
209 | - 'priority' => 5, |
|
210 | - 'panel' => 'colors', |
|
211 | - ) ); |
|
212 | - |
|
213 | - $wp_customize->add_section( 'colors-button-tertiary', array( |
|
214 | - 'title' => esc_html__( 'Button Tertiary', 'lsx-customizer' ), |
|
215 | - 'priority' => 6, |
|
216 | - 'panel' => 'colors', |
|
217 | - ) ); |
|
218 | - |
|
219 | - $wp_customize->add_section( 'colors-top-menu', array( |
|
220 | - 'title' => esc_html__( 'Top Menu', 'lsx-customizer' ), |
|
221 | - 'priority' => 7, |
|
222 | - 'panel' => 'colors', |
|
223 | - ) ); |
|
224 | - |
|
225 | - $wp_customize->add_section( 'colors-header', array( |
|
226 | - 'title' => esc_html__( 'Header', 'lsx-customizer' ), |
|
227 | - 'priority' => 8, |
|
228 | - 'panel' => 'colors', |
|
229 | - ) ); |
|
230 | - |
|
231 | - $wp_customize->add_section( 'colors-main-menu', array( |
|
232 | - 'title' => esc_html__( 'Main Menu', 'lsx-customizer' ), |
|
233 | - 'priority' => 9, |
|
234 | - 'panel' => 'colors', |
|
235 | - ) ); |
|
236 | - |
|
237 | - $wp_customize->add_section( 'colors-banner', array( |
|
238 | - 'title' => esc_html__( 'Banner', 'lsx-customizer' ), |
|
239 | - 'priority' => 10, |
|
240 | - 'panel' => 'colors', |
|
241 | - ) ); |
|
242 | - |
|
243 | - $wp_customize->add_section( 'colors-body', array( |
|
244 | - 'title' => esc_html__( 'Body', 'lsx-customizer' ), |
|
245 | - 'priority' => 11, |
|
246 | - 'panel' => 'colors', |
|
247 | - ) ); |
|
248 | - |
|
249 | - $wp_customize->add_section( 'colors-footer-cta', array( |
|
250 | - 'title' => esc_html__( 'Footer CTA', 'lsx-customizer' ), |
|
251 | - 'priority' => 12, |
|
252 | - 'panel' => 'colors', |
|
253 | - ) ); |
|
254 | - |
|
255 | - $wp_customize->add_section( 'colors-footer-widgets', array( |
|
256 | - 'title' => esc_html__( 'Footer Widgets', 'lsx-customizer' ), |
|
257 | - 'priority' => 13, |
|
258 | - 'panel' => 'colors', |
|
259 | - ) ); |
|
260 | - |
|
261 | - $wp_customize->add_section( 'colors-footer', array( |
|
262 | - 'title' => esc_html__( 'Footer', 'lsx-customizer' ), |
|
263 | - 'priority' => 14, |
|
264 | - 'panel' => 'colors', |
|
265 | - ) ); |
|
266 | - |
|
267 | - /** |
|
268 | - * Colour Palette |
|
269 | - */ |
|
270 | - $colors = $this->get_color_scheme(); |
|
271 | - |
|
272 | - $customizer_colour_defaults = array( |
|
273 | - __( 'Primary Colour', 'lsx-customizer' ) => get_theme_mod( 'button_background_color', $colors['button_background_color'] ), |
|
274 | - __( 'Strong Primary Colour', 'lsx-button_shadow' ) => get_theme_mod( 'button_background_hover_color', $colors['button_background_hover_color'] ), |
|
275 | - __( 'Call To Action Colour', 'lsx-customizer' ) => get_theme_mod( 'button_cta_background_color', $colors['button_cta_background_color'] ), |
|
276 | - __( 'Strong CTA Colour', 'lsx-button_shadow' ) => get_theme_mod( 'button_cta_shadow', $colors['button_cta_shadow'] ), |
|
277 | - __( 'Secondary Colour', 'lsx-customizer' ) => get_theme_mod( 'button_secondary_background_color', $colors['button_secondary_background_color'] ), |
|
278 | - __( 'Strong Secondary Colour', 'lsx-button_shadow' ) => get_theme_mod( 'button_secondary_shadow', $colors['button_secondary_shadow'] ), |
|
279 | - __( 'Tertiary Colour', 'lsx-customizer' ) => get_theme_mod( 'button_tertiary_background_color', $colors['button_tertiary_background_color'] ), |
|
280 | - __( 'Strong Tertiary Colour', 'lsx-button_shadow' ) => get_theme_mod( 'button_tertiary_shadow', $colors['button_tertiary_shadow'] ), |
|
281 | - ); |
|
282 | - foreach ( $customizer_colour_defaults as $key => $value ) { |
|
283 | - |
|
284 | - $color_name = strtolower( str_replace( ' ', '_', $key ) ); |
|
285 | - $color_name = $color_name; |
|
286 | - |
|
287 | - $wp_customize->add_setting( $color_name, array( |
|
288 | - 'default' => $value, |
|
289 | - 'type' => 'theme_mod', |
|
290 | - 'transport' => 'postMessage', |
|
291 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
292 | - ) ); |
|
293 | - $wp_customize->add_control( |
|
294 | - new WP_Customize_Color_Control( |
|
295 | - $wp_customize, |
|
296 | - $color_name, |
|
297 | - array( |
|
298 | - 'label' => $key, |
|
299 | - 'section' => 'colors-palette', |
|
300 | - 'settings' => $color_name, |
|
301 | - ) |
|
302 | - ) |
|
303 | - ); |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * Colors |
|
308 | - */ |
|
309 | - foreach ( $customizer_colour_names as $key => $value ) { |
|
310 | - $sanitize_callback = 'sanitize_hex_color'; |
|
311 | - |
|
312 | - if ( 'background_color' === $key ) { |
|
313 | - $sanitize_callback = 'sanitize_hex_color_no_hash'; |
|
314 | - } |
|
315 | - |
|
316 | - $section = 'colors-core'; |
|
317 | - |
|
318 | - if ( preg_match( '/^button_cta_.*/', $key ) ) { |
|
319 | - $section = 'colors-button-cta'; |
|
320 | - } elseif ( preg_match( '/^button_secondary_.*/', $key ) ) { |
|
321 | - $section = 'colors-button-secondary'; |
|
322 | - } elseif ( preg_match( '/^button_tertiary_.*/', $key ) ) { |
|
323 | - $section = 'colors-button-tertiary'; |
|
324 | - } elseif ( preg_match( '/^button_.*/', $key ) ) { |
|
325 | - $section = 'colors-button'; |
|
326 | - } elseif ( preg_match( '/^top_menu_.*/', $key ) ) { |
|
327 | - $section = 'colors-top-menu'; |
|
328 | - } elseif ( preg_match( '/^header_.*/', $key ) ) { |
|
329 | - $section = 'colors-header'; |
|
330 | - } elseif ( preg_match( '/^main_menu_.*/', $key ) ) { |
|
331 | - $section = 'colors-main-menu'; |
|
332 | - } elseif ( preg_match( '/^banner_.*/', $key ) ) { |
|
333 | - $section = 'colors-banner'; |
|
334 | - } elseif ( preg_match( '/^body_.*/', $key ) || 'background_color' === $key ) { |
|
335 | - $section = 'colors-body'; |
|
336 | - } elseif ( preg_match( '/^footer_cta_.*/', $key ) ) { |
|
337 | - $section = 'colors-footer-cta'; |
|
338 | - } elseif ( preg_match( '/^footer_widgets_.*/', $key ) ) { |
|
339 | - $section = 'colors-footer-widgets'; |
|
340 | - } elseif ( preg_match( '/^footer_.*/', $key ) ) { |
|
341 | - $section = 'colors-footer'; |
|
342 | - } |
|
343 | - |
|
344 | - $wp_customize->add_setting( $key, array( |
|
345 | - 'default' => $customizer_colour_choices['default']['colors'][ $key ], |
|
346 | - 'type' => 'theme_mod', |
|
347 | - 'transport' => 'postMessage', |
|
348 | - 'sanitize_callback' => $sanitize_callback, |
|
349 | - ) ); |
|
350 | - |
|
351 | - $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, $key, array( |
|
352 | - 'label' => $value, |
|
353 | - 'section' => $section, |
|
354 | - 'settings' => $key, |
|
355 | - ) ) ); |
|
356 | - } |
|
357 | - } |
|
358 | - |
|
359 | - /** |
|
360 | - * Outputs an Underscore template for generating CSS for the color scheme. |
|
361 | - * |
|
362 | - * @since 1.0.0 |
|
363 | - */ |
|
364 | - public function colour_scheme_css_template() { |
|
365 | - global $customizer_colour_names; |
|
366 | - |
|
367 | - $colors = array(); |
|
368 | - |
|
369 | - foreach ( $customizer_colour_names as $key => $value ) { |
|
370 | - $colors[ $key ] = 'unquote("{{ data.' . $key . ' }}")'; |
|
371 | - } |
|
372 | - ?> |
|
4 | + /** |
|
5 | + * LSX Customizer Colour Class |
|
6 | + * |
|
7 | + * @package LSX Customizer |
|
8 | + * @author LightSpeed |
|
9 | + * @license GPL3 |
|
10 | + * @link |
|
11 | + * @copyright 2016 LightSpeed |
|
12 | + */ |
|
13 | + class LSX_Customizer_Colour extends LSX_Customizer { |
|
14 | + |
|
15 | + /** |
|
16 | + * Button customizer instance. |
|
17 | + * |
|
18 | + * @var string |
|
19 | + * @since 1.0.0 |
|
20 | + */ |
|
21 | + public $button; |
|
22 | + |
|
23 | + /** |
|
24 | + * Button CTA customizer instance. |
|
25 | + * |
|
26 | + * @var string |
|
27 | + * @since 1.0.0 |
|
28 | + */ |
|
29 | + public $button_cta; |
|
30 | + |
|
31 | + /** |
|
32 | + * Button secondary customizer instance. |
|
33 | + * |
|
34 | + * @var string |
|
35 | + * @since 1.1.0 |
|
36 | + */ |
|
37 | + public $button_secondary; |
|
38 | + |
|
39 | + /** |
|
40 | + * Button tertiary customizer instance. |
|
41 | + * |
|
42 | + * @var string |
|
43 | + * @since 1.1.0 |
|
44 | + */ |
|
45 | + public $button_tertiary; |
|
46 | + |
|
47 | + /** |
|
48 | + * Top Menu customizer instance. |
|
49 | + * |
|
50 | + * @var string |
|
51 | + * @since 1.0.0 |
|
52 | + */ |
|
53 | + public $top_menu; |
|
54 | + |
|
55 | + /** |
|
56 | + * Header customizer instance. |
|
57 | + * |
|
58 | + * @var string |
|
59 | + * @since 1.0.0 |
|
60 | + */ |
|
61 | + public $header; |
|
62 | + |
|
63 | + /** |
|
64 | + * Main menu customizer instance. |
|
65 | + * |
|
66 | + * @var string |
|
67 | + * @since 1.0.0 |
|
68 | + */ |
|
69 | + public $main_menu; |
|
70 | + |
|
71 | + /** |
|
72 | + * Banner customizer instance. |
|
73 | + * |
|
74 | + * @var string |
|
75 | + * @since 1.0.0 |
|
76 | + */ |
|
77 | + public $banner; |
|
78 | + |
|
79 | + /** |
|
80 | + * Body customizer instance. |
|
81 | + * |
|
82 | + * @var string |
|
83 | + * @since 1.0.0 |
|
84 | + */ |
|
85 | + public $body; |
|
86 | + |
|
87 | + /** |
|
88 | + * Footer CTA customizer instance. |
|
89 | + * |
|
90 | + * @var string |
|
91 | + * @since 1.0.0 |
|
92 | + */ |
|
93 | + public $footer_cta; |
|
94 | + |
|
95 | + /** |
|
96 | + * Footer Widgets customizer instance. |
|
97 | + * |
|
98 | + * @var string |
|
99 | + * @since 1.0.0 |
|
100 | + */ |
|
101 | + public $footer_widgets; |
|
102 | + |
|
103 | + /** |
|
104 | + * Footer customizer instance. |
|
105 | + * |
|
106 | + * @var string |
|
107 | + * @since 1.0.0 |
|
108 | + */ |
|
109 | + public $footer; |
|
110 | + |
|
111 | + /** |
|
112 | + * Constructor. |
|
113 | + * |
|
114 | + * @since 1.0.0 |
|
115 | + */ |
|
116 | + public function __construct() { |
|
117 | + add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ), 20 ); |
|
118 | + add_action( 'customize_register', array( $this, 'customize_register' ), 20 ); |
|
119 | + add_action( 'customize_controls_print_footer_scripts', array( $this, 'colour_scheme_css_template' ) ); |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Customizer Controls and Settings. |
|
124 | + * |
|
125 | + * @param WP_Customize_Manager $wp_customize Theme Customizer object. |
|
126 | + * @since 1.0.0 |
|
127 | + */ |
|
128 | + public function after_setup_theme() { |
|
129 | + require_once( LSX_CUSTOMIZER_PATH . 'includes/lsx-customizer-colour-options.php' ); |
|
130 | + require_once( LSX_CUSTOMIZER_PATH . 'includes/lsx-customizer-colour-deprecated.php' ); |
|
131 | + require_once( LSX_CUSTOMIZER_PATH . 'includes/lsx-customizer-templates.php' ); |
|
132 | + |
|
133 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-button.php' ); |
|
134 | + $this->button = new LSX_Customizer_Colour_Button(); |
|
135 | + |
|
136 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-button-cta.php' ); |
|
137 | + $this->button_cta = new LSX_Customizer_Colour_Button_CTA(); |
|
138 | + |
|
139 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-button-secondary.php' ); |
|
140 | + $this->button_secondary = new LSX_Customizer_Colour_Button_Secondary(); |
|
141 | + |
|
142 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-button-tertiary.php' ); |
|
143 | + $this->button_tertiary = new LSX_Customizer_Colour_Button_Tertiary(); |
|
144 | + |
|
145 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-top-menu.php' ); |
|
146 | + $this->top_menu = new LSX_Customizer_Colour_Top_Menu(); |
|
147 | + |
|
148 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-header.php' ); |
|
149 | + $this->header = new LSX_Customizer_Colour_Header(); |
|
150 | + |
|
151 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-main-menu.php' ); |
|
152 | + $this->main_menu = new LSX_Customizer_Colour_Main_Menu(); |
|
153 | + |
|
154 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-banner.php' ); |
|
155 | + $this->banner = new LSX_Customizer_Colour_Banner(); |
|
156 | + |
|
157 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-body.php' ); |
|
158 | + $this->body = new LSX_Customizer_Colour_Body(); |
|
159 | + |
|
160 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-footer-cta.php' ); |
|
161 | + $this->footer_cta = new LSX_Customizer_Colour_Footer_CTA(); |
|
162 | + |
|
163 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-footer-widgets.php' ); |
|
164 | + $this->footer_widgets = new LSX_Customizer_Colour_Footer_Widgets(); |
|
165 | + |
|
166 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour-footer.php' ); |
|
167 | + $this->footer = new LSX_Customizer_Colour_Footer(); |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Customizer Controls and Settings. |
|
172 | + * |
|
173 | + * @param WP_Customize_Manager $wp_customize Theme Customizer object. |
|
174 | + * @since 1.0.0 |
|
175 | + */ |
|
176 | + public function customize_register( $wp_customize ) { |
|
177 | + global $customizer_colour_names; |
|
178 | + global $customizer_colour_choices; |
|
179 | + |
|
180 | + /** |
|
181 | + * Colors |
|
182 | + */ |
|
183 | + $wp_customize->add_panel( 'colors', array( |
|
184 | + 'title' => esc_html__( 'Site Design', 'lsx-customizer' ), |
|
185 | + 'priority' => 60, |
|
186 | + ) ); |
|
187 | + |
|
188 | + $wp_customize->add_section( 'colors-palette', array( |
|
189 | + 'title' => esc_html__( 'Block Editor', 'lsx-customizer' ), |
|
190 | + 'description' => esc_html__( 'Define the block editor colour pallette.', 'lsx-customizer' ), |
|
191 | + 'priority' => 2, |
|
192 | + 'panel' => 'colors', |
|
193 | + ) ); |
|
194 | + |
|
195 | + $wp_customize->add_section( 'colors-button', array( |
|
196 | + 'title' => esc_html__( 'Button', 'lsx-customizer' ), |
|
197 | + 'priority' => 3, |
|
198 | + 'panel' => 'colors', |
|
199 | + ) ); |
|
200 | + |
|
201 | + $wp_customize->add_section( 'colors-button-cta', array( |
|
202 | + 'title' => esc_html__( 'Button CTA', 'lsx-customizer' ), |
|
203 | + 'priority' => 4, |
|
204 | + 'panel' => 'colors', |
|
205 | + ) ); |
|
206 | + |
|
207 | + $wp_customize->add_section( 'colors-button-secondary', array( |
|
208 | + 'title' => esc_html__( 'Button Secondary', 'lsx-customizer' ), |
|
209 | + 'priority' => 5, |
|
210 | + 'panel' => 'colors', |
|
211 | + ) ); |
|
212 | + |
|
213 | + $wp_customize->add_section( 'colors-button-tertiary', array( |
|
214 | + 'title' => esc_html__( 'Button Tertiary', 'lsx-customizer' ), |
|
215 | + 'priority' => 6, |
|
216 | + 'panel' => 'colors', |
|
217 | + ) ); |
|
218 | + |
|
219 | + $wp_customize->add_section( 'colors-top-menu', array( |
|
220 | + 'title' => esc_html__( 'Top Menu', 'lsx-customizer' ), |
|
221 | + 'priority' => 7, |
|
222 | + 'panel' => 'colors', |
|
223 | + ) ); |
|
224 | + |
|
225 | + $wp_customize->add_section( 'colors-header', array( |
|
226 | + 'title' => esc_html__( 'Header', 'lsx-customizer' ), |
|
227 | + 'priority' => 8, |
|
228 | + 'panel' => 'colors', |
|
229 | + ) ); |
|
230 | + |
|
231 | + $wp_customize->add_section( 'colors-main-menu', array( |
|
232 | + 'title' => esc_html__( 'Main Menu', 'lsx-customizer' ), |
|
233 | + 'priority' => 9, |
|
234 | + 'panel' => 'colors', |
|
235 | + ) ); |
|
236 | + |
|
237 | + $wp_customize->add_section( 'colors-banner', array( |
|
238 | + 'title' => esc_html__( 'Banner', 'lsx-customizer' ), |
|
239 | + 'priority' => 10, |
|
240 | + 'panel' => 'colors', |
|
241 | + ) ); |
|
242 | + |
|
243 | + $wp_customize->add_section( 'colors-body', array( |
|
244 | + 'title' => esc_html__( 'Body', 'lsx-customizer' ), |
|
245 | + 'priority' => 11, |
|
246 | + 'panel' => 'colors', |
|
247 | + ) ); |
|
248 | + |
|
249 | + $wp_customize->add_section( 'colors-footer-cta', array( |
|
250 | + 'title' => esc_html__( 'Footer CTA', 'lsx-customizer' ), |
|
251 | + 'priority' => 12, |
|
252 | + 'panel' => 'colors', |
|
253 | + ) ); |
|
254 | + |
|
255 | + $wp_customize->add_section( 'colors-footer-widgets', array( |
|
256 | + 'title' => esc_html__( 'Footer Widgets', 'lsx-customizer' ), |
|
257 | + 'priority' => 13, |
|
258 | + 'panel' => 'colors', |
|
259 | + ) ); |
|
260 | + |
|
261 | + $wp_customize->add_section( 'colors-footer', array( |
|
262 | + 'title' => esc_html__( 'Footer', 'lsx-customizer' ), |
|
263 | + 'priority' => 14, |
|
264 | + 'panel' => 'colors', |
|
265 | + ) ); |
|
266 | + |
|
267 | + /** |
|
268 | + * Colour Palette |
|
269 | + */ |
|
270 | + $colors = $this->get_color_scheme(); |
|
271 | + |
|
272 | + $customizer_colour_defaults = array( |
|
273 | + __( 'Primary Colour', 'lsx-customizer' ) => get_theme_mod( 'button_background_color', $colors['button_background_color'] ), |
|
274 | + __( 'Strong Primary Colour', 'lsx-button_shadow' ) => get_theme_mod( 'button_background_hover_color', $colors['button_background_hover_color'] ), |
|
275 | + __( 'Call To Action Colour', 'lsx-customizer' ) => get_theme_mod( 'button_cta_background_color', $colors['button_cta_background_color'] ), |
|
276 | + __( 'Strong CTA Colour', 'lsx-button_shadow' ) => get_theme_mod( 'button_cta_shadow', $colors['button_cta_shadow'] ), |
|
277 | + __( 'Secondary Colour', 'lsx-customizer' ) => get_theme_mod( 'button_secondary_background_color', $colors['button_secondary_background_color'] ), |
|
278 | + __( 'Strong Secondary Colour', 'lsx-button_shadow' ) => get_theme_mod( 'button_secondary_shadow', $colors['button_secondary_shadow'] ), |
|
279 | + __( 'Tertiary Colour', 'lsx-customizer' ) => get_theme_mod( 'button_tertiary_background_color', $colors['button_tertiary_background_color'] ), |
|
280 | + __( 'Strong Tertiary Colour', 'lsx-button_shadow' ) => get_theme_mod( 'button_tertiary_shadow', $colors['button_tertiary_shadow'] ), |
|
281 | + ); |
|
282 | + foreach ( $customizer_colour_defaults as $key => $value ) { |
|
283 | + |
|
284 | + $color_name = strtolower( str_replace( ' ', '_', $key ) ); |
|
285 | + $color_name = $color_name; |
|
286 | + |
|
287 | + $wp_customize->add_setting( $color_name, array( |
|
288 | + 'default' => $value, |
|
289 | + 'type' => 'theme_mod', |
|
290 | + 'transport' => 'postMessage', |
|
291 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
292 | + ) ); |
|
293 | + $wp_customize->add_control( |
|
294 | + new WP_Customize_Color_Control( |
|
295 | + $wp_customize, |
|
296 | + $color_name, |
|
297 | + array( |
|
298 | + 'label' => $key, |
|
299 | + 'section' => 'colors-palette', |
|
300 | + 'settings' => $color_name, |
|
301 | + ) |
|
302 | + ) |
|
303 | + ); |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * Colors |
|
308 | + */ |
|
309 | + foreach ( $customizer_colour_names as $key => $value ) { |
|
310 | + $sanitize_callback = 'sanitize_hex_color'; |
|
311 | + |
|
312 | + if ( 'background_color' === $key ) { |
|
313 | + $sanitize_callback = 'sanitize_hex_color_no_hash'; |
|
314 | + } |
|
315 | + |
|
316 | + $section = 'colors-core'; |
|
317 | + |
|
318 | + if ( preg_match( '/^button_cta_.*/', $key ) ) { |
|
319 | + $section = 'colors-button-cta'; |
|
320 | + } elseif ( preg_match( '/^button_secondary_.*/', $key ) ) { |
|
321 | + $section = 'colors-button-secondary'; |
|
322 | + } elseif ( preg_match( '/^button_tertiary_.*/', $key ) ) { |
|
323 | + $section = 'colors-button-tertiary'; |
|
324 | + } elseif ( preg_match( '/^button_.*/', $key ) ) { |
|
325 | + $section = 'colors-button'; |
|
326 | + } elseif ( preg_match( '/^top_menu_.*/', $key ) ) { |
|
327 | + $section = 'colors-top-menu'; |
|
328 | + } elseif ( preg_match( '/^header_.*/', $key ) ) { |
|
329 | + $section = 'colors-header'; |
|
330 | + } elseif ( preg_match( '/^main_menu_.*/', $key ) ) { |
|
331 | + $section = 'colors-main-menu'; |
|
332 | + } elseif ( preg_match( '/^banner_.*/', $key ) ) { |
|
333 | + $section = 'colors-banner'; |
|
334 | + } elseif ( preg_match( '/^body_.*/', $key ) || 'background_color' === $key ) { |
|
335 | + $section = 'colors-body'; |
|
336 | + } elseif ( preg_match( '/^footer_cta_.*/', $key ) ) { |
|
337 | + $section = 'colors-footer-cta'; |
|
338 | + } elseif ( preg_match( '/^footer_widgets_.*/', $key ) ) { |
|
339 | + $section = 'colors-footer-widgets'; |
|
340 | + } elseif ( preg_match( '/^footer_.*/', $key ) ) { |
|
341 | + $section = 'colors-footer'; |
|
342 | + } |
|
343 | + |
|
344 | + $wp_customize->add_setting( $key, array( |
|
345 | + 'default' => $customizer_colour_choices['default']['colors'][ $key ], |
|
346 | + 'type' => 'theme_mod', |
|
347 | + 'transport' => 'postMessage', |
|
348 | + 'sanitize_callback' => $sanitize_callback, |
|
349 | + ) ); |
|
350 | + |
|
351 | + $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, $key, array( |
|
352 | + 'label' => $value, |
|
353 | + 'section' => $section, |
|
354 | + 'settings' => $key, |
|
355 | + ) ) ); |
|
356 | + } |
|
357 | + } |
|
358 | + |
|
359 | + /** |
|
360 | + * Outputs an Underscore template for generating CSS for the color scheme. |
|
361 | + * |
|
362 | + * @since 1.0.0 |
|
363 | + */ |
|
364 | + public function colour_scheme_css_template() { |
|
365 | + global $customizer_colour_names; |
|
366 | + |
|
367 | + $colors = array(); |
|
368 | + |
|
369 | + foreach ( $customizer_colour_names as $key => $value ) { |
|
370 | + $colors[ $key ] = 'unquote("{{ data.' . $key . ' }}")'; |
|
371 | + } |
|
372 | + ?> |
|
373 | 373 | <script type="text/html" id="tmpl-lsx-color-scheme"> |
374 | 374 | <?php echo esc_attr( $this->top_menu->get_css( $colors ) ); ?> |
375 | 375 | <?php echo esc_attr( $this->header->get_css( $colors ) ); ?> |
@@ -388,89 +388,89 @@ discard block |
||
388 | 388 | <?php echo esc_attr( $this->button_tertiary->get_css( $colors ) ); ?> |
389 | 389 | </script> |
390 | 390 | <?php |
391 | - } |
|
392 | - |
|
393 | - /** |
|
394 | - * Transform SCSS to CSS. |
|
395 | - * |
|
396 | - * @since 1.0.0 |
|
397 | - */ |
|
398 | - public function scss_to_css( $scss ) { |
|
399 | - $css = ''; |
|
400 | - $scss_php_file = LSX_CUSTOMIZER_PATH . 'vendor/leafo/scssphp/scss.inc.php'; |
|
401 | - $lsx_theme_sass_file = get_template_directory() . '/assets/css/scss/lsx.scss'; |
|
402 | - |
|
403 | - if ( ! empty( $scss ) && file_exists( $scss_php_file ) && file_exists( $lsx_theme_sass_file ) ) { |
|
404 | - require_once $scss_php_file; |
|
405 | - |
|
406 | - $compiler = new \Leafo\ScssPhp\Compiler(); |
|
407 | - $compiler->setFormatter( 'Leafo\ScssPhp\Formatter\Compact' ); |
|
408 | - |
|
409 | - try { |
|
410 | - $scss = ' |
|
391 | + } |
|
392 | + |
|
393 | + /** |
|
394 | + * Transform SCSS to CSS. |
|
395 | + * |
|
396 | + * @since 1.0.0 |
|
397 | + */ |
|
398 | + public function scss_to_css( $scss ) { |
|
399 | + $css = ''; |
|
400 | + $scss_php_file = LSX_CUSTOMIZER_PATH . 'vendor/leafo/scssphp/scss.inc.php'; |
|
401 | + $lsx_theme_sass_file = get_template_directory() . '/assets/css/scss/lsx.scss'; |
|
402 | + |
|
403 | + if ( ! empty( $scss ) && file_exists( $scss_php_file ) && file_exists( $lsx_theme_sass_file ) ) { |
|
404 | + require_once $scss_php_file; |
|
405 | + |
|
406 | + $compiler = new \Leafo\ScssPhp\Compiler(); |
|
407 | + $compiler->setFormatter( 'Leafo\ScssPhp\Formatter\Compact' ); |
|
408 | + |
|
409 | + try { |
|
410 | + $scss = ' |
|
411 | 411 | @import "' . LSX_CUSTOMIZER_PATH . '/assets/css/scss/include-media"; |
412 | 412 | @import "' . get_template_directory() . '/assets/css/scss/global/lsx-variables"; |
413 | 413 | @import "' . get_template_directory() . '/assets/css/scss/global/mixins/colours-helper"; |
414 | 414 | ' . $scss . ' |
415 | 415 | '; |
416 | 416 | |
417 | - $css = $compiler->compile( $scss ); |
|
418 | - } catch ( \Exception $e ) { |
|
419 | - $error = $e->getMessage(); |
|
420 | - return "/*\n\n\$error:\n\n{$error}\n\n\$scss:\n\n{$scss} */"; |
|
421 | - } |
|
422 | - } |
|
423 | - |
|
424 | - return $css; |
|
425 | - } |
|
426 | - |
|
427 | - /** |
|
428 | - * Converts a HEX value to RGB. |
|
429 | - * |
|
430 | - * @since 1.0.0 |
|
431 | - */ |
|
432 | - public static function hex2rgb( $color ) { |
|
433 | - $color = trim( $color, '#' ); |
|
434 | - |
|
435 | - if ( strlen( $color ) === 3 ) { |
|
436 | - $r = hexdec( substr( $color, 0, 1 ) . substr( $color, 0, 1 ) ); |
|
437 | - $g = hexdec( substr( $color, 1, 1 ) . substr( $color, 1, 1 ) ); |
|
438 | - $b = hexdec( substr( $color, 2, 1 ) . substr( $color, 2, 1 ) ); |
|
439 | - } elseif ( strlen( $color ) === 6 ) { |
|
440 | - $r = hexdec( substr( $color, 0, 2 ) ); |
|
441 | - $g = hexdec( substr( $color, 2, 2 ) ); |
|
442 | - $b = hexdec( substr( $color, 4, 2 ) ); |
|
443 | - } else { |
|
444 | - return array(); |
|
445 | - } |
|
446 | - |
|
447 | - return array( |
|
448 | - 'red' => $r, |
|
449 | - 'green' => $g, |
|
450 | - 'blue' => $b, |
|
451 | - ); |
|
452 | - } |
|
453 | - |
|
454 | - /** |
|
455 | - * Retrieves the current color scheme. |
|
456 | - * |
|
457 | - * @since 1.0.0 |
|
458 | - */ |
|
459 | - public function get_color_scheme() { |
|
460 | - global $customizer_colour_choices; |
|
461 | - |
|
462 | - //$color_scheme_option = get_theme_mod( 'color_scheme', 'default' ); |
|
463 | - $color_schemes = $customizer_colour_choices; |
|
464 | - |
|
465 | - // if ( array_key_exists( $color_scheme_option, $color_schemes ) ) { |
|
466 | - // return $color_schemes[ $color_scheme_option ]['colors']; |
|
467 | - // } |
|
468 | - |
|
469 | - return $color_schemes['default']['colors']; |
|
470 | - } |
|
471 | - |
|
472 | - } |
|
473 | - |
|
474 | - new LSX_Customizer_Colour(); |
|
417 | + $css = $compiler->compile( $scss ); |
|
418 | + } catch ( \Exception $e ) { |
|
419 | + $error = $e->getMessage(); |
|
420 | + return "/*\n\n\$error:\n\n{$error}\n\n\$scss:\n\n{$scss} */"; |
|
421 | + } |
|
422 | + } |
|
423 | + |
|
424 | + return $css; |
|
425 | + } |
|
426 | + |
|
427 | + /** |
|
428 | + * Converts a HEX value to RGB. |
|
429 | + * |
|
430 | + * @since 1.0.0 |
|
431 | + */ |
|
432 | + public static function hex2rgb( $color ) { |
|
433 | + $color = trim( $color, '#' ); |
|
434 | + |
|
435 | + if ( strlen( $color ) === 3 ) { |
|
436 | + $r = hexdec( substr( $color, 0, 1 ) . substr( $color, 0, 1 ) ); |
|
437 | + $g = hexdec( substr( $color, 1, 1 ) . substr( $color, 1, 1 ) ); |
|
438 | + $b = hexdec( substr( $color, 2, 1 ) . substr( $color, 2, 1 ) ); |
|
439 | + } elseif ( strlen( $color ) === 6 ) { |
|
440 | + $r = hexdec( substr( $color, 0, 2 ) ); |
|
441 | + $g = hexdec( substr( $color, 2, 2 ) ); |
|
442 | + $b = hexdec( substr( $color, 4, 2 ) ); |
|
443 | + } else { |
|
444 | + return array(); |
|
445 | + } |
|
446 | + |
|
447 | + return array( |
|
448 | + 'red' => $r, |
|
449 | + 'green' => $g, |
|
450 | + 'blue' => $b, |
|
451 | + ); |
|
452 | + } |
|
453 | + |
|
454 | + /** |
|
455 | + * Retrieves the current color scheme. |
|
456 | + * |
|
457 | + * @since 1.0.0 |
|
458 | + */ |
|
459 | + public function get_color_scheme() { |
|
460 | + global $customizer_colour_choices; |
|
461 | + |
|
462 | + //$color_scheme_option = get_theme_mod( 'color_scheme', 'default' ); |
|
463 | + $color_schemes = $customizer_colour_choices; |
|
464 | + |
|
465 | + // if ( array_key_exists( $color_scheme_option, $color_schemes ) ) { |
|
466 | + // return $color_schemes[ $color_scheme_option ]['colors']; |
|
467 | + // } |
|
468 | + |
|
469 | + return $color_schemes['default']['colors']; |
|
470 | + } |
|
471 | + |
|
472 | + } |
|
473 | + |
|
474 | + new LSX_Customizer_Colour(); |
|
475 | 475 | |
476 | 476 | } |
@@ -1,365 +1,365 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! class_exists( 'LSX_Customizer_WooCommerce' ) ) { |
3 | 3 | |
4 | - /** |
|
5 | - * LSX Customizer WooCommerce Class |
|
6 | - * |
|
7 | - * @package LSX Customizer |
|
8 | - * @author LightSpeed |
|
9 | - * @license GPL3 |
|
10 | - * @link |
|
11 | - * @copyright 2016 LightSpeed |
|
12 | - */ |
|
13 | - class LSX_Customizer_WooCommerce extends LSX_Customizer { |
|
14 | - |
|
15 | - /** |
|
16 | - * Constructor. |
|
17 | - * |
|
18 | - * @since 1.1.1 |
|
19 | - */ |
|
20 | - public function __construct() { |
|
21 | - add_action( 'customize_register', array( $this, 'customize_register' ), 20 ); |
|
22 | - |
|
23 | - add_filter( 'body_class', array( $this, 'body_class' ), 2999 ); |
|
24 | - |
|
25 | - add_action( 'template_redirect', array( $this, 'thankyou_page' ), 2999 ); |
|
26 | - |
|
27 | - if ( empty( get_theme_mod( 'lsx_two_step_checkout', false ) ) ) { |
|
28 | - add_action( 'lsx_entry_inside_top', array( $this, 'checkout_steps' ), 15 ); |
|
29 | - } |
|
30 | - |
|
31 | - add_action( 'wp', array( $this, 'cart_extra_html' ), 2999 ); |
|
32 | - add_action( 'wp', array( $this, 'checkout_extra_html' ), 2999 ); |
|
33 | - add_action( 'lsx_wc_cart_menu_item_position', array( $this, 'cart_menu_item_position' ) ); |
|
34 | - add_action( 'lsx_wc_cart_menu_item_class', array( $this, 'cart_menu_item_class' ) ); |
|
35 | - |
|
36 | - add_filter( 'wp_nav_menu_items', array( $this, 'my_account_menu_item' ), 9, 2 ); |
|
37 | - add_action( 'lsx_wc_my_account_menu_item_position', array( $this, 'my_account_menu_item_position' ) ); |
|
38 | - add_action( 'lsx_wc_my_account_menu_item_class', array( $this, 'my_account_menu_item_class' ) ); |
|
39 | - |
|
40 | - // Shop Layout Switcher. |
|
41 | - //add_action( 'wp_head', array( $this, 'show_layout_switcher' ), 1 ); |
|
42 | - //add_filter( 'gridlist_toggle_button_output', array( $this, 'gridlist_toggle_button_output' ), 10, 3 ); |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * Customizer Controls and Settings. |
|
47 | - * |
|
48 | - * @param WP_Customize_Manager $wp_customize Theme Customizer object. |
|
49 | - * @since 1.1.1 |
|
50 | - */ |
|
51 | - public function customize_register( $wp_customize ) { |
|
52 | - /** |
|
53 | - * Checkout. |
|
54 | - */ |
|
55 | - |
|
56 | - $wp_customize->add_section( 'lsx-wc-checkout', array( |
|
57 | - 'title' => esc_html__( 'LSX Checkout', 'lsx-customizer' ), |
|
58 | - 'description' => esc_html__( 'Change the WooCommerce checkout settings.', 'lsx-customizer' ), |
|
59 | - 'panel' => 'woocommerce', |
|
60 | - 'priority' => 3, |
|
61 | - ) ); |
|
62 | - |
|
63 | - $wp_customize->add_setting( 'lsx_checkout_steps', array( |
|
64 | - 'default' => true, |
|
65 | - 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), |
|
66 | - ) ); |
|
67 | - |
|
68 | - $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_checkout_steps', array( |
|
69 | - 'label' => esc_html__( 'Steps', 'lsx-customizer' ), |
|
70 | - 'description' => esc_html__( 'Enable the checkout steps header.', 'lsx-customizer' ), |
|
71 | - 'section' => 'lsx-wc-checkout', |
|
72 | - 'settings' => 'lsx_checkout_steps', |
|
73 | - 'type' => 'checkbox', |
|
74 | - 'priority' => 1, |
|
75 | - ) ) ); |
|
76 | - |
|
77 | - /** |
|
78 | - * Checkout Layout |
|
79 | - */ |
|
80 | - $wp_customize->add_setting( 'lsx_wc_checkout_layout', array( |
|
81 | - 'default' => 'default', |
|
82 | - 'sanitize_callback' => array( $this, 'sanitize_select' ), |
|
83 | - ) ); |
|
84 | - |
|
85 | - $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_checkout_layout', array( |
|
86 | - 'label' => esc_html__( 'Layout', 'lsx-customizer' ), |
|
87 | - 'description' => esc_html__( 'WooCommerce checkout layout.', 'lsx-customizer' ), |
|
88 | - 'section' => 'lsx-wc-checkout', |
|
89 | - 'settings' => 'lsx_wc_checkout_layout', |
|
90 | - 'type' => 'select', |
|
91 | - 'priority' => 2, |
|
92 | - 'choices' => array( |
|
93 | - 'default' => esc_html__( 'Default', 'lsx-customizer' ), |
|
94 | - 'stacked' => esc_html__( 'Stacked', 'lsx-customizer' ), |
|
95 | - 'columns' => esc_html__( 'Columns', 'lsx-customizer' ), |
|
96 | - ), |
|
97 | - ) ) ); |
|
98 | - |
|
99 | - $wp_customize->add_setting( 'lsx_wc_checkout_thankyou_page', array( |
|
100 | - 'default' => '0', |
|
101 | - 'sanitize_callback' => array( $this, 'sanitize_select' ), |
|
102 | - ) ); |
|
103 | - |
|
104 | - $choices = array( |
|
105 | - '0' => esc_html__( 'Default', 'lsx-customizer' ), |
|
106 | - ); |
|
107 | - |
|
108 | - /** |
|
109 | - * Distraction Free Checkout |
|
110 | - */ |
|
111 | - $wp_customize->add_setting( 'lsx_distraction_free_checkout', array( |
|
112 | - 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), |
|
113 | - ) ); |
|
114 | - |
|
115 | - $wp_customize->add_control( new WP_Customize_Control( |
|
116 | - $wp_customize, |
|
117 | - 'lsx_distraction_free_checkout', |
|
118 | - array( |
|
119 | - 'label' => esc_html__( 'Distraction Free Checkout', 'lsx-customizer' ), |
|
120 | - 'description' => esc_html__( 'Removes all clutter from the checkout, allowing the customer to focus entirely on that procedure. Removes the stepped cart and checkout.', 'lsx-customizer' ), |
|
121 | - 'section' => 'lsx-wc-checkout', |
|
122 | - 'settings' => 'lsx_distraction_free_checkout', |
|
123 | - 'type' => 'checkbox', |
|
124 | - 'priority' => 3, |
|
125 | - ) |
|
126 | - ) ); |
|
127 | - |
|
128 | - /** |
|
129 | - * Two Step Checkout |
|
130 | - */ |
|
131 | - $wp_customize->add_setting( 'lsx_two_step_checkout', array( |
|
132 | - 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), |
|
133 | - ) ); |
|
134 | - |
|
135 | - $wp_customize->add_control( new WP_Customize_Control( |
|
136 | - $wp_customize, |
|
137 | - 'lsx_two_step_checkout', |
|
138 | - array( |
|
139 | - 'label' => esc_html__( 'Two Step Checkout', 'lsx-customizer' ), |
|
140 | - 'description' => esc_html__( 'Separates the customer details collection form, and the order summary / payment details form in to two separate pages. Removes the stepped cart and checkout.', 'lsx-customizer' ), |
|
141 | - 'section' => 'lsx-wc-checkout', |
|
142 | - 'settings' => 'lsx_two_step_checkout', |
|
143 | - 'type' => 'checkbox', |
|
144 | - 'priority' => 4, |
|
145 | - ) |
|
146 | - ) ); |
|
147 | - |
|
148 | - /** |
|
149 | - * Thank you page options |
|
150 | - */ |
|
151 | - $pages = get_pages(); |
|
152 | - |
|
153 | - foreach ( $pages as $key => $page ) { |
|
154 | - $choices[ $page->ID ] = $page->post_title; |
|
155 | - } |
|
156 | - |
|
157 | - $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_checkout_thankyou_page', array( |
|
158 | - 'label' => esc_html__( 'Thank You Page', 'lsx-customizer' ), |
|
159 | - 'description' => esc_html__( 'WooCommerce checkout thank you page.', 'lsx-customizer' ), |
|
160 | - 'section' => 'lsx-wc-checkout', |
|
161 | - 'settings' => 'lsx_wc_checkout_thankyou_page', |
|
162 | - 'type' => 'select', |
|
163 | - 'priority' => 5, |
|
164 | - 'choices' => $choices, |
|
165 | - ) ) ); |
|
166 | - |
|
167 | - $wp_customize->add_setting( 'lsx_wc_checkout_extra_html', array( |
|
168 | - 'default' => '', |
|
169 | - 'sanitize_callback' => 'wp_kses_post', |
|
170 | - ) ); |
|
171 | - |
|
172 | - $wp_customize->add_control( new LSX_Customizer_Wysiwyg_Control( $wp_customize, 'lsx_wc_checkout_extra_html', array( |
|
173 | - 'label' => esc_html__( 'Extra HTML', 'lsx-customizer' ), |
|
174 | - 'description' => esc_html__( 'Extra HTML to display at checkout page (bottom/right).', 'lsx-customizer' ), |
|
175 | - 'section' => 'lsx-wc-checkout', |
|
176 | - 'settings' => 'lsx_wc_checkout_extra_html', |
|
177 | - 'priority' => 6, |
|
178 | - 'type' => 'wysiwyg', |
|
179 | - ) ) ); |
|
180 | - |
|
181 | - /** |
|
182 | - * Cart. |
|
183 | - */ |
|
184 | - |
|
185 | - $wp_customize->add_setting( 'lsx_wc_cart_menu_item_style', array( |
|
186 | - 'default' => 'extended', |
|
187 | - 'sanitize_callback' => array( $this, 'sanitize_select' ), |
|
188 | - ) ); |
|
189 | - |
|
190 | - $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_cart_menu_item_style', array( |
|
191 | - 'label' => esc_html__( 'Menu Item Style', 'lsx-customizer' ), |
|
192 | - 'description' => esc_html__( 'WooCommerce menu item cart style.', 'lsx-customizer' ), |
|
193 | - 'section' => 'lsx-wc-cart', |
|
194 | - 'settings' => 'lsx_wc_cart_menu_item_style', |
|
195 | - 'type' => 'select', |
|
196 | - 'priority' => 2, |
|
197 | - 'choices' => array( |
|
198 | - 'simple' => esc_html__( 'Simple', 'lsx-customizer' ), |
|
199 | - 'extended' => esc_html__( 'Extended', 'lsx-customizer' ), |
|
200 | - ), |
|
201 | - ) ) ); |
|
202 | - |
|
203 | - $wp_customize->add_setting( 'lsx_wc_cart_menu_item_position', array( |
|
204 | - 'default' => 'main-menu-in', |
|
205 | - 'sanitize_callback' => array( $this, 'sanitize_select' ), |
|
206 | - ) ); |
|
207 | - |
|
208 | - $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_cart_menu_item_position', array( |
|
209 | - 'label' => esc_html__( 'Menu Item Position', 'lsx-customizer' ), |
|
210 | - 'description' => esc_html__( 'WooCommerce menu item cart position.', 'lsx-customizer' ), |
|
211 | - 'section' => 'lsx-wc-cart', |
|
212 | - 'settings' => 'lsx_wc_cart_menu_item_position', |
|
213 | - 'type' => 'select', |
|
214 | - 'priority' => 3, |
|
215 | - 'choices' => array( |
|
216 | - 'main-menu-in' => esc_html__( 'Main Menu (as last item)', 'lsx-customizer' ), |
|
217 | - 'main-menu-out' => esc_html__( 'Main Menu (as last item, right aligned)', 'lsx-customizer' ), |
|
218 | - 'top-menu-left' => esc_html__( 'Top Menu (left)', 'lsx-customizer' ), |
|
219 | - 'top-menu-right' => esc_html__( 'Top Menu (right)', 'lsx-customizer' ), |
|
220 | - ), |
|
221 | - ) ) ); |
|
222 | - |
|
223 | - $wp_customize->add_setting( 'lsx_wc_cart_extra_html', array( |
|
224 | - 'default' => '', |
|
225 | - 'sanitize_callback' => 'wp_kses_post', |
|
226 | - ) ); |
|
227 | - |
|
228 | - $wp_customize->add_control( new LSX_Customizer_Wysiwyg_Control( $wp_customize, 'lsx_wc_cart_extra_html', array( |
|
229 | - 'label' => esc_html__( 'Extra HTML', 'lsx-customizer' ), |
|
230 | - 'description' => esc_html__( 'Extra HTML to display at cart page (bottom/left).', 'lsx-customizer' ), |
|
231 | - 'section' => 'lsx-wc-cart', |
|
232 | - 'settings' => 'lsx_wc_cart_extra_html', |
|
233 | - 'priority' => 4, |
|
234 | - 'type' => 'wysiwyg', |
|
235 | - ) ) ); |
|
236 | - |
|
237 | - /** |
|
238 | - * My Account. |
|
239 | - */ |
|
240 | - |
|
241 | - $wp_customize->add_section( 'lsx-wc-my-account', array( |
|
242 | - 'title' => esc_html__( 'LSX My Account', 'lsx-customizer' ), |
|
243 | - 'description' => esc_html__( 'Change the WooCommerce My Account settings.', 'lsx-customizer' ), |
|
244 | - 'panel' => 'woocommerce', |
|
245 | - 'priority' => 4, |
|
246 | - ) ); |
|
247 | - |
|
248 | - $wp_customize->add_setting( 'lsx_wc_my_account_menu_item', array( |
|
249 | - 'default' => false, |
|
250 | - 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), |
|
251 | - ) ); |
|
252 | - |
|
253 | - $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_my_account_menu_item', array( |
|
254 | - 'label' => esc_html__( 'Menu Item', 'lsx-customizer' ), |
|
255 | - 'description' => esc_html__( 'Enable the My Account menu item.', 'lsx-customizer' ), |
|
256 | - 'section' => 'lsx-wc-my-account', |
|
257 | - 'settings' => 'lsx_wc_my_account_menu_item', |
|
258 | - 'type' => 'checkbox', |
|
259 | - 'priority' => 1, |
|
260 | - ) ) ); |
|
261 | - |
|
262 | - $wp_customize->add_setting( 'lsx_wc_my_account_menu_item_style', array( |
|
263 | - 'default' => 'extended', |
|
264 | - 'sanitize_callback' => array( $this, 'sanitize_select' ), |
|
265 | - ) ); |
|
266 | - |
|
267 | - $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_my_account_menu_item_style', array( |
|
268 | - 'label' => esc_html__( 'Menu Item Style', 'lsx-customizer' ), |
|
269 | - 'description' => esc_html__( 'WooCommerce menu item My Account style.', 'lsx-customizer' ), |
|
270 | - 'section' => 'lsx-wc-my-account', |
|
271 | - 'settings' => 'lsx_wc_my_account_menu_item_style', |
|
272 | - 'type' => 'select', |
|
273 | - 'priority' => 2, |
|
274 | - 'choices' => array( |
|
275 | - 'simple' => esc_html__( 'Simple', 'lsx-customizer' ), |
|
276 | - 'extended' => esc_html__( 'Extended', 'lsx-customizer' ), |
|
277 | - ), |
|
278 | - ) ) ); |
|
279 | - |
|
280 | - $wp_customize->add_setting( 'lsx_wc_my_account_menu_item_position', array( |
|
281 | - 'default' => 'main-menu-in', |
|
282 | - 'sanitize_callback' => array( $this, 'sanitize_select' ), |
|
283 | - ) ); |
|
284 | - |
|
285 | - $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_my_account_menu_item_position', array( |
|
286 | - 'label' => esc_html__( 'Menu Item Position', 'lsx-customizer' ), |
|
287 | - 'description' => esc_html__( 'WooCommerce menu item My Account position.', 'lsx-customizer' ), |
|
288 | - 'section' => 'lsx-wc-my-account', |
|
289 | - 'settings' => 'lsx_wc_my_account_menu_item_position', |
|
290 | - 'type' => 'select', |
|
291 | - 'priority' => 3, |
|
292 | - 'choices' => array( |
|
293 | - 'main-menu-in' => esc_html__( 'Main Menu (as last item)', 'lsx-customizer' ), |
|
294 | - 'main-menu-out' => esc_html__( 'Main Menu (as last item, right aligned)', 'lsx-customizer' ), |
|
295 | - 'top-menu-left' => esc_html__( 'Top Menu (left)', 'lsx-customizer' ), |
|
296 | - 'top-menu-right' => esc_html__( 'Top Menu (right)', 'lsx-customizer' ), |
|
297 | - ), |
|
298 | - ) ) ); |
|
299 | - } |
|
300 | - |
|
301 | - /** |
|
302 | - * Add and remove WC body_class() classes. |
|
303 | - * |
|
304 | - * @since 1.1.1 |
|
305 | - */ |
|
306 | - public function body_class( $classes ) { |
|
307 | - $distraction_free = get_theme_mod( 'lsx_distraction_free_checkout', false ); |
|
308 | - $two_step_checkout = get_theme_mod( 'lsx_two_step_checkout', false ); |
|
309 | - if ( is_checkout() ) { |
|
310 | - $layout = get_theme_mod( 'lsx_wc_checkout_layout', 'default' ); |
|
311 | - |
|
312 | - if ( 'default' === $layout ) { |
|
313 | - $classes[] = 'lsx-wc-checkout-layout-default'; |
|
314 | - } elseif ( 'stacked' === $layout ) { |
|
315 | - $classes[] = 'lsx-wc-checkout-layout-stacked'; |
|
316 | - } elseif ( 'columns' === $layout ) { |
|
317 | - $classes[] = 'lsx-wc-checkout-layout-two-column-addreses'; |
|
318 | - } |
|
319 | - if ( ! empty( $distraction_free ) ) { |
|
320 | - $classes[] = 'lsx-wc-checkout-distraction-free'; |
|
321 | - } |
|
322 | - if ( ! empty( $two_step_checkout ) ) { |
|
323 | - $classes[] = 'lsx-wc-checkout-two-steps'; |
|
324 | - } |
|
325 | - } |
|
326 | - |
|
327 | - return $classes; |
|
328 | - } |
|
329 | - |
|
330 | - /** |
|
331 | - * WC thank you page. |
|
332 | - * |
|
333 | - * @since 1.1.1 |
|
334 | - */ |
|
335 | - public function thankyou_page() { |
|
336 | - global $wp; |
|
337 | - |
|
338 | - if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) { |
|
339 | - $thankyou_page = get_theme_mod( 'lsx_wc_checkout_thankyou_page', '0' ); |
|
340 | - |
|
341 | - if ( ! empty( $thankyou_page ) && ! is_page( $thankyou_page ) ) { |
|
342 | - $order_id = apply_filters( 'woocommerce_thankyou_order_id', absint( $wp->query_vars['order-received'] ) ); |
|
343 | - $order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( $_GET['key'] ) ); |
|
344 | - |
|
345 | - if ( $order_id > 0 ) { |
|
346 | - wp_safe_redirect( get_permalink( $thankyou_page ) . '?order-received=' . $order_id . '&key=' . $order_key, 302 ); |
|
347 | - exit; |
|
348 | - } |
|
349 | - } |
|
350 | - } |
|
351 | - } |
|
352 | - |
|
353 | - /** |
|
354 | - * Display WC checkout steps. |
|
355 | - * |
|
356 | - * @since 1.1.1 |
|
357 | - */ |
|
358 | - public function checkout_steps() { |
|
359 | - $cart_url = function_exists( 'wc_get_cart_url' ) ? wc_get_cart_url() : WC()->cart->get_cart_url(); |
|
360 | - if ( ( is_checkout() || is_cart() ) && ! empty( get_theme_mod( 'lsx_checkout_steps', '1' ) ) ) : |
|
361 | - global $wp; |
|
362 | - ?> |
|
4 | + /** |
|
5 | + * LSX Customizer WooCommerce Class |
|
6 | + * |
|
7 | + * @package LSX Customizer |
|
8 | + * @author LightSpeed |
|
9 | + * @license GPL3 |
|
10 | + * @link |
|
11 | + * @copyright 2016 LightSpeed |
|
12 | + */ |
|
13 | + class LSX_Customizer_WooCommerce extends LSX_Customizer { |
|
14 | + |
|
15 | + /** |
|
16 | + * Constructor. |
|
17 | + * |
|
18 | + * @since 1.1.1 |
|
19 | + */ |
|
20 | + public function __construct() { |
|
21 | + add_action( 'customize_register', array( $this, 'customize_register' ), 20 ); |
|
22 | + |
|
23 | + add_filter( 'body_class', array( $this, 'body_class' ), 2999 ); |
|
24 | + |
|
25 | + add_action( 'template_redirect', array( $this, 'thankyou_page' ), 2999 ); |
|
26 | + |
|
27 | + if ( empty( get_theme_mod( 'lsx_two_step_checkout', false ) ) ) { |
|
28 | + add_action( 'lsx_entry_inside_top', array( $this, 'checkout_steps' ), 15 ); |
|
29 | + } |
|
30 | + |
|
31 | + add_action( 'wp', array( $this, 'cart_extra_html' ), 2999 ); |
|
32 | + add_action( 'wp', array( $this, 'checkout_extra_html' ), 2999 ); |
|
33 | + add_action( 'lsx_wc_cart_menu_item_position', array( $this, 'cart_menu_item_position' ) ); |
|
34 | + add_action( 'lsx_wc_cart_menu_item_class', array( $this, 'cart_menu_item_class' ) ); |
|
35 | + |
|
36 | + add_filter( 'wp_nav_menu_items', array( $this, 'my_account_menu_item' ), 9, 2 ); |
|
37 | + add_action( 'lsx_wc_my_account_menu_item_position', array( $this, 'my_account_menu_item_position' ) ); |
|
38 | + add_action( 'lsx_wc_my_account_menu_item_class', array( $this, 'my_account_menu_item_class' ) ); |
|
39 | + |
|
40 | + // Shop Layout Switcher. |
|
41 | + //add_action( 'wp_head', array( $this, 'show_layout_switcher' ), 1 ); |
|
42 | + //add_filter( 'gridlist_toggle_button_output', array( $this, 'gridlist_toggle_button_output' ), 10, 3 ); |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * Customizer Controls and Settings. |
|
47 | + * |
|
48 | + * @param WP_Customize_Manager $wp_customize Theme Customizer object. |
|
49 | + * @since 1.1.1 |
|
50 | + */ |
|
51 | + public function customize_register( $wp_customize ) { |
|
52 | + /** |
|
53 | + * Checkout. |
|
54 | + */ |
|
55 | + |
|
56 | + $wp_customize->add_section( 'lsx-wc-checkout', array( |
|
57 | + 'title' => esc_html__( 'LSX Checkout', 'lsx-customizer' ), |
|
58 | + 'description' => esc_html__( 'Change the WooCommerce checkout settings.', 'lsx-customizer' ), |
|
59 | + 'panel' => 'woocommerce', |
|
60 | + 'priority' => 3, |
|
61 | + ) ); |
|
62 | + |
|
63 | + $wp_customize->add_setting( 'lsx_checkout_steps', array( |
|
64 | + 'default' => true, |
|
65 | + 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), |
|
66 | + ) ); |
|
67 | + |
|
68 | + $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_checkout_steps', array( |
|
69 | + 'label' => esc_html__( 'Steps', 'lsx-customizer' ), |
|
70 | + 'description' => esc_html__( 'Enable the checkout steps header.', 'lsx-customizer' ), |
|
71 | + 'section' => 'lsx-wc-checkout', |
|
72 | + 'settings' => 'lsx_checkout_steps', |
|
73 | + 'type' => 'checkbox', |
|
74 | + 'priority' => 1, |
|
75 | + ) ) ); |
|
76 | + |
|
77 | + /** |
|
78 | + * Checkout Layout |
|
79 | + */ |
|
80 | + $wp_customize->add_setting( 'lsx_wc_checkout_layout', array( |
|
81 | + 'default' => 'default', |
|
82 | + 'sanitize_callback' => array( $this, 'sanitize_select' ), |
|
83 | + ) ); |
|
84 | + |
|
85 | + $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_checkout_layout', array( |
|
86 | + 'label' => esc_html__( 'Layout', 'lsx-customizer' ), |
|
87 | + 'description' => esc_html__( 'WooCommerce checkout layout.', 'lsx-customizer' ), |
|
88 | + 'section' => 'lsx-wc-checkout', |
|
89 | + 'settings' => 'lsx_wc_checkout_layout', |
|
90 | + 'type' => 'select', |
|
91 | + 'priority' => 2, |
|
92 | + 'choices' => array( |
|
93 | + 'default' => esc_html__( 'Default', 'lsx-customizer' ), |
|
94 | + 'stacked' => esc_html__( 'Stacked', 'lsx-customizer' ), |
|
95 | + 'columns' => esc_html__( 'Columns', 'lsx-customizer' ), |
|
96 | + ), |
|
97 | + ) ) ); |
|
98 | + |
|
99 | + $wp_customize->add_setting( 'lsx_wc_checkout_thankyou_page', array( |
|
100 | + 'default' => '0', |
|
101 | + 'sanitize_callback' => array( $this, 'sanitize_select' ), |
|
102 | + ) ); |
|
103 | + |
|
104 | + $choices = array( |
|
105 | + '0' => esc_html__( 'Default', 'lsx-customizer' ), |
|
106 | + ); |
|
107 | + |
|
108 | + /** |
|
109 | + * Distraction Free Checkout |
|
110 | + */ |
|
111 | + $wp_customize->add_setting( 'lsx_distraction_free_checkout', array( |
|
112 | + 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), |
|
113 | + ) ); |
|
114 | + |
|
115 | + $wp_customize->add_control( new WP_Customize_Control( |
|
116 | + $wp_customize, |
|
117 | + 'lsx_distraction_free_checkout', |
|
118 | + array( |
|
119 | + 'label' => esc_html__( 'Distraction Free Checkout', 'lsx-customizer' ), |
|
120 | + 'description' => esc_html__( 'Removes all clutter from the checkout, allowing the customer to focus entirely on that procedure. Removes the stepped cart and checkout.', 'lsx-customizer' ), |
|
121 | + 'section' => 'lsx-wc-checkout', |
|
122 | + 'settings' => 'lsx_distraction_free_checkout', |
|
123 | + 'type' => 'checkbox', |
|
124 | + 'priority' => 3, |
|
125 | + ) |
|
126 | + ) ); |
|
127 | + |
|
128 | + /** |
|
129 | + * Two Step Checkout |
|
130 | + */ |
|
131 | + $wp_customize->add_setting( 'lsx_two_step_checkout', array( |
|
132 | + 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), |
|
133 | + ) ); |
|
134 | + |
|
135 | + $wp_customize->add_control( new WP_Customize_Control( |
|
136 | + $wp_customize, |
|
137 | + 'lsx_two_step_checkout', |
|
138 | + array( |
|
139 | + 'label' => esc_html__( 'Two Step Checkout', 'lsx-customizer' ), |
|
140 | + 'description' => esc_html__( 'Separates the customer details collection form, and the order summary / payment details form in to two separate pages. Removes the stepped cart and checkout.', 'lsx-customizer' ), |
|
141 | + 'section' => 'lsx-wc-checkout', |
|
142 | + 'settings' => 'lsx_two_step_checkout', |
|
143 | + 'type' => 'checkbox', |
|
144 | + 'priority' => 4, |
|
145 | + ) |
|
146 | + ) ); |
|
147 | + |
|
148 | + /** |
|
149 | + * Thank you page options |
|
150 | + */ |
|
151 | + $pages = get_pages(); |
|
152 | + |
|
153 | + foreach ( $pages as $key => $page ) { |
|
154 | + $choices[ $page->ID ] = $page->post_title; |
|
155 | + } |
|
156 | + |
|
157 | + $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_checkout_thankyou_page', array( |
|
158 | + 'label' => esc_html__( 'Thank You Page', 'lsx-customizer' ), |
|
159 | + 'description' => esc_html__( 'WooCommerce checkout thank you page.', 'lsx-customizer' ), |
|
160 | + 'section' => 'lsx-wc-checkout', |
|
161 | + 'settings' => 'lsx_wc_checkout_thankyou_page', |
|
162 | + 'type' => 'select', |
|
163 | + 'priority' => 5, |
|
164 | + 'choices' => $choices, |
|
165 | + ) ) ); |
|
166 | + |
|
167 | + $wp_customize->add_setting( 'lsx_wc_checkout_extra_html', array( |
|
168 | + 'default' => '', |
|
169 | + 'sanitize_callback' => 'wp_kses_post', |
|
170 | + ) ); |
|
171 | + |
|
172 | + $wp_customize->add_control( new LSX_Customizer_Wysiwyg_Control( $wp_customize, 'lsx_wc_checkout_extra_html', array( |
|
173 | + 'label' => esc_html__( 'Extra HTML', 'lsx-customizer' ), |
|
174 | + 'description' => esc_html__( 'Extra HTML to display at checkout page (bottom/right).', 'lsx-customizer' ), |
|
175 | + 'section' => 'lsx-wc-checkout', |
|
176 | + 'settings' => 'lsx_wc_checkout_extra_html', |
|
177 | + 'priority' => 6, |
|
178 | + 'type' => 'wysiwyg', |
|
179 | + ) ) ); |
|
180 | + |
|
181 | + /** |
|
182 | + * Cart. |
|
183 | + */ |
|
184 | + |
|
185 | + $wp_customize->add_setting( 'lsx_wc_cart_menu_item_style', array( |
|
186 | + 'default' => 'extended', |
|
187 | + 'sanitize_callback' => array( $this, 'sanitize_select' ), |
|
188 | + ) ); |
|
189 | + |
|
190 | + $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_cart_menu_item_style', array( |
|
191 | + 'label' => esc_html__( 'Menu Item Style', 'lsx-customizer' ), |
|
192 | + 'description' => esc_html__( 'WooCommerce menu item cart style.', 'lsx-customizer' ), |
|
193 | + 'section' => 'lsx-wc-cart', |
|
194 | + 'settings' => 'lsx_wc_cart_menu_item_style', |
|
195 | + 'type' => 'select', |
|
196 | + 'priority' => 2, |
|
197 | + 'choices' => array( |
|
198 | + 'simple' => esc_html__( 'Simple', 'lsx-customizer' ), |
|
199 | + 'extended' => esc_html__( 'Extended', 'lsx-customizer' ), |
|
200 | + ), |
|
201 | + ) ) ); |
|
202 | + |
|
203 | + $wp_customize->add_setting( 'lsx_wc_cart_menu_item_position', array( |
|
204 | + 'default' => 'main-menu-in', |
|
205 | + 'sanitize_callback' => array( $this, 'sanitize_select' ), |
|
206 | + ) ); |
|
207 | + |
|
208 | + $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_cart_menu_item_position', array( |
|
209 | + 'label' => esc_html__( 'Menu Item Position', 'lsx-customizer' ), |
|
210 | + 'description' => esc_html__( 'WooCommerce menu item cart position.', 'lsx-customizer' ), |
|
211 | + 'section' => 'lsx-wc-cart', |
|
212 | + 'settings' => 'lsx_wc_cart_menu_item_position', |
|
213 | + 'type' => 'select', |
|
214 | + 'priority' => 3, |
|
215 | + 'choices' => array( |
|
216 | + 'main-menu-in' => esc_html__( 'Main Menu (as last item)', 'lsx-customizer' ), |
|
217 | + 'main-menu-out' => esc_html__( 'Main Menu (as last item, right aligned)', 'lsx-customizer' ), |
|
218 | + 'top-menu-left' => esc_html__( 'Top Menu (left)', 'lsx-customizer' ), |
|
219 | + 'top-menu-right' => esc_html__( 'Top Menu (right)', 'lsx-customizer' ), |
|
220 | + ), |
|
221 | + ) ) ); |
|
222 | + |
|
223 | + $wp_customize->add_setting( 'lsx_wc_cart_extra_html', array( |
|
224 | + 'default' => '', |
|
225 | + 'sanitize_callback' => 'wp_kses_post', |
|
226 | + ) ); |
|
227 | + |
|
228 | + $wp_customize->add_control( new LSX_Customizer_Wysiwyg_Control( $wp_customize, 'lsx_wc_cart_extra_html', array( |
|
229 | + 'label' => esc_html__( 'Extra HTML', 'lsx-customizer' ), |
|
230 | + 'description' => esc_html__( 'Extra HTML to display at cart page (bottom/left).', 'lsx-customizer' ), |
|
231 | + 'section' => 'lsx-wc-cart', |
|
232 | + 'settings' => 'lsx_wc_cart_extra_html', |
|
233 | + 'priority' => 4, |
|
234 | + 'type' => 'wysiwyg', |
|
235 | + ) ) ); |
|
236 | + |
|
237 | + /** |
|
238 | + * My Account. |
|
239 | + */ |
|
240 | + |
|
241 | + $wp_customize->add_section( 'lsx-wc-my-account', array( |
|
242 | + 'title' => esc_html__( 'LSX My Account', 'lsx-customizer' ), |
|
243 | + 'description' => esc_html__( 'Change the WooCommerce My Account settings.', 'lsx-customizer' ), |
|
244 | + 'panel' => 'woocommerce', |
|
245 | + 'priority' => 4, |
|
246 | + ) ); |
|
247 | + |
|
248 | + $wp_customize->add_setting( 'lsx_wc_my_account_menu_item', array( |
|
249 | + 'default' => false, |
|
250 | + 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), |
|
251 | + ) ); |
|
252 | + |
|
253 | + $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_my_account_menu_item', array( |
|
254 | + 'label' => esc_html__( 'Menu Item', 'lsx-customizer' ), |
|
255 | + 'description' => esc_html__( 'Enable the My Account menu item.', 'lsx-customizer' ), |
|
256 | + 'section' => 'lsx-wc-my-account', |
|
257 | + 'settings' => 'lsx_wc_my_account_menu_item', |
|
258 | + 'type' => 'checkbox', |
|
259 | + 'priority' => 1, |
|
260 | + ) ) ); |
|
261 | + |
|
262 | + $wp_customize->add_setting( 'lsx_wc_my_account_menu_item_style', array( |
|
263 | + 'default' => 'extended', |
|
264 | + 'sanitize_callback' => array( $this, 'sanitize_select' ), |
|
265 | + ) ); |
|
266 | + |
|
267 | + $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_my_account_menu_item_style', array( |
|
268 | + 'label' => esc_html__( 'Menu Item Style', 'lsx-customizer' ), |
|
269 | + 'description' => esc_html__( 'WooCommerce menu item My Account style.', 'lsx-customizer' ), |
|
270 | + 'section' => 'lsx-wc-my-account', |
|
271 | + 'settings' => 'lsx_wc_my_account_menu_item_style', |
|
272 | + 'type' => 'select', |
|
273 | + 'priority' => 2, |
|
274 | + 'choices' => array( |
|
275 | + 'simple' => esc_html__( 'Simple', 'lsx-customizer' ), |
|
276 | + 'extended' => esc_html__( 'Extended', 'lsx-customizer' ), |
|
277 | + ), |
|
278 | + ) ) ); |
|
279 | + |
|
280 | + $wp_customize->add_setting( 'lsx_wc_my_account_menu_item_position', array( |
|
281 | + 'default' => 'main-menu-in', |
|
282 | + 'sanitize_callback' => array( $this, 'sanitize_select' ), |
|
283 | + ) ); |
|
284 | + |
|
285 | + $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_my_account_menu_item_position', array( |
|
286 | + 'label' => esc_html__( 'Menu Item Position', 'lsx-customizer' ), |
|
287 | + 'description' => esc_html__( 'WooCommerce menu item My Account position.', 'lsx-customizer' ), |
|
288 | + 'section' => 'lsx-wc-my-account', |
|
289 | + 'settings' => 'lsx_wc_my_account_menu_item_position', |
|
290 | + 'type' => 'select', |
|
291 | + 'priority' => 3, |
|
292 | + 'choices' => array( |
|
293 | + 'main-menu-in' => esc_html__( 'Main Menu (as last item)', 'lsx-customizer' ), |
|
294 | + 'main-menu-out' => esc_html__( 'Main Menu (as last item, right aligned)', 'lsx-customizer' ), |
|
295 | + 'top-menu-left' => esc_html__( 'Top Menu (left)', 'lsx-customizer' ), |
|
296 | + 'top-menu-right' => esc_html__( 'Top Menu (right)', 'lsx-customizer' ), |
|
297 | + ), |
|
298 | + ) ) ); |
|
299 | + } |
|
300 | + |
|
301 | + /** |
|
302 | + * Add and remove WC body_class() classes. |
|
303 | + * |
|
304 | + * @since 1.1.1 |
|
305 | + */ |
|
306 | + public function body_class( $classes ) { |
|
307 | + $distraction_free = get_theme_mod( 'lsx_distraction_free_checkout', false ); |
|
308 | + $two_step_checkout = get_theme_mod( 'lsx_two_step_checkout', false ); |
|
309 | + if ( is_checkout() ) { |
|
310 | + $layout = get_theme_mod( 'lsx_wc_checkout_layout', 'default' ); |
|
311 | + |
|
312 | + if ( 'default' === $layout ) { |
|
313 | + $classes[] = 'lsx-wc-checkout-layout-default'; |
|
314 | + } elseif ( 'stacked' === $layout ) { |
|
315 | + $classes[] = 'lsx-wc-checkout-layout-stacked'; |
|
316 | + } elseif ( 'columns' === $layout ) { |
|
317 | + $classes[] = 'lsx-wc-checkout-layout-two-column-addreses'; |
|
318 | + } |
|
319 | + if ( ! empty( $distraction_free ) ) { |
|
320 | + $classes[] = 'lsx-wc-checkout-distraction-free'; |
|
321 | + } |
|
322 | + if ( ! empty( $two_step_checkout ) ) { |
|
323 | + $classes[] = 'lsx-wc-checkout-two-steps'; |
|
324 | + } |
|
325 | + } |
|
326 | + |
|
327 | + return $classes; |
|
328 | + } |
|
329 | + |
|
330 | + /** |
|
331 | + * WC thank you page. |
|
332 | + * |
|
333 | + * @since 1.1.1 |
|
334 | + */ |
|
335 | + public function thankyou_page() { |
|
336 | + global $wp; |
|
337 | + |
|
338 | + if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) { |
|
339 | + $thankyou_page = get_theme_mod( 'lsx_wc_checkout_thankyou_page', '0' ); |
|
340 | + |
|
341 | + if ( ! empty( $thankyou_page ) && ! is_page( $thankyou_page ) ) { |
|
342 | + $order_id = apply_filters( 'woocommerce_thankyou_order_id', absint( $wp->query_vars['order-received'] ) ); |
|
343 | + $order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( $_GET['key'] ) ); |
|
344 | + |
|
345 | + if ( $order_id > 0 ) { |
|
346 | + wp_safe_redirect( get_permalink( $thankyou_page ) . '?order-received=' . $order_id . '&key=' . $order_key, 302 ); |
|
347 | + exit; |
|
348 | + } |
|
349 | + } |
|
350 | + } |
|
351 | + } |
|
352 | + |
|
353 | + /** |
|
354 | + * Display WC checkout steps. |
|
355 | + * |
|
356 | + * @since 1.1.1 |
|
357 | + */ |
|
358 | + public function checkout_steps() { |
|
359 | + $cart_url = function_exists( 'wc_get_cart_url' ) ? wc_get_cart_url() : WC()->cart->get_cart_url(); |
|
360 | + if ( ( is_checkout() || is_cart() ) && ! empty( get_theme_mod( 'lsx_checkout_steps', '1' ) ) ) : |
|
361 | + global $wp; |
|
362 | + ?> |
|
363 | 363 | <div class="lsx-wc-checkout-steps"> |
364 | 364 | <ul class="lsx-wc-checkout-steps-items"> |
365 | 365 | |
@@ -452,270 +452,270 @@ discard block |
||
452 | 452 | </ul> |
453 | 453 | </div> |
454 | 454 | <?php |
455 | - endif; |
|
456 | - } |
|
457 | - |
|
458 | - /** |
|
459 | - * Display extra HTML on checkout. |
|
460 | - * |
|
461 | - * @since 1.1.1 |
|
462 | - */ |
|
463 | - public function checkout_extra_html() { |
|
464 | - if ( is_checkout() ) { |
|
465 | - $checkout_extra_html = get_theme_mod( 'lsx_wc_checkout_extra_html', '' ); |
|
466 | - |
|
467 | - if ( ! empty( $checkout_extra_html ) ) { |
|
468 | - add_action( 'woocommerce_review_order_after_payment', array( $this, 'checkout_extra_html_echo' ), 9 ); |
|
469 | - } |
|
470 | - } |
|
471 | - } |
|
472 | - |
|
473 | - /** |
|
474 | - * Display extra HTML on checkout. |
|
475 | - * |
|
476 | - * @since 1.1.1 |
|
477 | - */ |
|
478 | - public function checkout_extra_html_echo() { |
|
479 | - if ( is_checkout() ) { |
|
480 | - $checkout_extra_html = get_theme_mod( 'lsx_wc_checkout_extra_html', '' ); |
|
481 | - |
|
482 | - if ( ! empty( $checkout_extra_html ) ) { |
|
483 | - ?> |
|
455 | + endif; |
|
456 | + } |
|
457 | + |
|
458 | + /** |
|
459 | + * Display extra HTML on checkout. |
|
460 | + * |
|
461 | + * @since 1.1.1 |
|
462 | + */ |
|
463 | + public function checkout_extra_html() { |
|
464 | + if ( is_checkout() ) { |
|
465 | + $checkout_extra_html = get_theme_mod( 'lsx_wc_checkout_extra_html', '' ); |
|
466 | + |
|
467 | + if ( ! empty( $checkout_extra_html ) ) { |
|
468 | + add_action( 'woocommerce_review_order_after_payment', array( $this, 'checkout_extra_html_echo' ), 9 ); |
|
469 | + } |
|
470 | + } |
|
471 | + } |
|
472 | + |
|
473 | + /** |
|
474 | + * Display extra HTML on checkout. |
|
475 | + * |
|
476 | + * @since 1.1.1 |
|
477 | + */ |
|
478 | + public function checkout_extra_html_echo() { |
|
479 | + if ( is_checkout() ) { |
|
480 | + $checkout_extra_html = get_theme_mod( 'lsx_wc_checkout_extra_html', '' ); |
|
481 | + |
|
482 | + if ( ! empty( $checkout_extra_html ) ) { |
|
483 | + ?> |
|
484 | 484 | <div class="lsx-wc-checkout-extra-html"> |
485 | 485 | <?php echo wp_kses_post( $checkout_extra_html ); ?> |
486 | 486 | </div> |
487 | 487 | <?php |
488 | - } |
|
489 | - } |
|
490 | - } |
|
491 | - |
|
492 | - /** |
|
493 | - * Display extra HTML on cart. |
|
494 | - * |
|
495 | - * @since 1.1.1 |
|
496 | - */ |
|
497 | - public function cart_extra_html() { |
|
498 | - if ( is_cart() ) { |
|
499 | - $cart_extra_html = get_theme_mod( 'lsx_wc_cart_extra_html', '' ); |
|
500 | - |
|
501 | - if ( ! empty( $cart_extra_html ) ) { |
|
502 | - remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' ); |
|
503 | - add_action( 'woocommerce_cart_collaterals', array( $this, 'cart_extra_html_echo' ), 9 ); |
|
504 | - } |
|
505 | - } |
|
506 | - } |
|
507 | - |
|
508 | - /** |
|
509 | - * Display extra HTML on cart. |
|
510 | - * |
|
511 | - * @since 1.1.1 |
|
512 | - */ |
|
513 | - public function cart_extra_html_echo() { |
|
514 | - if ( is_cart() ) { |
|
515 | - $cart_extra_html = get_theme_mod( 'lsx_wc_cart_extra_html', '' ); |
|
516 | - |
|
517 | - if ( ! empty( $cart_extra_html ) ) { |
|
518 | - ?> |
|
488 | + } |
|
489 | + } |
|
490 | + } |
|
491 | + |
|
492 | + /** |
|
493 | + * Display extra HTML on cart. |
|
494 | + * |
|
495 | + * @since 1.1.1 |
|
496 | + */ |
|
497 | + public function cart_extra_html() { |
|
498 | + if ( is_cart() ) { |
|
499 | + $cart_extra_html = get_theme_mod( 'lsx_wc_cart_extra_html', '' ); |
|
500 | + |
|
501 | + if ( ! empty( $cart_extra_html ) ) { |
|
502 | + remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' ); |
|
503 | + add_action( 'woocommerce_cart_collaterals', array( $this, 'cart_extra_html_echo' ), 9 ); |
|
504 | + } |
|
505 | + } |
|
506 | + } |
|
507 | + |
|
508 | + /** |
|
509 | + * Display extra HTML on cart. |
|
510 | + * |
|
511 | + * @since 1.1.1 |
|
512 | + */ |
|
513 | + public function cart_extra_html_echo() { |
|
514 | + if ( is_cart() ) { |
|
515 | + $cart_extra_html = get_theme_mod( 'lsx_wc_cart_extra_html', '' ); |
|
516 | + |
|
517 | + if ( ! empty( $cart_extra_html ) ) { |
|
518 | + ?> |
|
519 | 519 | <div class="lsx-wc-cart-extra-html"> |
520 | 520 | <?php echo wp_kses_post( $cart_extra_html ); ?> |
521 | 521 | </div> |
522 | 522 | <?php |
523 | - } |
|
524 | - } |
|
525 | - } |
|
526 | - |
|
527 | - /** |
|
528 | - * The place (menu) to display the cart menu item position. |
|
529 | - * |
|
530 | - * @since 1.1.1 |
|
531 | - */ |
|
532 | - public function cart_menu_item_position( $menu_position ) { |
|
533 | - $position = get_theme_mod( 'lsx_wc_cart_menu_item_position', '' ); |
|
534 | - |
|
535 | - if ( ! empty( $position ) ) { |
|
536 | - switch ( $position ) { |
|
537 | - case 'main-menu-in': |
|
538 | - case 'main-menu-out': |
|
539 | - $menu_position = 'primary'; |
|
540 | - break; |
|
541 | - |
|
542 | - case 'top-menu-right': |
|
543 | - $menu_position = 'top-menu'; |
|
544 | - break; |
|
545 | - |
|
546 | - case 'top-menu-left': |
|
547 | - $menu_position = 'top-menu-left'; |
|
548 | - break; |
|
549 | - } |
|
550 | - } |
|
551 | - |
|
552 | - return $menu_position; |
|
553 | - } |
|
554 | - |
|
555 | - /** |
|
556 | - * The place (menu) to display the cart menu item position. |
|
557 | - * |
|
558 | - * @since 1.1.1 |
|
559 | - */ |
|
560 | - public function cart_menu_item_class( $item_class ) { |
|
561 | - $position = get_theme_mod( 'lsx_wc_cart_menu_item_position', '' ); |
|
562 | - |
|
563 | - if ( 'main-menu-out' === $position ) { |
|
564 | - $item_class .= ' lsx-wc-cart-menu-item-right-aligned'; |
|
565 | - } |
|
566 | - |
|
567 | - $style = get_theme_mod( 'lsx_wc_cart_menu_item_style', '' ); |
|
568 | - |
|
569 | - if ( 'simple' === $style ) { |
|
570 | - $item_class .= ' lsx-wc-cart-menu-item-simple'; |
|
571 | - } |
|
572 | - |
|
573 | - return $item_class; |
|
574 | - } |
|
575 | - |
|
576 | - /** |
|
577 | - * Adds WC My Account to the header. |
|
578 | - * |
|
579 | - * @since 1.1.1 |
|
580 | - */ |
|
581 | - public function my_account_menu_item( $items, $args ) { |
|
582 | - $my_account_menu_item_position = apply_filters( 'lsx_wc_my_account_menu_item_position', 'primary' ); |
|
583 | - |
|
584 | - if ( $my_account_menu_item_position === $args->theme_location || ( 'primary_logged_out' === $args->theme_location && 'primary' === $my_account_menu_item_position ) ) { |
|
585 | - $customizer_option = get_theme_mod( 'lsx_wc_my_account_menu_item', false ); |
|
586 | - |
|
587 | - if ( ! empty( $customizer_option ) ) { |
|
588 | - if ( is_account_page() ) { |
|
589 | - $class = 'current-menu-item'; |
|
590 | - } else { |
|
591 | - $class = ''; |
|
592 | - } |
|
593 | - |
|
594 | - $item_class = 'menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children dropdown lsx-wc-my-account-menu-item ' . $class; |
|
595 | - $item_class = apply_filters( 'lsx_wc_my_account_menu_item_class', $item_class ); |
|
596 | - |
|
597 | - $endpoints = WC()->query->get_query_vars(); |
|
598 | - |
|
599 | - if ( is_user_logged_in() ) { |
|
600 | - $item = '<li class="' . $item_class . '">'; |
|
601 | - $item .= '<a title="' . esc_attr__( 'View your account', 'lsx-customizer' ) . '" href="' . esc_url( get_permalink( wc_get_page_id( 'myaccount' ) ) ) . '" data-toggle="dropdown" class="dropdown-toggle" aria-haspopup="true"><span>' . esc_attr__( 'My Account', 'lsx-customizer' ) . '</span></a>'; |
|
602 | - $item .= '<ul role="menu" class=" dropdown-menu lsx-wc-my-account-sub-menu">'; |
|
603 | - foreach ( wc_get_account_menu_items() as $endpoint => $label ) { |
|
604 | - $slug = $endpoint; |
|
605 | - if ( isset( $endpoints[ $endpoint ] ) && '' !== $endpoints[ $endpoint ] ) { |
|
606 | - $slug = $endpoints[ $endpoint ]; |
|
607 | - } |
|
608 | - if ( 'dashboard' === $slug ) { |
|
609 | - $slug = ''; |
|
610 | - } |
|
611 | - $item .= '<li class="menu-item"><a title="" href="' . esc_url( get_permalink( wc_get_page_id( 'myaccount' ) ) . $slug ) . '">' . $label . '</a></li>'; |
|
612 | - } |
|
613 | - $item .= '</ul></li>'; |
|
614 | - |
|
615 | - } else { |
|
616 | - $item = '<li class="' . $item_class . '">' . |
|
617 | - '<a title="' . esc_attr__( 'View your account', 'lsx-customizer' ) . '" href="' . esc_url( get_permalink( wc_get_page_id( 'myaccount' ) ) ) . '"><span>' . esc_attr__( 'Login', 'lsx-customizer' ) . '</span></a>' . |
|
618 | - '</li>'; |
|
619 | - } |
|
620 | - |
|
621 | - $item = apply_filters( 'lsx_wc_my_account_menu_item', $item ); |
|
622 | - |
|
623 | - if ( 'top-menu' === $args->theme_location ) { |
|
624 | - $items = $item . $items; |
|
625 | - } else { |
|
626 | - $items = $items . $item; |
|
627 | - } |
|
628 | - } |
|
629 | - } |
|
630 | - |
|
631 | - return $items; |
|
632 | - } |
|
633 | - |
|
634 | - /** |
|
635 | - * The place (menu) to display the My Account menu item position. |
|
636 | - * |
|
637 | - * @since 1.1.1 |
|
638 | - */ |
|
639 | - public function my_account_menu_item_position( $menu_position ) { |
|
640 | - $position = get_theme_mod( 'lsx_wc_my_account_menu_item_position', '' ); |
|
641 | - |
|
642 | - if ( ! empty( $position ) ) { |
|
643 | - switch ( $position ) { |
|
644 | - case 'main-menu-in': |
|
645 | - case 'main-menu-out': |
|
646 | - $menu_position = 'primary'; |
|
647 | - break; |
|
648 | - |
|
649 | - case 'top-menu-right': |
|
650 | - $menu_position = 'top-menu'; |
|
651 | - break; |
|
652 | - |
|
653 | - case 'top-menu-left': |
|
654 | - $menu_position = 'top-menu-left'; |
|
655 | - break; |
|
656 | - } |
|
657 | - } |
|
658 | - |
|
659 | - return $menu_position; |
|
660 | - } |
|
661 | - |
|
662 | - /** |
|
663 | - * The place (menu) to display the My Account menu item position. |
|
664 | - * |
|
665 | - * @since 1.1.1 |
|
666 | - */ |
|
667 | - public function my_account_menu_item_class( $item_class ) { |
|
668 | - $position = get_theme_mod( 'lsx_wc_my_account_menu_item_position', '' ); |
|
669 | - |
|
670 | - if ( 'main-menu-out' === $position ) { |
|
671 | - $item_class .= ' lsx-wc-my-account-menu-item-right-aligned'; |
|
672 | - } |
|
673 | - |
|
674 | - if ( ! is_user_logged_in() ) { |
|
675 | - $item_class .= ' lsx-wc-my-account-login'; |
|
676 | - } |
|
677 | - |
|
678 | - $style = get_theme_mod( 'lsx_wc_my_account_menu_item_style', '' ); |
|
679 | - |
|
680 | - if ( 'simple' === $style ) { |
|
681 | - $item_class .= ' lsx-wc-my-account-menu-item-simple'; |
|
682 | - } |
|
683 | - |
|
684 | - return $item_class; |
|
685 | - } |
|
686 | - /** |
|
687 | - * Display the woocommerce archive swticher. |
|
688 | - */ |
|
689 | - public function show_layout_switcher() { |
|
690 | - $body_classes = get_body_class(); |
|
691 | - if ( in_array( 'post-type-archive-product', $body_classes ) ) { |
|
692 | - global $WC_List_Grid; |
|
693 | - if ( null !== $WC_List_Grid ) { |
|
694 | - remove_action( 'woocommerce_before_shop_loop', array( $WC_List_Grid, 'gridlist_toggle_button' ), 30 ); |
|
695 | - add_action( 'lsx_banner_inner_bottom', array( $this, 'shop_gridlist_toggle_button' ), 90 ); |
|
696 | - add_action( 'lsx_global_header_inner_bottom', array( $this, 'shop_gridlist_toggle_button' ), 90 ); |
|
697 | - wp_deregister_style( 'grid-list-button' ); |
|
698 | - } |
|
699 | - } |
|
700 | - } |
|
701 | - /** |
|
702 | - * Display the woocommerce archive swticher. |
|
703 | - */ |
|
704 | - public function shop_gridlist_toggle_button() { |
|
705 | - global $WC_List_Grid; |
|
706 | - ?> |
|
523 | + } |
|
524 | + } |
|
525 | + } |
|
526 | + |
|
527 | + /** |
|
528 | + * The place (menu) to display the cart menu item position. |
|
529 | + * |
|
530 | + * @since 1.1.1 |
|
531 | + */ |
|
532 | + public function cart_menu_item_position( $menu_position ) { |
|
533 | + $position = get_theme_mod( 'lsx_wc_cart_menu_item_position', '' ); |
|
534 | + |
|
535 | + if ( ! empty( $position ) ) { |
|
536 | + switch ( $position ) { |
|
537 | + case 'main-menu-in': |
|
538 | + case 'main-menu-out': |
|
539 | + $menu_position = 'primary'; |
|
540 | + break; |
|
541 | + |
|
542 | + case 'top-menu-right': |
|
543 | + $menu_position = 'top-menu'; |
|
544 | + break; |
|
545 | + |
|
546 | + case 'top-menu-left': |
|
547 | + $menu_position = 'top-menu-left'; |
|
548 | + break; |
|
549 | + } |
|
550 | + } |
|
551 | + |
|
552 | + return $menu_position; |
|
553 | + } |
|
554 | + |
|
555 | + /** |
|
556 | + * The place (menu) to display the cart menu item position. |
|
557 | + * |
|
558 | + * @since 1.1.1 |
|
559 | + */ |
|
560 | + public function cart_menu_item_class( $item_class ) { |
|
561 | + $position = get_theme_mod( 'lsx_wc_cart_menu_item_position', '' ); |
|
562 | + |
|
563 | + if ( 'main-menu-out' === $position ) { |
|
564 | + $item_class .= ' lsx-wc-cart-menu-item-right-aligned'; |
|
565 | + } |
|
566 | + |
|
567 | + $style = get_theme_mod( 'lsx_wc_cart_menu_item_style', '' ); |
|
568 | + |
|
569 | + if ( 'simple' === $style ) { |
|
570 | + $item_class .= ' lsx-wc-cart-menu-item-simple'; |
|
571 | + } |
|
572 | + |
|
573 | + return $item_class; |
|
574 | + } |
|
575 | + |
|
576 | + /** |
|
577 | + * Adds WC My Account to the header. |
|
578 | + * |
|
579 | + * @since 1.1.1 |
|
580 | + */ |
|
581 | + public function my_account_menu_item( $items, $args ) { |
|
582 | + $my_account_menu_item_position = apply_filters( 'lsx_wc_my_account_menu_item_position', 'primary' ); |
|
583 | + |
|
584 | + if ( $my_account_menu_item_position === $args->theme_location || ( 'primary_logged_out' === $args->theme_location && 'primary' === $my_account_menu_item_position ) ) { |
|
585 | + $customizer_option = get_theme_mod( 'lsx_wc_my_account_menu_item', false ); |
|
586 | + |
|
587 | + if ( ! empty( $customizer_option ) ) { |
|
588 | + if ( is_account_page() ) { |
|
589 | + $class = 'current-menu-item'; |
|
590 | + } else { |
|
591 | + $class = ''; |
|
592 | + } |
|
593 | + |
|
594 | + $item_class = 'menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children dropdown lsx-wc-my-account-menu-item ' . $class; |
|
595 | + $item_class = apply_filters( 'lsx_wc_my_account_menu_item_class', $item_class ); |
|
596 | + |
|
597 | + $endpoints = WC()->query->get_query_vars(); |
|
598 | + |
|
599 | + if ( is_user_logged_in() ) { |
|
600 | + $item = '<li class="' . $item_class . '">'; |
|
601 | + $item .= '<a title="' . esc_attr__( 'View your account', 'lsx-customizer' ) . '" href="' . esc_url( get_permalink( wc_get_page_id( 'myaccount' ) ) ) . '" data-toggle="dropdown" class="dropdown-toggle" aria-haspopup="true"><span>' . esc_attr__( 'My Account', 'lsx-customizer' ) . '</span></a>'; |
|
602 | + $item .= '<ul role="menu" class=" dropdown-menu lsx-wc-my-account-sub-menu">'; |
|
603 | + foreach ( wc_get_account_menu_items() as $endpoint => $label ) { |
|
604 | + $slug = $endpoint; |
|
605 | + if ( isset( $endpoints[ $endpoint ] ) && '' !== $endpoints[ $endpoint ] ) { |
|
606 | + $slug = $endpoints[ $endpoint ]; |
|
607 | + } |
|
608 | + if ( 'dashboard' === $slug ) { |
|
609 | + $slug = ''; |
|
610 | + } |
|
611 | + $item .= '<li class="menu-item"><a title="" href="' . esc_url( get_permalink( wc_get_page_id( 'myaccount' ) ) . $slug ) . '">' . $label . '</a></li>'; |
|
612 | + } |
|
613 | + $item .= '</ul></li>'; |
|
614 | + |
|
615 | + } else { |
|
616 | + $item = '<li class="' . $item_class . '">' . |
|
617 | + '<a title="' . esc_attr__( 'View your account', 'lsx-customizer' ) . '" href="' . esc_url( get_permalink( wc_get_page_id( 'myaccount' ) ) ) . '"><span>' . esc_attr__( 'Login', 'lsx-customizer' ) . '</span></a>' . |
|
618 | + '</li>'; |
|
619 | + } |
|
620 | + |
|
621 | + $item = apply_filters( 'lsx_wc_my_account_menu_item', $item ); |
|
622 | + |
|
623 | + if ( 'top-menu' === $args->theme_location ) { |
|
624 | + $items = $item . $items; |
|
625 | + } else { |
|
626 | + $items = $items . $item; |
|
627 | + } |
|
628 | + } |
|
629 | + } |
|
630 | + |
|
631 | + return $items; |
|
632 | + } |
|
633 | + |
|
634 | + /** |
|
635 | + * The place (menu) to display the My Account menu item position. |
|
636 | + * |
|
637 | + * @since 1.1.1 |
|
638 | + */ |
|
639 | + public function my_account_menu_item_position( $menu_position ) { |
|
640 | + $position = get_theme_mod( 'lsx_wc_my_account_menu_item_position', '' ); |
|
641 | + |
|
642 | + if ( ! empty( $position ) ) { |
|
643 | + switch ( $position ) { |
|
644 | + case 'main-menu-in': |
|
645 | + case 'main-menu-out': |
|
646 | + $menu_position = 'primary'; |
|
647 | + break; |
|
648 | + |
|
649 | + case 'top-menu-right': |
|
650 | + $menu_position = 'top-menu'; |
|
651 | + break; |
|
652 | + |
|
653 | + case 'top-menu-left': |
|
654 | + $menu_position = 'top-menu-left'; |
|
655 | + break; |
|
656 | + } |
|
657 | + } |
|
658 | + |
|
659 | + return $menu_position; |
|
660 | + } |
|
661 | + |
|
662 | + /** |
|
663 | + * The place (menu) to display the My Account menu item position. |
|
664 | + * |
|
665 | + * @since 1.1.1 |
|
666 | + */ |
|
667 | + public function my_account_menu_item_class( $item_class ) { |
|
668 | + $position = get_theme_mod( 'lsx_wc_my_account_menu_item_position', '' ); |
|
669 | + |
|
670 | + if ( 'main-menu-out' === $position ) { |
|
671 | + $item_class .= ' lsx-wc-my-account-menu-item-right-aligned'; |
|
672 | + } |
|
673 | + |
|
674 | + if ( ! is_user_logged_in() ) { |
|
675 | + $item_class .= ' lsx-wc-my-account-login'; |
|
676 | + } |
|
677 | + |
|
678 | + $style = get_theme_mod( 'lsx_wc_my_account_menu_item_style', '' ); |
|
679 | + |
|
680 | + if ( 'simple' === $style ) { |
|
681 | + $item_class .= ' lsx-wc-my-account-menu-item-simple'; |
|
682 | + } |
|
683 | + |
|
684 | + return $item_class; |
|
685 | + } |
|
686 | + /** |
|
687 | + * Display the woocommerce archive swticher. |
|
688 | + */ |
|
689 | + public function show_layout_switcher() { |
|
690 | + $body_classes = get_body_class(); |
|
691 | + if ( in_array( 'post-type-archive-product', $body_classes ) ) { |
|
692 | + global $WC_List_Grid; |
|
693 | + if ( null !== $WC_List_Grid ) { |
|
694 | + remove_action( 'woocommerce_before_shop_loop', array( $WC_List_Grid, 'gridlist_toggle_button' ), 30 ); |
|
695 | + add_action( 'lsx_banner_inner_bottom', array( $this, 'shop_gridlist_toggle_button' ), 90 ); |
|
696 | + add_action( 'lsx_global_header_inner_bottom', array( $this, 'shop_gridlist_toggle_button' ), 90 ); |
|
697 | + wp_deregister_style( 'grid-list-button' ); |
|
698 | + } |
|
699 | + } |
|
700 | + } |
|
701 | + /** |
|
702 | + * Display the woocommerce archive swticher. |
|
703 | + */ |
|
704 | + public function shop_gridlist_toggle_button() { |
|
705 | + global $WC_List_Grid; |
|
706 | + ?> |
|
707 | 707 | <div class="lsx-layout-switcher"> |
708 | 708 | <span class="lsx-layout-switcher-label"><?php esc_html_e( 'Select view:', 'lsx-blog-customizer' ); ?></span> |
709 | 709 | <?php $WC_List_Grid->gridlist_toggle_button(); ?> |
710 | 710 | </div> |
711 | 711 | <?php |
712 | - } |
|
713 | - public function gridlist_toggle_button_output( $output, $grid_view, $list_view ) { |
|
714 | - $output = sprintf( '<div class="gridlist-toggle lsx-layout-switcher-options"><a href="#" class="lsx-layout-switcher-option" id="grid" title="%1$s"><span class="fa fa fa-th"></span></a><a href="#" class="lsx-layout-switcher-option" id="list" title="%2$s"><span class="fa fa-bars"></span></a></div>', $grid_view, $list_view ); |
|
715 | - return $output; |
|
716 | - } |
|
717 | - } |
|
718 | - |
|
719 | - new LSX_Customizer_WooCommerce(); |
|
712 | + } |
|
713 | + public function gridlist_toggle_button_output( $output, $grid_view, $list_view ) { |
|
714 | + $output = sprintf( '<div class="gridlist-toggle lsx-layout-switcher-options"><a href="#" class="lsx-layout-switcher-option" id="grid" title="%1$s"><span class="fa fa fa-th"></span></a><a href="#" class="lsx-layout-switcher-option" id="list" title="%2$s"><span class="fa fa-bars"></span></a></div>', $grid_view, $list_view ); |
|
715 | + return $output; |
|
716 | + } |
|
717 | + } |
|
718 | + |
|
719 | + new LSX_Customizer_WooCommerce(); |
|
720 | 720 | |
721 | 721 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | // If this file is called directly, abort. |
18 | 18 | if ( ! defined( 'WPINC' ) ) { |
19 | - die; |
|
19 | + die; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | define( 'LSX_CUSTOMIZER_PATH', plugin_dir_path( __FILE__ ) ); |
@@ -29,21 +29,21 @@ discard block |
||
29 | 29 | require_once LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer.php'; |
30 | 30 | |
31 | 31 | if ( in_array( 'wordpress-seo/wp-seo.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) || in_array( 'wordpress-seo-premium/wp-seo-premium.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { |
32 | - require LSX_CUSTOMIZER_PATH . 'includes/yoast/class-lsx-yoast.php'; |
|
32 | + require LSX_CUSTOMIZER_PATH . 'includes/yoast/class-lsx-yoast.php'; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | if ( class_exists( 'Tribe__Events__Main' ) ) { |
36 | - require LSX_CUSTOMIZER_PATH . 'includes/the-events-calendar/the-events-calendar.php'; |
|
36 | + require LSX_CUSTOMIZER_PATH . 'includes/the-events-calendar/the-events-calendar.php'; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | if ( class_exists( 'Sensei_Main' ) || class_exists( 'Sensei_WC' ) ) { |
40 | - require LSX_CUSTOMIZER_PATH . 'includes/sensei/class-lsx-sensei.php'; |
|
40 | + require LSX_CUSTOMIZER_PATH . 'includes/sensei/class-lsx-sensei.php'; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | if ( class_exists( 'Popup_Maker' ) ) { |
44 | - require LSX_CUSTOMIZER_PATH . 'includes/popup-maker/class-lsx-popup-maker.php'; |
|
44 | + require LSX_CUSTOMIZER_PATH . 'includes/popup-maker/class-lsx-popup-maker.php'; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | if ( class_exists( 'bbPress' ) ) { |
48 | - require LSX_CUSTOMIZER_PATH . 'includes/bbpress/bbpress.php'; |
|
48 | + require LSX_CUSTOMIZER_PATH . 'includes/bbpress/bbpress.php'; |
|
49 | 49 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
4 | - exit; |
|
4 | + exit; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -15,79 +15,79 @@ discard block |
||
15 | 15 | */ |
16 | 16 | class LSX_WC_Widget_Recent_Reviews extends WC_Widget { |
17 | 17 | |
18 | - /** |
|
19 | - * Constructor. |
|
20 | - */ |
|
21 | - public function __construct() { |
|
22 | - $this->widget_cssclass = 'woocommerce widget_recent_reviews'; |
|
23 | - $this->widget_description = __( 'Display a list of your most recent reviews on your site.', 'lsx' ); |
|
24 | - $this->widget_id = 'woocommerce_recent_reviews'; |
|
25 | - $this->widget_name = __( 'WooCommerce recent reviews', 'lsx' ); |
|
26 | - $this->settings = array( |
|
27 | - 'title' => array( |
|
28 | - 'type' => 'text', |
|
29 | - 'std' => __( 'Recent reviews', 'lsx' ), |
|
30 | - 'label' => __( 'Title', 'lsx' ), |
|
31 | - ), |
|
32 | - 'number' => array( |
|
33 | - 'type' => 'number', |
|
34 | - 'step' => 1, |
|
35 | - 'min' => 1, |
|
36 | - 'max' => '', |
|
37 | - 'std' => 10, |
|
38 | - 'label' => __( 'Number of reviews to show', 'lsx' ), |
|
39 | - ), |
|
40 | - ); |
|
18 | + /** |
|
19 | + * Constructor. |
|
20 | + */ |
|
21 | + public function __construct() { |
|
22 | + $this->widget_cssclass = 'woocommerce widget_recent_reviews'; |
|
23 | + $this->widget_description = __( 'Display a list of your most recent reviews on your site.', 'lsx' ); |
|
24 | + $this->widget_id = 'woocommerce_recent_reviews'; |
|
25 | + $this->widget_name = __( 'WooCommerce recent reviews', 'lsx' ); |
|
26 | + $this->settings = array( |
|
27 | + 'title' => array( |
|
28 | + 'type' => 'text', |
|
29 | + 'std' => __( 'Recent reviews', 'lsx' ), |
|
30 | + 'label' => __( 'Title', 'lsx' ), |
|
31 | + ), |
|
32 | + 'number' => array( |
|
33 | + 'type' => 'number', |
|
34 | + 'step' => 1, |
|
35 | + 'min' => 1, |
|
36 | + 'max' => '', |
|
37 | + 'std' => 10, |
|
38 | + 'label' => __( 'Number of reviews to show', 'lsx' ), |
|
39 | + ), |
|
40 | + ); |
|
41 | 41 | |
42 | - parent::__construct(); |
|
43 | - } |
|
42 | + parent::__construct(); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Output widget. |
|
47 | - * |
|
48 | - * @see WP_Widget |
|
49 | - * |
|
50 | - * @param array $args |
|
51 | - * @param array $instance |
|
52 | - */ |
|
53 | - public function widget( $args, $instance ) { |
|
54 | - if ( $this->get_cached_widget( $args ) ) { |
|
55 | - return; |
|
56 | - } |
|
57 | - ob_start(); |
|
58 | - $number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : $this->settings['number']['std']; |
|
59 | - $comments = get_comments( |
|
60 | - array( |
|
61 | - 'number' => $number, |
|
62 | - 'status' => 'approve', |
|
63 | - 'post_status' => 'publish', |
|
64 | - 'post_type' => 'product', |
|
65 | - 'parent' => 0, |
|
66 | - ) |
|
67 | - ); |
|
45 | + /** |
|
46 | + * Output widget. |
|
47 | + * |
|
48 | + * @see WP_Widget |
|
49 | + * |
|
50 | + * @param array $args |
|
51 | + * @param array $instance |
|
52 | + */ |
|
53 | + public function widget( $args, $instance ) { |
|
54 | + if ( $this->get_cached_widget( $args ) ) { |
|
55 | + return; |
|
56 | + } |
|
57 | + ob_start(); |
|
58 | + $number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : $this->settings['number']['std']; |
|
59 | + $comments = get_comments( |
|
60 | + array( |
|
61 | + 'number' => $number, |
|
62 | + 'status' => 'approve', |
|
63 | + 'post_status' => 'publish', |
|
64 | + 'post_type' => 'product', |
|
65 | + 'parent' => 0, |
|
66 | + ) |
|
67 | + ); |
|
68 | 68 | |
69 | - if ( $comments ) { |
|
70 | - $this->widget_start( $args, $instance ); |
|
69 | + if ( $comments ) { |
|
70 | + $this->widget_start( $args, $instance ); |
|
71 | 71 | |
72 | - echo wp_kses_post( apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' ) ); |
|
72 | + echo wp_kses_post( apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' ) ); |
|
73 | 73 | |
74 | - global $stored_comment, $_product, $rating; |
|
74 | + global $stored_comment, $_product, $rating; |
|
75 | 75 | |
76 | - the_comment(); |
|
77 | - foreach ( (array) $comments as $comment ) { |
|
78 | - $_product = wc_get_product( $comment->comment_post_ID ); |
|
79 | - $rating = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) ); |
|
80 | - $stored_comment = $comment; |
|
76 | + the_comment(); |
|
77 | + foreach ( (array) $comments as $comment ) { |
|
78 | + $_product = wc_get_product( $comment->comment_post_ID ); |
|
79 | + $rating = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) ); |
|
80 | + $stored_comment = $comment; |
|
81 | 81 | |
82 | - wc_get_template( 'content-widget-review.php' ); |
|
83 | - } |
|
82 | + wc_get_template( 'content-widget-review.php' ); |
|
83 | + } |
|
84 | 84 | |
85 | - echo wp_kses_post( apply_filters( 'woocommerce_after_widget_product_list', '</ul>' ) ); |
|
85 | + echo wp_kses_post( apply_filters( 'woocommerce_after_widget_product_list', '</ul>' ) ); |
|
86 | 86 | |
87 | - $this->widget_end( $args ); |
|
88 | - } |
|
89 | - $content = ob_get_clean(); |
|
90 | - echo wp_kses_post( $content ); |
|
91 | - $this->cache_widget( $args, $content ); |
|
92 | - } |
|
87 | + $this->widget_end( $args ); |
|
88 | + } |
|
89 | + $content = ob_get_clean(); |
|
90 | + echo wp_kses_post( $content ); |
|
91 | + $this->cache_widget( $args, $content ); |
|
92 | + } |
|
93 | 93 | } |
@@ -1,63 +1,63 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! class_exists( 'LSX_Customizer_Frontend' ) ) { |
3 | 3 | |
4 | - /** |
|
5 | - * LSX Customizer Frontend Class |
|
6 | - * |
|
7 | - * @package LSX Customizer |
|
8 | - * @author LightSpeed |
|
9 | - * @license GPL3 |
|
10 | - * @link |
|
11 | - * @copyright 2016 LightSpeed |
|
12 | - */ |
|
13 | - class LSX_Customizer_Frontend extends LSX_Customizer { |
|
14 | - |
|
15 | - /** |
|
16 | - * Constructor. |
|
17 | - * |
|
18 | - * @since 1.0.0 |
|
19 | - */ |
|
20 | - public function __construct() { |
|
21 | - add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 2999 ); |
|
22 | - add_action( 'wp_enqueue_scripts', array( $this, 'lsx_customizer_color_palette_css' ), 2999 ); |
|
23 | - add_action( 'wp', array( $this, 'layout' ), 2999 ); |
|
24 | - add_action( 'wp', array( $this, 'lsx_distraction_free_checkout' ), 2999 ); |
|
25 | - add_action( 'wp', array( $this, 'lsx_customizer_two_step_checkout' ) ); |
|
26 | - add_action( 'after_setup_theme', array( $this, 'lsx_customizer_color_palette_setup' ), 100 ); |
|
27 | - } |
|
28 | - |
|
29 | - /** |
|
30 | - * Enques the assets. |
|
31 | - * |
|
32 | - * @since 1.0.0 |
|
33 | - */ |
|
34 | - public function assets() { |
|
35 | - wp_enqueue_script( 'lsx-customizer', LSX_CUSTOMIZER_PATH . 'assets/js/lsx-customizer.min.js', array( 'jquery' ), LSX_CUSTOMIZER_VER, true ); |
|
36 | - |
|
37 | - $params = apply_filters( 'lsx_customizer_js_params', array( |
|
38 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
39 | - )); |
|
40 | - |
|
41 | - wp_localize_script( 'lsx-customizer', 'lsx_customizer_params', $params ); |
|
42 | - |
|
43 | - wp_enqueue_style( 'lsx-customizer', LSX_CUSTOMIZER_PATH . 'assets/css/lsx-customizer.css', array(), LSX_CUSTOMIZER_VER ); |
|
44 | - wp_style_add_data( 'lsx-customizer', 'rtl', 'replace' ); |
|
45 | - |
|
46 | - $two_step_checkout = get_theme_mod( 'lsx_two_step_checkout', false ); |
|
47 | - if ( class_exists( 'WooCommerce' ) && function_exists( 'is_checkout' ) && is_checkout() && ! empty( $two_step_checkout ) ) { |
|
48 | - |
|
49 | - wp_enqueue_script( 'flexslider', LSX_CUSTOMIZER_PATH . 'assets/js/jquery.flexslider.min.js', array( 'jquery' ), '2.5.0' ); |
|
50 | - } |
|
51 | - |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Enqueues front-end colour palette CSS. |
|
56 | - * |
|
57 | - * @since 1.0.0 |
|
58 | - */ |
|
59 | - public function lsx_customizer_color_palette_css() { |
|
60 | - $styles = ' |
|
4 | + /** |
|
5 | + * LSX Customizer Frontend Class |
|
6 | + * |
|
7 | + * @package LSX Customizer |
|
8 | + * @author LightSpeed |
|
9 | + * @license GPL3 |
|
10 | + * @link |
|
11 | + * @copyright 2016 LightSpeed |
|
12 | + */ |
|
13 | + class LSX_Customizer_Frontend extends LSX_Customizer { |
|
14 | + |
|
15 | + /** |
|
16 | + * Constructor. |
|
17 | + * |
|
18 | + * @since 1.0.0 |
|
19 | + */ |
|
20 | + public function __construct() { |
|
21 | + add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 2999 ); |
|
22 | + add_action( 'wp_enqueue_scripts', array( $this, 'lsx_customizer_color_palette_css' ), 2999 ); |
|
23 | + add_action( 'wp', array( $this, 'layout' ), 2999 ); |
|
24 | + add_action( 'wp', array( $this, 'lsx_distraction_free_checkout' ), 2999 ); |
|
25 | + add_action( 'wp', array( $this, 'lsx_customizer_two_step_checkout' ) ); |
|
26 | + add_action( 'after_setup_theme', array( $this, 'lsx_customizer_color_palette_setup' ), 100 ); |
|
27 | + } |
|
28 | + |
|
29 | + /** |
|
30 | + * Enques the assets. |
|
31 | + * |
|
32 | + * @since 1.0.0 |
|
33 | + */ |
|
34 | + public function assets() { |
|
35 | + wp_enqueue_script( 'lsx-customizer', LSX_CUSTOMIZER_PATH . 'assets/js/lsx-customizer.min.js', array( 'jquery' ), LSX_CUSTOMIZER_VER, true ); |
|
36 | + |
|
37 | + $params = apply_filters( 'lsx_customizer_js_params', array( |
|
38 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
39 | + )); |
|
40 | + |
|
41 | + wp_localize_script( 'lsx-customizer', 'lsx_customizer_params', $params ); |
|
42 | + |
|
43 | + wp_enqueue_style( 'lsx-customizer', LSX_CUSTOMIZER_PATH . 'assets/css/lsx-customizer.css', array(), LSX_CUSTOMIZER_VER ); |
|
44 | + wp_style_add_data( 'lsx-customizer', 'rtl', 'replace' ); |
|
45 | + |
|
46 | + $two_step_checkout = get_theme_mod( 'lsx_two_step_checkout', false ); |
|
47 | + if ( class_exists( 'WooCommerce' ) && function_exists( 'is_checkout' ) && is_checkout() && ! empty( $two_step_checkout ) ) { |
|
48 | + |
|
49 | + wp_enqueue_script( 'flexslider', LSX_CUSTOMIZER_PATH . 'assets/js/jquery.flexslider.min.js', array( 'jquery' ), '2.5.0' ); |
|
50 | + } |
|
51 | + |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Enqueues front-end colour palette CSS. |
|
56 | + * |
|
57 | + * @since 1.0.0 |
|
58 | + */ |
|
59 | + public function lsx_customizer_color_palette_css() { |
|
60 | + $styles = ' |
|
61 | 61 | .container #primary.content-area .has-primary-color-background-color { |
62 | 62 | background-color:' . get_theme_mod( 'primary_color', '#428bca' ) . '; |
63 | 63 | } |
@@ -136,122 +136,122 @@ discard block |
||
136 | 136 | } |
137 | 137 | |
138 | 138 | '; |
139 | - wp_add_inline_style( 'lsx-customizer', $styles ); |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * Layout. |
|
144 | - * |
|
145 | - * @since 1.0.0 |
|
146 | - */ |
|
147 | - public function layout() { |
|
148 | - $theme_credit = get_theme_mod( 'lsx_theme_credit_status', true ); |
|
149 | - |
|
150 | - if ( false == $theme_credit ) { |
|
151 | - add_filter( 'lsx_credit_link', '__return_false' ); |
|
152 | - } |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * Create the distraction free checkout. |
|
157 | - * |
|
158 | - * @since 1.0.0 |
|
159 | - * @return void |
|
160 | - */ |
|
161 | - public function lsx_distraction_free_checkout() { |
|
162 | - |
|
163 | - $distraction_free = get_theme_mod( 'lsx_distraction_free_checkout', false ); |
|
164 | - |
|
165 | - if ( class_exists( 'WooCommerce' ) && function_exists( 'is_checkout' ) && is_checkout() && ! empty( $distraction_free ) ) { |
|
166 | - remove_action( 'lsx_body_bottom', 'lsx_wc_footer_bar', 15 ); |
|
167 | - |
|
168 | - } |
|
169 | - } |
|
170 | - |
|
171 | - /** |
|
172 | - * Create the two step checkout. |
|
173 | - * |
|
174 | - * @since 1.0.0 |
|
175 | - * @return void |
|
176 | - */ |
|
177 | - public function lsx_customizer_two_step_checkout() { |
|
178 | - $two_step_checkout = get_theme_mod( 'lsx_two_step_checkout', false ); |
|
179 | - |
|
180 | - if ( class_exists( 'WooCommerce' ) && function_exists( 'is_checkout' ) && is_checkout() && ! empty( $two_step_checkout ) ) { |
|
181 | - add_action( 'woocommerce_checkout_before_customer_details', 'lsx_customizer_checkout_form_wrapper_div', 1 ); |
|
182 | - add_action( 'woocommerce_checkout_before_customer_details', 'lsx_customizer_checkout_form_wrapper', 2 ); |
|
183 | - add_action( 'woocommerce_checkout_order_review', 'lsx_customizer_close_div', 30 ); |
|
184 | - add_action( 'woocommerce_checkout_order_review', 'lsx_customizer_close_ul', 30 ); |
|
185 | - add_action( 'woocommerce_checkout_before_customer_details', 'lsx_customizer_address_wrapper', 5 ); |
|
186 | - add_action( 'woocommerce_checkout_after_customer_details', 'lsx_customizer_close_li' ); |
|
187 | - add_action( 'wp_footer', 'lsx_customizer_fire_flexslider' ); |
|
188 | - add_action( 'woocommerce_checkout_before_order_review', 'lsx_customizer_order_review_wrap', 1 ); |
|
189 | - add_action( 'woocommerce_checkout_after_order_review', 'lsx_customizer_close_li', 40 ); |
|
190 | - } |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * Editor color palette. |
|
195 | - * |
|
196 | - * @return void |
|
197 | - */ |
|
198 | - public function lsx_customizer_color_palette_setup() { |
|
199 | - add_theme_support( 'editor-color-palette', array( |
|
200 | - array( |
|
201 | - 'name' => esc_html__( 'Primary Colour', 'lsx-customizer' ), |
|
202 | - 'slug' => 'primary-color', |
|
203 | - 'color' => get_theme_mod( 'primary_color', '#428bca' ), |
|
204 | - ), |
|
205 | - array( |
|
206 | - 'name' => esc_html__( 'Strong Primary Colour', 'lsx-customizer' ), |
|
207 | - 'slug' => 'strong-primary-color', |
|
208 | - 'color' => get_theme_mod( 'strong_primary_color', '#2a6496' ), |
|
209 | - ), |
|
210 | - array( |
|
211 | - 'name' => esc_html__( 'CTA Colour', 'lsx-customizer' ), |
|
212 | - 'slug' => 'cta-color', |
|
213 | - 'color' => get_theme_mod( 'call_to_action_color', '#f7941d' ), |
|
214 | - ), |
|
215 | - array( |
|
216 | - 'name' => esc_html__( 'Strong CTA Colour', 'lsx-customizer' ), |
|
217 | - 'slug' => 'strong-cta-color', |
|
218 | - 'color' => get_theme_mod( 'strong_cta_color', '#f7741d' ), |
|
219 | - ), |
|
220 | - array( |
|
221 | - 'name' => esc_html__( 'Secondary Colour', 'lsx-customizer' ), |
|
222 | - 'slug' => 'secondary-color', |
|
223 | - 'color' => get_theme_mod( 'secondary_color', '#eaeaea' ), |
|
224 | - ), |
|
225 | - array( |
|
226 | - 'name' => esc_html__( 'Strong Secondary Colour', 'lsx-customizer' ), |
|
227 | - 'slug' => 'strong-secondary-color', |
|
228 | - 'color' => get_theme_mod( 'strong_secondary_color', '#c4c4c4' ), |
|
229 | - ), |
|
230 | - array( |
|
231 | - 'name' => esc_html__( 'Tertiary Colour', 'lsx-customizer' ), |
|
232 | - 'slug' => 'tertiary-color', |
|
233 | - 'color' => get_theme_mod( 'tertiary_color', '#6BA913' ), |
|
234 | - ), |
|
235 | - array( |
|
236 | - 'name' => esc_html__( 'Strong Tertiary Colour', 'lsx-customizer' ), |
|
237 | - 'slug' => 'strong-tertiary-color', |
|
238 | - 'color' => get_theme_mod( 'strong_tertiary_color', '#3F640B' ), |
|
239 | - ), |
|
240 | - array( |
|
241 | - 'name' => esc_html__( 'White', 'lsx-customizer' ), |
|
242 | - 'slug' => 'white', |
|
243 | - 'color' => '#ffffff', |
|
244 | - ), |
|
245 | - array( |
|
246 | - 'name' => esc_html__( 'Black', 'lsx-customizer' ), |
|
247 | - 'slug' => 'black', |
|
248 | - 'color' => '#000000', |
|
249 | - ), |
|
250 | - )); |
|
251 | - } |
|
252 | - |
|
253 | - } |
|
254 | - |
|
255 | - new LSX_Customizer_Frontend(); |
|
139 | + wp_add_inline_style( 'lsx-customizer', $styles ); |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * Layout. |
|
144 | + * |
|
145 | + * @since 1.0.0 |
|
146 | + */ |
|
147 | + public function layout() { |
|
148 | + $theme_credit = get_theme_mod( 'lsx_theme_credit_status', true ); |
|
149 | + |
|
150 | + if ( false == $theme_credit ) { |
|
151 | + add_filter( 'lsx_credit_link', '__return_false' ); |
|
152 | + } |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * Create the distraction free checkout. |
|
157 | + * |
|
158 | + * @since 1.0.0 |
|
159 | + * @return void |
|
160 | + */ |
|
161 | + public function lsx_distraction_free_checkout() { |
|
162 | + |
|
163 | + $distraction_free = get_theme_mod( 'lsx_distraction_free_checkout', false ); |
|
164 | + |
|
165 | + if ( class_exists( 'WooCommerce' ) && function_exists( 'is_checkout' ) && is_checkout() && ! empty( $distraction_free ) ) { |
|
166 | + remove_action( 'lsx_body_bottom', 'lsx_wc_footer_bar', 15 ); |
|
167 | + |
|
168 | + } |
|
169 | + } |
|
170 | + |
|
171 | + /** |
|
172 | + * Create the two step checkout. |
|
173 | + * |
|
174 | + * @since 1.0.0 |
|
175 | + * @return void |
|
176 | + */ |
|
177 | + public function lsx_customizer_two_step_checkout() { |
|
178 | + $two_step_checkout = get_theme_mod( 'lsx_two_step_checkout', false ); |
|
179 | + |
|
180 | + if ( class_exists( 'WooCommerce' ) && function_exists( 'is_checkout' ) && is_checkout() && ! empty( $two_step_checkout ) ) { |
|
181 | + add_action( 'woocommerce_checkout_before_customer_details', 'lsx_customizer_checkout_form_wrapper_div', 1 ); |
|
182 | + add_action( 'woocommerce_checkout_before_customer_details', 'lsx_customizer_checkout_form_wrapper', 2 ); |
|
183 | + add_action( 'woocommerce_checkout_order_review', 'lsx_customizer_close_div', 30 ); |
|
184 | + add_action( 'woocommerce_checkout_order_review', 'lsx_customizer_close_ul', 30 ); |
|
185 | + add_action( 'woocommerce_checkout_before_customer_details', 'lsx_customizer_address_wrapper', 5 ); |
|
186 | + add_action( 'woocommerce_checkout_after_customer_details', 'lsx_customizer_close_li' ); |
|
187 | + add_action( 'wp_footer', 'lsx_customizer_fire_flexslider' ); |
|
188 | + add_action( 'woocommerce_checkout_before_order_review', 'lsx_customizer_order_review_wrap', 1 ); |
|
189 | + add_action( 'woocommerce_checkout_after_order_review', 'lsx_customizer_close_li', 40 ); |
|
190 | + } |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * Editor color palette. |
|
195 | + * |
|
196 | + * @return void |
|
197 | + */ |
|
198 | + public function lsx_customizer_color_palette_setup() { |
|
199 | + add_theme_support( 'editor-color-palette', array( |
|
200 | + array( |
|
201 | + 'name' => esc_html__( 'Primary Colour', 'lsx-customizer' ), |
|
202 | + 'slug' => 'primary-color', |
|
203 | + 'color' => get_theme_mod( 'primary_color', '#428bca' ), |
|
204 | + ), |
|
205 | + array( |
|
206 | + 'name' => esc_html__( 'Strong Primary Colour', 'lsx-customizer' ), |
|
207 | + 'slug' => 'strong-primary-color', |
|
208 | + 'color' => get_theme_mod( 'strong_primary_color', '#2a6496' ), |
|
209 | + ), |
|
210 | + array( |
|
211 | + 'name' => esc_html__( 'CTA Colour', 'lsx-customizer' ), |
|
212 | + 'slug' => 'cta-color', |
|
213 | + 'color' => get_theme_mod( 'call_to_action_color', '#f7941d' ), |
|
214 | + ), |
|
215 | + array( |
|
216 | + 'name' => esc_html__( 'Strong CTA Colour', 'lsx-customizer' ), |
|
217 | + 'slug' => 'strong-cta-color', |
|
218 | + 'color' => get_theme_mod( 'strong_cta_color', '#f7741d' ), |
|
219 | + ), |
|
220 | + array( |
|
221 | + 'name' => esc_html__( 'Secondary Colour', 'lsx-customizer' ), |
|
222 | + 'slug' => 'secondary-color', |
|
223 | + 'color' => get_theme_mod( 'secondary_color', '#eaeaea' ), |
|
224 | + ), |
|
225 | + array( |
|
226 | + 'name' => esc_html__( 'Strong Secondary Colour', 'lsx-customizer' ), |
|
227 | + 'slug' => 'strong-secondary-color', |
|
228 | + 'color' => get_theme_mod( 'strong_secondary_color', '#c4c4c4' ), |
|
229 | + ), |
|
230 | + array( |
|
231 | + 'name' => esc_html__( 'Tertiary Colour', 'lsx-customizer' ), |
|
232 | + 'slug' => 'tertiary-color', |
|
233 | + 'color' => get_theme_mod( 'tertiary_color', '#6BA913' ), |
|
234 | + ), |
|
235 | + array( |
|
236 | + 'name' => esc_html__( 'Strong Tertiary Colour', 'lsx-customizer' ), |
|
237 | + 'slug' => 'strong-tertiary-color', |
|
238 | + 'color' => get_theme_mod( 'strong_tertiary_color', '#3F640B' ), |
|
239 | + ), |
|
240 | + array( |
|
241 | + 'name' => esc_html__( 'White', 'lsx-customizer' ), |
|
242 | + 'slug' => 'white', |
|
243 | + 'color' => '#ffffff', |
|
244 | + ), |
|
245 | + array( |
|
246 | + 'name' => esc_html__( 'Black', 'lsx-customizer' ), |
|
247 | + 'slug' => 'black', |
|
248 | + 'color' => '#000000', |
|
249 | + ), |
|
250 | + )); |
|
251 | + } |
|
252 | + |
|
253 | + } |
|
254 | + |
|
255 | + new LSX_Customizer_Frontend(); |
|
256 | 256 | |
257 | 257 | } |
@@ -1,104 +1,104 @@ |
||
1 | 1 | <?php |
2 | 2 | if ( ! class_exists( 'LSX_Customizer' ) ) { |
3 | 3 | |
4 | - /** |
|
5 | - * LSX Customizer Main Class |
|
6 | - * |
|
7 | - * @package LSX Customizer |
|
8 | - * @author LightSpeed |
|
9 | - * @license GPL3 |
|
10 | - * @link |
|
11 | - * @copyright 2016 LightSpeed |
|
12 | - */ |
|
13 | - class LSX_Customizer { |
|
4 | + /** |
|
5 | + * LSX Customizer Main Class |
|
6 | + * |
|
7 | + * @package LSX Customizer |
|
8 | + * @author LightSpeed |
|
9 | + * @license GPL3 |
|
10 | + * @link |
|
11 | + * @copyright 2016 LightSpeed |
|
12 | + */ |
|
13 | + class LSX_Customizer { |
|
14 | 14 | |
15 | - /** |
|
16 | - * Plugin slug. |
|
17 | - * |
|
18 | - * @var string |
|
19 | - * @since 1.0.0 |
|
20 | - */ |
|
21 | - public $plugin_slug = 'lsx-customizer'; |
|
15 | + /** |
|
16 | + * Plugin slug. |
|
17 | + * |
|
18 | + * @var string |
|
19 | + * @since 1.0.0 |
|
20 | + */ |
|
21 | + public $plugin_slug = 'lsx-customizer'; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Constructor. |
|
25 | - * |
|
26 | - * @since 1.0.0 |
|
27 | - */ |
|
28 | - public function __construct() { |
|
29 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-admin.php' ); |
|
30 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-frontend.php' ); |
|
31 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-core.php' ); |
|
32 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour.php' ); |
|
33 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-login.php' ); |
|
23 | + /** |
|
24 | + * Constructor. |
|
25 | + * |
|
26 | + * @since 1.0.0 |
|
27 | + */ |
|
28 | + public function __construct() { |
|
29 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-admin.php' ); |
|
30 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-frontend.php' ); |
|
31 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-core.php' ); |
|
32 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-colour.php' ); |
|
33 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-login.php' ); |
|
34 | 34 | |
35 | - add_action( 'plugins_loaded', array( $this, 'woocommerce' ) ); |
|
36 | - add_action( 'after_setup_theme', array( $this, 'wysiwyg_editor_control' ), 20 ); |
|
37 | - add_filter( 'login_headerurl', array( $this, 'custom_login_url' ) ); |
|
38 | - } |
|
35 | + add_action( 'plugins_loaded', array( $this, 'woocommerce' ) ); |
|
36 | + add_action( 'after_setup_theme', array( $this, 'wysiwyg_editor_control' ), 20 ); |
|
37 | + add_filter( 'login_headerurl', array( $this, 'custom_login_url' ) ); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Check if WooCommerce is installed to load the related file. |
|
42 | - * |
|
43 | - * @since 1.1.1 |
|
44 | - */ |
|
45 | - public function woocommerce() { |
|
46 | - if ( class_exists( 'WooCommerce' ) ) { |
|
47 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-woocommerce.php' ); |
|
48 | - require_once( LSX_CUSTOMIZER_PATH . 'includes/woocommerce/woocommerce.php' ); |
|
49 | - require_once( LSX_CUSTOMIZER_PATH . 'includes/woocommerce/addons.php' ); |
|
50 | - } |
|
51 | - } |
|
40 | + /** |
|
41 | + * Check if WooCommerce is installed to load the related file. |
|
42 | + * |
|
43 | + * @since 1.1.1 |
|
44 | + */ |
|
45 | + public function woocommerce() { |
|
46 | + if ( class_exists( 'WooCommerce' ) ) { |
|
47 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-woocommerce.php' ); |
|
48 | + require_once( LSX_CUSTOMIZER_PATH . 'includes/woocommerce/woocommerce.php' ); |
|
49 | + require_once( LSX_CUSTOMIZER_PATH . 'includes/woocommerce/addons.php' ); |
|
50 | + } |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Customizer Controls and Settings. |
|
55 | - * |
|
56 | - * @param WP_Customize_Manager $wp_customize Theme Customizer object. |
|
57 | - * @since 1.1.1 |
|
58 | - */ |
|
59 | - public function wysiwyg_editor_control() { |
|
60 | - if ( class_exists( 'WP_Customize_Control' ) ) { |
|
61 | - require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-wysiwyg-control.php' ); |
|
62 | - } |
|
63 | - } |
|
53 | + /** |
|
54 | + * Customizer Controls and Settings. |
|
55 | + * |
|
56 | + * @param WP_Customize_Manager $wp_customize Theme Customizer object. |
|
57 | + * @since 1.1.1 |
|
58 | + */ |
|
59 | + public function wysiwyg_editor_control() { |
|
60 | + if ( class_exists( 'WP_Customize_Control' ) ) { |
|
61 | + require_once( LSX_CUSTOMIZER_PATH . 'classes/class-lsx-customizer-wysiwyg-control.php' ); |
|
62 | + } |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Sanitize checkbox. |
|
67 | - * |
|
68 | - * @since 1.0.0 |
|
69 | - */ |
|
70 | - public function sanitize_checkbox( $input ) { |
|
71 | - return ( 1 === absint( $input ) ) ? 1 : 0; |
|
72 | - } |
|
65 | + /** |
|
66 | + * Sanitize checkbox. |
|
67 | + * |
|
68 | + * @since 1.0.0 |
|
69 | + */ |
|
70 | + public function sanitize_checkbox( $input ) { |
|
71 | + return ( 1 === absint( $input ) ) ? 1 : 0; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Sanitize select. |
|
76 | - * |
|
77 | - * @since 1.1.1 |
|
78 | - */ |
|
79 | - public function sanitize_select( $input ) { |
|
80 | - if ( is_string( $input ) || is_integer( $input ) || is_bool( $input ) ) { |
|
81 | - return $input; |
|
82 | - } else { |
|
83 | - return ''; |
|
84 | - } |
|
85 | - } |
|
74 | + /** |
|
75 | + * Sanitize select. |
|
76 | + * |
|
77 | + * @since 1.1.1 |
|
78 | + */ |
|
79 | + public function sanitize_select( $input ) { |
|
80 | + if ( is_string( $input ) || is_integer( $input ) || is_bool( $input ) ) { |
|
81 | + return $input; |
|
82 | + } else { |
|
83 | + return ''; |
|
84 | + } |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * Sanitize textarea. |
|
89 | - * |
|
90 | - * @since 1.1.1 |
|
91 | - */ |
|
92 | - public function sanitize_textarea( $input ) { |
|
93 | - return wp_kses_post( $input ); |
|
94 | - } |
|
87 | + /** |
|
88 | + * Sanitize textarea. |
|
89 | + * |
|
90 | + * @since 1.1.1 |
|
91 | + */ |
|
92 | + public function sanitize_textarea( $input ) { |
|
93 | + return wp_kses_post( $input ); |
|
94 | + } |
|
95 | 95 | |
96 | - function custom_login_url() { |
|
97 | - return home_url(); |
|
98 | - } |
|
96 | + function custom_login_url() { |
|
97 | + return home_url(); |
|
98 | + } |
|
99 | 99 | |
100 | - } |
|
100 | + } |
|
101 | 101 | |
102 | - new LSX_Customizer(); |
|
102 | + new LSX_Customizer(); |
|
103 | 103 | |
104 | 104 | } |
@@ -7,59 +7,59 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
10 | - exit; |
|
10 | + exit; |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | if ( ! class_exists( 'LSX_Yoast' ) ) : |
14 | 14 | |
15 | - /** |
|
16 | - * The LSX Yoast integration class |
|
17 | - */ |
|
18 | - class LSX_Yoast { |
|
15 | + /** |
|
16 | + * The LSX Yoast integration class |
|
17 | + */ |
|
18 | + class LSX_Yoast { |
|
19 | 19 | |
20 | - /** |
|
21 | - * Holds class instance |
|
22 | - * |
|
23 | - * @since 1.0.0 |
|
24 | - * @var object |
|
25 | - */ |
|
26 | - protected static $instance = null; |
|
20 | + /** |
|
21 | + * Holds class instance |
|
22 | + * |
|
23 | + * @since 1.0.0 |
|
24 | + * @var object |
|
25 | + */ |
|
26 | + protected static $instance = null; |
|
27 | 27 | |
28 | - /** |
|
29 | - * Setup class. |
|
30 | - * |
|
31 | - * @since 1.0 |
|
32 | - */ |
|
33 | - public function __construct() { |
|
28 | + /** |
|
29 | + * Setup class. |
|
30 | + * |
|
31 | + * @since 1.0 |
|
32 | + */ |
|
33 | + public function __construct() { |
|
34 | 34 | |
35 | - add_action( 'wp_enqueue_scripts', array( $this, 'lsx_yoast_scripts_add_styles' ) ); |
|
36 | - } |
|
35 | + add_action( 'wp_enqueue_scripts', array( $this, 'lsx_yoast_scripts_add_styles' ) ); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Return an instance of this class. |
|
40 | - * |
|
41 | - * @since 1.0.0 |
|
42 | - * @return object A single instance of this class. |
|
43 | - */ |
|
44 | - public static function get_instance() { |
|
45 | - // If the single instance hasn't been set, set it now. |
|
46 | - if ( null === self::$instance ) { |
|
47 | - self::$instance = new self(); |
|
48 | - } |
|
49 | - return self::$instance; |
|
50 | - } |
|
38 | + /** |
|
39 | + * Return an instance of this class. |
|
40 | + * |
|
41 | + * @since 1.0.0 |
|
42 | + * @return object A single instance of this class. |
|
43 | + */ |
|
44 | + public static function get_instance() { |
|
45 | + // If the single instance hasn't been set, set it now. |
|
46 | + if ( null === self::$instance ) { |
|
47 | + self::$instance = new self(); |
|
48 | + } |
|
49 | + return self::$instance; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Yoast enqueue styles. |
|
54 | - * |
|
55 | - * @package lsx |
|
56 | - * @subpackage yoast |
|
57 | - */ |
|
58 | - public function lsx_yoast_scripts_add_styles() { |
|
59 | - wp_enqueue_script( 'lsx_yoast_js', LSX_CUSTOMIZER_PATH . 'assets/js/yoast/yoast.js', array( 'jquery' ), LSX_VERSION, true ); |
|
60 | - wp_enqueue_style( 'lsx_yoast_css', LSX_CUSTOMIZER_PATH . 'assets/css/yoast/yoast.css', array( 'lsx_main' ), LSX_VERSION ); |
|
61 | - } |
|
62 | - } |
|
52 | + /** |
|
53 | + * Yoast enqueue styles. |
|
54 | + * |
|
55 | + * @package lsx |
|
56 | + * @subpackage yoast |
|
57 | + */ |
|
58 | + public function lsx_yoast_scripts_add_styles() { |
|
59 | + wp_enqueue_script( 'lsx_yoast_js', LSX_CUSTOMIZER_PATH . 'assets/js/yoast/yoast.js', array( 'jquery' ), LSX_VERSION, true ); |
|
60 | + wp_enqueue_style( 'lsx_yoast_css', LSX_CUSTOMIZER_PATH . 'assets/css/yoast/yoast.css', array( 'lsx_main' ), LSX_VERSION ); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | 64 | endif; |
65 | 65 |
@@ -7,210 +7,210 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
10 | - exit; |
|
10 | + exit; |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | if ( ! function_exists( 'lsx_tec_scripts_add_styles' ) ) : |
14 | 14 | |
15 | - /** |
|
16 | - * The Events Calendar enqueue styles. |
|
17 | - * |
|
18 | - * @package lsx |
|
19 | - * @subpackage the-events-calendar |
|
20 | - */ |
|
21 | - function lsx_tec_scripts_add_styles() { |
|
22 | - |
|
23 | - // Get plugin version. |
|
24 | - $plugin = 'the-events-calendar/the-events-calendar.php'; |
|
25 | - $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); |
|
26 | - $version = $data['Version']; |
|
27 | - |
|
28 | - if ( substr( $version, 0, 1 ) >= '5' ) { |
|
29 | - // New Version 5.0 and up. |
|
30 | - wp_enqueue_style( 'the-events-calendar-lsx', LSX_CUSTOMIZER_URL . 'assets/css/the-events-calendar/the-events-calendar-5.css', array( 'lsx_main' ), LSX_VERSION ); |
|
31 | - } else { |
|
32 | - // Old Version. |
|
33 | - wp_enqueue_style( 'the-events-calendar-lsx', LSX_CUSTOMIZER_URL . 'assets/css/the-events-calendar/the-events-calendar.css', array( 'lsx_main' ), LSX_VERSION ); |
|
34 | - } |
|
35 | - |
|
36 | - wp_enqueue_style( 'the-events-calendar-lsx', LSX_CUSTOMIZER_URL . 'assets/css/the-events-calendar/the-events-calendar.css', array( 'lsx_main' ), LSX_VERSION ); |
|
37 | - wp_style_add_data( 'the-events-calendar-lsx', 'rtl', 'replace' ); |
|
38 | - } |
|
39 | - |
|
40 | - add_action( 'wp_enqueue_scripts', 'lsx_tec_scripts_add_styles' ); |
|
15 | + /** |
|
16 | + * The Events Calendar enqueue styles. |
|
17 | + * |
|
18 | + * @package lsx |
|
19 | + * @subpackage the-events-calendar |
|
20 | + */ |
|
21 | + function lsx_tec_scripts_add_styles() { |
|
22 | + |
|
23 | + // Get plugin version. |
|
24 | + $plugin = 'the-events-calendar/the-events-calendar.php'; |
|
25 | + $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); |
|
26 | + $version = $data['Version']; |
|
27 | + |
|
28 | + if ( substr( $version, 0, 1 ) >= '5' ) { |
|
29 | + // New Version 5.0 and up. |
|
30 | + wp_enqueue_style( 'the-events-calendar-lsx', LSX_CUSTOMIZER_URL . 'assets/css/the-events-calendar/the-events-calendar-5.css', array( 'lsx_main' ), LSX_VERSION ); |
|
31 | + } else { |
|
32 | + // Old Version. |
|
33 | + wp_enqueue_style( 'the-events-calendar-lsx', LSX_CUSTOMIZER_URL . 'assets/css/the-events-calendar/the-events-calendar.css', array( 'lsx_main' ), LSX_VERSION ); |
|
34 | + } |
|
35 | + |
|
36 | + wp_enqueue_style( 'the-events-calendar-lsx', LSX_CUSTOMIZER_URL . 'assets/css/the-events-calendar/the-events-calendar.css', array( 'lsx_main' ), LSX_VERSION ); |
|
37 | + wp_style_add_data( 'the-events-calendar-lsx', 'rtl', 'replace' ); |
|
38 | + } |
|
39 | + |
|
40 | + add_action( 'wp_enqueue_scripts', 'lsx_tec_scripts_add_styles' ); |
|
41 | 41 | |
42 | 42 | endif; |
43 | 43 | |
44 | 44 | if ( ! function_exists( 'lsx_tec_theme_wrapper_start' ) ) : |
45 | 45 | |
46 | - /** |
|
47 | - * The Events Calendar wrapper start. |
|
48 | - * |
|
49 | - * @package lsx |
|
50 | - * @subpackage the-events-calendar |
|
51 | - */ |
|
52 | - function lsx_tec_theme_wrapper_start() { |
|
53 | - if ( function_exists( 'lsx_is_rest_api_request' ) && lsx_is_rest_api_request() ) { |
|
54 | - return; |
|
55 | - } |
|
56 | - lsx_content_wrap_before(); |
|
57 | - echo '<div id="primary" class="content-area ' . esc_attr( lsx_main_class() ) . '">'; |
|
58 | - lsx_content_before(); |
|
59 | - echo '<main id="main" class="site-main" role="main">'; |
|
60 | - lsx_content_top(); |
|
61 | - } |
|
62 | - |
|
63 | - add_action( 'tribe_events_before_html', 'lsx_tec_theme_wrapper_start', 9 ); |
|
46 | + /** |
|
47 | + * The Events Calendar wrapper start. |
|
48 | + * |
|
49 | + * @package lsx |
|
50 | + * @subpackage the-events-calendar |
|
51 | + */ |
|
52 | + function lsx_tec_theme_wrapper_start() { |
|
53 | + if ( function_exists( 'lsx_is_rest_api_request' ) && lsx_is_rest_api_request() ) { |
|
54 | + return; |
|
55 | + } |
|
56 | + lsx_content_wrap_before(); |
|
57 | + echo '<div id="primary" class="content-area ' . esc_attr( lsx_main_class() ) . '">'; |
|
58 | + lsx_content_before(); |
|
59 | + echo '<main id="main" class="site-main" role="main">'; |
|
60 | + lsx_content_top(); |
|
61 | + } |
|
62 | + |
|
63 | + add_action( 'tribe_events_before_html', 'lsx_tec_theme_wrapper_start', 9 ); |
|
64 | 64 | |
65 | 65 | endif; |
66 | 66 | |
67 | 67 | if ( ! function_exists( 'lsx_tec_theme_wrapper_end' ) ) : |
68 | 68 | |
69 | - /** |
|
70 | - * The Events Calendar wrapper end. |
|
71 | - * |
|
72 | - * @package lsx |
|
73 | - * @subpackage the-events-calendar |
|
74 | - */ |
|
75 | - function lsx_tec_theme_wrapper_end() { |
|
76 | - if ( function_exists( 'lsx_is_rest_api_request' ) && lsx_is_rest_api_request() ) { |
|
77 | - return; |
|
78 | - } |
|
79 | - lsx_content_bottom(); |
|
80 | - echo '</main>'; |
|
81 | - lsx_content_after(); |
|
82 | - echo '</div>'; |
|
83 | - lsx_content_wrap_after(); |
|
84 | - } |
|
85 | - |
|
86 | - add_action( 'tribe_events_after_html', 'lsx_tec_theme_wrapper_end', 11 ); |
|
69 | + /** |
|
70 | + * The Events Calendar wrapper end. |
|
71 | + * |
|
72 | + * @package lsx |
|
73 | + * @subpackage the-events-calendar |
|
74 | + */ |
|
75 | + function lsx_tec_theme_wrapper_end() { |
|
76 | + if ( function_exists( 'lsx_is_rest_api_request' ) && lsx_is_rest_api_request() ) { |
|
77 | + return; |
|
78 | + } |
|
79 | + lsx_content_bottom(); |
|
80 | + echo '</main>'; |
|
81 | + lsx_content_after(); |
|
82 | + echo '</div>'; |
|
83 | + lsx_content_wrap_after(); |
|
84 | + } |
|
85 | + |
|
86 | + add_action( 'tribe_events_after_html', 'lsx_tec_theme_wrapper_end', 11 ); |
|
87 | 87 | |
88 | 88 | endif; |
89 | 89 | |
90 | 90 | if ( ! function_exists( 'lsx_tec_global_header_title' ) ) : |
91 | 91 | |
92 | - /** |
|
93 | - * Move the events title into the global header |
|
94 | - * |
|
95 | - * @package lsx |
|
96 | - * @subpackage the-events-calendar |
|
97 | - */ |
|
98 | - function lsx_tec_global_header_title( $title ) { |
|
99 | - |
|
100 | - if ( tribe_is_community_edit_event_page() ) { |
|
101 | - |
|
102 | - $is_route = get_query_var( 'WP_Route' ); |
|
103 | - switch ( $is_route ) { |
|
104 | - case 'ce-edit-route': |
|
105 | - $title = apply_filters( 'tribe_ce_edit_event_page_title', __( 'Edit an Event', 'lsx' ) ); |
|
106 | - break; |
|
107 | - |
|
108 | - case 'ce-edit-organizer-route': |
|
109 | - $title = __( 'Edit an Organizer', 'lsx' ); |
|
110 | - break; |
|
111 | - |
|
112 | - case 'ce-edit-venue-route': |
|
113 | - $title = __( 'Edit a Venue', 'lsx' ); |
|
114 | - break; |
|
115 | - |
|
116 | - default: |
|
117 | - $title = apply_filters( 'tribe_ce_submit_event_page_title', __( 'Submit an Event', 'lsx' ) ); |
|
118 | - break; |
|
119 | - } |
|
120 | - } elseif ( tribe_is_community_my_events_page() ) { |
|
121 | - $title = apply_filters( 'tribe_ce_submit_event_page_title', __( 'My Events', 'lsx' ) ); |
|
122 | - } elseif ( tribe_is_event() && ( ! is_tag() ) ) { |
|
123 | - $title = tribe_get_events_title(); |
|
124 | - } |
|
125 | - |
|
126 | - // Only disable the title after we have retrieved it. |
|
127 | - add_filter( 'tribe_get_events_title', 'lsx_text_disable_body_title', 200, 1 ); |
|
128 | - |
|
129 | - if ( is_singular( 'tribe_events' ) ) { |
|
130 | - add_filter( 'the_title', 'lsx_text_disable_body_title', 200, 1 ); |
|
131 | - } |
|
132 | - |
|
133 | - if ( class_exists( 'LSX_Banners' ) ) { |
|
134 | - if ( is_archive() && is_post_type_archive( 'tribe_events' ) ) { |
|
135 | - $options = get_option( '_lsx_settings', false ); |
|
136 | - if ( is_array( $options ) && isset( $options['tribe_events'] ) && isset( $options['tribe_events']['title'] ) && '' !== $options['tribe_events']['title'] ) { |
|
137 | - $title = $options['tribe_events']['title']; |
|
138 | - } |
|
139 | - } |
|
140 | - $title = '<h1 class="page-title">' . $title . '</h1>'; |
|
141 | - } |
|
142 | - return $title; |
|
143 | - } |
|
144 | - add_filter( 'lsx_banner_title', 'lsx_tec_global_header_title', 200, 1 ); |
|
145 | - add_filter( 'lsx_global_header_title', 'lsx_tec_global_header_title', 200, 1 ); |
|
92 | + /** |
|
93 | + * Move the events title into the global header |
|
94 | + * |
|
95 | + * @package lsx |
|
96 | + * @subpackage the-events-calendar |
|
97 | + */ |
|
98 | + function lsx_tec_global_header_title( $title ) { |
|
99 | + |
|
100 | + if ( tribe_is_community_edit_event_page() ) { |
|
101 | + |
|
102 | + $is_route = get_query_var( 'WP_Route' ); |
|
103 | + switch ( $is_route ) { |
|
104 | + case 'ce-edit-route': |
|
105 | + $title = apply_filters( 'tribe_ce_edit_event_page_title', __( 'Edit an Event', 'lsx' ) ); |
|
106 | + break; |
|
107 | + |
|
108 | + case 'ce-edit-organizer-route': |
|
109 | + $title = __( 'Edit an Organizer', 'lsx' ); |
|
110 | + break; |
|
111 | + |
|
112 | + case 'ce-edit-venue-route': |
|
113 | + $title = __( 'Edit a Venue', 'lsx' ); |
|
114 | + break; |
|
115 | + |
|
116 | + default: |
|
117 | + $title = apply_filters( 'tribe_ce_submit_event_page_title', __( 'Submit an Event', 'lsx' ) ); |
|
118 | + break; |
|
119 | + } |
|
120 | + } elseif ( tribe_is_community_my_events_page() ) { |
|
121 | + $title = apply_filters( 'tribe_ce_submit_event_page_title', __( 'My Events', 'lsx' ) ); |
|
122 | + } elseif ( tribe_is_event() && ( ! is_tag() ) ) { |
|
123 | + $title = tribe_get_events_title(); |
|
124 | + } |
|
125 | + |
|
126 | + // Only disable the title after we have retrieved it. |
|
127 | + add_filter( 'tribe_get_events_title', 'lsx_text_disable_body_title', 200, 1 ); |
|
128 | + |
|
129 | + if ( is_singular( 'tribe_events' ) ) { |
|
130 | + add_filter( 'the_title', 'lsx_text_disable_body_title', 200, 1 ); |
|
131 | + } |
|
132 | + |
|
133 | + if ( class_exists( 'LSX_Banners' ) ) { |
|
134 | + if ( is_archive() && is_post_type_archive( 'tribe_events' ) ) { |
|
135 | + $options = get_option( '_lsx_settings', false ); |
|
136 | + if ( is_array( $options ) && isset( $options['tribe_events'] ) && isset( $options['tribe_events']['title'] ) && '' !== $options['tribe_events']['title'] ) { |
|
137 | + $title = $options['tribe_events']['title']; |
|
138 | + } |
|
139 | + } |
|
140 | + $title = '<h1 class="page-title">' . $title . '</h1>'; |
|
141 | + } |
|
142 | + return $title; |
|
143 | + } |
|
144 | + add_filter( 'lsx_banner_title', 'lsx_tec_global_header_title', 200, 1 ); |
|
145 | + add_filter( 'lsx_global_header_title', 'lsx_tec_global_header_title', 200, 1 ); |
|
146 | 146 | |
147 | 147 | endif; |
148 | 148 | |
149 | 149 | if ( ! function_exists( 'lsx_text_disable_body_title' ) ) : |
150 | - /** |
|
151 | - * Disable the events title for the post archive if the dynamic setting is active. |
|
152 | - * |
|
153 | - * @param $title |
|
154 | - * @return string |
|
155 | - */ |
|
156 | - function lsx_text_disable_body_title( $title ) { |
|
157 | - $title = ''; |
|
158 | - remove_filter( 'the_title', 'lsx_text_disable_body_title', 200, 1 ); |
|
159 | - return $title; |
|
160 | - } |
|
150 | + /** |
|
151 | + * Disable the events title for the post archive if the dynamic setting is active. |
|
152 | + * |
|
153 | + * @param $title |
|
154 | + * @return string |
|
155 | + */ |
|
156 | + function lsx_text_disable_body_title( $title ) { |
|
157 | + $title = ''; |
|
158 | + remove_filter( 'the_title', 'lsx_text_disable_body_title', 200, 1 ); |
|
159 | + return $title; |
|
160 | + } |
|
161 | 161 | |
162 | 162 | endif; |
163 | 163 | |
164 | 164 | if ( ! function_exists( 'lsx_tec_breadcrumb_filter' ) ) : |
165 | - /** |
|
166 | - * Fixes the community events breadcrumb |
|
167 | - * |
|
168 | - * @package lsx |
|
169 | - * @subpackage the-events-calendar |
|
170 | - */ |
|
171 | - function lsx_tec_breadcrumb_filter( $crumbs ) { |
|
172 | - |
|
173 | - if ( tribe_is_venue() || tribe_is_organizer() || tribe_is_community_edit_event_page() || tribe_is_community_my_events_page() ) { |
|
174 | - $new_crumbs = array(); |
|
175 | - $new_crumbs[0] = $crumbs[0]; |
|
176 | - |
|
177 | - if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
|
178 | - $new_crumbs[1] = array( |
|
179 | - 0 => __( 'Events', 'lsx' ), |
|
180 | - 1 => get_post_type_archive_link( 'tribe_events' ), |
|
181 | - ); |
|
182 | - } else { |
|
183 | - $new_crumbs[1] = array( |
|
184 | - 'text' => __( 'Events', 'lsx' ), |
|
185 | - 'url' => get_post_type_archive_link( 'tribe_events' ), |
|
186 | - ); |
|
187 | - } |
|
188 | - |
|
189 | - if ( tribe_is_community_my_events_page() ) { |
|
190 | - $new_crumbs[2] = $crumbs[2]; |
|
191 | - } elseif ( tribe_is_community_edit_event_page() ) { |
|
192 | - |
|
193 | - if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
|
194 | - $new_crumbs[2] = array( |
|
195 | - 0 => apply_filters( 'tribe_ce_submit_event_page_title', __( 'My Events', 'lsx' ) ), |
|
196 | - 1 => tribe_community_events_list_events_link(), |
|
197 | - ); |
|
198 | - } else { |
|
199 | - $new_crumbs[2] = array( |
|
200 | - 'text' => apply_filters( 'tribe_ce_submit_event_page_title', __( 'My Events', 'lsx' ) ), |
|
201 | - 'url' => tribe_community_events_list_events_link(), |
|
202 | - ); |
|
203 | - } |
|
204 | - |
|
205 | - $new_crumbs[3] = $crumbs[2]; |
|
206 | - } else { |
|
207 | - $new_crumbs[2] = $crumbs[1]; |
|
208 | - } |
|
209 | - $crumbs = $new_crumbs; |
|
210 | - } |
|
211 | - return $crumbs; |
|
212 | - } |
|
213 | - add_filter( 'wpseo_breadcrumb_links', 'lsx_tec_breadcrumb_filter', 30, 1 ); |
|
214 | - add_filter( 'woocommerce_get_breadcrumb', 'lsx_tec_breadcrumb_filter', 30, 1 ); |
|
165 | + /** |
|
166 | + * Fixes the community events breadcrumb |
|
167 | + * |
|
168 | + * @package lsx |
|
169 | + * @subpackage the-events-calendar |
|
170 | + */ |
|
171 | + function lsx_tec_breadcrumb_filter( $crumbs ) { |
|
172 | + |
|
173 | + if ( tribe_is_venue() || tribe_is_organizer() || tribe_is_community_edit_event_page() || tribe_is_community_my_events_page() ) { |
|
174 | + $new_crumbs = array(); |
|
175 | + $new_crumbs[0] = $crumbs[0]; |
|
176 | + |
|
177 | + if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
|
178 | + $new_crumbs[1] = array( |
|
179 | + 0 => __( 'Events', 'lsx' ), |
|
180 | + 1 => get_post_type_archive_link( 'tribe_events' ), |
|
181 | + ); |
|
182 | + } else { |
|
183 | + $new_crumbs[1] = array( |
|
184 | + 'text' => __( 'Events', 'lsx' ), |
|
185 | + 'url' => get_post_type_archive_link( 'tribe_events' ), |
|
186 | + ); |
|
187 | + } |
|
188 | + |
|
189 | + if ( tribe_is_community_my_events_page() ) { |
|
190 | + $new_crumbs[2] = $crumbs[2]; |
|
191 | + } elseif ( tribe_is_community_edit_event_page() ) { |
|
192 | + |
|
193 | + if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
|
194 | + $new_crumbs[2] = array( |
|
195 | + 0 => apply_filters( 'tribe_ce_submit_event_page_title', __( 'My Events', 'lsx' ) ), |
|
196 | + 1 => tribe_community_events_list_events_link(), |
|
197 | + ); |
|
198 | + } else { |
|
199 | + $new_crumbs[2] = array( |
|
200 | + 'text' => apply_filters( 'tribe_ce_submit_event_page_title', __( 'My Events', 'lsx' ) ), |
|
201 | + 'url' => tribe_community_events_list_events_link(), |
|
202 | + ); |
|
203 | + } |
|
204 | + |
|
205 | + $new_crumbs[3] = $crumbs[2]; |
|
206 | + } else { |
|
207 | + $new_crumbs[2] = $crumbs[1]; |
|
208 | + } |
|
209 | + $crumbs = $new_crumbs; |
|
210 | + } |
|
211 | + return $crumbs; |
|
212 | + } |
|
213 | + add_filter( 'wpseo_breadcrumb_links', 'lsx_tec_breadcrumb_filter', 30, 1 ); |
|
214 | + add_filter( 'woocommerce_get_breadcrumb', 'lsx_tec_breadcrumb_filter', 30, 1 ); |
|
215 | 215 | |
216 | 216 | endif; |