Issues (1724)

classes/class-lsx-customizer-colour-footer-cta.php (30 issues)

1
<?php
0 ignored issues
show
This file is missing a doc comment.
Loading history...
2
if ( ! class_exists( 'LSX_Customizer_Colour_Footer_CTA' ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
3
4
	/**
5
	 * LSX Customizer Colour Footer CTA Class
6
	 *
7
	 * @package   LSX Customizer
8
	 * @author    LightSpeed
9
	 * @license   GPL3
10
	 * @link
11
	 * @copyright 2016 LightSpeed
12
	 */
13
	class LSX_Customizer_Colour_Footer_CTA extends LSX_Customizer_Colour {
14
15
		/**
16
		 * Constructor.
17
		 *
18
		 * @since 1.0.0
19
		 */
20
		public function __construct() {
0 ignored issues
show
Expected 2 blank lines before function; 1 found
Loading history...
21
			add_action( 'after_switch_theme',   array( $this, 'set_theme_mod' ) );
0 ignored issues
show
Expected 1 space after comma in argument list; 3 found
Loading history...
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
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
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__footer_cta_theme_mod', $styles );
37
		}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
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__footer_cta_theme_mod' );
46
47
			if ( is_customize_preview() || false === $styles_from_theme_mod ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
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
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
52
					set_theme_mod( 'lsx_customizer_colour__footer_cta_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
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
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_footer_cta', array(
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
70
				'footer_cta_background_color' => get_theme_mod( 'footer_cta_background_color', $colors['footer_cta_background_color'] ),
71
				'footer_cta_text_color'       => get_theme_mod( 'footer_cta_text_color',       $colors['footer_cta_text_color'] ),
0 ignored issues
show
Expected 1 space after comma in argument list; 7 found
Loading history...
72
				'footer_cta_link_color'       => get_theme_mod( 'footer_cta_link_color',       $colors['footer_cta_link_color'] ),
0 ignored issues
show
Expected 1 space after comma in argument list; 7 found
Loading history...
73
				'footer_cta_link_hover_color' => get_theme_mod( 'footer_cta_link_hover_color', $colors['footer_cta_link_hover_color'] ),
74
			) );
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.
Loading history...
75
		}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
76
77
		/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$colors" missing
Loading history...
78
		 * Returns CSS.
79
		 *
80
		 * @since 1.0.0
81
		 */
82
		function get_css( $colors ) {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Comprehensibility Best Practice introduced by
It is recommend to declare an explicit visibility for get_css.

Generally, we recommend to declare visibility for all methods in your source code. This has the advantage of clearly communication to other developers, and also yourself, how this method should be consumed.

If you are not sure which visibility to choose, it is a good idea to start with the most restrictive visibility, and then raise visibility as needed, i.e. start with private, and only raise it to protected if a sub-class needs to have access, or public if an external class needs access.

Loading history...
83
			global $customizer_colour_names;
84
85
			$colors_template = array();
86
87
			foreach ( $customizer_colour_names as $key => $value ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
88
				$colors_template[ $key ] = '';
89
			}
90
91
			$colors = wp_parse_args( $colors, $colors_template );
92
93
			if ( empty( $colors['footer_cta_background_color'] )
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
94
				|| empty( $colors['footer_cta_text_color'] )
95
				|| empty( $colors['footer_cta_link_color'] )
96
				|| empty( $colors['footer_cta_link_hover_color'] ) ) {
97
				return '';
98
			}
99
100
			$css = '
101
				@import "' . get_template_directory() . '/assets/css/scss/global/mixins/footer-cta";
102
103
				/**
104
				 * LSX Customizer - Footer CTA
105
				 */
106
				@include footer-cta-colours (
107
					$bg:    ' . $colors['footer_cta_background_color'] . ',
108
					$color: ' . $colors['footer_cta_text_color'] . ',
109
					$link:  ' . $colors['footer_cta_link_color'] . ',
110
					$hover: ' . $colors['footer_cta_link_hover_color'] . '
111
				);
112
			';
113
114
			$css = apply_filters( 'lsx_customizer_colour_selectors_footer_cta', $css, $colors );
115
			$css = parent::scss_to_css( $css );
116
			return $css;
117
		}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
118
119
	}
120
121
}
122