Completed
Push — update/5.4-changelog ( eddd9e...9ff665 )
by Jeremy
11:34 queued 03:51
created

twentysixteen.php ➔ twentysixteen_infinite_scroll_init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Infinite Scroll Theme Assets
4
 *
5
 * Register support for Twenty Sixteen.
6
 */
7
8
/**
9
 * Add theme support for infinite scroll
10
 */
11
function twentysixteen_infinite_scroll_init() {
12
	add_theme_support( 'infinite-scroll', array(
13
		'container' => 'main',
14
		'render'    => 'twentysixteen_infinite_scroll_render',
15
		'footer'    => 'content',
16
	) );
17
}
18
add_action( 'after_setup_theme', 'twentysixteen_infinite_scroll_init' );
19
20
/**
21
 * Custom render function for Infinite Scroll.
22
 */
23 View Code Duplication
function twentysixteen_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...
24
	while ( have_posts() ) {
25
		the_post();
26
		if ( is_search() ) {
27
			get_template_part( 'template-parts/content', 'search' );
28
		} else {
29
			get_template_part( 'template-parts/content', get_post_format() );
30
		}
31
	}
32
}
33
34
/**
35
 * Enqueue CSS stylesheet with theme styles for Infinite Scroll.
36
 */
37
function twentysixteen_infinite_scroll_enqueue_styles() {
38
	if ( wp_script_is( 'the-neverending-homepage' ) ) {
39
		wp_enqueue_style( 'infinity-twentysixteen', plugins_url( 'twentysixteen.css', __FILE__ ), array( 'the-neverending-homepage' ), '20151102' );
40
		wp_style_add_data( 'infinity-twentysixteen', 'rtl', 'replace' );
41
	}
42
}
43
add_action( 'wp_enqueue_scripts', 'twentysixteen_infinite_scroll_enqueue_styles', 25 );
44