Completed
Push — master ( 7b75c8...9eb875 )
by Warwick
02:05
created

layout.php ➔ lsx_post_wrapper_class()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * LSX functions and definitions - Layout.
4
 *
5
 * @package    lsx
6
 * @subpackage layout
7
 */
8
9
if ( ! defined( 'ABSPATH' ) ) {
10
	exit;
11
}
12
13
if ( ! function_exists( 'lsx_layout_selector' ) ) :
14
	/**
15
	 * Layout selector.
16
	 *
17
	 * @package    lsx
18
	 * @subpackage layout
19
	 */
20
	function lsx_layout_selector( $class, $area = 'site' ) {
0 ignored issues
show
Unused Code introduced by
The parameter $area is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
21
		$return_class = '';
22
		$layout       = get_theme_mod( 'lsx_layout', '1c' );
23
		$layout       = apply_filters( 'lsx_layout', $layout );
24
		$default_size = 'sm';
25
		$size         = apply_filters( 'lsx_bootstrap_column_size', $default_size );
26
27
		switch ( $layout ) {
28
			case '1c':
29
				$main_class    = 'col-' . $size . '-12';
30
				$sidebar_class = 'col-' . $size . '-12';
31
				break;
32 View Code Duplication
			case '2cr':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
				$main_class    = 'col-' . $size . '-8';
34
				$sidebar_class = 'col-' . $size . '-4';
35
				break;
36
			case '2cl':
37
				$main_class    = 'col-' . $size . '-8 col-' . $size . '-push-4';
38
				$sidebar_class = 'col-' . $size . '-4 col-' . $size . '-pull-8';
39
				break;
40 View Code Duplication
			default:
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
				$main_class    = 'col-' . $size . '-8';
42
				$sidebar_class = 'col-' . $size . '-4';
43
				break;
44
		}
45
46
		if ( 'main' === $class ) {
47
			$return_class = apply_filters( 'lsx_layout_selector', $main_class, $class, $layout, $size );
48
		}
49
50
		if ( 'sidebar' === $class ) {
51
			$return_class = apply_filters( 'lsx_layout_selector', $sidebar_class, $class, $layout, $size );
52
		}
53
54
		return $return_class;
55
	}
56
endif;
57
58
if ( ! function_exists( 'lsx_main_class' ) ) :
59
	/**
60
	 * .main classes.
61
	 *
62
	 * @package    lsx
63
	 * @subpackage layout
64
	 */
65
	function lsx_main_class() {
66
		return lsx_layout_selector( 'main' );
67
	}
68
endif;
69
70
if ( ! function_exists( 'lsx_sidebar_class' ) ) :
71
	/**
72
	 * .sidebar classes.
73
	 *
74
	 * @package    lsx
75
	 * @subpackage layout
76
	 */
77
	function lsx_sidebar_class() {
78
		return lsx_layout_selector( 'sidebar' );
79
	}
80
endif;
81
82 View Code Duplication
if ( ! function_exists( 'lsx_header_classes' ) ) :
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
83
	/**
84
	 * Output the classes for the header.
85
	 *
86
	 * @package    lsx
87
	 * @subpackage layout
88
	 */
89
	function lsx_header_classes( $additional = false ) {
90
		$classes = 'banner navbar navbar-default';
91
92
		if ( false !== $additional ) {
93
			$classes .= ' ' . $additional;
94
		}
95
96
		echo esc_attr( $classes );
97
	}
98
endif;
99
100 View Code Duplication
if ( ! function_exists( 'lsx_top_menu_classes' ) ) :
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
101
	/**
102
	 * Output the classes for the top-menu.
103
	 *
104
	 * @package    lsx
105
	 * @subpackage layout
106
	 */
107
	function lsx_top_menu_classes( $additional = false ) {
108
		$classes = 'top-menu-default';
109
110
		if ( false !== $additional ) {
111
			$classes .= ' ' . $additional;
112
		}
113
114
		echo esc_attr( $classes );
115
	}
116
endif;
117
118
if ( ! function_exists( 'lsx_post_wrapper_class' ) ) :
119
	/**
120
	 * Output the classes for the top-menu.
121
	 *
122
	 * @package    lsx
123
	 * @subpackage layout
124
	 */
125
	function lsx_post_wrapper_class() {
126
		return apply_filters( 'lsx_post_wrapper_class', '' );
127
	}
128
endif;
129
130
131
132
if ( ! function_exists( 'lsx_add_footer_sidebar_area' ) ) :
133
	/**
134
	 * Output the Footer CTA and/pr Footer Widgets.
135
	 *
136
	 * @package    lsx
137
	 * @subpackage layout
138
	 */
139
	function lsx_add_footer_sidebar_area() {
140
		if ( is_active_sidebar( 'sidebar-footer-cta' ) ) : ?>
141
			<div id="footer-cta">
142
				<div class="container">
143
					<div class="lsx-full-width">
144
						<div class="lsx-hero-unit">
145
							<?php dynamic_sidebar( 'sidebar-footer-cta' ); ?>
146
						</div>
147
					</div>
148
				</div>
149
			</div>
150
		<?php endif; ?>
151
152
		<?php if ( is_active_sidebar( 'sidebar-footer' ) ) : ?>
153
			<div id="footer-widgets">
154
				<div class="container">
155
					<div class="row">
156
						<?php dynamic_sidebar( 'sidebar-footer' ); ?>
157
					</div>
158
				</div>
159
			</div>
160
			<?php
161
		endif;
162
	}
163
	add_action( 'lsx_footer_before', 'lsx_add_footer_sidebar_area' );
164
endif;
165
166
if ( ! function_exists( 'lsx_global_header' ) ) :
167
	/**
168
	 * Displays the global header.
169
	 *
170
	 * @package    lsx
171
	 * @subpackage layout
172
	 */
173
	function lsx_global_header() {
174
		$show_on_front  = get_option( 'show_on_front' );
175
		$queried_object = get_queried_object();
176
		$default_size   = 'sm';
177
		$size           = apply_filters( 'lsx_bootstrap_column_size', $default_size );
178
179
		// Pages have their own banner function 'lsx_page_banner()'
180
		// if ( function_exists( 'is_woocommerce' ) && ( is_woocommerce() || is_checkout() || is_cart() || is_account_page() ) ) {
181
		// return;
182
		// }
183
		// Product pages have their own banner function 'lsx_page_banner()'.
184
		if ( function_exists( 'is_woocommerce' ) && ( is_product() ) ) {
185
			return;
186
		}
187
188
		if ( is_page() && ( 'page' !== $show_on_front || ! is_front_page() ) ) :
189
			?>
190
			<div class="archive-header-wrapper banner-page col-<?php echo esc_attr( $size ); ?>-12">
191
				<?php lsx_global_header_inner_bottom(); ?>
192
				<header class="archive-header">
193
					<h1 class="archive-title"><?php the_title(); ?></h1>
194
				</header>
195
196
			</div>
197
			<?php
198
		elseif ( is_single() && ! is_singular( 'post' ) ) :
199
			?>
200
			<div class="archive-header-wrapper banner-single col-<?php echo esc_attr( $size ); ?>-12">
201
				<?php lsx_global_header_inner_bottom(); ?>
202
				<header class="archive-header">
203
					<h1 class="archive-title"><?php echo wp_kses_post( apply_filters( 'lsx_global_header_title', get_the_title() ) ); ?></h1>
204
				</header>
205
206
			</div>
207
			<?php
208
		elseif ( is_search() ) :
209
			?>
210
			<div class="archive-header-wrapper banner-search col-<?php echo esc_attr( $size ); ?>-12">
211
				<?php lsx_global_header_inner_bottom(); ?>
212
				<header class="archive-header">
213
					<h1 class="archive-title">
214
						<?php
215
							printf(
216
								/* Translators: %s: search term/query */
217
								esc_html__( 'Search Results for: %s', 'lsx' ),
218
								'<span>' . get_search_query() . '</span>'
219
							);
220
						?>
221
					</h1>
222
				</header>
223
224
			</div>
225
			<?php
226
		elseif ( is_author() ) :
227
			$author        = get_the_author();
0 ignored issues
show
Unused Code introduced by
$author is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
228
			$author_avatar = get_avatar( get_the_author_meta( 'ID' ), 256 );
0 ignored issues
show
Unused Code introduced by
$author_avatar is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
229
			$author_bio    = get_the_archive_description();
0 ignored issues
show
Unused Code introduced by
$author_bio is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
230
			?>
231
			<div class="archive-header-wrapper banner-archive-author col-<?php echo esc_attr( $size ); ?>-12">
232
				<?php lsx_global_header_inner_bottom(); ?>
233
				<header class="archive-header">
234
					<h1 class="archive-title"><?php the_archive_title(); ?></h1>
235
				</header>
236
237
			</div>
238
			<?php
239
		elseif ( is_archive() ) :
240
			?>
241
			<div class="archive-header-wrapper banner-archive col-<?php echo esc_attr( $size ); ?>-12">
242
				<?php lsx_global_header_inner_bottom(); ?>
243
				<header class="archive-header">
244
					<h1 class="archive-title">
245
						<?php if ( has_post_format() && ! is_category() && ! is_tag() && ! is_date() && ! is_tax( 'post_format' ) ) { ?>
246
							<?php the_archive_title( esc_html__( 'Type:', 'lsx' ) ); ?>
247
						<?php } else { ?>
248
							<?php echo wp_kses_post( apply_filters( 'lsx_global_header_title', get_the_archive_title() ) ); ?>
249
						<?php } ?>
250
					</h1>
251
252
					<?php
253
					if ( false === apply_filters( 'lsx_display_global_header_description', false ) ) {
254
						the_archive_description();
255
					}
256
					?>
257
				</header>
258
			</div>
259
			<?php
260
		elseif ( 'page' === $show_on_front && (int) get_option( 'page_for_posts' ) === $queried_object->ID ) :
261
			?>
262
			<div class="archive-header-wrapper banner-page col-<?php echo esc_attr( $size ); ?>-12">
263
				<?php lsx_global_header_inner_bottom(); ?>
264
				<header class="archive-header">
265
					<h1 class="archive-title"><?php esc_html_e( 'Blog', 'lsx' ); ?></h1>
266
				</header>
267
268
			</div>
269
			<?php
270
		elseif ( ! is_singular( 'post' ) ) :
271
			// Display only the breadcrumbs.
272
			?>
273
			<div class="archive-header-wrapper banner-singular col-<?php echo esc_attr( $size ); ?>-12">
274
				<?php lsx_global_header_inner_bottom(); ?>
275
			</div>
276
			<?php
277
		elseif ( ( true === apply_filters( 'lsx_global_header_disable', false ) ) && ( ! is_search() ) ) :
278
			// Display only the breadcrumbs.
279
			?>
280
			<div class="archive-header-wrapper banner-global col-<?php echo esc_attr( $size ); ?>-12">
281
				<?php lsx_global_header_inner_bottom(); ?>
282
			</div>
283
			<?php
284
		endif;
285
	}
286
	add_action( 'lsx_content_wrap_before', 'lsx_global_header' );
287
endif;
288
289
if ( ! function_exists( 'lsx_author_extra_info' ) ) :
290
	/**
291
	 * Displays the author extra info.
292
	 *
293
	 * @package    lsx
294
	 * @subpackage layout
295
	 */
296
	function lsx_author_extra_info() {
297
		$default_size = 'sm';
298
		$size         = apply_filters( 'lsx_bootstrap_column_size', $default_size );
299
300
		if ( is_author() ) :
301
			$author_id         = get_the_author_meta( 'ID' );
302
			$author            = get_the_author();
303
			$author_avatar     = get_avatar( $author_id, 400 );
304
			$author_bio        = get_the_archive_description();
305
			$author_url        = get_the_author_meta( 'url', $author_id );
306
			$author_email      = get_the_author_meta( 'email', $author_id );
307
			$author_facebook   = get_the_author_meta( 'facebook', $author_id );
308
			$author_linkedin   = get_the_author_meta( 'linkedin', $author_id );
309
			$author_twitter    = get_the_author_meta( 'twitter', $author_id );
310
			$author_googleplus = get_the_author_meta( 'googleplus', $author_id );
311
			?>
312
			<div class="col-<?php echo esc_attr( $size ); ?>-12">
313
				<div class="archive-author-data">
314
					<div class="row">
315
						<?php if ( ! empty( $author_avatar ) ) : ?>
316
							<div class="col-xs-12 col-sm-4 col-md-3">
317
							<figure class="archive-author-avatar"><?php echo wp_kses_post( $author_avatar ); ?></figure>
318
							</div>
319
						<?php endif; ?>
320
						<div class="col-xs-12 col-sm-8 col-md-9">
321
							<a class="back-to-blog" href="<?php echo ( esc_url( get_post_type_archive_link( 'post' ) ) ); ?>"><?php echo esc_html__( 'Back To Blog', 'lsx' ); ?></a>
322
							<!-- Name -->
323
							<h2 class="archive-author-title">
324
								<?php
325
								if ( '' !== $author ) {
326
									echo esc_html( $author );
327
								}
328
								?>
329
							</h2>
330
							<!-- Social -->
331
							<?php if ( ! empty( $author_url ) || ! empty( $author_email ) || ! empty( $author_facebook ) || ! empty( $author_twitter ) || ! empty( $author_googleplus ) ) : ?>
332
								<div class="archive-author-social-links">
333
									<?php if ( ! empty( $author_url ) ) : ?>
334
										<a href="<?php echo esc_url( $author_url ); ?>" target="_blank" rel="nofollow noreferrer noopener" class="archive-author-social-link archive-author-social-link-url"><i class="fa fa-link" aria-hidden="true"></i></a>
335
									<?php endif; ?>
336
337
									<?php if ( ! empty( $author_email ) ) : ?>
338
										<a href="mailto:<?php echo esc_attr( $author_email ); ?>" class="archive-author-social-link archive-author-social-link-email"><i class="fa fa-envelope" aria-hidden="true"></i></a>
339
									<?php endif; ?>
340
341
									<?php if ( ! empty( $author_facebook ) ) : ?>
342
										<a href="<?php echo esc_url( $author_facebook ); ?>" target="_blank" rel="nofollow noreferrer noopener" class="archive-author-social-link archive-author-social-link-facebook"><i class="fa fa-facebook" aria-hidden="true"></i></a>
343
									<?php endif; ?>
344
345
									<?php if ( ! empty( $author_twitter ) ) : ?>
346
										<a href="https://twitter.com/<?php echo esc_attr( $author_twitter ); ?>" target="_blank" rel="nofollow noreferrer noopener" class="archive-author-social-link archive-author-social-link-twitter"><i class="fa fa-twitter" aria-hidden="true"></i></a>
347
									<?php endif; ?>
348
349
									<?php if ( ! empty( $author_linkedin ) ) : ?>
350
										<a href="<?php echo esc_url( $author_linkedin ); ?>" target="_blank" rel="nofollow noreferrer noopener" class="archive-author-social-link archive-author-social-link-linkedin"><i class="fa fa-linkedin" aria-hidden="true"></i></a>
351
									<?php endif; ?>
352
353
									<?php if ( ! empty( $author_googleplus ) ) : ?>
354
										<a href="<?php echo esc_url( $author_googleplus ); ?>" target="_blank" rel="nofollow noreferrer noopener" class="archive-author-social-link archive-author-social-link-googleplus"><i class="fa fa-google-plus" aria-hidden="true"></i></a>
355
									<?php endif; ?>
356
								</div>
357
							<?php endif; ?>
358
359
							<!-- Bio -->
360
							<?php if ( ! empty( $author_bio ) ) : ?>
361
								<p class="archive-author-bio"><?php echo wp_kses_post( $author_bio ); ?></p>
362
							<?php endif; ?>
363
						</div>
364
					</div>
365
				</div>
366
				<h2><?php echo esc_html__( 'Posts', 'lsx' ); ?></h2>
367
			</div>
368
			<?php
369
		endif;
370
	}
371
	add_action( 'lsx_content_wrap_before', 'lsx_author_extra_info', 11 );
372
endif;
373
374
if ( ! function_exists( 'lsx_post_header' ) ) :
375
	/**
376
	 * Displays the post header.
377
	 *
378
	 * @package    lsx
379
	 * @subpackage layout
380
	 */
381
	function lsx_post_header() {
382
		$default_size = 'sm';
383
		$size         = apply_filters( 'lsx_bootstrap_column_size', $default_size );
384
385
		if ( is_singular( 'post' ) ) :
386
			$format = get_post_format();
387
388
			if ( false === $format ) {
389
				$format = 'standard';
390
			}
391
392
			$format = lsx_translate_format_to_fontawesome( $format );
393
			?>
394
			<div class="archive-header-wrapper banner-post-header col-<?php echo esc_attr( $size ); ?>-12">
395
				<header class="archive-header">
396
					<h1 class="archive-title">
397
						<i class="format-link fa fa-<?php echo esc_attr( $format ); ?>"></i>
398
						<span><?php the_title(); ?></span>
399
					</h1>
400
				</header>
401
			</div>
402
			<?php
403
		endif;
404
	}
405
	add_action( 'lsx_entry_top', 'lsx_post_header' );
406
endif;
407
408
if ( ! function_exists( 'lsx_add_viewport_meta_tag' ) ) :
409
	/**
410
	 * Add Viewport Meta Tag to head.
411
	 *
412
	 * @package    lsx
413
	 * @subpackage layout
414
	 */
415
	function lsx_add_viewport_meta_tag() {
416
		?>
417
		<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0">
418
		<?php
419
	}
420
	add_action( 'wp_head', 'lsx_add_viewport_meta_tag' );
421
endif;
422
423
if ( ! function_exists( 'lsx_header_search_form' ) ) :
424
	/**
425
	 * Add a search form to just above the nav menu.
426
	 *
427
	 * @package    lsx
428
	 * @subpackage layout
429
	 */
430
	function lsx_header_search_form() {
431
		$search_form = get_theme_mod( 'lsx_header_search', false );
432
433
		if ( false !== $search_form || is_customize_preview() ) {
434
			get_search_form( true );
435
		}
436
	}
437
	$mobile_header_layout = get_theme_mod( 'lsx_header_mobile_layout', 'navigation-bar' );
438
	add_action( 'lsx_nav_before', 'lsx_header_search_form', 0 );
439
endif;
440
441
// Add entry meta to single post if active.
442
if ( ! function_exists( 'lsx_add_entry_meta' ) ) :
443
	function lsx_add_entry_meta() {
444
		if ( is_single() && is_singular( 'post' ) ) {
445
			?>
446
			<div class="entry-meta">
447
				<?php lsx_post_meta_single_top(); ?>
448
			</div><!-- .entry-meta -->
449
			<?php
450
		}
451
	}
452
	add_action( 'lsx_entry_top', 'lsx_add_entry_meta', 999 );
453
endif;
454