1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Infinite Scroll Theme Assets |
4
|
|
|
* |
5
|
|
|
* Register support for Twenty Fourteen. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Add theme support for infinite scroll |
10
|
|
|
*/ |
11
|
|
|
function twentyfourteen_infinite_scroll_init() { |
12
|
|
|
add_theme_support( 'infinite-scroll', array( |
13
|
|
|
'container' => 'content', |
14
|
|
|
'footer' => 'page' |
15
|
|
|
) ); |
16
|
|
|
} |
17
|
|
|
add_action( 'after_setup_theme', 'twentyfourteen_infinite_scroll_init' ); |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Switch to the "click to load" type IS with the following cases |
21
|
|
|
* 1. Viewed from iPad and the primary sidebar is active. |
22
|
|
|
* 2. Viewed from mobile and either the primary or the content sudebar is active. |
23
|
|
|
* 3. The footer widget is active. |
24
|
|
|
* |
25
|
|
|
* @return bool |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
if ( function_exists( 'jetpack_is_mobile' ) ) { |
29
|
|
|
function twentyfourteen_has_footer_widgets( $has_widgets ) { |
30
|
|
|
if ( ( Jetpack_User_Agent_Info::is_ipad() && is_active_sidebar( 'sidebar-1' ) ) |
31
|
|
|
|| ( jetpack_is_mobile( '', true ) && ( is_active_sidebar( 'sidebar-1' ) || is_active_sidebar( 'sidebar-2' ) ) ) |
32
|
|
|
|| is_active_sidebar( 'sidebar-3' ) ) |
33
|
|
|
|
34
|
|
|
return true; |
35
|
|
|
|
36
|
|
|
return $has_widgets; |
37
|
|
|
} |
38
|
|
|
add_filter( 'infinite_scroll_has_footer_widgets', 'twentyfourteen_has_footer_widgets' ); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Enqueue CSS stylesheet with theme styles for Infinite Scroll. |
43
|
|
|
*/ |
44
|
|
|
function twentyfourteen_infinite_scroll_enqueue_styles() { |
45
|
|
|
if ( wp_script_is( 'the-neverending-homepage' ) ) { |
46
|
|
|
wp_enqueue_style( 'infinity-twentyfourteen', plugins_url( 'twentyfourteen.css', __FILE__ ), array( 'the-neverending-homepage' ), '20131118' ); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
add_action( 'wp_enqueue_scripts', 'twentyfourteen_infinite_scroll_enqueue_styles', 25 ); |