Completed
Push — update/security-notice ( 43dc45...78cf5f )
by
unknown
100:34 queued 91:04
created

modules/infinite-scroll/themes/twentyseventeen.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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