updated plugin Jetpack Protect version 1.4.2

This commit is contained in:
2023-10-22 22:21:06 +00:00
committed by Gitium
parent f512d25847
commit f07dfae114
242 changed files with 6494 additions and 1502 deletions

View File

@ -51,5 +51,4 @@ class Cache {
public static function clear() {
self::$cache = array();
}
}

View File

@ -32,7 +32,7 @@ class Files {
return $files;
}
// phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
// phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
while ( false !== $file = readdir( $dir ) ) {
if ( '.' === substr( $file, 0, 1 ) || '.php' !== substr( $file, -4 ) ) {
continue;

View File

@ -93,4 +93,30 @@ class Host {
$domains[] = 'calypso.localhost';
return $domains;
}
/**
* Return Calypso environment value; used for developing Jetpack and pairing
* it with different Calypso environments, such as localhost.
*
* @since 1.18.0
*
* @return string Calypso environment
*/
public function get_calypso_env() {
// phpcs:disable WordPress.Security.NonceVerification.Recommended -- Nonce is not required; only used for changing environments.
if ( isset( $_GET['calypso_env'] ) ) {
return sanitize_key( $_GET['calypso_env'] );
}
// phpcs:enable WordPress.Security.NonceVerification.Recommended
if ( getenv( 'CALYPSO_ENV' ) ) {
return sanitize_key( getenv( 'CALYPSO_ENV' ) );
}
if ( defined( 'CALYPSO_ENV' ) && CALYPSO_ENV ) {
return sanitize_key( CALYPSO_ENV );
}
return '';
}
}

View File

@ -7,8 +7,9 @@
namespace Automattic\Jetpack;
use Automattic\Jetpack\Constants as Constants;
use Automattic\Jetpack\Current_Plan as Jetpack_Plan;
use Automattic\Jetpack\IP\Utils as IP_Utils;
use Automattic\Jetpack\Status\Host;
/**
* Class Automattic\Jetpack\Modules
@ -193,8 +194,11 @@ class Modules {
$active = array_diff( $active, array( 'vaultpress' ) );
}
// If protect is active on the main site of a multisite, it should be active on all sites.
if ( ! in_array( 'protect', $active, true ) && is_multisite() && get_site_option( 'jetpack_protect_active' ) ) {
// If protect is active on the main site of a multisite, it should be active on all sites. Doesn't apply to WP.com.
if ( ! in_array( 'protect', $active, true )
&& ! ( new Host() )->is_wpcom_simple()
&& is_multisite()
&& get_site_option( 'jetpack_protect_active' ) ) {
$active[] = 'protect';
}
@ -426,7 +430,7 @@ class Modules {
}
}
if ( $deactivated ) {
$state->state( 'deactivated_plugins', join( ',', $deactivated ) );
$state->state( 'deactivated_plugins', implode( ',', $deactivated ) );
wp_safe_redirect( add_query_arg( 'jetpack_restate', 1 ) );
exit;
}
@ -441,7 +445,7 @@ class Modules {
}
}
if ( class_exists( 'Jetpack_Plan' ) && ! \Jetpack_Plan::supports( $module ) ) {
if ( ! Jetpack_Plan::supports( $module ) ) {
return false;
}

View File

@ -169,9 +169,8 @@ class Status {
// Check for localhost and sites using an IP only first.
$is_local = $site_url && false === strpos( $site_url, '.' );
// @todo Remove function_exists when the package has a documented minimum WP version.
// Use Core's environment check, if available. Added in 5.5.0 / 5.5.1 (for `local` return value).
if ( function_exists( 'wp_get_environment_type' ) && 'local' === wp_get_environment_type() ) {
// Use Core's environment check, if available.
if ( 'local' === wp_get_environment_type() ) {
$is_local = true;
}
@ -184,6 +183,7 @@ class Status {
'#\.docksal\.site$#i', // Docksal.
'#\.dev\.cc$#i', // ServerPress.
'#\.lndo\.site$#i', // Lando.
'#^https?://127\.0\.0\.1$#',
);
if ( ! $is_local ) {
@ -221,24 +221,26 @@ class Status {
return $cached;
}
// @todo Remove function_exists when the package has a documented minimum WP version.
// Core's wp_get_environment_type allows for a few specific options. We should default to bowing out gracefully for anything other than production or local.
$is_staging = function_exists( 'wp_get_environment_type' ) && ! in_array( wp_get_environment_type(), array( 'production', 'local' ), true );
/*
* Core's wp_get_environment_type allows for a few specific options.
* We should default to bowing out gracefully for anything other than production or local.
*/
$is_staging = ! in_array( wp_get_environment_type(), array( 'production', 'local' ), true );
$known_staging = array(
'urls' => array(
'#\.staging\.wpengine\.com$#i', // WP Engine. This is their legacy staging URL structure. Their new platform does not have a common URL. https://github.com/Automattic/jetpack/issues/21504
'#\.staging\.kinsta\.com$#i', // Kinsta.com.
'#\.kinsta\.cloud$#i', // Kinsta.com.
'#\.stage\.site$#i', // DreamPress.
'#\.newspackstaging\.com$#i', // Newspack.
'#\.pantheonsite\.io$#i', // Pantheon.
'#\.flywheelsites\.com$#i', // Flywheel.
'#\.flywheelstaging\.com$#i', // Flywheel.
'#\.cloudwaysapps\.com$#i', // Cloudways.
'#\.azurewebsites\.net$#i', // Azure.
'#\.wpserveur\.net$#i', // WPServeur.
'#\-liquidwebsites\.com$#i', // Liquidweb.
'#\.staging\.wpengine\.com$#i', // WP Engine. This is their legacy staging URL structure. Their new platform does not have a common URL. https://github.com/Automattic/jetpack/issues/21504
'#\.staging\.kinsta\.com$#i', // Kinsta.com.
'#\.kinsta\.cloud$#i', // Kinsta.com.
'#\.stage\.site$#i', // DreamPress.
'#\.newspackstaging\.com$#i', // Newspack.
'#^(?!live-)([a-zA-Z0-9-]+)\.pantheonsite\.io$#i', // Pantheon.
'#\.flywheelsites\.com$#i', // Flywheel.
'#\.flywheelstaging\.com$#i', // Flywheel.
'#\.cloudwaysapps\.com$#i', // Cloudways.
'#\.azurewebsites\.net$#i', // Azure.
'#\.wpserveur\.net$#i', // WPServeur.
'#\-liquidwebsites\.com$#i', // Liquidweb.
),
'constants' => array(
'IS_WPE_SNAPSHOT', // WP Engine. This is used on their legacy staging environment. Their new platform does not have a constant. https://github.com/Automattic/jetpack/issues/21504

View File

@ -40,5 +40,4 @@ class Visitor {
return ! empty( $_SERVER['REMOTE_ADDR'] ) ? filter_var( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) : '';
}
}