Aucune description

twentyfourteen.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Infinite Scroll Theme Assets
  4. *
  5. * Register support for Twenty Fourteen.
  6. */
  7. use Automattic\Jetpack\Device_Detection\User_Agent_Info;
  8. /**
  9. * Add theme support for infinite scroll
  10. */
  11. function jetpack_twentyfourteen_infinite_scroll_init() {
  12. add_theme_support( 'infinite-scroll', array(
  13. 'container' => 'content',
  14. 'footer' => 'page',
  15. 'footer_widgets' => jetpack_twentyfourteen_has_footer_widgets(),
  16. ) );
  17. }
  18. add_action( 'after_setup_theme', 'jetpack_twentyfourteen_infinite_scroll_init' );
  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 sidebar is active.
  23. * 3. The footer widget is active.
  24. *
  25. * @return bool
  26. */
  27. function jetpack_twentyfourteen_has_footer_widgets() {
  28. if ( function_exists( 'jetpack_is_mobile' ) ) {
  29. if ( ( User_Agent_Info::is_ipad() && is_active_sidebar( 'sidebar-1' ) )
  30. || ( jetpack_is_mobile( '', true ) && ( is_active_sidebar( 'sidebar-1' ) || is_active_sidebar( 'sidebar-2' ) ) )
  31. || is_active_sidebar( 'sidebar-3' ) )
  32. return true;
  33. }
  34. return false;
  35. }
  36. /**
  37. * Enqueue CSS stylesheet with theme styles for Infinite Scroll.
  38. */
  39. function jetpack_twentyfourteen_infinite_scroll_enqueue_styles() {
  40. if ( wp_script_is( 'the-neverending-homepage' ) ) {
  41. wp_enqueue_style( 'infinity-twentyfourteen', plugins_url( 'twentyfourteen.css', __FILE__ ), array( 'the-neverending-homepage' ), '20131118' );
  42. }
  43. }
  44. add_action( 'wp_enqueue_scripts', 'jetpack_twentyfourteen_infinite_scroll_enqueue_styles', 25 );