Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
95.24% covered (success)
95.24%
40 / 42
100.00% covered (success)
100.00%
1 / 1
CRAP
n/a
0 / 0
jetpack_widgets_add_suffix
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
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 automattic/jetpack
8 */
9
10if ( ! defined( 'ABSPATH' ) ) {
11    exit( 0 );
12}
13
14/**
15 * Features available all the time:
16 *    - When in offline mode.
17 *    - When connected to WordPress.com.
18 */
19$tools = array(
20    // Those oEmbed providers are always available.
21    'shortcodes/facebook.php',
22    'shortcodes/others.php',
23    // Theme Tools.
24    'theme-tools.php',
25    'theme-tools/social-links.php',
26    'theme-tools/featured-content.php',
27    'theme-tools/responsive-videos.php',
28    'theme-tools/site-logo.php',
29    'theme-tools/site-breadcrumbs.php',
30    'theme-tools/social-menu.php',
31    'theme-tools/content-options.php',
32    // Needed for VideoPress, so videos keep working in existing posts/pages when the module is deactivated.
33    'videopress/class.videopress-gutenberg.php',
34    // Reprint export. Registers nothing off Pressable and WordPress.com (Atomic).
35    'reprint-export.php',
36    // Names the SEO plugin that owns SEO output, for the SEO dashboard and canonical URLs.
37    'seo-tools/seo-tools-conflicts.php',
38    // Lets the SEO dashboard lock the canonical URLs switch while another SEO plugin is active.
39    'canonical-urls/canonical-urls-conflicts.php',
40);
41
42// WordPress 7.2 handles random content redirects (/random/, ?random) in core; every 7.2 beta includes it.
43// @todo Once WordPress 7.2 is the minimum, deprecate the jetpack_random_redirect_enabled filter for core's; not before, so it isn't deprecated only on some versions.
44if ( version_compare( $GLOBALS['wp_version'], '7.2-beta', '<' ) ) {
45    $tools[] = 'theme-tools/random-redirect.php';
46} else {
47    $tools[] = 'theme-tools/random-redirect-core-compat.php';
48}
49
50// Some features are only available when connected to WordPress.com.
51$connected_tools = array(
52    'external-media/external-media.php',
53    'plugin-search.php',
54    'scan/scan.php', // Shows Jetpack Scan alerts in the admin bar if threats found.
55    'simple-payments.php',
56    'wpcom-tos/wpcom-tos.php',
57    // These oEmbed providers are available when connected to WordPress.com.
58    // Starting from 2020-10-24, they need an authentication token, and that token is stored on WordPress.com.
59    // More information: https://developers.facebook.com/docs/instagram/oembed/.
60    'shortcodes/instagram.php',
61    // This Twitter oEmbed provider relies on a connection to WordPress.com to proxy the request.
62    'shortcodes/twitter.php',
63);
64
65// Add connected features to our existing list if the site is currently connected.
66if ( Jetpack::is_connection_ready() ) {
67    $tools = array_merge( $tools, $connected_tools );
68}
69
70/**
71 * Filter extra tools (not modules) to include.
72 *
73 * @since 2.4.0
74 * @since 5.4.0 can be used in multisite when Jetpack is not connected to WordPress.com and not in offline mode.
75 *
76 * @param array $tools Array of extra tools to include.
77 */
78$jetpack_tools_to_include = apply_filters( 'jetpack_tools_to_include', $tools );
79
80if ( ! empty( $jetpack_tools_to_include ) ) {
81    foreach ( $jetpack_tools_to_include as $tool ) {
82        if ( file_exists( JETPACK__PLUGIN_DIR . '/modules/' . $tool ) ) {
83            require_once JETPACK__PLUGIN_DIR . '/modules/' . $tool;
84        }
85    }
86}
87
88/**
89 * Add the "(Jetpack)" suffix to the widget names
90 *
91 * @param string $widget_name Widget name.
92 */
93function jetpack_widgets_add_suffix( $widget_name ) {
94    return sprintf(
95        /* Translators: Placeholder is the name of a widget. */
96        __( '%s (Jetpack)', 'jetpack' ),
97        $widget_name
98    );
99}
100add_filter( 'jetpack_widget_name', 'jetpack_widgets_add_suffix' );