/modules/infinite-scroll/themes/twentytwelve.php

  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. add_action( 'after_setup_theme', 'twenty_twelve_infinite_scroll_init' ); 
  17.  
  18. /** 
  19. * Enqueue CSS stylesheet with theme styles for infinity. 
  20. */ 
  21. function twenty_twelve_infinite_scroll_enqueue_styles() { 
  22. // Add theme specific styles. 
  23. wp_enqueue_style( 'infinity-twentytwelve', plugins_url( 'twentytwelve.css', __FILE__ ), array( 'the-neverending-homepage' ), '20120817' ); 
  24. add_action( 'wp_enqueue_scripts', 'twenty_twelve_infinite_scroll_enqueue_styles', 25 ); 
  25.  
  26. /** 
  27. * Handle `footer_widgets` argument for mobile devices 
  28. * 
  29. * @param bool $has_widgets 
  30. * @uses jetpack_is_mobile, is_front_page, is_active_sidebar 
  31. * @filter infinite_scroll_has_footer_widgets 
  32. * @return bool 
  33. */ 
  34. function twenty_twelve_has_footer_widgets( $has_widgets ) { 
  35. if ( function_exists( 'jetpack_is_mobile' ) && jetpack_is_mobile() ) { 
  36. if ( is_front_page() && ( is_active_sidebar( 'sidebar-2' ) || is_active_sidebar( 'sidebar-3' ) ) ) 
  37. $has_widgets = true; 
  38. elseif ( is_active_sidebar( 'sidebar-1' ) ) 
  39. $has_widgets = true; 
  40.  
  41. return $has_widgets; 
  42. add_filter( 'infinite_scroll_has_footer_widgets', 'twenty_twelve_has_footer_widgets' ); 
.