twentysixteen.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Infinite Scroll Theme Assets
  4. *
  5. * Register support for Twenty Sixteen.
  6. */
  7. /**
  8. * Add theme support for infinite scroll
  9. */
  10. function jetpack_twentysixteen_infinite_scroll_init() {
  11. add_theme_support( 'infinite-scroll', array(
  12. 'container' => 'main',
  13. 'render' => 'jetpack_twentysixteen_infinite_scroll_render',
  14. 'footer' => 'content',
  15. ) );
  16. }
  17. add_action( 'after_setup_theme', 'jetpack_twentysixteen_infinite_scroll_init' );
  18. /**
  19. * Custom render function for Infinite Scroll.
  20. */
  21. function jetpack_twentysixteen_infinite_scroll_render() {
  22. while ( have_posts() ) {
  23. the_post();
  24. if ( is_search() ) {
  25. get_template_part( 'template-parts/content', 'search' );
  26. } else {
  27. get_template_part( 'template-parts/content', get_post_format() );
  28. }
  29. }
  30. }
  31. /**
  32. * Enqueue CSS stylesheet with theme styles for Infinite Scroll.
  33. */
  34. function jetpack_twentysixteen_infinite_scroll_enqueue_styles() {
  35. if ( wp_script_is( 'the-neverending-homepage' ) ) {
  36. wp_enqueue_style( 'infinity-twentysixteen', plugins_url( 'twentysixteen.css', __FILE__ ), array( 'the-neverending-homepage' ), '20151102' );
  37. wp_style_add_data( 'infinity-twentysixteen', 'rtl', 'replace' );
  38. }
  39. }
  40. add_action( 'wp_enqueue_scripts', 'jetpack_twentysixteen_infinite_scroll_enqueue_styles', 25 );