PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 7.4.3
Jetpack – WP Security, Backup, Speed, & Growth v7.4.3
12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 14.4.2 All 500 releases
jetpack / modules / theme-tools / infinite-scroll.php
infinite-scroll.php
51 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * INFINITE SCROLL
4 */
5
6 /**
7 * Load theme's infinite scroll annotation file, if present in the IS plugin.
8 * The `setup_theme` action is used because the annotation files should be using `after_setup_theme` to register support for IS.
9 *
10 * 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.
11 *
12 * @uses is_admin, wp_get_theme, apply_filters
13 * @action setup_theme
14 * @return null
15 */
16 function jetpack_load_infinite_scroll_annotation() {
17 if ( is_admin() && isset( $_GET['page'] ) && 'jetpack' == $_GET['page'] ) {
18 $theme = wp_get_theme();
19
20 if ( ! is_a( $theme, 'WP_Theme' ) && ! is_array( $theme ) ) {
21 return;
22 }
23
24 /** This filter is already documented in modules/infinite-scroll/infinity.php */
25 $customization_file = apply_filters( 'infinite_scroll_customization_file', dirname( __FILE__ ) . "/infinite-scroll/themes/{$theme['Stylesheet']}.php", $theme['Stylesheet'] );
26
27 if ( is_readable( $customization_file ) ) {
28 require_once $customization_file;
29 } elseif ( ! empty( $theme['Template'] ) ) {
30 $customization_file = dirname( __FILE__ ) . "/infinite-scroll/themes/{$theme['Template']}.php";
31
32 if ( is_readable( $customization_file ) ) {
33 require_once $customization_file;
34 }
35 }
36 }
37 }
38 add_action( 'setup_theme', 'jetpack_load_infinite_scroll_annotation' );
39
40 /**
41 * Prevent IS from being activated if theme doesn't support it
42 *
43 * @param bool $can_activate
44 * @filter jetpack_can_activate_infinite-scroll
45 * @return bool
46 */
47 function jetpack_can_activate_infinite_scroll() {
48 return (bool) current_theme_supports( 'infinite-scroll' );
49 }
50 add_filter( 'jetpack_can_activate_infinite-scroll', 'jetpack_can_activate_infinite_scroll' );
51