module-extras.php
| 1 | <?php |
| 2 | /** |
| 3 | * Load module code that is needed even when a module isn't active. |
| 4 | * For example, if a module shouldn't be activatable unless certain conditions are met, |
| 5 | * the code belongs in this file. |
| 6 | * |
| 7 | * @package Jetpack |
| 8 | */ |
| 9 | |
| 10 | /** |
| 11 | * Features available all the time: |
| 12 | * - When in offline mode. |
| 13 | * - When connected to WordPress.com. |
| 14 | */ |
| 15 | $tools = array( |
| 16 | // Always loaded, but only registered if theme supports it. |
| 17 | 'custom-post-types/comics.php', |
| 18 | 'custom-post-types/testimonial.php', |
| 19 | 'custom-post-types/nova.php', |
| 20 | 'geo-location.php', |
| 21 | // Those oEmbed providers are always available. |
| 22 | 'shortcodes/others.php', |
| 23 | 'theme-tools.php', |
| 24 | 'theme-tools/social-links.php', |
| 25 | 'theme-tools/random-redirect.php', |
| 26 | 'theme-tools/featured-content.php', |
| 27 | 'theme-tools/infinite-scroll.php', |
| 28 | 'theme-tools/responsive-videos.php', |
| 29 | 'theme-tools/site-logo.php', |
| 30 | 'theme-tools/site-breadcrumbs.php', |
| 31 | 'theme-tools/social-menu.php', |
| 32 | 'theme-tools/content-options.php', |
| 33 | 'theme-tools/devicepx.php', |
| 34 | // Needed for SEO Tools. |
| 35 | 'seo-tools/jetpack-seo-utils.php', |
| 36 | 'seo-tools/jetpack-seo-titles.php', |
| 37 | 'seo-tools/jetpack-seo-posts.php', |
| 38 | 'verification-tools/verification-tools-utils.php', |
| 39 | // Needed for VideoPress, so videos keep working in existing posts/pages when the module is deactivated. |
| 40 | 'videopress/utility-functions.php', |
| 41 | 'videopress/class.videopress-gutenberg.php', |
| 42 | ); |
| 43 | |
| 44 | // Some features are only available when connected to WordPress.com. |
| 45 | $connected_tools = array( |
| 46 | 'calypsoify/class.jetpack-calypsoify.php', |
| 47 | 'plugin-search.php', |
| 48 | 'scan/scan.php', // Shows Jetpack Scan alerts in the admin bar if threats found. |
| 49 | 'simple-payments/simple-payments.php', |
| 50 | 'wpcom-block-editor/class-jetpack-wpcom-block-editor.php', |
| 51 | 'wpcom-tos/wpcom-tos.php', |
| 52 | ); |
| 53 | |
| 54 | // Add connected features to our existing list if the site is currently connected. |
| 55 | if ( Jetpack::is_active() ) { |
| 56 | $tools = array_merge( $tools, $connected_tools ); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Filter extra tools (not modules) to include. |
| 61 | * |
| 62 | * @since 2.4.0 |
| 63 | * @since 5.4.0 can be used in multisite when Jetpack is not connected to WordPress.com and not in offline mode. |
| 64 | * |
| 65 | * @param array $tools Array of extra tools to include. |
| 66 | */ |
| 67 | $jetpack_tools_to_include = apply_filters( 'jetpack_tools_to_include', $tools ); |
| 68 | |
| 69 | if ( ! empty( $jetpack_tools_to_include ) ) { |
| 70 | foreach ( $jetpack_tools_to_include as $tool ) { |
| 71 | if ( file_exists( JETPACK__PLUGIN_DIR . '/modules/' . $tool ) ) { |
| 72 | require_once JETPACK__PLUGIN_DIR . '/modules/' . $tool; |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Add the "(Jetpack)" suffix to the widget names |
| 79 | * |
| 80 | * @param string $widget_name Widget name. |
| 81 | */ |
| 82 | function jetpack_widgets_add_suffix( $widget_name ) { |
| 83 | return sprintf( |
| 84 | /* Translators: Placeholder is the name of a widget. */ |
| 85 | __( '%s (Jetpack)', 'jetpack' ), |
| 86 | $widget_name |
| 87 | ); |
| 88 | } |
| 89 | add_filter( 'jetpack_widget_name', 'jetpack_widgets_add_suffix' ); |
| 90 |