Passed
Push — master ( 21f271...41e4ce )
by Warwick
02:15 queued 12s
created

customizer.php ➔ lsx_customizer_template_cover_controls()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 66

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 66
rs 8.7418
c 0
b 0
f 0

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' ) ) {
10
	exit;
11
}
12
13
if ( ! function_exists( 'lsx_customizer_core_controls' ) ) :
14
15
	/**
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 introduced by
The doc-type $lsx_controls could not be parsed: Unknown type name "$lsx_controls" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
22
	 */
23
	function lsx_customizer_core_controls( $lsx_controls ) {
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
	}
56
57
endif;
58
59
add_filter( 'lsx_customizer_controls', 'lsx_customizer_core_controls' );
60
61
if ( ! function_exists( 'lsx_customizer_layout_controls' ) ) :
62
63
	/**
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 introduced by
The doc-type $lsx_controls could not be parsed: Unknown type name "$lsx_controls" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
70
	 */
71
	function lsx_customizer_layout_controls( $lsx_controls ) {
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 ) {
158
					echo 'body #searchform { display: block; }';
159
				} else {
160
					echo 'body #searchform { display: none; }';
161
				}
162
			},
163
		);
164
165
		return $lsx_controls;
166
	}
167
168
endif;
169
170
add_filter( 'lsx_customizer_controls', 'lsx_customizer_layout_controls' );
171
172
if ( ! function_exists( 'lsx_customizer_template_cover_controls' ) ) :
173
174
	/**
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 introduced by
The doc-type $lsx_controls could not be parsed: Unknown type name "$lsx_controls" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
181
	 */
182
	function lsx_customizer_template_cover_controls( $lsx_controls ) {
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_overlay_opacity'] = array(
232
			'default'           => 80,
233
			'sanitize_callback' => 'absint',
234
			'transport'         => 'postMessage',
235
		);
236
237
		$lsx_controls['fields']['lsx_cover_template_overlay_opacity'] = (
238
			array(
239
				'label'       => __( 'Overlay Opacity', 'lsx' ),
240
				'description' => __( 'Make sure that the contrast is high enough so that the text is readable.', 'lsx' ),
241
				'section'     => 'lsx-cover-template',
242
				'type'        => 'range',
243
			)
244
		);
245
246
		return $lsx_controls;
247
	}
248
249
endif;
250
251
add_filter( 'lsx_customizer_controls', 'lsx_customizer_template_cover_controls' );
252
253
254
if ( ! function_exists( 'lsx_get_customizer_controls' ) ) :
255
256
	/**
257
	 * Returns an array of $controls for the customizer class to generate.
258
	 *
259
	 * @package    lsx
260
	 * @subpackage customizer
261
	 *
262
	 * @return $lsx_controls array()
0 ignored issues
show
Documentation introduced by
The doc-type $lsx_controls could not be parsed: Unknown type name "$lsx_controls" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
263
	 */
264
	function lsx_get_customizer_controls() {
265
		$lsx_controls = array();
266
		$lsx_controls = apply_filters( 'lsx_customizer_controls', $lsx_controls );
267
		return $lsx_controls;
268
	}
269
270
endif;
271
272
$lsx_customizer = new LSX_Theme_Customizer( lsx_get_customizer_controls() );
273