Completed
Push — master ( baabf5...12a59e )
by Warwick
03:22
created

customizer.php ➔ lsx_customizer_font_controls()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 31
rs 9.424
c 0
b 0
f 0
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_lazyload_status'] = array(
31
			'default'           => '1',
32
			'sanitize_callback' => 'lsx_sanitize_checkbox',
33
			'transport'         => 'postMessage',
34
		);
35
36
		$lsx_controls['fields']['lsx_lazyload_status'] = array(
37
			'label'   => esc_html__( 'Lazy Loading Images', 'lsx' ),
38
			'section' => 'lsx-core',
39
			'type'    => 'checkbox',
40
		);
41
42
		$lsx_controls['settings']['lsx_preloader_content_status'] = array(
43
			'default'           => '1',
44
			'sanitize_callback' => 'lsx_sanitize_checkbox',
45
			'transport'         => 'postMessage',
46
		);
47
48
		$lsx_controls['fields']['lsx_preloader_content_status'] = array(
49
			'label'   => esc_html__( 'Preloader Content', '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_layout'] = array(
96
			'default'   => '2cr',
97
			'type'      => 'theme_mod',
98
			'transport' => 'refresh',
99
		);
100
101
		$lsx_controls['fields']['lsx_layout'] = array(
102
			'label'   => esc_html__( 'Body', 'lsx' ),
103
			'section' => 'lsx-layout',
104
			'control' => 'LSX_Customize_Layout_Control',
105
			'choices' => array(
106
				'1c',
107
				'2cr',
108
				'2cl',
109
			),
110
		);
111
112
		$lsx_controls['settings']['lsx_header_fixed'] = array(
113
			'default'           => false,
114
			'sanitize_callback' => 'lsx_sanitize_checkbox',
115
			'transport'         => 'postMessage',
116
		);
117
118
		$lsx_controls['fields']['lsx_header_fixed'] = array(
119
			'label'   => esc_html__( 'Fixed Header', 'lsx' ),
120
			'section' => 'lsx-layout',
121
			'type'    => 'checkbox',
122
		);
123
124
		$lsx_controls['settings']['lsx_header_search'] = array(
125
			'default'           => false,
126
			'sanitize_callback' => 'lsx_sanitize_checkbox',
127
			'transport'         => 'postMessage',
128
		);
129
130
		$lsx_controls['fields']['lsx_header_search'] = array(
131
			'label'   => esc_html__( 'Search Box in Header', 'lsx' ),
132
			'section' => 'lsx-layout',
133
			'type'    => 'checkbox',
134
		);
135
136
		$lsx_controls['selective_refresh']['lsx_header_search'] = array(
137
			'selector'          => '#lsx-header-search-css',
138
			'render_callback'   => function() {
139
				$search_form = get_theme_mod( 'lsx_header_search' );
140
141
				if ( false !== $search_form ) {
142
					echo 'body #searchform { display: block; }';
143
				} else {
144
					echo 'body #searchform { display: none; }';
145
				}
146
			},
147
		);
148
149
		return $lsx_controls;
150
	}
151
152
endif;
153
154
add_filter( 'lsx_customizer_controls', 'lsx_customizer_layout_controls' );
155
156
if ( ! function_exists( 'lsx_customizer_font_controls' ) ) :
157
158
	/**
159
	 * Returns an array of the font controls.
160
	 *
161
	 * @package    lsx
162
	 * @subpackage customizer
163
	 *
164
	 * @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...
165
	 */
166
	function lsx_customizer_font_controls( $lsx_controls ) {
167
		$data_fonts_file = get_template_directory() . '/assets/jsons/lsx-fonts.json';
168
		$data_fonts = lsx_file_get_contents( $data_fonts_file );
169
		$data_fonts = apply_filters( 'lsx_fonts_json', $data_fonts );
170
171
		$data_fonts = '{' . $data_fonts . '}';
172
		$data_fonts = json_decode( $data_fonts, true );
173
174
		$lsx_controls['sections']['lsx-font'] = array(
175
			'title'       => esc_html__( 'Font', 'lsx' ),
176
			'description' => esc_html__( 'Change the fonts sitewide.', 'lsx' ),
177
			'priority'    => 41,
178
		);
179
180
		$lsx_controls['settings']['lsx_font']  = array(
181
			'default'   => 'lora_noto_sans',
182
			'type'      => 'theme_mod',
183
			'transport' => 'refresh',
184
		);
185
186
		$lsx_controls['fields']['lsx_font'] = array(
187
			'label'    => '',
188
			'section'  => 'lsx-font',
189
			'settings' => 'lsx_font',
190
			'control'  => 'LSX_Customize_Font_Control',
191
			'choices'  => $data_fonts,
192
			'priority' => 2,
193
		);
194
195
		return $lsx_controls;
196
	}
197
198
endif;
199
200
add_filter( 'lsx_customizer_controls', 'lsx_customizer_font_controls' );
201
202
if ( ! function_exists( 'lsx_get_customizer_controls' ) ) :
203
204
	/**
205
	 * Returns an array of $controls for the customizer class to generate.
206
	 *
207
	 * @package    lsx
208
	 * @subpackage customizer
209
	 *
210
	 * @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...
211
	 */
212
	function lsx_get_customizer_controls() {
213
		$lsx_controls = array();
214
		$lsx_controls = apply_filters( 'lsx_customizer_controls', $lsx_controls );
215
		return $lsx_controls;
216
	}
217
218
endif;
219
220
$lsx_customizer = new LSX_Theme_Customizer( lsx_get_customizer_controls() );
221