updated plugin Jetpack Protect version 3.0.2

This commit is contained in:
2024-10-09 12:44:31 +00:00
committed by Gitium
parent a35dc419bc
commit f970470c59
283 changed files with 6970 additions and 2338 deletions

View File

@ -31,12 +31,14 @@ class Errors {
static $display_errors, $error_reporting;
if ( $catch ) {
// Force error reporting and output, store original values.
$display_errors = @ini_set( 'display_errors', 1 );
$error_reporting = @error_reporting( E_ALL );
if ( class_exists( 'Jetpack' ) ) {
add_action( 'shutdown', array( 'Jetpack', 'catch_errors_on_shutdown' ), 0 );
}
} else {
// Restore the original values for error reporting and output.
@ini_set( 'display_errors', $display_errors );
@error_reporting( $error_reporting );
if ( class_exists( 'Jetpack' ) ) {

View File

@ -22,14 +22,16 @@ class Modules {
* Check whether or not a Jetpack module is active.
*
* @param string $module The slug of a Jetpack module.
* @param bool $available_only Whether to only check among available modules.
*
* @return bool
*/
public function is_active( $module ) {
public function is_active( $module, $available_only = true ) {
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
return true;
}
return in_array( $module, self::get_active(), true );
return in_array( $module, self::get_active( $available_only ), true );
}
/**
@ -184,8 +186,12 @@ class Modules {
/**
* Get a list of activated modules as an array of module slugs.
*
* @param bool $available_only Filter out the unavailable (deleted) modules.
*
* @return array
*/
public function get_active() {
public function get_active( $available_only = true ) {
$active = \Jetpack_Options::get_option( 'active_modules' );
if ( ! is_array( $active ) ) {
@ -206,9 +212,11 @@ class Modules {
$active[] = 'protect';
}
// If it's not available, it shouldn't be active.
// We don't delete it from the options though, as it will be active again when a plugin gets reactivated.
$active = array_intersect( $active, $this->get_available() );
if ( $available_only ) {
// If it's not available, it shouldn't be active.
// We don't delete it from the options though, as it will be active again when a plugin gets reactivated.
$active = array_intersect( $active, $this->get_available() );
}
/**
* Allow filtering of the active modules.
@ -409,7 +417,7 @@ class Modules {
$state = new CookieState();
if ( ! \Jetpack::is_connection_ready() ) {
if ( ! $status->is_offline_mode() && ! $status->is_onboarding() ) {
if ( ! $status->is_offline_mode() ) {
return false;
}

View File

@ -171,11 +171,12 @@ class Status {
/**
* If is a staging site.
*
* @todo Add IDC detection to a package.
* @deprecated since 3.3.0
*
* @return bool
*/
public function is_staging_site() {
_deprecated_function( __FUNCTION__, '3.3.0', 'in_safe_mode' );
$cached = Cache::get( 'is_staging_site' );
if ( null !== $cached ) {
return $cached;
@ -261,12 +262,72 @@ class Status {
return $is_staging;
}
/**
* If the site is in safe mode.
*
* @since 3.3.0
*
* @return bool
*/
public function in_safe_mode() {
$cached = Cache::get( 'in_safe_mode' );
if ( null !== $cached ) {
return $cached;
}
$in_safe_mode = false;
if ( method_exists( 'Automattic\\Jetpack\\Identity_Crisis', 'validate_sync_error_idc_option' ) && \Automattic\Jetpack\Identity_Crisis::validate_sync_error_idc_option() ) {
$in_safe_mode = true;
}
/**
* Filters in_safe_mode check.
*
* @since 3.3.0
*
* @param bool $in_safe_mode If the current site is in safe mode.
*/
$in_safe_mode = apply_filters( 'jetpack_is_in_safe_mode', $in_safe_mode );
Cache::set( 'in_safe_mode', $in_safe_mode );
return $in_safe_mode;
}
/**
* If the site is a development/staging site.
* This is a new version of is_staging_site added to separate safe mode from the legacy staging mode.
* This method checks for core WP_ENVIRONMENT_TYPE setting
* Using the jetpack_is_development_site filter.
*
* @since 3.3.0
*
* @return bool
*/
public static function is_development_site() {
$cached = Cache::get( 'is_development_site' );
if ( null !== $cached ) {
return $cached;
}
$is_dev_site = ! in_array( wp_get_environment_type(), array( 'production', 'local' ), true );
/**
* Filters is_development_site check.
*
* @since 3.3.0
*
* @param bool $is_dev_site If the current site is a staging or dev site.
*/
$is_dev_site = apply_filters( 'jetpack_is_development_site', $is_dev_site );
Cache::set( 'is_development_site', $is_dev_site );
return $is_dev_site;
}
/**
* Whether the site is currently onboarding or not.
* A site is considered as being onboarded if it currently has an onboarding token.
*
* @since-jetpack 5.8
*
* @deprecated since 4.0.0
*
* @access public
* @static
*