2019-11-15 23:26:29 +01:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Compatibility files for third-party plugins.
|
|
|
|
|
* This is used to improve compatibility of specific Jetpack features with third-party plugins.
|
|
|
|
|
*
|
2021-04-27 08:32:47 +02:00
|
|
|
* @package automattic/jetpack
|
2019-11-15 23:26:29 +01:00
|
|
|
*/
|
|
|
|
|
|
2020-01-26 12:53:20 +01:00
|
|
|
namespace Automattic\Jetpack;
|
2019-11-15 23:26:29 +01:00
|
|
|
|
2022-04-02 10:26:41 +02:00
|
|
|
use Automattic\Jetpack\Status\Host;
|
|
|
|
|
|
2020-01-26 12:53:20 +01:00
|
|
|
/**
|
|
|
|
|
* Loads the individual 3rd-party compat files.
|
|
|
|
|
*/
|
|
|
|
|
function load_3rd_party() {
|
|
|
|
|
// Array of third-party compat files to always require.
|
|
|
|
|
$compat_files = array(
|
|
|
|
|
'bbpress.php',
|
|
|
|
|
'beaverbuilder.php',
|
|
|
|
|
'bitly.php',
|
|
|
|
|
'buddypress.php',
|
|
|
|
|
'class.jetpack-amp-support.php',
|
2020-10-20 18:05:12 +02:00
|
|
|
'class-jetpack-crm-data.php',
|
2021-04-27 08:32:47 +02:00
|
|
|
'class-jetpack-modules-overrides.php', // Special case. Tools to be used to override module settings.
|
2022-12-15 17:41:53 +01:00
|
|
|
'class-salesforce-lead-form.php', // not a module but the handler for Salesforce forms
|
2020-09-15 14:30:05 +02:00
|
|
|
'creative-mail.php',
|
2022-04-02 10:26:41 +02:00
|
|
|
'jetpack-backup.php',
|
|
|
|
|
'jetpack-boost.php',
|
2020-01-26 12:53:20 +01:00
|
|
|
'debug-bar.php',
|
2021-04-27 08:32:47 +02:00
|
|
|
'class-domain-mapping.php',
|
|
|
|
|
'crowdsignal.php',
|
2020-01-26 12:53:20 +01:00
|
|
|
'qtranslate-x.php',
|
|
|
|
|
'vaultpress.php',
|
2020-12-10 14:04:11 +01:00
|
|
|
'web-stories.php',
|
2020-01-26 12:53:20 +01:00
|
|
|
'wpml.php',
|
|
|
|
|
'woocommerce.php',
|
|
|
|
|
'woocommerce-services.php',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
foreach ( $compat_files as $file ) {
|
|
|
|
|
if ( file_exists( JETPACK__PLUGIN_DIR . '/3rd-party/' . $file ) ) {
|
|
|
|
|
require_once JETPACK__PLUGIN_DIR . '/3rd-party/' . $file;
|
|
|
|
|
}
|
2019-11-15 23:26:29 +01:00
|
|
|
}
|
2022-04-02 10:26:41 +02:00
|
|
|
|
|
|
|
|
add_filter( 'jetpack_development_version', __NAMESPACE__ . '\atomic_weekly_override' );
|
2022-12-15 17:41:53 +01:00
|
|
|
add_filter( 'jetpack_get_available_modules', __NAMESPACE__ . '\atomic_remove_modules' );
|
|
|
|
|
|
|
|
|
|
if ( ( new Host() )->is_atomic_platform() && ! defined( 'DISABLE_JETPACK_WAF' ) ) {
|
|
|
|
|
define( 'DISABLE_JETPACK_WAF', true );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Disables modules not compatible with the Atomic platform.
|
|
|
|
|
*
|
|
|
|
|
* @param array $modules Filterable value for `jetpack_get_available_modules.
|
|
|
|
|
*
|
|
|
|
|
* @return array Array of module slugs.
|
|
|
|
|
*/
|
|
|
|
|
function atomic_remove_modules( $modules ) {
|
|
|
|
|
if ( ( new Host() )->is_atomic_platform() ) {
|
|
|
|
|
// WAF should never be available on the Atomic platform.
|
|
|
|
|
unset( $modules['waf'] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $modules;
|
2022-04-02 10:26:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handles suppressing development version notices on Atomic-hosted sites.
|
|
|
|
|
*
|
|
|
|
|
* @param bool $development_version Filterable value if this is a development version of Jetpack.
|
|
|
|
|
*
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
function atomic_weekly_override( $development_version ) {
|
|
|
|
|
if ( ( new Host() )->is_atomic_platform() ) {
|
|
|
|
|
$haystack = Constants::get_constant( 'JETPACK__PLUGIN_DIR' );
|
|
|
|
|
$needle = '/jetpack-dev/';
|
|
|
|
|
if (
|
|
|
|
|
( function_exists( 'str_ends_with' ) && str_ends_with( $haystack, $needle ) ) || // phpcs:ignore PHPCompatibility.FunctionUse.NewFunctions.str_ends_withFound
|
|
|
|
|
0 === substr_compare( $haystack, $needle, -13 )
|
|
|
|
|
) {
|
|
|
|
|
return $development_version; // Returns the default response if the active Jetpack version is from the beta plugin.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$development_version = false; // Returns false for regular installs on Atomic.
|
|
|
|
|
}
|
|
|
|
|
return $development_version; // Return default if not on Atomic.
|
2019-11-15 23:26:29 +01:00
|
|
|
}
|
2020-01-26 12:53:20 +01:00
|
|
|
|
|
|
|
|
load_3rd_party();
|