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

config.php ➔ lsx_file_get_contents()   A

Complexity

Conditions 5
Paths 7

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
nc 7
nop 1
dl 0
loc 20
rs 9.2888
c 0
b 0
f 0
1
<?php
2
/**
3
 * LSX functions and definitions - Config.
4
 *
5
 * @package    lsx
6
 * @subpackage config
7
 */
8
9
if ( ! defined( 'ABSPATH' ) ) {
10
	exit;
11
}
12
13
if ( ! function_exists( 'lsx_setup' ) ) :
14
15
	/**
16
	 * Theme after_setup_theme action.
17
	 *
18
	 * @package    lsx
19
	 * @subpackage config
20
	 */
21
	function lsx_setup() {
22
		global $content_width;
23
		$content_width = 1140;
24
25
		load_theme_textdomain( 'lsx', get_template_directory() . '/languages' );
26
27
		add_image_size( 'lsx-thumbnail-wide',   350, 230, true );
28
		add_image_size( 'lsx-thumbnail-square', 350, 350, true );
29
		add_image_size( 'lsx-thumbnail-single', 750, 350, true );
30
		add_image_size( 'lsx-banner', 1920, 600, true );
31
32
		register_nav_menus( array(
33
			'primary'       => esc_html__( 'Primary Menu', 'lsx' ),
34
			'top-menu'      => esc_html__( 'Top Menu (right)' , 'lsx' ),
35
			'top-menu-left' => esc_html__( 'Top Menu (left)' , 'lsx' ),
36
			'social'        => esc_html__( 'Social Menu' , 'lsx' ),
37
			'footer'        => esc_html__( 'Footer Menu' , 'lsx' ),
38
		) );
39
40
		add_theme_support( 'automatic-feed-links' );
41
		add_theme_support( 'custom-background' );
42
43
		add_theme_support( 'custom-logo', array(
44
			'height'      => 50,
45
			'width'       => 160,
46
			'flex-width'  => true,
47
			'flex-height' => true,
48
		) );
49
50
		add_theme_support( 'html5', array( 'caption' ) );
51
52
		add_theme_support( 'post-formats', array(
53
			'image',
54
			'video',
55
			'gallery',
56
			'audio',
57
			'quote',
58
		) );
59
60
		add_theme_support( 'post-thumbnails' );
61
		add_theme_support( 'sensei' );
62
63
		add_theme_support( 'site-logo', array(
64
			'header-text' => array(
65
				'site-title',
66
				'site-description',
67
			),
68
			'size' => 'medium',
69
		) );
70
71
		add_theme_support( 'title-tag' );
72
73
		/* @TODO - Necessary to test it */
74
		// add_theme_support( 'woocommerce' );
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
75
76
		add_theme_support( 'starter-content', array(
77
			'widgets' => array(
78
				'sidebar-home' => array(
79
					'custom_widget_1' => array(
80
						'text',
81
82
						array(
83
							'title' => '',
84
							'text'  => wp_kses_post( '<div class="row"><div class="col-sm-12 text-center"><h3>Build your perfect website <small>with the LSX theme</small></h3></div></div><div class="row"><div class="col-sm-4 text-center"><h4>Fast</h4><p>"Quick" isn\'t a word most people use when describing their website building experience.</p></div><div class="col-sm-4 text-center"><h4>Easy</h4><p>We\'ve built websites for countless clients, and we know what kind of back-end makes sense easily.</p></div><div class="col-sm-4 text-center"><h4>Comprehensive</h4><p>The LSX extensions come with features out the box that are essential.</p></div></div>' ),
85
						),
86
					),
87
88
					'custom_widget_2' => array(
89
						'text',
90
91
						array(
92
							'title' => '',
93
							'text'  => wp_kses_post( '<div class="lsx-full-width-alt"><div class="row"><div class="col-xs-12"><h3>A big CTA title</h3><p class="text-center"><a class="btn cta-btn" href="http://www.lsdeb.biz/" target="_blank" rel="noreferrer noopener">Hire Us</a><p></div></div></div>' ),
94
						),
95
					),
96
97
					'custom_widget_3' => array(
98
						'text',
99
100
						array(
101
							'title' => '',
102
							'text'  => wp_kses_post( '<div class="row"><div class="col-xs-12"><h3>Homepage Widget</h3><p>Lorem ipsum dolor sit amet, <a href="#">consectetuer adipiscing elit</a>. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p></div></div>' ),
103
						),
104
					),
105
				),
106
107
				'sidebar-footer' => array(
108
					'custom_widget_1' => array(
109
						'text',
110
111
						array(
112
							'title' => esc_html__( 'Space for Footer Widgets', 'lsx' ),
113
							'text'  => esc_html__( 'This is here to showcase some footer widgets. You can decide what to add and what to hide. Nam nostrum evertitur ad, ut pri nibh veniam, urbanitas definitionem eum ex.', 'lsx' ),
114
						),
115
					),
116
117
					'custom_widget_2' => array(
118
						'text',
119
120
						array(
121
							'title' => esc_html__( 'Space for Footer Widgets', 'lsx' ),
122
							'text'  => esc_html__( 'This is here to showcase some footer widgets. You can decide what to add and what to hide. Nam nostrum evertitur ad, ut pri nibh veniam, urbanitas definitionem eum ex.', 'lsx' ),
123
						),
124
					),
125
126
					'custom_widget_3' => array(
127
						'text',
128
129
						array(
130
							'title' => esc_html__( 'Contact us:', 'lsx' ),
131
							'text'  => wp_kses_post( '<a href="mailto:[email protected]><i class="fa fa-envelope fa-fw"></i> [email protected]</a><br><a href="tel:+27214489843"><i class="fa fa-phone fa-fw"></i> +27 21 448 9843</a><br><i class="fa fa-skype fa-fw"></i> /lightspeeddevelopment' ),
132
						),
133
					),
134
				),
135
136
				'sidebar-footer-cta' => array(
137
					'custom_widget_1' => array(
138
						'text',
139
140
						array(
141
							'title' => esc_html__( 'A Footer Call to Action', 'lsx' ),
142
							'text'  => esc_html__( 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.', 'lsx' ),
143
						),
144
					),
145
				),
146
			),
147
148
			'posts' => array(
149
				'home' => array(
150
					'template' => 'page-templates/template-front-page.php',
151
					'thumbnail' => '{{image-banner-example-01}}',
152
					'post_title' => esc_html__( 'LSX is a free WordPress theme', 'lsx' ),
153
					'post_content' => '',
154
				),
155
156
				'about' => array(
157
					'thumbnail' => '{{image-banner-example-02}}',
158
				),
159
160
				'blog',
161
162
				'contact' => array(
163
					'thumbnail' => '{{image-banner-example-03}}',
164
				),
165
			),
166
167
			'attachments' => array(
168
				'image-banner-example-01' => array(
169
					'post_title' => esc_html_x( 'Banner Example 01', 'Theme starter content', 'lsx' ),
170
					'file' => 'assets/images/admin/banner-example-01.jpg',
171
				),
172
173
				'image-banner-example-02' => array(
174
					'post_title' => esc_html_x( 'Banner Example 02', 'Theme starter content', 'lsx' ),
175
					'file' => 'assets/images/admin/banner-example-02.jpg',
176
				),
177
178
				'image-banner-example-03' => array(
179
					'post_title' => esc_html_x( 'Banner Example 03', 'Theme starter content', 'lsx' ),
180
					'file' => 'assets/images/admin/banner-example-03.jpg',
181
				),
182
			),
183
184
			'options' => array(
185
				'show_on_front' => 'page',
186
				'page_on_front' => '{{home}}',
187
				'page_for_posts' => '{{blog}}',
188
				'blogdescription' => esc_html__( 'LSX starter content example', 'lsx' ),
189
			),
190
191
			'nav_menus' => array(
192
				'primary' => array(
193
					'name' => esc_html__( 'Primary Menu', 'lsx' ),
194
195
					'items' => array(
196
						'page_home',
197
						'page_about',
198
						'page_blog',
199
						'page_contact',
200
					),
201
				),
202
203
				'top-menu' => array(
204
					'name' => esc_html__( 'Top Menu', 'lsx' ),
205
206
					'items' => array(
207
						'custom_link_1' => array(
208
							'title' => 'View Map',
209
							'url' => 'https://www.google.com/maps/place/LightSpeed+WordPress+Development/@-33.92945,18.45345,17z/data=!3m1!4b1!4m2!3m1!1s0x1dcc5da1b2446d25:0xc8ecdb1cc8afd170',
210
							'classes' => 'map',
211
						),
212
213
						'custom_link_2' => array(
214
							'title' => '+27 21 448 9843',
215
							'url' => 'tel:+27214489843',
216
							'classes' => 'tel',
217
						),
218
219
						'custom_link_3' => array(
220
							'title' => '[email protected]',
221
							'url' => 'mailto:[email protected]',
222
							'classes' => 'email',
223
						),
224
225
						'page_contact' => array(
226
							'classes' => 'cta',
227
						),
228
					),
229
				),
230
231
				'social' => array(
232
					'name' => esc_html__( 'Social Menu', 'lsx' ),
233
234
					'items' => array(
235
						'link_facebook',
236
						'link_foursquare',
237
						'link_github',
238
						'link_instagram',
239
						'link_linkedin',
240
						'link_pinterest',
241
						'link_twitter',
242
						'link_youtube',
243
					),
244
				),
245
246
				'footer' => array(
247
					'name' => esc_html__( 'Footer Menu', 'lsx' ),
248
249
					'items' => array(
250
						'page_about',
251
						'page_contact',
252
					),
253
				),
254
			),
255
256
			'theme_mods' => array(
257
				'lsx_header_fixed' => true,
258
				'lsx_header_search' => false,
259
				'lsx_layout' => '1c',
260
			),
261
		) );
262
	}
263
264
endif;
265
266
add_action( 'after_setup_theme', 'lsx_setup' );
267
268
if ( ! function_exists( 'lsx_init' ) ) :
269
270
	/**
271
	 * Theme init action.
272
	 *
273
	 * @package    lsx
274
	 * @subpackage config
275
	 */
276
	function lsx_init() {
277
		add_post_type_support( 'page', 'excerpt' );
278
279
		if ( class_exists( 'WooCommerce' ) ) {
280
			remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
281
		}
282
	}
283
284
endif;
285
286
add_action( 'init', 'lsx_init', 100 );
287
288
if ( ! function_exists( 'lsx_process_content_width' ) ) :
289
290
	/**
291
	 * Overwrite the $content_width var, based on the layout of the page.
292
	 *
293
	 * @package    lsx
294
	 * @subpackage config
295
	 */
296
	function lsx_process_content_width() {
297
		global $content_width;
298
299
		if (
300
			is_page_template( 'page-templates/template-front-page.php' ) ||
301
			is_page_template( 'page-templates/template-full-width.php' )
302
		) {
303
			$content_width = 1140;
304
		}
305
	}
306
307
endif;
308
309
add_action( 'wp_head', 'lsx_process_content_width' );
310
311
if ( ! function_exists( 'lsx_file_get_contents' ) ) :
312
313
	/**
314
	 * Get file contents.
315
	 *
316
	 * @package    lsx
317
	 * @subpackage config
318
	 */
319
	function lsx_file_get_contents( $file ) {
320
		if ( file_exists( $file ) ) {
321
			global $wp_filesystem;
322
323
			if ( empty( $wp_filesystem ) ) {
324
				require_once( ABSPATH . 'wp-admin/includes/file.php' );
325
				WP_Filesystem();
326
			}
327
328
			if ( $wp_filesystem ) {
329
				$contents = $wp_filesystem->get_contents( $file );
330
331
				if ( ! empty( $contents ) ) {
332
					return $contents;
333
				}
334
			}
335
		}
336
337
		return '';
338
	}
339
340
endif;
341