Completed
Push — master ( e77289...d72873 )
by Fernando
02:50
created

customizer-colour-extended.php ➔ test_lsx_customizer_colour_choices()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 65
Code Lines 51

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 51
nc 1
nop 1
dl 0
loc 65
rs 9.3571
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
if ( ! defined( 'ABSPATH' ) ) return; // Exit if accessed directly
3
4
/**
5
 * Filter: lsx_customizer_colour_names
6
 *
7
 * Add two new colors (test) in main array of colors
8
 */
9
function test_lsx_customizer_colour_names( $array ) {
10
	$array['test_text_color'] = esc_html__( 'TEST: Text', 'lsx' );
11
	$array['test_text_color_hover'] = esc_html__( 'TEST: Text (hover)', 'lsx' );
12
	return $array;
13
}
14
add_filter( 'lsx_customizer_colour_names', 'test_lsx_customizer_colour_names' );
15
16
/**
17
 * Filter: lsx_customizer_colour_choices_default
18
 *
19
 * Add the new colors (test) in default scheme
20
 */
21
function test_lsx_customizer_colour_choices_default( $array ) {
22
	$array['test_text_color'] = '#ddddd1';
23
	$array['test_text_color_hover'] = '#eeeee1';
24
	return $array;
25
}
26
add_filter( 'lsx_customizer_colour_choices_default', 'test_lsx_customizer_colour_choices_default' );
27
28
/**
29
 * Filter: lsx_customizer_colour_choices_red
30
 *
31
 * Add the new colors (test) in red scheme
32
 */
33
function test_lsx_customizer_colour_choices_red( $array ) {
34
	$array['test_text_color'] = '#ddddd2';
35
	$array['test_text_color_hover'] = '#eeeee2';
36
	return $array;
37
}
38
add_filter( 'lsx_customizer_colour_choices_red', 'test_lsx_customizer_colour_choices_red' );
39
40
/**
41
 * Filter: lsx_customizer_colour_choices_orange
42
 *
43
 * Add the new colors (test) in orange scheme
44
 */
45
function test_lsx_customizer_colour_choices_orange( $array ) {
46
	$array['test_text_color'] = '#ddddd3';
47
	$array['test_text_color_hover'] = '#eeeee3';
48
	return $array;
49
}
50
add_filter( 'lsx_customizer_colour_choices_orange', 'test_lsx_customizer_colour_choices_orange' );
51
52
/**
53
 * Filter: lsx_customizer_colour_choices_green
54
 *
55
 * Add the new colors (test) in green scheme
56
 */
57
function test_lsx_customizer_colour_choices_green( $array ) {
58
	$array['test_text_color'] = '#ddddd4';
59
	$array['test_text_color_hover'] = '#eeeee4';
60
	return $array;
61
}
62
add_filter( 'lsx_customizer_colour_choices_green', 'test_lsx_customizer_colour_choices_green' );
63
64
/**
65
 * Filter: lsx_customizer_colour_choices_brown
66
 *
67
 * Add the new colors (test) in brown scheme
68
 */
69
function test_lsx_customizer_colour_choices_brown( $array ) {
70
	$array['test_text_color'] = '#ddddd5';
71
	$array['test_text_color_hover'] = '#eeeee5';
72
	return $array;
73
}
74
add_filter( 'lsx_customizer_colour_choices_brown', 'test_lsx_customizer_colour_choices_brown' );
75
76
/**
77
 * Filter: lsx_customizer_colour_choices
78
 *
79
 * Add a new scheme
80
 * Also add the new colors (test) in new scheme
81
 */
82
function test_lsx_customizer_colour_choices( $array ) {
83
	$array['test'] = array(
84
		'label'  => __( 'Test', 'lsx' ),
85
		'colors' => array(
86
			'button_background_color'                => '#428bca',
87
			'button_background_hover_color'          => '#2a6496',
88
			'button_text_color'                      => '#ffffff',
89
			'button_text_color_hover'                => '#ffffff',
90
91
			'button_cta_background_color'            => '#f7941d',
92
			'button_cta_background_hover_color'      => '#f7741d',
93
			'button_cta_text_color'                  => '#ffffff',
94
			'button_cta_text_color_hover'            => '#ffffff',
95
96
			'top_menu_background_color'              => '#333333',
97
			'top_menu_text_color'                    => '#ffffff',
98
			'top_menu_text_hover_color'              => '#428bca',
99
100
			'header_background_color'                => '#ffffff',
101
			'header_title_color'                     => '#337ab7',
102
			'header_title_hover_color'               => '#23527c',
103
			'header_description_color'               => '#777777',
104
105
			'main_menu_background_hover1_color'      => '#428bca',
106
			'main_menu_background_hover2_color'      => '#333333',
107
			'main_menu_text_color'                   => '#555555',
108
			'main_menu_text_hover1_color'            => '#ffffff',
109
			'main_menu_text_hover2_color'            => '#ffffff',
110
111
			'banner_background_color'                => '#2a6496',
112
			'banner_text_color'                      => '#ffffff',
113
			'banner_text_image_color'                => '#ffffff',
114
115
			'body_line_color'                        => '#dddddd',
116
			'body_text_heading_color'                => '#333333',
117
			'body_text_color'                        => '#333333',
118
			'body_link_color'                        => '#337ab7',
119
			'body_link_hover_color'                  => '#23527c',
120
			'body_section_full_background_color'     => '#428bca',
121
			'body_section_full_text_color'           => '#ffffff',
122
			'body_section_full_cta_background_color' => '#333333',
123
			'body_section_full_cta_text_color'       => '#ffffff',
124
125
			'footer_cta_background_color'            => '#428bca',
126
			'footer_cta_text_color'                  => '#ffffff',
127
			'footer_cta_link_color'                  => '#eeeeee',
128
			'footer_cta_link_hover_color'            => '#dddddd',
129
130
			'footer_widgets_background_color'        => '#333333',
131
			'footer_widgets_text_color'              => '#eeeeee',
132
			'footer_widgets_link_color'              => '#dddddd',
133
			'footer_widgets_link_hover_color'        => '#cccccc',
134
135
			'footer_background_color'                => '#232222',
136
			'footer_text_color'                      => '#ffffff',
137
			'footer_link_color'                      => '#337ab7',
138
			'footer_link_hover_color'                => '#969696',
139
140
			'test_text_color'                        => '#ddddd6',
141
			'test_text_color_hover'                  => '#eeeee6',
142
		)
143
	);
144
145
	return $array;
146
}
147
add_filter( 'lsx_customizer_colour_choices', 'test_lsx_customizer_colour_choices' );
148
149
/**
150
 * Filter: lsx_customizer_colour_selectors_button
151
 *
152
 * Add new selectors in "button" group of colours
153
 */
154
function test_lsx_customizer_colour_selectors_button( $css, $colors ) {
155
	$css .= <<<CSS
156
	
157
	/* Button TEST */
158
159
	.selector-test-button {
160
		attr1: {$colors['button_background_color']};
161
		attr2: {$colors['button_background_hover_color']};
162
		attr3: {$colors['button_text_color']};
163
		attr4: {$colors['button_text_color_hover']};
164
	}
165
CSS;
166
167
	return $css;
168
}
169
add_filter( 'lsx_customizer_colour_selectors_button', 'test_lsx_customizer_colour_selectors_button', 10, 2 );
170
171
/**
172
 * Filter: lsx_customizer_colour_selectors_button_cta
173
 *
174
 * Add new selectors in "button cta" group of colours
175
 */
176
function test_lsx_customizer_colour_selectors_button_cta( $css, $colors ) {
177
	$css .= <<<CSS
178
	
179
	/* Button CTA TEST */
180
181
	.selector-test-button-cta {
182
		attr1: {$colors['button_cta_background_color']};
183
		attr2: {$colors['button_cta_background_hover_color']};
184
		attr3: {$colors['button_cta_text_color']};
185
		attr4: {$colors['button_cta_text_color_hover']};
186
	}
187
CSS;
188
189
	return $css;
190
}
191
add_filter( 'lsx_customizer_colour_selectors_button_cta', 'test_lsx_customizer_colour_selectors_button_cta', 10, 2 );
192
193
/**
194
 * Filter: lsx_customizer_colour_selectors_top_menu
195
 *
196
 * Add new selectors in "top menu" group of colours
197
 */
198
function test_lsx_customizer_colour_selectors_top_menu( $css, $colors ) {
199
	$css .= <<<CSS
200
	
201
	/* Top Menu TEST */
202
203
	.selector-test-top-menu {
204
		attr1: {$colors['top_menu_background_color']};
205
		attr2: {$colors['top_menu_text_color']};
206
		attr3: {$colors['top_menu_text_hover_color']};
207
	}
208
CSS;
209
210
	return $css;
211
}
212
add_filter( 'lsx_customizer_colour_selectors_top_menu', 'test_lsx_customizer_colour_selectors_top_menu', 10, 2 );
213
214
/**
215
 * Filter: lsx_customizer_colour_selectors_header
216
 *
217
 * Add new selectors in "header" group of colours
218
 */
219
function test_lsx_customizer_colour_selectors_header( $css, $colors ) {
220
	$css .= <<<CSS
221
	
222
	/* Header TEST */
223
224
	.selector-test-header {
225
		attr1: {$colors['header_background_color']};
226
		attr2: {$colors['header_title_color']};
227
		attr3: {$colors['header_title_hover_color']};
228
		attr4: {$colors['header_description_color']};
229
	}
230
CSS;
231
232
	return $css;
233
}
234
add_filter( 'lsx_customizer_colour_selectors_header', 'test_lsx_customizer_colour_selectors_header', 10, 2 );
235
236
/**
237
 * Filter: lsx_customizer_colour_selectors_main_menu
238
 *
239
 * Add new selectors in "main meun" group of colours
240
 */
241
function test_lsx_customizer_colour_selectors_main_menu( $css, $colors ) {
242
	$css .= <<<CSS
243
	
244
	/* Main Menu TEST */
245
246
	.selector-test-main-menu {
247
		attr1: {$colors['main_menu_background_hover1_color']};
248
		attr2: {$colors['main_menu_background_hover2_color']};
249
		attr3: {$colors['main_menu_text_color']};
250
		attr4: {$colors['main_menu_text_hover1_color']};
251
		attr5: {$colors['main_menu_text_hover2_color']};
252
	}
253
CSS;
254
255
	return $css;
256
}
257
add_filter( 'lsx_customizer_colour_selectors_main_menu', 'test_lsx_customizer_colour_selectors_main_menu', 10, 2 );
258
259
/**
260
 * Filter: lsx_customizer_colour_selectors_banner
261
 *
262
 * Add new selectors in "banner" group of colours
263
 */
264
function test_lsx_customizer_colour_selectors_banner( $css, $colors ) {
265
	$css .= <<<CSS
266
	
267
	/* Banner TEST */
268
269
	.selector-test-banner {
270
		attr1: {$colors['banner_background_color']};
271
		attr2: {$colors['banner_text_color']};
272
		attr3: {$colors['banner_text_image_color']};
273
	}
274
CSS;
275
276
	return $css;
277
}
278
add_filter( 'lsx_customizer_colour_selectors_banner', 'test_lsx_customizer_colour_selectors_banner', 10, 2 );
279
280
/**
281
 * Filter: lsx_customizer_colour_selectors_body
282
 *
283
 * Add new selectors in "body" group of colours
284
 */
285
function test_lsx_customizer_colour_selectors_body( $css, $colors ) {
286
	$css .= <<<CSS
287
	
288
	/* Body TEST */
289
290
	.selector-test-body {
291
		attr1: {$colors['background_color']};
292
		attr2: {$colors['body_line_color']};
293
		attr3: {$colors['body_text_heading_color']};
294
		attr4: {$colors['body_text_color']};
295
		attr5: {$colors['body_link_color']};
296
		attr6: {$colors['body_link_hover_color']};
297
		attr7: {$colors['body_section_full_background_color']};
298
		attr8: {$colors['body_section_full_text_color']};
299
		attr9: {$colors['body_section_full_cta_background_color']};
300
		attr10: {$colors['body_section_full_cta_text_color']};
301
	}
302
CSS;
303
304
	return $css;
305
}
306
add_filter( 'lsx_customizer_colour_selectors_body', 'test_lsx_customizer_colour_selectors_body', 10, 2 );
307
308
/**
309
 * Filter: lsx_customizer_colour_selectors_footer_cta
310
 *
311
 * Add new selectors in "footer cta" group of colours
312
 */
313
function test_lsx_customizer_colour_selectors_footer_cta( $css, $colors ) {
314
	$css .= <<<CSS
315
	
316
	/* Footer CTA TEST */
317
318
	.selector-test-footer-cta {
319
		attr1: {$colors['footer_cta_background_color']};
320
		attr2: {$colors['footer_cta_text_color']};
321
		attr3: {$colors['footer_cta_link_color']};
322
		attr4: {$colors['footer_cta_link_hover_color']};
323
	}
324
CSS;
325
326
	return $css;
327
}
328
add_filter( 'lsx_customizer_colour_selectors_footer_cta', 'test_lsx_customizer_colour_selectors_footer_cta', 10, 2 );
329
330
/**
331
 * Filter: lsx_customizer_colour_selectors_footer_widgets
332
 *
333
 * Add new selectors in "footer widgets" group of colours
334
 */
335
function test_lsx_customizer_colour_selectors_footer_widgets( $css, $colors ) {
336
	$css .= <<<CSS
337
	
338
	/* Footer Widgets TEST */
339
340
	.selector-test-footer-widgets {
341
		attr1: {$colors['footer_widgets_background_color']};
342
		attr2: {$colors['footer_widgets_text_color']};
343
		attr3: {$colors['footer_widgets_link_color']};
344
		attr4: {$colors['footer_widgets_link_hover_color']};
345
	}
346
CSS;
347
348
	return $css;
349
}
350
add_filter( 'lsx_customizer_colour_selectors_footer_widgets', 'test_lsx_customizer_colour_selectors_footer_widgets', 10, 2 );
351
352
/**
353
 * Filter: lsx_customizer_colour_selectors_footer
354
 *
355
 * Add new selectors in "footer" group of colours
356
 */
357
function test_lsx_customizer_colour_selectors_footer( $css, $colors ) {
358
	$css .= <<<CSS
359
	
360
	/* Footer TEST */
361
362
	.selector-test-footer {
363
		attr1: {$colors['footer_background_color']};
364
		attr2: {$colors['footer_text_color']};
365
		attr3: {$colors['footer_link_color']};
366
		attr4: {$colors['footer_link_hover_color']};
367
	}
368
CSS;
369
370
	return $css;
371
}
372
add_filter( 'lsx_customizer_colour_selectors_footer', 'test_lsx_customizer_colour_selectors_footer', 10, 2 );
373