Skip to content
Open
11 changes: 7 additions & 4 deletions packages/wp-mu-plugin/stretch-extra/stretch-extra.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down
5 changes: 1 addition & 4 deletions packages/wp-plugin/ionos-essentials/ionos-essentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -150,7 +149,7 @@ class="link link--action"><?php \esc_html_e('Preview maintenance page', 'ionos-e
'checked' => 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace ionos\essentials\security;

use function ionos\essentials\is_stretch;
use ionos\essentials\Tenant;

defined('ABSPATH') || exit();
Expand Down Expand Up @@ -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';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? [
[
Expand Down
Loading