1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Infinite Scroll Theme Assets |
4
|
|
|
* |
5
|
|
|
* Register support for @Twenty Eleven and enqueue relevant styles. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Add theme support for infinity scroll |
10
|
|
|
*/ |
11
|
|
|
function twenty_eleven_infinite_scroll_init() { |
12
|
|
|
add_theme_support( 'infinite-scroll', array( |
13
|
|
|
'container' => 'content', |
14
|
|
|
'footer' => 'page', |
15
|
|
|
) ); |
16
|
|
|
} |
17
|
|
|
add_action( 'init', 'twenty_eleven_infinite_scroll_init' ); |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Enqueue CSS stylesheet with theme styles for infinity. |
21
|
|
|
*/ |
22
|
|
|
function twenty_eleven_infinite_scroll_enqueue_styles() { |
23
|
|
|
if ( wp_script_is( 'the-neverending-homepage' ) ) { |
24
|
|
|
// Add theme specific styles. |
25
|
|
|
wp_enqueue_style( 'infinity-twentyeleven', plugins_url( 'twentyeleven.css', __FILE__ ), array( 'the-neverending-homepage' ), '20121002' ); |
26
|
|
|
} |
27
|
|
|
} |
28
|
|
|
add_action( 'wp_enqueue_scripts', 'twenty_eleven_infinite_scroll_enqueue_styles', 25 ); |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Have we any footer widgets? |
32
|
|
|
* |
33
|
|
|
* @param bool $has_widgets |
34
|
|
|
* @uses is_active_sidebar |
35
|
|
|
* @uses jetpack_is_mobile |
36
|
|
|
* @filter infinite_scroll_has_footer_widgets |
37
|
|
|
* @return bool |
38
|
|
|
*/ |
39
|
|
|
function twenty_eleven_has_footer_widgets( $has_widgets ) { |
40
|
|
|
// Are any of the "Footer Area" sidebars active? |
41
|
|
|
if ( is_active_sidebar( 'sidebar-3' ) || is_active_sidebar( 'sidebar-4' ) || is_active_sidebar( 'sidebar-5' ) ) |
42
|
|
|
return true; |
43
|
|
|
|
44
|
|
|
// If we're on mobile and the Main Sidebar has widgets, it falls below the content, so we have footer widgets. |
45
|
|
|
if ( function_exists( 'jetpack_is_mobile' ) && jetpack_is_mobile() && is_active_sidebar( 'sidebar-1' ) ) |
46
|
|
|
return true; |
47
|
|
|
|
48
|
|
|
return $has_widgets; |
49
|
|
|
} |
50
|
|
|
add_filter( 'infinite_scroll_has_footer_widgets', 'twenty_eleven_has_footer_widgets' ); |
51
|
|
|
|