Passed
Push — master ( e51c9a...41921a )
by Chris
04:16
created

lsx_file_get_contents()   A

Complexity

Conditions 5
Paths 7

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 10
nc 7
nop 1
dl 0
loc 19
rs 9.6111
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' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
10
	exit;
11
}
12
13
if ( ! function_exists( 'lsx_setup' ) ) :
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
14
15
	/**
16
	 * Theme after_setup_theme action.
17
	 *
18
	 * @package    lsx
19
	 * @subpackage config
20
	 */
21
	function lsx_setup() {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
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-carousel', 350, 230, true );
28
		add_image_size( 'lsx-thumbnail-wide', 360, 168, true );
29
		add_image_size( 'lsx-thumbnail-square', 350, 350, true );
30
		add_image_size( 'lsx-thumbnail-single', 750, 350, true );
31
		add_image_size( 'lsx-banner', 1920, 600, true );
32
33
		register_nav_menus(
34
			array(
35
				'primary'       => esc_html__( 'Primary Menu', 'lsx' ),
36
				'top-menu'      => esc_html__( 'Top Menu (right)', 'lsx' ),
37
				'top-menu-left' => esc_html__( 'Top Menu (left)', 'lsx' ),
38
				'social'        => esc_html__( 'Social Menu', 'lsx' ),
39
				'footer'        => esc_html__( 'Footer Menu', 'lsx' ),
40
			)
41
		);
42
43
		add_theme_support( 'automatic-feed-links' );
44
		add_theme_support( 'custom-background' );
45
46
		add_theme_support(
47
			'custom-logo',
48
			array(
49
				'height'      => 50,
50
				'width'       => 160,
51
				'flex-width'  => true,
52
				'flex-height' => true,
53
			)
54
		);
55
56
		add_theme_support( 'html5', array( 'caption' ) );
57
58
		add_theme_support(
59
			'post-formats',
60
			array(
61
				'image',
62
				'video',
63
				'gallery',
64
				'audio',
65
				'quote',
66
			)
67
		);
68
69
		add_theme_support( 'post-thumbnails' );
70
		add_theme_support( 'sensei' );
71
72
		add_theme_support(
73
			'site-logo',
74
			array(
75
				'header-text' => array(
76
					'site-title',
77
					'site-description',
78
				),
79
				'size'        => 'medium',
80
			)
81
		);
82
83
		add_theme_support( 'title-tag' );
84
85
		/*
86
		 * @TODO - Necessary to test it
87
		 */
88
89
		// 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...
90
		add_theme_support( 'starter-content', array(
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
91
			'widgets'     => array(
92
				'sidebar-home'       => array(
93
					'custom_widget_1' => array(
94
						'text',
95
96
						array(
97
							'title' => '',
98
							'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>' ),
99
						),
100
					),
101
102
					'custom_widget_2' => array(
103
						'text',
104
105
						array(
106
							'title' => '',
107
							'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>' ),
108
						),
109
					),
110
111
					'custom_widget_3' => array(
112
						'text',
113
114
						array(
115
							'title' => '',
116
							'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>' ),
117
						),
118
					),
119
				),
120
121
				'sidebar-footer'     => array(
122
					'custom_widget_1' => array(
123
						'text',
124
125
						array(
126
							'title' => esc_html__( 'Space for Footer Widgets', 'lsx' ),
127
							'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' ),
128
						),
129
					),
130
131
					'custom_widget_2' => array(
132
						'text',
133
134
						array(
135
							'title' => esc_html__( 'Space for Footer Widgets', 'lsx' ),
136
							'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' ),
137
						),
138
					),
139
140
					'custom_widget_3' => array(
141
						'text',
142
143
						array(
144
							'title' => esc_html__( 'Contact us:', 'lsx' ),
145
							'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' ),
146
						),
147
					),
148
				),
149
150
				'sidebar-footer-cta' => array(
151
					'custom_widget_1' => array(
152
						'text',
153
154
						array(
155
							'title' => esc_html__( 'A Footer Call to Action', 'lsx' ),
156
							'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' ),
157
						),
158
					),
159
				),
160
			),
161
162
			'posts'       => array(
163
				'home'    => array(
164
					'template'     => 'page-templates/template-front-page.php',
165
					'thumbnail'    => '{{image-banner-example-01}}',
166
					'post_title'   => esc_html__( 'LSX is a free WordPress theme', 'lsx' ),
167
					'post_content' => '',
168
				),
169
170
				'about'   => array(
171
					'thumbnail' => '{{image-banner-example-02}}',
172
				),
173
174
				'blog',
175
176
				'contact' => array(
177
					'thumbnail' => '{{image-banner-example-03}}',
178
				),
179
			),
180
181
			'attachments' => array(
182
				'image-banner-example-01' => array(
183
					'post_title' => esc_html_x( 'Banner Example 01', 'Theme starter content', 'lsx' ),
184
					'file'       => 'assets/images/admin/banner-example-01.jpg',
185
				),
186
187
				'image-banner-example-02' => array(
188
					'post_title' => esc_html_x( 'Banner Example 02', 'Theme starter content', 'lsx' ),
189
					'file'       => 'assets/images/admin/banner-example-02.jpg',
190
				),
191
192
				'image-banner-example-03' => array(
193
					'post_title' => esc_html_x( 'Banner Example 03', 'Theme starter content', 'lsx' ),
194
					'file'       => 'assets/images/admin/banner-example-03.jpg',
195
				),
196
			),
197
198
			'options'     => array(
199
				'show_on_front'   => 'page',
200
				'page_on_front'   => '{{home}}',
201
				'page_for_posts'  => '{{blog}}',
202
				'blogdescription' => esc_html__( 'LSX starter content example', 'lsx' ),
203
			),
204
205
			'nav_menus'   => array(
206
				'primary'  => array(
207
					'name'  => esc_html__( 'Primary Menu', 'lsx' ),
208
209
					'items' => array(
210
						'page_home',
211
						'page_about',
212
						'page_blog',
213
						'page_contact',
214
					),
215
				),
216
217
				'top-menu' => array(
218
					'name'  => esc_html__( 'Top Menu', 'lsx' ),
219
220
					'items' => array(
221
						'custom_link_1' => array(
222
							'title'   => 'View Map',
223
							'url'     => 'https://www.google.com/maps/place/LightSpeed+WordPress+Development/@-33.92945,18.45345,17z/data=!3m1!4b1!4m2!3m1!1s0x1dcc5da1b2446d25:0xc8ecdb1cc8afd170',
224
							'classes' => 'map',
225
						),
226
227
						'custom_link_2' => array(
228
							'title'   => '+27 21 448 9843',
229
							'url'     => 'tel:+27214489843',
230
							'classes' => 'tel',
231
						),
232
233
						'custom_link_3' => array(
234
							'title'   => '[email protected]',
235
							'url'     => 'mailto:[email protected]',
236
							'classes' => 'email',
237
						),
238
239
						'page_contact'  => array(
240
							'classes' => 'cta',
241
						),
242
					),
243
				),
244
245
				'social'   => array(
246
					'name'  => esc_html__( 'Social Menu', 'lsx' ),
247
248
					'items' => array(
249
						'link_facebook',
250
						'link_foursquare',
251
						'link_github',
252
						'link_instagram',
253
						'link_linkedin',
254
						'link_pinterest',
255
						'link_twitter',
256
						'link_youtube',
257
					),
258
				),
259
260
				'footer'   => array(
261
					'name'  => esc_html__( 'Footer Menu', 'lsx' ),
262
263
					'items' => array(
264
						'page_about',
265
						'page_contact',
266
					),
267
				),
268
			),
269
270
			'theme_mods'  => array(
271
				'lsx_header_fixed'  => true,
272
				'lsx_header_search' => false,
273
				'lsx_layout'        => '1c',
274
			),
275
		) );
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
276
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
277
278
endif;
279
280
add_action( 'after_setup_theme', 'lsx_setup' );
281
282
if ( ! function_exists( 'lsx_init' ) ) :
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
283
284
	/**
285
	 * Theme init action.
286
	 *
287
	 * @package    lsx
288
	 * @subpackage config
289
	 */
290
	function lsx_init() {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
291
		add_post_type_support( 'page', 'excerpt' );
292
293
		if ( class_exists( 'WooCommerce' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
294
			remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
295
		}
296
297
		remove_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce', 10 );
298
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
299
300
endif;
301
302
add_action( 'init', 'lsx_init', 100 );
303
304
if ( ! function_exists( 'lsx_process_content_width' ) ) :
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
305
306
	/**
307
	 * Overwrite the $content_width var, based on the layout of the page.
308
	 *
309
	 * @package    lsx
310
	 * @subpackage config
311
	 */
312
	function lsx_process_content_width() {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
313
		global $content_width;
314
315
		if (
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; newline found
Loading history...
316
			is_page_template( 'page-templates/template-front-page.php' ) ||
317
			is_page_template( 'page-templates/template-full-width.php' )
318
		) {
319
			$content_width = 1140;
320
		}
321
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
322
323
endif;
324
325
add_action( 'wp_head', 'lsx_process_content_width' );
326
327
if ( ! function_exists( 'lsx_file_get_contents' ) ) :
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
328
329
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$file" missing
Loading history...
330
	 * Get file contents.
331
	 *
332
	 * @package    lsx
333
	 * @subpackage config
334
	 */
335
	function lsx_file_get_contents( $file ) {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
336
		if ( file_exists( $file ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
337
			global $wp_filesystem;
338
339
			if ( empty( $wp_filesystem ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
340
				require_once ABSPATH . 'wp-admin/includes/file.php';
341
				WP_Filesystem();
342
			}
343
344
			if ( $wp_filesystem ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
345
				$contents = $wp_filesystem->get_contents( $file );
346
347
				if ( ! empty( $contents ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
348
					return $contents;
349
				}
350
			}
351
		}
352
353
		return '';
354
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
355
356
endif;
357