Passed
Pull Request — master (#477)
by Virginia
04:02
created

lsx_customizer_template_cover_controls()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 81
Code Lines 55

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 55
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 81
rs 8.9818

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * LSX functions and definitions - Customizer.
4
 *
5
 * @package    lsx
6
 * @subpackage customizer
7
 */
8
9
if ( ! defined( 'ABSPATH' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
10
	exit;
11
}
12
13
if ( ! function_exists( 'lsx_customizer_layout_controls' ) ) :
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
14
15
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$lsx_controls" missing
Loading history...
16
	 * Returns an array of the layout panel.
17
	 *
18
	 * @package    lsx
19
	 * @subpackage customizer
20
	 *
21
	 * @return $lsx_controls array()
0 ignored issues
show
Documentation Bug introduced by
The doc comment $lsx_controls at position 0 could not be parsed: Unknown type name '$lsx_controls' at position 0 in $lsx_controls.
Loading history...
22
	 */
23
	function lsx_customizer_layout_controls( $lsx_controls ) {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
24
		$lsx_controls['sections']['lsx-layout'] = array(
25
			'title'       => esc_html__( 'Layout', 'lsx' ),
26
			'description' => esc_html__( 'Change the layout sitewide. If your homepage is set to use a page with a template, the following will not apply to it.', 'lsx' ),
27
			'priority'    => 22,
28
		);
29
30
		$lsx_controls['settings']['lsx_header_layout'] = array(
31
			'default'   => 'inline',
32
			'type'      => 'theme_mod',
33
			'transport' => 'postMessage',
34
		);
35
36
		$lsx_controls['fields']['lsx_header_layout'] = array(
37
			'label'   => esc_html__( 'Header', 'lsx' ),
38
			'section' => 'lsx-layout',
39
			'control' => 'LSX_Customize_Header_Layout_Control',
40
			'choices' => array(
41
				'central',
42
				'expanded',
43
				'inline',
44
			),
45
		);
46
47
		$lsx_controls['settings']['lsx_header_mobile_layout'] = array(
48
			'default'   => 'navigation-bar',
49
			'type'      => 'theme_mod',
50
			'transport' => 'postMessage',
51
		);
52
53
		$lsx_controls['fields']['lsx_header_mobile_layout'] = array(
54
			'label'   => esc_html__( 'Mobile Header', 'lsx' ),
55
			'section' => 'lsx-layout',
56
			'control' => 'LSX_Customize_Mobile_Header_Layout_Control',
57
			'choices' => array(
58
				'navigation-bar',
59
				'hamburger',
60
			),
61
		);
62
63
		$lsx_controls['settings']['lsx_layout'] = array(
64
			'default'   => '1c',
65
			'type'      => 'theme_mod',
66
			'transport' => 'refresh',
67
		);
68
69
		$lsx_controls['fields']['lsx_layout'] = array(
70
			'label'   => esc_html__( 'Body', 'lsx' ),
71
			'section' => 'lsx-layout',
72
			'control' => 'LSX_Customize_Layout_Control',
73
			'choices' => array(
74
				'1c',
75
				'2cr',
76
				'2cl',
77
			),
78
		);
79
80
		$lsx_controls['settings']['lsx_header_fixed'] = array(
81
			'default'           => false,
82
			'sanitize_callback' => 'lsx_sanitize_checkbox',
83
			'transport'         => 'postMessage',
84
		);
85
86
		$lsx_controls['fields']['lsx_header_fixed'] = array(
87
			'label'   => esc_html__( 'Fixed Header', 'lsx' ),
88
			'section' => 'lsx-layout',
89
			'type'    => 'checkbox',
90
		);
91
92
		$lsx_controls['settings']['lsx_header_search'] = array(
93
			'default'           => false,
94
			'sanitize_callback' => 'lsx_sanitize_checkbox',
95
			'transport'         => 'postMessage',
96
		);
97
98
		$lsx_controls['fields']['lsx_header_search'] = array(
99
			'label'   => esc_html__( 'Search Box in Header', 'lsx' ),
100
			'section' => 'lsx-layout',
101
			'type'    => 'checkbox',
102
		);
103
104
		$lsx_controls['selective_refresh']['lsx_header_search'] = array(
105
			'selector'        => '#lsx-header-search-css',
106
			'render_callback' => function() {
107
				$search_form = get_theme_mod( 'lsx_header_search' );
108
109
				if ( false !== $search_form ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
110
					echo 'body #searchform { display: block; }';
111
				} else {
112
					echo 'body #searchform { display: none; }';
113
				}
114
			},
115
		);
116
117
		return $lsx_controls;
118
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
119
120
endif;
121
122
add_filter( 'lsx_customizer_controls', 'lsx_customizer_layout_controls' );
123
124
if ( ! function_exists( 'lsx_customizer_template_cover_controls' ) ) :
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
125
126
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$lsx_controls" missing
Loading history...
127
	 * Returns an array of the Cover Template panel.
128
	 *
129
	 * @package    lsx
130
	 * @subpackage customizer
131
	 *
132
	 * @return $lsx_controls array()
0 ignored issues
show
Documentation Bug introduced by
The doc comment $lsx_controls at position 0 could not be parsed: Unknown type name '$lsx_controls' at position 0 in $lsx_controls.
Loading history...
133
	 */
134
	function lsx_customizer_template_cover_controls( $lsx_controls ) {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
135
		$lsx_controls['sections']['lsx-cover-template'] = array(
136
			'title'       => esc_html__( 'Cover Template Settings', 'lsx' ),
137
			'description' => esc_html__( 'Change the cover template settings.', 'lsx' ),
138
			'priority'    => 23,
139
		);
140
141
		$lsx_controls['settings']['lsx_cover_template_fixed_background'] = array(
142
			'default'           => '1',
143
			'sanitize_callback' => 'lsx_sanitize_checkbox',
144
			'transport'         => 'postMessage',
145
		);
146
147
		$lsx_controls['fields']['lsx_cover_template_fixed_background'] = array(
148
			'label'   => esc_html__( 'Fixed Background Image', 'lsx' ),
149
			'section' => 'lsx-cover-template',
150
			'type'    => 'checkbox',
151
		);
152
153
		$lsx_controls['settings']['lsx_cover_template_overlay_background_color'] = array(
154
			'default'           => '#000000',
155
			'sanitize_callback' => 'sanitize_hex_color',
156
			'type'              => 'theme_mod',
157
			'transport'         => 'postMessage',
158
		);
159
160
		$lsx_controls['fields']['lsx_cover_template_overlay_background_color'] = array(
161
			'label'       => esc_html__( 'Overlay Background Color', 'lsx' ),
162
			'description' => __( 'The color used for the overlay. Defaults to black.', 'lsx' ),
163
			'section'     => 'lsx-cover-template',
164
			'control'     => 'WP_Customize_Color_Control',
165
		);
166
167
		$lsx_controls['settings']['lsx_cover_template_overlay_text_color'] = array(
168
			'default'           => '#ffffff',
169
			'sanitize_callback' => 'sanitize_hex_color',
170
			'type'              => 'theme_mod',
171
			'transport'         => 'postMessage',
172
		);
173
174
		$lsx_controls['fields']['lsx_cover_template_overlay_text_color'] = (
175
			array(
176
				'label'       => __( 'Overlay Text Color', 'lsx' ),
177
				'description' => __( 'The color used for the text in the overlay.', 'lsx' ),
178
				'section'     => 'lsx-cover-template',
179
				'control'     => 'WP_Customize_Color_Control',
180
			)
181
		);
182
183
		$lsx_controls['settings']['lsx_cover_template_menu_text_color'] = array(
184
			'default'           => '#ffffff',
185
			'sanitize_callback' => 'sanitize_hex_color',
186
			'type'              => 'theme_mod',
187
			'transport'         => 'postMessage',
188
		);
189
190
		$lsx_controls['fields']['lsx_cover_template_menu_text_color'] = (
191
			array(
192
				'label'       => __( 'Menu Text Color', 'lsx' ),
193
				'description' => __( 'The color used for the text in the nav menu.', 'lsx' ),
194
				'section'     => 'lsx-cover-template',
195
				'control'     => 'WP_Customize_Color_Control',
196
			)
197
		);
198
199
		$lsx_controls['settings']['lsx_cover_template_overlay_opacity'] = array(
200
			'default'           => 80,
201
			'sanitize_callback' => 'absint',
202
			'transport'         => 'postMessage',
203
		);
204
205
		$lsx_controls['fields']['lsx_cover_template_overlay_opacity'] = (
206
			array(
207
				'label'       => __( 'Overlay Opacity', 'lsx' ),
208
				'description' => __( 'Make sure that the contrast is high enough so that the text is readable.', 'lsx' ),
209
				'section'     => 'lsx-cover-template',
210
				'type'        => 'range',
211
			)
212
		);
213
214
		return $lsx_controls;
215
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
216
217
endif;
218
219
add_filter( 'lsx_customizer_controls', 'lsx_customizer_template_cover_controls' );
220
221
222
if ( ! function_exists( 'lsx_get_customizer_controls' ) ) :
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
223
224
	/**
225
	 * Returns an array of $controls for the customizer class to generate.
226
	 *
227
	 * @package    lsx
228
	 * @subpackage customizer
229
	 *
230
	 * @return $lsx_controls array()
0 ignored issues
show
Documentation Bug introduced by
The doc comment $lsx_controls at position 0 could not be parsed: Unknown type name '$lsx_controls' at position 0 in $lsx_controls.
Loading history...
231
	 */
232
	function lsx_get_customizer_controls() {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
233
		$lsx_controls = array();
234
		$lsx_controls = apply_filters( 'lsx_customizer_controls', $lsx_controls );
235
		return $lsx_controls;
236
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
237
238
endif;
239
240
$lsx_customizer = new LSX_Theme_Customizer( lsx_get_customizer_controls() );
241