1 | <?php |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
2 | if ( ! class_exists( 'LSX_Customizer_Colour_Banner' ) ) { |
||
0 ignored issues
–
show
|
|||
3 | |||
4 | /** |
||
5 | * LSX Customizer Colour Banner Class |
||
6 | * |
||
7 | * @package LSX Customizer |
||
8 | * @author LightSpeed |
||
9 | * @license GPL3 |
||
10 | * @link |
||
11 | * @copyright 2016 LightSpeed |
||
12 | */ |
||
13 | class LSX_Customizer_Colour_Banner extends LSX_Customizer_Colour { |
||
14 | |||
15 | /** |
||
16 | * Constructor. |
||
17 | * |
||
18 | * @since 1.0.0 |
||
19 | */ |
||
20 | public function __construct() { |
||
0 ignored issues
–
show
|
|||
21 | add_action( 'after_switch_theme', array( $this, 'set_theme_mod' ) ); |
||
0 ignored issues
–
show
|
|||
22 | add_action( 'customize_save_after', array( $this, 'set_theme_mod' ) ); |
||
23 | |||
24 | add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_css' ), 2999 ); |
||
25 | } |
||
0 ignored issues
–
show
|
|||
26 | |||
27 | /** |
||
28 | * Assign CSS to theme mod. |
||
29 | * |
||
30 | * @since 1.0.0 |
||
31 | */ |
||
32 | public function set_theme_mod() { |
||
33 | $theme_mods = $this->get_theme_mods(); |
||
34 | $styles = $this->get_css( $theme_mods ); |
||
35 | |||
36 | set_theme_mod( 'lsx_customizer_colour__banner_theme_mod', $styles ); |
||
37 | } |
||
0 ignored issues
–
show
|
|||
38 | |||
39 | /** |
||
40 | * Enqueues front-end CSS. |
||
41 | * |
||
42 | * @since 1.0.0 |
||
43 | */ |
||
44 | public function enqueue_css() { |
||
45 | $styles_from_theme_mod = get_theme_mod( 'lsx_customizer_colour__banner_theme_mod' ); |
||
46 | |||
47 | if ( is_customize_preview() || false === $styles_from_theme_mod ) { |
||
0 ignored issues
–
show
|
|||
48 | $theme_mods = $this->get_theme_mods(); |
||
49 | $styles = $this->get_css( $theme_mods ); |
||
50 | |||
51 | if ( false === $styles_from_theme_mod ) { |
||
0 ignored issues
–
show
|
|||
52 | set_theme_mod( 'lsx_customizer_colour__banner_theme_mod', $styles ); |
||
53 | } |
||
54 | } else { |
||
55 | $styles = $styles_from_theme_mod; |
||
56 | } |
||
57 | |||
58 | wp_add_inline_style( 'lsx-customizer', $styles ); |
||
59 | } |
||
0 ignored issues
–
show
|
|||
60 | |||
61 | /** |
||
62 | * Get CSS theme mods. |
||
63 | * |
||
64 | * @since 1.0.0 |
||
65 | */ |
||
66 | public function get_theme_mods() { |
||
67 | $colors = parent::get_color_scheme(); |
||
68 | |||
69 | return apply_filters( 'lsx_customizer_colours_banner', array( |
||
0 ignored issues
–
show
|
|||
70 | 'banner_background_color' => get_theme_mod( 'banner_background_color', $colors['banner_background_color'] ), |
||
0 ignored issues
–
show
|
|||
71 | 'banner_text_color' => get_theme_mod( 'banner_text_color', $colors['banner_text_color'] ), |
||
0 ignored issues
–
show
|
|||
72 | 'banner_text_image_color' => get_theme_mod( 'banner_text_image_color', $colors['banner_text_image_color'] ), |
||
0 ignored issues
–
show
|
|||
73 | 'banner_breadcrumb_background_color' => get_theme_mod( 'banner_breadcrumb_background_color', $colors['banner_breadcrumb_background_color'] ), |
||
0 ignored issues
–
show
|
|||
74 | 'banner_breadcrumb_text_color' => get_theme_mod( 'banner_breadcrumb_text_color', $colors['banner_breadcrumb_text_color'] ), |
||
0 ignored issues
–
show
|
|||
75 | 'banner_breadcrumb_text_selected_color' => get_theme_mod( 'banner_breadcrumb_text_selected_color', $colors['banner_breadcrumb_text_selected_color'] ), |
||
76 | ) ); |
||
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
![]() |
|||
77 | } |
||
0 ignored issues
–
show
|
|||
78 | |||
79 | /** |
||
0 ignored issues
–
show
|
|||
80 | * Returns CSS. |
||
81 | * |
||
82 | * @since 1.0.0 |
||
83 | */ |
||
84 | function get_css( $colors ) { |
||
85 | global $customizer_colour_names; |
||
86 | |||
87 | $colors_template = array(); |
||
88 | |||
89 | foreach ( $customizer_colour_names as $key => $value ) { |
||
0 ignored issues
–
show
|
|||
90 | $colors_template[ $key ] = ''; |
||
91 | } |
||
92 | |||
93 | $colors = wp_parse_args( $colors, $colors_template ); |
||
94 | |||
95 | if ( empty( $colors['banner_background_color'] ) |
||
0 ignored issues
–
show
|
|||
96 | || empty( $colors['banner_text_color'] ) |
||
97 | || empty( $colors['banner_text_image_color'] ) |
||
98 | || empty( $colors['banner_breadcrumb_background_color'] ) |
||
99 | || empty( $colors['banner_breadcrumb_text_color'] ) |
||
100 | || empty( $colors['banner_breadcrumb_text_selected_color'] ) ) { |
||
101 | return ''; |
||
102 | } |
||
103 | |||
104 | $css = ' |
||
105 | @import "' . get_template_directory() . '/assets/css/scss/global/mixins/banner"; |
||
106 | |||
107 | /** |
||
108 | * LSX Customizer - Banner |
||
109 | */ |
||
110 | @include banner-colours ( |
||
111 | $bg: ' . $colors['banner_background_color'] . ', |
||
112 | $color: ' . $colors['banner_text_color'] . ', |
||
113 | $color-image: ' . $colors['banner_text_image_color'] . ', |
||
114 | $breadcrumb-bg: ' . $colors['banner_breadcrumb_background_color'] . ', |
||
115 | $breadcrumb-color: ' . $colors['banner_breadcrumb_text_color'] . ', |
||
116 | $breadcrumb-current: ' . $colors['banner_breadcrumb_text_selected_color'] . ' |
||
117 | ); |
||
118 | |||
119 | .lsx:not(.single-post) .archive-header .archive-title, .lsx:not(.single-post) .archive-header .page-title, .lsx:not(.single-post) .archive-header *, .lsx:not(.single-post) .archive-header *, .lsx:not(.single-post) .archive-header >p, .lsx:not(.single-post) .archive-header >p, .lsx:not(.single-post):not(.page-has-banner) .archive-header-wrapper .archive-header .archive-title, .lsx:not(.single-post):not(.page-has-banner) .archive-header-wrapper .archive-header>p, .lsx-layout-switcher .lsx-layout-switcher-option { |
||
120 | color: ' . $colors['banner_text_color'] . '; |
||
121 | } |
||
122 | |||
123 | .lsx:not(.single-post) .archive-header.banner-has-custom-bg .archive-title, .lsx:not(.single-post) .archive-header.banner-has-custom-bg .page-title, .lsx:not(.single-post) .archive-header.banner-has-custom-bg *, .lsx:not(.single-post) .archive-header.banner-has-custom-bg *, .lsx:not(.single-post) .archive-header.banner-has-custom-bg >p, .lsx:not(.single-post) .archive-header.banner-has-custom-bg >p, .lsx:not(.single-post):not(.page-has-banner) .archive-header-wrapper .archive-header.banner-has-custom-bg .archive-title, .lsx:not(.single-post):not(.page-has-banner) .archive-header-wrapper .archive-header.banner-has-custom-bg>p, .banner-has-custom-bg .lsx-layout-switcher .lsx-layout-switcher-option { |
||
124 | color: ' . $colors['banner_text_image_color'] . '; |
||
125 | } |
||
126 | .lsx-hero-banner-block { |
||
127 | background-color: ' . $colors['banner_background_color'] . '; |
||
128 | .lsx-title-block { |
||
129 | h1 { |
||
130 | color: ' . $colors['banner_text_color'] . '; |
||
131 | } |
||
132 | } |
||
133 | } |
||
134 | '; |
||
135 | |||
136 | $css = apply_filters( 'lsx_customizer_colour_selectors_banner', $css, $colors ); |
||
137 | $css = parent::scss_to_css( $css ); |
||
138 | |||
139 | return $css; |
||
140 | } |
||
0 ignored issues
–
show
|
|||
141 | |||
142 | } |
||
143 | |||
144 | } |
||
145 |