| @@ -9,65 +9,95 @@ | ||
| 9 | 9 | namespace Automattic\Jetpack; |
| 10 | 10 | |
| 11 | 11 | use Automattic\Jetpack\Status\Host; |
| 12 | 12 | |
| 13 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 14 | + exit( 0 ); | |
| 15 | +} | |
| 16 | + | |
| 17 | +add_action( 'plugins_loaded', __NAMESPACE__ . '\load_3rd_party_compat_filters', 11 ); | |
| 13 | 18 | /** |
| 14 | - * Loads the individual 3rd-party compat files. | |
| 19 | + * Loads the individual 3rd-party compat functions. | |
| 20 | + * | |
| 21 | + * This is a refactor of load_3rd_party() to load the individual compat files only when needed instead of universally. | |
| 15 | 22 | */ |
| 16 | -function load_3rd_party() { | |
| 17 | - // Array of third-party compat files to always require. | |
| 18 | - $compat_files = array( | |
| 19 | - 'bbpress.php', | |
| 20 | - 'beaverbuilder.php', | |
| 21 | - 'bitly.php', | |
| 22 | - 'buddypress.php', | |
| 23 | - 'class.jetpack-amp-support.php', | |
| 24 | - 'class-jetpack-crm-data.php', | |
| 25 | - 'class-jetpack-modules-overrides.php', // Special case. Tools to be used to override module settings. | |
| 26 | - 'class-salesforce-lead-form.php', // not a module but the handler for Salesforce forms | |
| 27 | - 'creative-mail.php', | |
| 28 | - 'jetpack-backup.php', | |
| 29 | - 'jetpack-boost.php', | |
| 30 | - 'debug-bar.php', | |
| 31 | - 'class-domain-mapping.php', | |
| 32 | - 'crowdsignal.php', | |
| 33 | - 'qtranslate-x.php', | |
| 34 | - 'vaultpress.php', | |
| 35 | - 'web-stories.php', | |
| 36 | - 'wpml.php', | |
| 37 | - 'woocommerce.php', | |
| 38 | - 'woocommerce-services.php', | |
| 39 | - ); | |
| 23 | +function load_3rd_party_compat_filters() { | |
| 40 | 24 | |
| 41 | - foreach ( $compat_files as $file ) { | |
| 42 | - if ( file_exists( JETPACK__PLUGIN_DIR . '/3rd-party/' . $file ) ) { | |
| 43 | - require_once JETPACK__PLUGIN_DIR . '/3rd-party/' . $file; | |
| 44 | - } | |
| 25 | + // ActivityPub | |
| 26 | + if ( Constants::is_defined( 'ACTIVITYPUB_PLUGIN_VERSION' ) ) { | |
| 27 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/activitypub.php'; | |
| 45 | 28 | } |
| 46 | 29 | |
| 47 | - add_filter( 'jetpack_development_version', __NAMESPACE__ . '\atomic_weekly_override' ); | |
| 48 | -} | |
| 30 | + // bbPress | |
| 31 | + if ( function_exists( 'bbpress' ) ) { | |
| 32 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/bbpress.php'; | |
| 33 | + } | |
| 49 | 34 | |
| 50 | -/** | |
| 51 | - * Handles suppressing development version notices on Atomic-hosted sites. | |
| 52 | - * | |
| 53 | - * @param bool $development_version Filterable value if this is a development version of Jetpack. | |
| 54 | - * | |
| 55 | - * @return bool | |
| 56 | - */ | |
| 57 | -function atomic_weekly_override( $development_version ) { | |
| 35 | + // Beaver Builder | |
| 36 | + if ( class_exists( 'FLBuilder' ) ) { | |
| 37 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/beaverbuilder.php'; | |
| 38 | + } | |
| 39 | + | |
| 40 | + // Bitly | |
| 41 | + if ( class_exists( 'Bitly' ) ) { | |
| 42 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/bitly.php'; | |
| 43 | + } | |
| 44 | + | |
| 45 | + // BuddyPress | |
| 46 | + if ( class_exists( 'BuddyPress' ) ) { | |
| 47 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/buddypress.php'; | |
| 48 | + } | |
| 49 | + | |
| 50 | + // AMP. AMP__DIR__ is defined in the AMP plugin since the very first version. | |
| 51 | + if ( Constants::is_defined( 'AMP__DIR__' ) ) { | |
| 52 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/amp.php'; | |
| 53 | + } | |
| 54 | + | |
| 55 | + // Domain Mapping. All assume multisite, so it's an easy check. | |
| 56 | + if ( Constants::is_defined( 'SUNRISE' ) ) { | |
| 57 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/class-domain-mapping.php'; | |
| 58 | + } | |
| 59 | + | |
| 60 | + // Debug Bar | |
| 61 | + if ( class_exists( 'Debug_Bar' ) ) { | |
| 62 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/debug-bar.php'; | |
| 63 | + } | |
| 64 | + | |
| 65 | + // Letting these always load since it handles somethings upon plugin activation. | |
| 66 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/creative-mail.php'; | |
| 67 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/jetpack-backup.php'; | |
| 68 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/jetpack-boost.php'; | |
| 69 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/woocommerce-services.php'; | |
| 70 | + | |
| 71 | + // qTranslate. Plugin closed in 2021, but leaving support for now to allow sites to drop it. | |
| 72 | + if ( Constants::is_defined( 'QTX_VERSION' ) ) { | |
| 73 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/qtranslate-x.php'; | |
| 74 | + } | |
| 75 | + | |
| 76 | + // VaultPress. | |
| 77 | + if ( Constants::is_defined( 'VAULTPRESS__VERSION' ) || class_exists( 'VaultPress' ) ) { | |
| 78 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/vaultpress.php'; | |
| 79 | + } | |
| 80 | + | |
| 81 | + // Web Stories | |
| 82 | + if ( Constants::is_defined( 'WEBSTORIES_VERSION' ) ) { | |
| 83 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/web-stories.php'; | |
| 84 | + } | |
| 85 | + | |
| 86 | + // WooCommerce | |
| 87 | + if ( class_exists( 'WooCommerce' ) ) { | |
| 88 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/woocommerce.php'; | |
| 89 | + } | |
| 90 | + | |
| 91 | + // Atomic Weekly | |
| 58 | 92 | if ( ( new Host() )->is_atomic_platform() ) { |
| 59 | - $haystack = Constants::get_constant( 'JETPACK__PLUGIN_DIR' ); | |
| 60 | - $needle = '/jetpack-dev/'; | |
| 61 | - if ( | |
| 62 | - ( function_exists( 'str_ends_with' ) && str_ends_with( $haystack, $needle ) ) || // phpcs:ignore PHPCompatibility.FunctionUse.NewFunctions.str_ends_withFound | |
| 63 | - 0 === substr_compare( $haystack, $needle, -13 ) | |
| 64 | - ) { | |
| 65 | - return $development_version; // Returns the default response if the active Jetpack version is from the beta plugin. | |
| 66 | - } | |
| 93 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/atomic.php'; | |
| 94 | + } | |
| 67 | 95 | |
| 68 | - $development_version = false; // Returns false for regular installs on Atomic. | |
| 96 | + // WordPress.com Reader | |
| 97 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/wpcom-reader.php'; | |
| 98 | + | |
| 99 | + // WPML | |
| 100 | + if ( defined( 'ICL_SITEPRESS_VERSION' ) ) { | |
| 101 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/wpml.php'; | |
| 69 | 102 | } |
| 70 | - return $development_version; // Return default if not on Atomic. | |
| 71 | 103 | } |
| 72 | - | |
| 73 | -load_3rd_party(); | |