Passed
Push — add/cover-template-update ( 504704 )
by Virginia
04:39
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_core_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 core 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_core_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-core'] = array(
25
			'title'       => esc_html__( 'Core Settings', 'lsx' ),
26
			'description' => esc_html__( 'Change the core settings.', 'lsx' ),
27
			'priority'    => 21,
28
		);
29
30
		$lsx_controls['settings']['lsx_preloader_content_status'] = array(
31
			'default'           => '1',
32
			'sanitize_callback' => 'lsx_sanitize_checkbox',
33
			'transport'         => 'postMessage',
34
		);
35
36
		$lsx_controls['fields']['lsx_preloader_content_status'] = array(
37
			'label'   => esc_html__( 'Preloader Content', 'lsx' ),
38
			'section' => 'lsx-core',
39
			'type'    => 'checkbox',
40
		);
41
42
		$lsx_controls['settings']['lsx_disable_fonts'] = array(
43
			'default'           => 0,
44
			'sanitize_callback' => 'lsx_sanitize_checkbox',
45
			'transport'         => 'postMessage',
46
		);
47
48
		$lsx_controls['fields']['lsx_disable_fonts'] = array(
49
			'label'   => esc_html__( 'Disable Fonts', 'lsx' ),
50
			'section' => 'lsx-core',
51
			'type'    => 'checkbox',
52
		);
53
54
		return $lsx_controls;
55
	}
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...
56
57
endif;
58
59
add_filter( 'lsx_customizer_controls', 'lsx_customizer_core_controls' );
60
61
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...
62
63
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$lsx_controls" missing
Loading history...
64
	 * Returns an array of the layout panel.
65
	 *
66
	 * @package    lsx
67
	 * @subpackage customizer
68
	 *
69
	 * @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...
70
	 */
71
	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...
72
		$lsx_controls['sections']['lsx-layout'] = array(
73
			'title'       => esc_html__( 'Layout', 'lsx' ),
74
			'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' ),
75
			'priority'    => 22,
76
		);
77
78
		$lsx_controls['settings']['lsx_header_layout'] = array(
79
			'default'   => 'inline',
80
			'type'      => 'theme_mod',
81
			'transport' => 'postMessage',
82
		);
83
84
		$lsx_controls['fields']['lsx_header_layout'] = array(
85
			'label'   => esc_html__( 'Header', 'lsx' ),
86
			'section' => 'lsx-layout',
87
			'control' => 'LSX_Customize_Header_Layout_Control',
88
			'choices' => array(
89
				'central',
90
				'expanded',
91
				'inline',
92
			),
93
		);
94
95
		$lsx_controls['settings']['lsx_header_mobile_layout'] = array(
96
			'default'   => 'navigation-bar',
97
			'type'      => 'theme_mod',
98
			'transport' => 'postMessage',
99
		);
100
101
		$lsx_controls['fields']['lsx_header_mobile_layout'] = array(
102
			'label'   => esc_html__( 'Mobile Header', 'lsx' ),
103
			'section' => 'lsx-layout',
104
			'control' => 'LSX_Customize_Mobile_Header_Layout_Control',
105
			'choices' => array(
106
				'navigation-bar',
107
				'hamburger',
108
			),
109
		);
110
111
		$lsx_controls['settings']['lsx_layout'] = array(
112
			'default'   => '1c',
113
			'type'      => 'theme_mod',
114
			'transport' => 'refresh',
115
		);
116
117
		$lsx_controls['fields']['lsx_layout'] = array(
118
			'label'   => esc_html__( 'Body', 'lsx' ),
119
			'section' => 'lsx-layout',
120
			'control' => 'LSX_Customize_Layout_Control',
121
			'choices' => array(
122
				'1c',
123
				'2cr',
124
				'2cl',
125
			),
126
		);
127
128
		$lsx_controls['settings']['lsx_header_fixed'] = array(
129
			'default'           => false,
130
			'sanitize_callback' => 'lsx_sanitize_checkbox',
131
			'transport'         => 'postMessage',
132
		);
133
134
		$lsx_controls['fields']['lsx_header_fixed'] = array(
135
			'label'   => esc_html__( 'Fixed Header', 'lsx' ),
136
			'section' => 'lsx-layout',
137
			'type'    => 'checkbox',
138
		);
139
140
		$lsx_controls['settings']['lsx_header_search'] = array(
141
			'default'           => false,
142
			'sanitize_callback' => 'lsx_sanitize_checkbox',
143
			'transport'         => 'postMessage',
144
		);
145
146
		$lsx_controls['fields']['lsx_header_search'] = array(
147
			'label'   => esc_html__( 'Search Box in Header', 'lsx' ),
148
			'section' => 'lsx-layout',
149
			'type'    => 'checkbox',
150
		);
151
152
		$lsx_controls['selective_refresh']['lsx_header_search'] = array(
153
			'selector'        => '#lsx-header-search-css',
154
			'render_callback' => function() {
155
				$search_form = get_theme_mod( 'lsx_header_search' );
156
157
				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...
158
					echo 'body #searchform { display: block; }';
159
				} else {
160
					echo 'body #searchform { display: none; }';
161
				}
162
			},
163
		);
164
165
		return $lsx_controls;
166
	}
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...
167
168
endif;
169
170
add_filter( 'lsx_customizer_controls', 'lsx_customizer_layout_controls' );
171
172
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...
173
174
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$lsx_controls" missing
Loading history...
175
	 * Returns an array of the Cover Template panel.
176
	 *
177
	 * @package    lsx
178
	 * @subpackage customizer
179
	 *
180
	 * @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...
181
	 */
182
	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...
183
		$lsx_controls['sections']['lsx-cover-template'] = array(
184
			'title'       => esc_html__( 'Cover Template Settings', 'lsx' ),
185
			'description' => esc_html__( 'Change the cover template settings.', 'lsx' ),
186
			'priority'    => 23,
187
		);
188
189
		$lsx_controls['settings']['lsx_cover_template_fixed_background'] = array(
190
			'default'           => '1',
191
			'sanitize_callback' => 'lsx_sanitize_checkbox',
192
			'transport'         => 'postMessage',
193
		);
194
195
		$lsx_controls['fields']['lsx_cover_template_fixed_background'] = array(
196
			'label'   => esc_html__( 'Fixed Background Image', 'lsx' ),
197
			'section' => 'lsx-cover-template',
198
			'type'    => 'checkbox',
199
		);
200
201
		$lsx_controls['settings']['lsx_cover_template_overlay_background_color'] = array(
202
			'default'           => '#000000',
203
			'sanitize_callback' => 'sanitize_hex_color',
204
			'type'              => 'theme_mod',
205
			'transport'         => 'postMessage',
206
		);
207
208
		$lsx_controls['fields']['lsx_cover_template_overlay_background_color'] = array(
209
			'label'       => esc_html__( 'Overlay Background Color', 'lsx' ),
210
			'description' => __( 'The color used for the overlay. Defaults to black.', 'lsx' ),
211
			'section'     => 'lsx-cover-template',
212
			'control'     => 'WP_Customize_Color_Control',
213
		);
214
215
		$lsx_controls['settings']['lsx_cover_template_overlay_text_color'] = array(
216
			'default'           => '#ffffff',
217
			'sanitize_callback' => 'sanitize_hex_color',
218
			'type'              => 'theme_mod',
219
			'transport'         => 'postMessage',
220
		);
221
222
		$lsx_controls['fields']['lsx_cover_template_overlay_text_color'] = (
223
			array(
224
				'label'       => __( 'Overlay Text Color', 'lsx' ),
225
				'description' => __( 'The color used for the text in the overlay.', 'lsx' ),
226
				'section'     => 'lsx-cover-template',
227
				'control'     => 'WP_Customize_Color_Control',
228
			)
229
		);
230
231
		$lsx_controls['settings']['lsx_cover_template_menu_text_color'] = array(
232
			'default'           => '#ffffff',
233
			'sanitize_callback' => 'sanitize_hex_color',
234
			'type'              => 'theme_mod',
235
			'transport'         => 'postMessage',
236
		);
237
238
		$lsx_controls['fields']['lsx_cover_template_menu_text_color'] = (
239
			array(
240
				'label'       => __( 'Menu Text Color', 'lsx' ),
241
				'description' => __( 'The color used for the text in the nav menu.', 'lsx' ),
242
				'section'     => 'lsx-cover-template',
243
				'control'     => 'WP_Customize_Color_Control',
244
			)
245
		);
246
247
		$lsx_controls['settings']['lsx_cover_template_overlay_opacity'] = array(
248
			'default'           => 80,
249
			'sanitize_callback' => 'absint',
250
			'transport'         => 'postMessage',
251
		);
252
253
		$lsx_controls['fields']['lsx_cover_template_overlay_opacity'] = (
254
			array(
255
				'label'       => __( 'Overlay Opacity', 'lsx' ),
256
				'description' => __( 'Make sure that the contrast is high enough so that the text is readable.', 'lsx' ),
257
				'section'     => 'lsx-cover-template',
258
				'type'        => 'range',
259
			)
260
		);
261
262
		return $lsx_controls;
263
	}
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...
264
265
endif;
266
267
add_filter( 'lsx_customizer_controls', 'lsx_customizer_template_cover_controls' );
268
269
270
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...
271
272
	/**
273
	 * Returns an array of $controls for the customizer class to generate.
274
	 *
275
	 * @package    lsx
276
	 * @subpackage customizer
277
	 *
278
	 * @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...
279
	 */
280
	function lsx_get_customizer_controls() {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
281
		$lsx_controls = array();
282
		$lsx_controls = apply_filters( 'lsx_customizer_controls', $lsx_controls );
283
		return $lsx_controls;
284
	}
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...
285
286
endif;
287
288
$lsx_customizer = new LSX_Theme_Customizer( lsx_get_customizer_controls() );
289