| @@ -1,0 +1,103 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Compatibility files for third-party plugins. | |
| 4 | + * This is used to improve compatibility of specific Jetpack features with third-party plugins. | |
| 5 | + * | |
| 6 | + * @package automattic/jetpack | |
| 7 | + */ | |
| 8 | + | |
| 9 | +namespace Automattic\Jetpack; | |
| 10 | + | |
| 11 | +use Automattic\Jetpack\Status\Host; | |
| 12 | + | |
| 13 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 14 | + exit( 0 ); | |
| 15 | +} | |
| 16 | + | |
| 17 | +add_action( 'plugins_loaded', __NAMESPACE__ . '\load_3rd_party_compat_filters', 11 ); | |
| 18 | +/** | |
| 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. | |
| 22 | + */ | |
| 23 | +function load_3rd_party_compat_filters() { | |
| 24 | + | |
| 25 | + // ActivityPub | |
| 26 | + if ( Constants::is_defined( 'ACTIVITYPUB_PLUGIN_VERSION' ) ) { | |
| 27 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/activitypub.php'; | |
| 28 | + } | |
| 29 | + | |
| 30 | + // bbPress | |
| 31 | + if ( function_exists( 'bbpress' ) ) { | |
| 32 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/bbpress.php'; | |
| 33 | + } | |
| 34 | + | |
| 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 | |
| 92 | + if ( ( new Host() )->is_atomic_platform() ) { | |
| 93 | + require_once JETPACK__PLUGIN_DIR . '/3rd-party/atomic.php'; | |
| 94 | + } | |
| 95 | + | |
| 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'; | |
| 102 | + } | |
| 103 | +} | |