Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 3
CRAP
n/a
0 / 0
jetpack_twentyfourteen_infinite_scroll_init
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
jetpack_twentyfourteen_has_footer_widgets
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
72
jetpack_twentyfourteen_infinite_scroll_enqueue_styles
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2/**
3 * Infinite Scroll Theme Assets
4 *
5 * Register support for Twenty Fourteen.
6 *
7 * @package jetpack
8 */
9
10use Automattic\Jetpack\Device_Detection\User_Agent_Info;
11
12if ( ! defined( 'ABSPATH' ) ) {
13    exit( 0 );
14}
15
16/**
17 * Add theme support for infinite scroll
18 */
19function jetpack_twentyfourteen_infinite_scroll_init() {
20    add_theme_support(
21        'infinite-scroll',
22        array(
23            'container'      => 'content',
24            'footer'         => 'page',
25            'footer_widgets' => jetpack_twentyfourteen_has_footer_widgets(),
26        )
27    );
28}
29add_action( 'after_setup_theme', 'jetpack_twentyfourteen_infinite_scroll_init' );
30
31/**
32 * Switch to the "click to load" type IS with the following cases
33 * 1. Viewed from iPad and the primary sidebar is active.
34 * 2. Viewed from mobile and either the primary or the content sidebar is active.
35 * 3. The footer widget is active.
36 *
37 * @return bool
38 */
39function jetpack_twentyfourteen_has_footer_widgets() {
40    if ( function_exists( 'jetpack_is_mobile' ) ) {
41        if ( ( User_Agent_Info::is_ipad() && is_active_sidebar( 'sidebar-1' ) )
42            || ( jetpack_is_mobile( '', true ) && ( is_active_sidebar( 'sidebar-1' ) || is_active_sidebar( 'sidebar-2' ) ) )
43            || is_active_sidebar( 'sidebar-3' ) ) {
44
45            return true;
46        }
47    }
48
49    return false;
50}
51
52/**
53 * Enqueue CSS stylesheet with theme styles for Infinite Scroll.
54 */
55function jetpack_twentyfourteen_infinite_scroll_enqueue_styles() {
56    if ( wp_script_is( 'the-neverending-homepage' ) ) {
57        wp_enqueue_style( 'infinity-twentyfourteen', plugins_url( 'twentyfourteen.css', __FILE__ ), array( 'the-neverending-homepage' ), '20131118' );
58    }
59}
60add_action( 'wp_enqueue_scripts', 'jetpack_twentyfourteen_infinite_scroll_enqueue_styles', 25 );