PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 3.0.6
Jetpack – WP Security, Backup, Speed, & Growth v3.0.6
16.2-beta 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 All 501 releases
jetpack / modules / theme-tools.php

theme-tools.php in Jetpack – WP Security, Backup, Speed, & Growth 3.0.6, at modules/theme-tools.php

120 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * Load code specific to themes or theme tools
4 * This file is special, and is not an actual `module` as such.
5 * It is included by ./module-extras.php
6 */
7
8 function jetpack_load_theme_tools() {
9 if ( current_theme_supports( 'social-links' ) ) {
10 require_once( JETPACK__PLUGIN_DIR . 'modules/theme-tools/social-links.php' );
11 }
12
13 if ( current_theme_supports( 'tonesque' ) ) {
14 jetpack_require_lib( 'tonesque' );
15 }
16
17 require_once( JETPACK__PLUGIN_DIR . 'modules/theme-tools/random-redirect.php' );
18 }
19 add_action( 'init', 'jetpack_load_theme_tools', 30 );
20
21 // Featured Content has an internal check for theme support in the constructor.
22 // This could already be defined by Twenty Fourteen if it's loaded first.
23 // Be sure to not load this on the plugin page in case another plugin is activating
24 // with the same class name in an attempt to override Jetpack's Featured_Content
25 if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'plugins.php' !== $GLOBALS['pagenow'] ) {
26 require_once( JETPACK__PLUGIN_DIR . 'modules/theme-tools/featured-content.php' );
27 }
28
29 /**
30 * INFINITE SCROLL
31 */
32
33 /**
34 * Load theme's infinite scroll annotation file, if present in the IS plugin.
35 * The `setup_theme` action is used because the annotation files should be using `after_setup_theme` to register support for IS.
36 *
37 * 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.
38 *
39 * @uses is_admin, wp_get_theme, get_theme, get_current_theme, apply_filters
40 * @action setup_theme
41 * @return null
42 */
43 function jetpack_load_infinite_scroll_annotation() {
44 if ( is_admin() && isset( $_GET['page'] ) && 'jetpack' == $_GET['page'] ) {
45 $theme = function_exists( 'wp_get_theme' ) ? wp_get_theme() : get_theme( get_current_theme() );
46
47 if ( ! is_a( $theme, 'WP_Theme' ) && ! is_array( $theme ) )
48 return;
49
50 $customization_file = apply_filters( 'infinite_scroll_customization_file', dirname( __FILE__ ) . "/infinite-scroll/themes/{$theme['Stylesheet']}.php", $theme['Stylesheet'] );
51
52 if ( is_readable( $customization_file ) ) {
53 require_once( $customization_file );
54 }
55 elseif ( ! empty( $theme['Template'] ) ) {
56 $customization_file = dirname( __FILE__ ) . "/infinite-scroll/themes/{$theme['Template']}.php";
57
58 if ( is_readable( $customization_file ) )
59 require_once( $customization_file );
60 }
61 }
62 }
63 add_action( 'setup_theme', 'jetpack_load_infinite_scroll_annotation' );
64
65 /**
66 * Prevent IS from being activated if theme doesn't support it
67 *
68 * @param bool $can_activate
69 * @filter jetpack_can_activate_infinite-scroll
70 * @return bool
71 */
72 function jetpack_can_activate_infinite_scroll( $can_activate ) {
73 return (bool) current_theme_supports( 'infinite-scroll' );
74 }
75 add_filter( 'jetpack_can_activate_infinite-scroll', 'jetpack_can_activate_infinite_scroll' );
76
77 // Custom Post Types - we don't want a module card for these (yet)
78 require_once( JETPACK__PLUGIN_DIR . 'modules/custom-post-types/comics.php' );
79 require_once( JETPACK__PLUGIN_DIR . 'modules/custom-post-types/testimonial.php' );
80 require_once( JETPACK__PLUGIN_DIR . 'modules/custom-post-types/nova.php' );
81
82 /**
83 * Load theme compat file if it exists.
84 *
85 * A theme could add its own compat files here if they like. For example:
86 *
87 * add_filter( 'jetpack_theme_compat_files', 'mytheme_jetpack_compat_file' );
88 * function mytheme_jetpack_compat_file( $files ) {
89 * $files['mytheme'] = locate_template( 'jetpack-compat.php' );
90 * return $files;
91 * }
92 */
93 function jetpack_load_theme_compat() {
94 $compat_files = apply_filters( 'jetpack_theme_compat_files', array(
95 'twentyfourteen' => JETPACK__PLUGIN_DIR . 'modules/theme-tools/compat/twentyfourteen.php',
96 ) );
97
98 _jetpack_require_compat_file( get_stylesheet(), $compat_files );
99
100 if ( is_child_theme() ) {
101 _jetpack_require_compat_file( get_template(), $compat_files );
102 }
103 }
104 add_action( 'after_setup_theme', 'jetpack_load_theme_compat', -1 );
105
106
107 /**
108 * Requires a file once, if the passed key exists in the files array.
109 *
110 * @access private
111 * @param string $key
112 * @param array $files
113 * @return void
114 */
115 function _jetpack_require_compat_file( $key, $files ) {
116 if ( array_key_exists( $key, $files ) && is_readable( $files[ $key ] ) ) {
117 require_once $files[ $key ];
118 }
119 }
120