Нема описа

infinite-scroll.php 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * INFINITE SCROLL
  4. */
  5. /**
  6. * Load theme's infinite scroll annotation file, if present in the IS plugin.
  7. * The `setup_theme` action is used because the annotation files should be using `after_setup_theme` to register support for IS.
  8. *
  9. * As released in Jetpack 2.0, a child theme's parent wasn't checked for in the plugin's bundled support, hence the convoluted way the parent is checked for now.
  10. *
  11. * @uses is_admin, wp_get_theme, apply_filters
  12. * @action setup_theme
  13. * @return null
  14. */
  15. function jetpack_load_infinite_scroll_annotation() {
  16. if ( is_admin() && isset( $_GET['page'] ) && 'jetpack' == $_GET['page'] ) {
  17. $theme = wp_get_theme();
  18. if ( ! is_a( $theme, 'WP_Theme' ) && ! is_array( $theme ) ) {
  19. return;
  20. }
  21. /** This filter is already documented in modules/infinite-scroll/infinity.php */
  22. $customization_file = apply_filters( 'infinite_scroll_customization_file', dirname( __FILE__ ) . "/infinite-scroll/themes/{$theme['Stylesheet']}.php", $theme['Stylesheet'] );
  23. if ( is_readable( $customization_file ) ) {
  24. require_once $customization_file;
  25. } elseif ( ! empty( $theme['Template'] ) ) {
  26. $customization_file = dirname( __FILE__ ) . "/infinite-scroll/themes/{$theme['Template']}.php";
  27. if ( is_readable( $customization_file ) ) {
  28. require_once $customization_file;
  29. }
  30. }
  31. }
  32. }
  33. add_action( 'setup_theme', 'jetpack_load_infinite_scroll_annotation' );
  34. /**
  35. * Prevent IS from being activated if theme doesn't support it
  36. *
  37. * @param bool $can_activate
  38. * @filter jetpack_can_activate_infinite-scroll
  39. * @return bool
  40. */
  41. function jetpack_can_activate_infinite_scroll() {
  42. return (bool) current_theme_supports( 'infinite-scroll' );
  43. }
  44. add_filter( 'jetpack_can_activate_infinite-scroll', 'jetpack_can_activate_infinite_scroll' );