1 | <?php |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
2 | if ( ! class_exists( 'LSX_Customizer_Colour_Top_Menu' ) ) { |
||
0 ignored issues
–
show
|
|||
3 | |||
4 | /** |
||
5 | * LSX Customizer Colour Top Menu Class |
||
6 | * |
||
7 | * @package LSX Customizer |
||
8 | * @author LightSpeed |
||
9 | * @license GPL3 |
||
10 | * @link |
||
11 | * @copyright 2016 LightSpeed |
||
12 | */ |
||
13 | class LSX_Customizer_Colour_Top_Menu 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__top_menu_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__top_menu_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__top_menu_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_top_menu', array( |
||
0 ignored issues
–
show
|
|||
70 | 'top_menu_background_color' => get_theme_mod( 'top_menu_background_color', $colors['top_menu_background_color'] ), |
||
0 ignored issues
–
show
|
|||
71 | 'top_menu_link_color' => get_theme_mod( 'top_menu_link_color', $colors['top_menu_link_color'] ), |
||
0 ignored issues
–
show
|
|||
72 | 'top_menu_link_hover_color' => get_theme_mod( 'top_menu_link_hover_color', $colors['top_menu_link_hover_color'] ), |
||
0 ignored issues
–
show
|
|||
73 | 'top_menu_icon_color' => get_theme_mod( 'top_menu_icon_color', $colors['top_menu_icon_color'] ), |
||
0 ignored issues
–
show
|
|||
74 | 'top_menu_icon_hover_color' => get_theme_mod( 'top_menu_icon_hover_color', $colors['top_menu_icon_hover_color'] ), |
||
0 ignored issues
–
show
|
|||
75 | 'top_menu_dropdown_color' => get_theme_mod( 'top_menu_dropdown_color', $colors['top_menu_dropdown_color'] ), |
||
0 ignored issues
–
show
|
|||
76 | 'top_menu_dropdown_hover_color' => get_theme_mod( 'top_menu_dropdown_hover_color', $colors['top_menu_dropdown_hover_color'] ), |
||
0 ignored issues
–
show
|
|||
77 | 'top_menu_dropdown_link_color' => get_theme_mod( 'top_menu_dropdown_link_color', $colors['top_menu_dropdown_link_color'] ), |
||
0 ignored issues
–
show
|
|||
78 | 'top_menu_dropdown_link_hover_color' => get_theme_mod( 'top_menu_dropdown_link_hover_color', $colors['top_menu_dropdown_link_hover_color'] ), |
||
79 | ) ); |
||
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.
![]() |
|||
80 | } |
||
0 ignored issues
–
show
|
|||
81 | |||
82 | /** |
||
0 ignored issues
–
show
|
|||
83 | * Returns CSS. |
||
84 | * |
||
85 | * @since 1.0.0 |
||
86 | */ |
||
87 | function get_css( $colors ) { |
||
88 | global $customizer_colour_names; |
||
89 | |||
90 | $colors_template = array(); |
||
91 | |||
92 | foreach ( $customizer_colour_names as $key => $value ) { |
||
0 ignored issues
–
show
|
|||
93 | $colors_template[ $key ] = ''; |
||
94 | } |
||
95 | |||
96 | $colors = wp_parse_args( $colors, $colors_template ); |
||
97 | |||
98 | if ( empty( $colors['top_menu_background_color'] ) |
||
0 ignored issues
–
show
|
|||
99 | || empty( $colors['top_menu_link_color'] ) |
||
100 | || empty( $colors['top_menu_link_hover_color'] ) |
||
101 | || empty( $colors['top_menu_icon_color'] ) |
||
102 | || empty( $colors['top_menu_icon_hover_color'] ) |
||
103 | || empty( $colors['top_menu_dropdown_color'] ) |
||
104 | || empty( $colors['top_menu_dropdown_hover_color'] ) |
||
105 | || empty( $colors['top_menu_dropdown_link_color'] ) |
||
106 | || empty( $colors['top_menu_dropdown_link_hover_color'] ) ) { |
||
107 | return ''; |
||
108 | } |
||
109 | |||
110 | $css = ' |
||
111 | @import "' . get_template_directory() . '/assets/css/scss/global/mixins/top-menu"; |
||
112 | |||
113 | /** |
||
114 | * LSX Customizer - Top Menu |
||
115 | */ |
||
116 | @include top-menu-colours ( |
||
117 | $bg: ' . $colors['top_menu_background_color'] . ', |
||
118 | $link: ' . $colors['top_menu_link_color'] . ', |
||
119 | $hover: ' . $colors['top_menu_link_hover_color'] . ', |
||
120 | $icon: ' . $colors['top_menu_icon_color'] . ', |
||
121 | $icon-hover: ' . $colors['top_menu_icon_hover_color'] . ', |
||
122 | $dropdown: ' . $colors['top_menu_dropdown_color'] . ', |
||
123 | $dropdown-hover: ' . $colors['top_menu_dropdown_hover_color'] . ', |
||
124 | $dropdown-link: ' . $colors['top_menu_dropdown_link_color'] . ', |
||
125 | $dropdown-link-hover: ' . $colors['top_menu_dropdown_link_hover_color'] . ' |
||
126 | ); |
||
127 | '; |
||
128 | |||
129 | $css = apply_filters( 'lsx_customizer_colour_selectors_top_menu', $css, $colors ); |
||
130 | $css = parent::scss_to_css( $css ); |
||
131 | |||
132 | return $css; |
||
133 | } |
||
0 ignored issues
–
show
|
|||
134 | |||
135 | } |
||
136 | |||
137 | } |
||
138 |