Completed
Push — test/woocommerce-sync ( 663fdc...33fe8d )
by
unknown
25:49 queued 10:26
created

twentyseventeen.php ➔ jetpack_twentyseventeen_has_footer_widgets()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 7
nc 2
nop 0
dl 0
loc 9
rs 9.2
c 0
b 0
f 0
1
<?php
2
/**
3
 * Infinite Scroll Theme Assets
4
 *
5
 * Register support for Twenty Seventeen.
6
 */
7
8
/**
9
 * Add theme support for infinite scroll
10
 */
11
function jetpack_twentyseventeen_infinite_scroll_init() {
12
	add_theme_support( 'infinite-scroll', array(
13
		'container'      => 'main',
14
		'render'         => 'jetpack_twentyseventeen_infinite_scroll_render',
15
		'footer'         => 'content',
16
		'footer_widgets' => jetpack_twentyseventeen_has_footer_widgets(),
17
	) );
18
}
19
add_action( 'init', 'jetpack_twentyseventeen_infinite_scroll_init' );
20
21
/**
22
 * Custom render function for Infinite Scroll.
23
 */
24 View Code Duplication
function jetpack_twentyseventeen_infinite_scroll_render() {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in 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...
25
	while ( have_posts() ) {
26
		the_post();
27
		if ( is_search() ) {
28
			get_template_part( 'template-parts/post/content', 'search' );
29
		} else {
30
			get_template_part( 'template-parts/post/content', get_post_format() );
31
		}
32
	}
33
}
34
35
/**
36
 * Custom function to check for the presence of footer widgets or the social links menu
37
 */
38
function jetpack_twentyseventeen_has_footer_widgets() {
39
	if ( is_active_sidebar( 'sidebar-2' ) ||
40
		 is_active_sidebar( 'sidebar-3' ) ||
41
		 has_nav_menu( 'social' ) ) {
42
		return true;
43
	} else {
44
		return false;
45
	}
46
}
47
48
/**
49
 * Enqueue CSS stylesheet with theme styles for Infinite Scroll.
50
 */
51
function jetpack_twentyseventeen_infinite_scroll_enqueue_styles() {
52
	if ( wp_script_is( 'the-neverending-homepage' ) ) {
53
		wp_enqueue_style( 'infinity-twentyseventeen', plugins_url( 'twentyseventeen.css', __FILE__ ), array( 'the-neverending-homepage' ), '20161219' );
54
		wp_style_add_data( 'infinity-twentyseventeen', 'rtl', 'replace' );
55
	}
56
}
57
add_action( 'wp_enqueue_scripts', 'jetpack_twentyseventeen_infinite_scroll_enqueue_styles', 25 );
58