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

twentytwelve.php ➔ twenty_twelve_infinite_scroll_init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Infinite Scroll Theme Assets
4
 *
5
 * Register support for Twenty Twelve and enqueue relevant styles.
6
 */
7
8
/**
9
 * Add theme support for infinite scroll
10
 */
11
function twenty_twelve_infinite_scroll_init() {
12
	add_theme_support( 'infinite-scroll', array(
13
		'container'      => 'content',
14
		'footer'         => 'page'
15
	) );
16
}
17
add_action( 'after_setup_theme', 'twenty_twelve_infinite_scroll_init' );
18
19
/**
20
 * Enqueue CSS stylesheet with theme styles for infinity.
21
 */
22
function twenty_twelve_infinite_scroll_enqueue_styles() {
23
	if ( wp_script_is( 'the-neverending-homepage' ) ) {
24
		// Add theme specific styles.
25
		wp_enqueue_style( 'infinity-twentytwelve', plugins_url( 'twentytwelve.css', __FILE__ ), array( 'the-neverending-homepage' ), '20120817' );
26
	}
27
}
28
add_action( 'wp_enqueue_scripts', 'twenty_twelve_infinite_scroll_enqueue_styles', 25 );
29
30
/**
31
 * Handle `footer_widgets` argument for mobile devices
32
 *
33
 * @param bool $has_widgets
34
 * @uses jetpack_is_mobile, is_front_page, is_active_sidebar
35
 * @filter infinite_scroll_has_footer_widgets
36
 * @return bool
37
 */
38
function twenty_twelve_has_footer_widgets( $has_widgets ) {
39
	if ( function_exists( 'jetpack_is_mobile' ) && jetpack_is_mobile() ) {
40
		if ( is_front_page() && ( is_active_sidebar( 'sidebar-2' ) || is_active_sidebar( 'sidebar-3' ) ) )
41
			$has_widgets = true;
42
		elseif ( is_active_sidebar( 'sidebar-1' ) )
43
			$has_widgets = true;
44
	}
45
46
	return $has_widgets;
47
}
48
add_filter( 'infinite_scroll_has_footer_widgets', 'twenty_twelve_has_footer_widgets' );