|
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' ); |