Passed
Push — master ( 8c108b...d88a32 )
by Virginia
02:43
created

layout.php ➔ lsx_add_entry_meta()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 2
nop 0
dl 0
loc 9
rs 9.9666
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
	/**
16
	 * Layout selector.
17
	 *
18
	 * @package    lsx
19
	 * @subpackage layout
20
	 */
21
	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...
22
		$return_class = '';
23
		$layout       = get_theme_mod( 'lsx_layout', '1c' );
24
		$layout       = apply_filters( 'lsx_layout', $layout );
25
		$default_size = 'sm';
26
		$size         = apply_filters( 'lsx_bootstrap_column_size', $default_size );
27
28
		switch ( $layout ) {
29
			case '1c':
30
				$main_class    = 'col-' . $size . '-12';
31
				$sidebar_class = 'col-' . $size . '-12';
32
				break;
33 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...
34
				$main_class    = 'col-' . $size . '-8';
35
				$sidebar_class = 'col-' . $size . '-4';
36
				break;
37
			case '2cl':
38
				$main_class    = 'col-' . $size . '-8 col-' . $size . '-push-4';
39
				$sidebar_class = 'col-' . $size . '-4 col-' . $size . '-pull-8';
40
				break;
41 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...
42
				$main_class    = 'col-' . $size . '-8';
43
				$sidebar_class = 'col-' . $size . '-4';
44
				break;
45
		}
46
47
		if ( 'main' === $class ) {
48
			$return_class = apply_filters( 'lsx_layout_selector', $main_class, $class, $layout, $size );
49
		}
50
51
		if ( 'sidebar' === $class ) {
52
			$return_class = apply_filters( 'lsx_layout_selector', $sidebar_class, $class, $layout, $size );
53
		}
54
55
		return $return_class;
56
	}
57
58
endif;
59
60
if ( ! function_exists( 'lsx_main_class' ) ) :
61
62
	/**
63
	 * .main classes.
64
	 *
65
	 * @package    lsx
66
	 * @subpackage layout
67
	 */
68
	function lsx_main_class() {
69
		return lsx_layout_selector( 'main' );
70
	}
71
72
endif;
73
74
if ( ! function_exists( 'lsx_sidebar_class' ) ) :
75
76
	/**
77
	 * .sidebar classes.
78
	 *
79
	 * @package    lsx
80
	 * @subpackage layout
81
	 */
82
	function lsx_sidebar_class() {
83
		return lsx_layout_selector( 'sidebar' );
84
	}
85
86
endif;
87
88 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...
89
90
	/**
91
	 * Output the classes for the header.
92
	 *
93
	 * @package    lsx
94
	 * @subpackage layout
95
	 */
96
	function lsx_header_classes( $additional = false ) {
97
		$classes = 'banner navbar navbar-default';
98
99
		if ( false !== $additional ) {
100
			$classes .= ' ' . $additional;
101
		}
102
103
		echo esc_attr( $classes );
104
	}
105
106
endif;
107
108 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...
109
110
	/**
111
	 * Output the classes for the top-menu.
112
	 *
113
	 * @package    lsx
114
	 * @subpackage layout
115
	 */
116
	function lsx_top_menu_classes( $additional = false ) {
117
		$classes = 'top-menu-default';
118
119
		if ( false !== $additional ) {
120
			$classes .= ' ' . $additional;
121
		}
122
123
		echo esc_attr( $classes );
124
	}
125
126
endif;
127
128
if ( ! function_exists( 'lsx_add_footer_sidebar_area' ) ) :
129
130
	/**
131
	 * Output the Footer CTA and/pr Footer Widgets.
132
	 *
133
	 * @package    lsx
134
	 * @subpackage layout
135
	 */
136
	function lsx_add_footer_sidebar_area() {
137
		if ( is_active_sidebar( 'sidebar-footer-cta' ) ) : ?>
138
			<div id="footer-cta">
139
				<div class="container">
140
					<div class="lsx-full-width">
141
						<div class="lsx-hero-unit">
142
							<?php dynamic_sidebar( 'sidebar-footer-cta' ); ?>
143
						</div>
144
					</div>
145
				</div>
146
			</div>
147
		<?php endif; ?>
148
149
		<?php if ( is_active_sidebar( 'sidebar-footer' ) ) : ?>
150
			<div id="footer-widgets">
151
				<div class="container">
152
					<div class="row">
153
						<?php dynamic_sidebar( 'sidebar-footer' ); ?>
154
					</div>
155
				</div>
156
			</div>
157
		<?php endif;
158
	}
159
160
	add_action( 'lsx_footer_before', 'lsx_add_footer_sidebar_area' );
161
162
endif;
163
164
if ( ! function_exists( 'lsx_global_header' ) ) :
165
166
	/**
167
	 * Displays the global header.
168
	 *
169
	 * @package    lsx
170
	 * @subpackage layout
171
	 */
172
	function lsx_global_header() {
173
		$show_on_front  = get_option( 'show_on_front' );
174
		$queried_object = get_queried_object();
175
		$default_size   = 'sm';
176
		$size           = apply_filters( 'lsx_bootstrap_column_size', $default_size );
177
178
		if ( true === apply_filters( 'lsx_global_header_disable', false ) ) :
179
			// Display only the breadcrumbs
180
			?>
181
			<div class="archive-header-wrapper col-<?php echo esc_attr( $size ); ?>-12">
182
				<?php lsx_global_header_inner_bottom(); ?>
183
			</div>
184
			<?php
185
		elseif ( is_page() && ( 'page' !== $show_on_front || ! is_front_page() ) ) :
186
			?>
187
			<div class="archive-header-wrapper col-<?php echo esc_attr( $size ); ?>-12">
188
				<?php lsx_global_header_inner_bottom(); ?>
189
				<header class="archive-header">
190
					<h1 class="archive-title"><?php the_title(); ?></h1>
191
				</header>
192
193
			</div>
194
			<?php
195
		elseif ( is_single() && ! is_singular( 'post' ) ) :
196
			?>
197
			<div class="archive-header-wrapper col-<?php echo esc_attr( $size ); ?>-12">
198
				<?php lsx_global_header_inner_bottom(); ?>
199
				<header class="archive-header">
200
					<h1 class="archive-title"><?php echo wp_kses_post( apply_filters( 'lsx_global_header_title', get_the_title() ) ); ?></h1>
201
				</header>
202
203
			</div>
204
			<?php
205
		elseif ( is_search() ) :
206
			?>
207
			<div class="archive-header-wrapper col-<?php echo esc_attr( $size ); ?>-12">
208
				<?php lsx_global_header_inner_bottom(); ?>
209
				<header class="archive-header">
210
					<h1 class="archive-title">
211
						<?php
212
							printf(
213
								/* Translators: %s: search term/query */
214
								esc_html__( 'Search Results for: %s', 'lsx' ),
215
								'<span>' . get_search_query() . '</span>'
216
							);
217
						?>
218
					</h1>
219
				</header>
220
221
			</div>
222
			<?php
223
		elseif ( is_author() ) :
224
			$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...
225
			$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...
226
			$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...
227
			?>
228
			<div class="archive-header-wrapper col-<?php echo esc_attr( $size ); ?>-12">
229
				<?php lsx_global_header_inner_bottom(); ?>
230
				<header class="archive-header">
231
					<h1 class="archive-title"><?php the_archive_title(); ?></h1>
232
				</header>
233
234
			</div>
235
			<?php
236
		elseif ( is_archive() ) :
237
			?>
238
			<div class="archive-header-wrapper col-<?php echo esc_attr( $size ); ?>-12">
239
				<?php lsx_global_header_inner_bottom(); ?>
240
				<header class="archive-header">
241
					<h1 class="archive-title">
242
						<?php if ( has_post_format() && ! is_category() && ! is_tag() && ! is_date() && ! is_tax( 'post_format' ) ) { ?>
243
							<?php the_archive_title( esc_html__( 'Type:', 'lsx' ) ); ?>
244
						<?php } else { ?>
245
							<?php echo wp_kses_post( apply_filters( 'lsx_global_header_title', get_the_archive_title() ) ); ?>
246
						<?php } ?>
247
					</h1>
248
249
					<?php the_archive_description(); ?>
250
				</header>
251
			</div>
252
			<?php
253
		elseif ( 'page' === $show_on_front && (int) get_option( 'page_for_posts' ) === $queried_object->ID ) :
254
			?>
255
			<div class="archive-header-wrapper col-<?php echo esc_attr( $size ); ?>-12">
256
				<?php lsx_global_header_inner_bottom(); ?>
257
				<header class="archive-header">
258
					<h1 class="archive-title"><?php esc_html_e( 'Blog', 'lsx' ); ?></h1>
259
				</header>
260
261
			</div>
262
			<?php
263
		elseif ( ! is_singular( 'post' ) ) :
264
			// Display only the breadcrumbs
265
			?>
266
			<div class="archive-header-wrapper col-<?php echo esc_attr( $size ); ?>-12">
267
				<?php lsx_global_header_inner_bottom(); ?>
268
			</div>
269
			<?php
270
		endif;
271
	}
272
273
	add_action( 'lsx_content_wrap_before', 'lsx_global_header' );
274
275
endif;
276
277
if ( ! function_exists( 'lsx_author_extra_info' ) ) :
278
279
	/**
280
	 * Displays the author extra info.
281
	 *
282
	 * @package    lsx
283
	 * @subpackage layout
284
	 */
285
	function lsx_author_extra_info() {
286
		$default_size   = 'sm';
287
		$size           = apply_filters( 'lsx_bootstrap_column_size', $default_size );
288
289
		if ( is_author() ) :
290
			$author_id         = get_the_author_meta( 'ID' );
291
			$author            = get_the_author();
292
			$author_avatar     = get_avatar( $author_id, 256 );
293
			$author_bio        = get_the_archive_description();
294
			$author_url        = get_the_author_meta( 'url', $author_id );
295
			$author_email      = get_the_author_meta( 'email', $author_id );
296
			$author_facebook   = get_the_author_meta( 'facebook', $author_id );
297
			$author_twitter    = get_the_author_meta( 'twitter', $author_id );
298
			$author_googleplus = get_the_author_meta( 'googleplus', $author_id );
299
			?>
300
			<div class="col-<?php echo esc_attr( $size ); ?>-12">
301
				<div class="archive-author-data">
302
					<figure class="archive-author-avatar"><?php echo wp_kses_post( $author_avatar ); ?></figure>
303
304
					<?php if ( ! empty( $author_url ) || ! empty( $author_email ) || ! empty( $author_facebook ) || ! empty( $author_twitter ) || ! empty( $author_googleplus ) ) : ?>
305
						<div class="archive-author-social-links">
306
							<?php if ( ! empty( $author_url ) ) : ?>
307
								<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>
308
							<?php endif; ?>
309
310
							<?php if ( ! empty( $author_email ) ) : ?>
311
								<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>
312
							<?php endif; ?>
313
314
							<?php if ( ! empty( $author_facebook ) ) : ?>
315
								<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>
316
							<?php endif; ?>
317
318
							<?php if ( ! empty( $author_twitter ) ) : ?>
319
								<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>
320
							<?php endif; ?>
321
322
							<?php if ( ! empty( $author_googleplus ) ) : ?>
323
								<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>
324
							<?php endif; ?>
325
						</div>
326
					<?php endif; ?>
327
328
					<?php if ( ! empty( $author_bio ) ) : ?>
329
						<h2 class="archive-author-title text-center"><?php esc_html_e( 'About the author', 'lsx' ); ?></h2>
330
						<p class="archive-author-bio"><?php echo wp_kses_post( $author_bio ); ?></p>
331
					<?php endif; ?>
332
333
					<h2 class="archive-author-posts text-center">
334
						<?php
335
						if ( '' !== $author ) {
336
							esc_html_e( 'All posts by ', 'lsx' );
337
							esc_html( $author );
338
						}
339
						?>
340
					</h2>
341
				</div>
342
			</div>
343
			<?php
344
		endif;
345
	}
346
347
	add_action( 'lsx_content_wrap_before', 'lsx_author_extra_info', 11 );
348
349
endif;
350
351
if ( ! function_exists( 'lsx_post_header' ) ) :
352
353
	/**
354
	 * Displays the post header.
355
	 *
356
	 * @package    lsx
357
	 * @subpackage layout
358
	 */
359
	function lsx_post_header() {
360
		$default_size  = 'sm';
361
		$size          = apply_filters( 'lsx_bootstrap_column_size', $default_size );
362
363
		if ( is_singular( 'post' ) ) :
364
			$format = get_post_format();
365
366
			if ( false === $format ) {
367
				$format = 'standard';
368
			}
369
370
			$format = lsx_translate_format_to_fontawesome( $format );
371
			?>
372
			<div class="archive-header-wrapper col-<?php echo esc_attr( $size ); ?>-12">
373
				<header class="archive-header">
374
					<h1 class="archive-title">
375
						<i class="format-link fa fa-<?php echo esc_attr( $format ); ?>"></i>
376
						<span><?php the_title(); ?></span>
377
					</h1>
378
				</header>
379
			</div>
380
			<?php
381
		endif;
382
	}
383
384
	add_action( 'lsx_entry_top', 'lsx_post_header' );
385
386
endif;
387
388
if ( ! function_exists( 'lsx_add_viewport_meta_tag' ) ) :
389
390
	/**
391
	 * Add Viewport Meta Tag to head.
392
	 *
393
	 * @package    lsx
394
	 * @subpackage layout
395
	 */
396
	function lsx_add_viewport_meta_tag() {
397
		?>
398
		<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0">
399
		<?php
400
	}
401
402
	add_action( 'wp_head', 'lsx_add_viewport_meta_tag' );
403
404
endif;
405
406
if ( ! function_exists( 'lsx_header_search_form' ) ) :
407
408
	/**
409
	 * Add a search form to just above the nav menu.
410
	 *
411
	 * @package    lsx
412
	 * @subpackage layout
413
	 */
414
	function lsx_header_search_form() {
415
		$search_form = get_theme_mod( 'lsx_header_search', false );
416
417
		if ( false !== $search_form || is_customize_preview() ) {
418
			get_search_form( true );
419
		}
420
	}
421
422
	add_action( 'lsx_nav_before', 'lsx_header_search_form', 0 );
423
424
endif;
425
426
427
// Add entry meta to single post if active
428
429
if ( ! function_exists( 'lsx_add_entry_meta' ) ) :
430
	function lsx_add_entry_meta() {
431
		if ( is_single() && is_singular( 'post' ) ) {
432
			?>
433
			<div class="entry-meta">
434
				<?php lsx_post_meta_single_top(); ?>
435
			</div><!-- .entry-meta -->
436
			<?php
437
		}
438
	}
439
	add_action( 'lsx_entry_top', 'lsx_add_entry_meta', 0 );
440
endif;
441