lsx_customizer_template_cover_controls()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 128
Code Lines 88

Duplication

Lines 0
Ratio 0 %

Importance

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