diff --git a/packages/wp-mu-plugin/stretch-extra/stretch-extra.php b/packages/wp-mu-plugin/stretch-extra/stretch-extra.php index e37547d9..44451a63 100644 --- a/packages/wp-mu-plugin/stretch-extra/stretch-extra.php +++ b/packages/wp-mu-plugin/stretch-extra/stretch-extra.php @@ -19,10 +19,13 @@ defined('ABSPATH') || exit(); -// // Set SFS server variable to fake stretch-extra context -// if (!array_key_exists('SFS', $_SERVER)) { -// $_SERVER['SFS'] = 'stretch-extra'; -// } +// Set SFS server variable to fake stretch-extra context +if (! defined('IONOS_IS_STRETCH_SFS') && defined('IONOS_IS_STRETCH') && \IONOS_IS_STRETCH) { + define('IONOS_IS_STRETCH_SFS', array_key_exists('SFS', $_SERVER)); +} +if (defined('IONOS_IS_STRETCH_SFS') && ! \IONOS_IS_STRETCH_SFS) { + $_SERVER['SFS'] = 'stretch-extra'; +} // abort if called from WP-CLI to avoid issues with command line scripts // (need to prevent execution while wp was loaded by wp-cli) diff --git a/packages/wp-mu-plugin/stretch-extra/stretch-extra/inc/secondary-plugin-dir.php b/packages/wp-mu-plugin/stretch-extra/stretch-extra/inc/secondary-plugin-dir.php index 861f3639..400f29a4 100644 --- a/packages/wp-mu-plugin/stretch-extra/stretch-extra/inc/secondary-plugin-dir.php +++ b/packages/wp-mu-plugin/stretch-extra/stretch-extra/inc/secondary-plugin-dir.php @@ -171,8 +171,8 @@ function get_custom_plugins(): array */ \add_filter('plugins_url', function ($url, $path, $plugin) { // if its not one of our plugins just return the original url - // array_key_exists('SFS', $_SERVER) is required to work in local wp-env - if (! str_starts_with($plugin, IONOS_CUSTOM_PLUGINS_DIR) && ! array_key_exists('SFS', $_SERVER)) { + // array_key_exists('SFS', $_SERVER) or constant IONOS_IS_STRETCH_SFS is required to work in local wp-env + if (! str_starts_with($plugin, IONOS_CUSTOM_PLUGINS_DIR) && ! \IONOS_IS_STRETCH_SFS) { return $url; } diff --git a/packages/wp-mu-plugin/stretch-extra/stretch-extra/inc/secondary-theme-dir.php b/packages/wp-mu-plugin/stretch-extra/stretch-extra/inc/secondary-theme-dir.php index d6611df8..c7b9bcdd 100644 --- a/packages/wp-mu-plugin/stretch-extra/stretch-extra/inc/secondary-theme-dir.php +++ b/packages/wp-mu-plugin/stretch-extra/stretch-extra/inc/secondary-theme-dir.php @@ -40,8 +40,8 @@ 'stylesheet_directory_uri', function ($stylesheet_dir_uri, $stylesheet, $theme_root_uri) { // if its not one of our themes just return the original url - // array_key_exists('SFS', $_SERVER) is required to work in local wp-env - if (! str_ends_with($theme_root_uri, '/extra/themes') && ! array_key_exists('SFS', $_SERVER)) { + // array_key_exists('SFS', $_SERVER) or constant IONOS_IS_STRETCH_SFS is required to work in local wp-env + if (! str_ends_with($theme_root_uri, '/extra/themes') && ! \IONOS_IS_STRETCH_SFS) { return $stylesheet_dir_uri; } @@ -65,8 +65,8 @@ function ($stylesheet_dir_uri, $stylesheet, $theme_root_uri) { 'theme_file_uri', function ($url, $file) { // if its not one of our themes just return the original url - // array_key_exists('SFS', $_SERVER) is required to work in local wp-env - if (! str_contains($url, '/extra/themes/') && ! array_key_exists('SFS', $_SERVER)) { + // array_key_exists('SFS', $_SERVER) or constant IONOS_IS_STRETCH_SFS is required to work in local wp-env + if (! str_contains($url, '/extra/themes/') && ! \IONOS_IS_STRETCH_SFS) { return $url; } @@ -88,8 +88,8 @@ function ($url, $file) { 'template_directory_uri', function ($template_dir_uri, $template, $theme_root_uri) { // if its not one of our themes just return the original url - // array_key_exists('SFS', $_SERVER) is required to work in local wp-env - if (! str_ends_with($theme_root_uri, '/extra/themes') && ! array_key_exists('SFS', $_SERVER)) { + // array_key_exists('SFS', $_SERVER) or constant IONOS_IS_STRETCH_SFS is required to work in local wp-env + if (! str_ends_with($theme_root_uri, '/extra/themes') && ! \IONOS_IS_STRETCH_SFS) { return $template_dir_uri; } @@ -103,8 +103,8 @@ function ($template_dir_uri, $template, $theme_root_uri) { \add_filter( 'theme_root_uri', function ($theme_root_uri, $siteurl) { - // array_key_exists('SFS', $_SERVER) is required to work in local wp-env - if (! str_ends_with($theme_root_uri, '/extra/themes') && ! array_key_exists('SFS', $_SERVER)) { + // array_key_exists('SFS', $_SERVER) or constant IONOS_IS_STRETCH_SFS is required to work in local wp-env + if (! str_ends_with($theme_root_uri, '/extra/themes') && ! \IONOS_IS_STRETCH_SFS) { return $theme_root_uri; } diff --git a/packages/wp-plugin/ionos-essentials/ionos-essentials.php b/packages/wp-plugin/ionos-essentials/ionos-essentials.php index 072303f9..78580cca 100644 --- a/packages/wp-plugin/ionos-essentials/ionos-essentials.php +++ b/packages/wp-plugin/ionos-essentials/ionos-essentials.php @@ -151,10 +151,7 @@ function () { // soc plugin components require_once __DIR__ . '/ionos-essentials/inc/migration/index.php'; -function is_stretch(): bool -{ - return str_starts_with(getcwd(), '/home/www/public') || array_key_exists('SFS', $_SERVER); -} +define('IONOS_IS_STRETCH', str_starts_with(getcwd(), '/home/www/public')); /** * Check if a plugin is active, including custom plugins loaded via ionos stretch extra diff --git a/packages/wp-plugin/ionos-essentials/ionos-essentials/inc/dashboard/tabs/tools.php b/packages/wp-plugin/ionos-essentials/ionos-essentials/inc/dashboard/tabs/tools.php index 0da018d0..fc16daf6 100644 --- a/packages/wp-plugin/ionos-essentials/ionos-essentials/inc/dashboard/tabs/tools.php +++ b/packages/wp-plugin/ionos-essentials/ionos-essentials/inc/dashboard/tabs/tools.php @@ -5,7 +5,6 @@ defined('ABSPATH') || exit(); use function ionos\essentials\_is_plugin_active; -use function ionos\essentials\is_stretch; use const ionos\essentials\security\IONOS_SECURITY_FEATURE_OPTION; use const ionos\essentials\security\IONOS_SECURITY_FEATURE_OPTION_CREDENTIALS_CHECKING; use const ionos\essentials\security\IONOS_SECURITY_FEATURE_OPTION_DEFAULT; @@ -150,7 +149,7 @@ class="link link--action"> get_settings_value(IONOS_SECURITY_FEATURE_OPTION_CREDENTIALS_CHECKING) ? 'checked' : '', ]); -if (! is_stretch()) { +if (! \IONOS_IS_STRETCH) { render_section([ 'title' => \esc_html__('Block XML-RPC access', 'ionos-essentials'), 'id' => IONOS_SECURITY_FEATURE_OPTION_XMLRPC, diff --git a/packages/wp-plugin/ionos-essentials/ionos-essentials/inc/migration/index.php b/packages/wp-plugin/ionos-essentials/ionos-essentials/inc/migration/index.php index 8d3664b5..98992524 100644 --- a/packages/wp-plugin/ionos-essentials/ionos-essentials/inc/migration/index.php +++ b/packages/wp-plugin/ionos-essentials/ionos-essentials/inc/migration/index.php @@ -16,6 +16,8 @@ defined('ABSPATH') || exit(); +define('IS_LOCAL', wp_get_environment_type() === 'local'); + use const ionos\essentials\PLUGIN_FILE; use const ionos\essentials\security\IONOS_SECURITY_FEATURE_OPTION; use const ionos\essentials\security\IONOS_SECURITY_FEATURE_OPTION_CREDENTIALS_CHECKING; @@ -90,9 +92,9 @@ function _install() \add_option('ionos_loop_consent', $ionos_loop_consent_given); // install the performance plugin for all non stretch spaces - if (\ionos\essentials\is_stretch() === false && - ! is_plugin_active('ionos-performance/ionos-performance.php') && - false == strpos(home_url(), 'localhost')) { + if (! \IONOS_IS_STRETCH && + ! is_plugin_active('ionos-performance/ionos-performance.php') && + ! IS_LOCAL) { install_plugin_from_url( 'https://s3-eu-central-1.ionoscloud.com/web-hosting/ionos-group/ionos-performance.latest.zip' ); diff --git a/packages/wp-plugin/ionos-essentials/ionos-essentials/inc/security/index.php b/packages/wp-plugin/ionos-essentials/ionos-essentials/inc/security/index.php index ff458e04..d44c0311 100644 --- a/packages/wp-plugin/ionos-essentials/ionos-essentials/inc/security/index.php +++ b/packages/wp-plugin/ionos-essentials/ionos-essentials/inc/security/index.php @@ -2,7 +2,6 @@ namespace ionos\essentials\security; -use function ionos\essentials\is_stretch; use ionos\essentials\Tenant; defined('ABSPATH') || exit(); @@ -38,7 +37,7 @@ } require_once __DIR__ . '/ssl.php'; - if (! is_stretch()) { + if (! \IONOS_IS_STRETCH) { if (true === $security_options[IONOS_SECURITY_FEATURE_OPTION_XMLRPC]) { require_once __DIR__ . '/xmlrpc.php'; } diff --git a/packages/wp-plugin/ionos-essentials/ionos-essentials/inc/tenants/ionos.php b/packages/wp-plugin/ionos-essentials/ionos-essentials/inc/tenants/ionos.php index d1d38c47..b15351b5 100644 --- a/packages/wp-plugin/ionos-essentials/ionos-essentials/inc/tenants/ionos.php +++ b/packages/wp-plugin/ionos-essentials/ionos-essentials/inc/tenants/ionos.php @@ -4,7 +4,10 @@ defined('ABSPATH') || exit(); -$is_sfs = array_key_exists('SFS', $_SERVER) || get_option('sfs_website_id'); +if (! defined('IONOS_IS_STRETCH_SFS') && defined('IONOS_IS_STRETCH') && \IONOS_IS_STRETCH) { + define('IONOS_IS_STRETCH_SFS', array_key_exists('SFS', $_SERVER)); +} +$is_sfs = (defined('IONOS_IS_STRETCH_SFS') && \IONOS_IS_STRETCH_SFS) || get_option('sfs_website_id'); $links = $is_sfs ? [ [