twentyfourteen.php 1.5 KB

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