Merged in feature/280-dev-dev01 (pull request #21)

auto-patch  280-dev-dev01-2024-01-19T16_41_58

* auto-patch  280-dev-dev01-2024-01-19T16_41_58
This commit is contained in:
Tony Volpe
2024-01-19 16:44:43 +00:00
parent 2699b5437a
commit be83910651
2125 changed files with 179300 additions and 35639 deletions

View File

@@ -178,5 +178,4 @@ class A8c_Mc_Stats {
$url = add_query_arg( $args, $base_url );
return $url;
}
}

View File

@@ -13,7 +13,7 @@ namespace Automattic\Jetpack\Admin_UI;
*/
class Admin_Menu {
const PACKAGE_VERSION = '0.2.20';
const PACKAGE_VERSION = '0.2.25';
/**
* Whether this class has been initialized
@@ -49,7 +49,7 @@ class Admin_Menu {
* we use this method to move the menu item.
*/
private static function handle_akismet_menu() {
if ( ! class_exists( 'Jetpack' ) && class_exists( 'Akismet_Admin' ) ) {
if ( class_exists( 'Akismet_Admin' ) ) {
// Prevent Akismet from adding a menu item.
add_action(
'admin_menu',
@@ -60,7 +60,7 @@ class Admin_Menu {
);
// Add an Anti-spam menu item for Jetpack.
self::add_menu( __( 'Anti-Spam', 'jetpack-admin-ui' ), __( 'Anti-Spam', 'jetpack-admin-ui' ), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) );
self::add_menu( __( 'Akismet Anti-spam', 'jetpack-admin-ui' ), __( 'Akismet Anti-spam', 'jetpack-admin-ui' ), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) );
}
}
@@ -104,7 +104,13 @@ class Admin_Menu {
function ( $a, $b ) {
$position_a = empty( $a['position'] ) ? 0 : $a['position'];
$position_b = empty( $b['position'] ) ? 0 : $b['position'];
return $position_a - $position_b;
$result = $position_a - $position_b;
if ( 0 === $result ) {
$result = strcmp( $a['menu_title'], $b['menu_title'] );
}
return $result;
}
);
@@ -150,7 +156,7 @@ class Admin_Menu {
* and only include lowercase alphanumeric, dashes, and underscores characters
* to be compatible with sanitize_key().
* @param callable $function The function to be called to output the content for this page.
* @param int $position The position in the menu order this item should appear.
* @param int $position The position in the menu order this item should appear. Leave empty typically.
*
* @return string The resulting page's hook_suffix
*/
@@ -198,5 +204,4 @@ class Admin_Menu {
$url = $fallback ? $fallback : admin_url();
return $url;
}
}

View File

@@ -874,5 +874,4 @@ class Jetpack_XMLRPC_Server {
}
return array();
}
}

View File

@@ -240,5 +240,4 @@ class Connection_Notice {
echo '</p>';
echo '</div>';
}
}

View File

@@ -772,5 +772,4 @@ class Error_Handler {
$this->report_error( $error, false, true );
}
}

View File

@@ -249,5 +249,4 @@ class Heartbeat {
WP_CLI::line( sprintf( __( 'Last heartbeat sent at: %s', 'jetpack-connection' ), $last_date ) );
}
}
}

View File

@@ -14,13 +14,6 @@ use Automattic\Jetpack\Status;
*/
class Initial_State {
/**
* Whether the initial state was already rendered
*
* @var boolean
*/
private static $rendered = false;
/**
* Get the initial state data.
*
@@ -52,11 +45,7 @@ class Initial_State {
* @return string
*/
public static function render() {
if ( self::$rendered ) {
return null;
}
self::$rendered = true;
return 'var JP_CONNECTION_INITIAL_STATE=JSON.parse(decodeURIComponent("' . rawurlencode( wp_json_encode( self::get_data() ) ) . '"));';
return 'var JP_CONNECTION_INITIAL_STATE; typeof JP_CONNECTION_INITIAL_STATE === "object" || (JP_CONNECTION_INITIAL_STATE = JSON.parse(decodeURIComponent("' . rawurlencode( wp_json_encode( self::get_data() ) ) . '")));';
}
/**
@@ -67,9 +56,6 @@ class Initial_State {
* @return void
*/
public static function render_script( $handle ) {
if ( ! static::$rendered ) {
wp_add_inline_script( $handle, static::render(), 'before' );
}
wp_add_inline_script( $handle, static::render(), 'before' );
}
}

View File

@@ -7,7 +7,7 @@
namespace Automattic\Jetpack\Connection;
use Automattic\Jetpack\A8c_Mc_Stats as A8c_Mc_Stats;
use Automattic\Jetpack\A8c_Mc_Stats;
use Automattic\Jetpack\Constants;
use Automattic\Jetpack\Heartbeat;
use Automattic\Jetpack\Roles;
@@ -1916,6 +1916,7 @@ class Manager {
'site_created' => $this->get_assumed_site_creation_date(),
'allow_site_connection' => ! $this->has_connected_owner(),
'calypso_env' => ( new Host() )->get_calypso_env(),
'source' => ( new Host() )->get_source_query(),
)
);
@@ -2139,7 +2140,6 @@ class Manager {
'wordpress.com',
'localhost',
'localhost.localdomain',
'127.0.0.1',
'local.wordpress.test', // VVV pattern.
'local.wordpress-trunk.test', // VVV pattern.
'src.wordpress-develop.test', // VVV pattern.
@@ -2195,6 +2195,24 @@ class Manager {
return true;
}
$domain = preg_replace( '#^https?://#', '', untrailingslashit( $domain ) );
if ( filter_var( $domain, FILTER_VALIDATE_IP )
&& ! filter_var( $domain, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE )
) {
return new \WP_Error(
'fail_ip_forbidden',
sprintf(
/* translators: %1$s is a domain name. */
__(
'IP address `%1$s` just failed is_usable_domain check as it is in the private network.',
'jetpack-connection'
),
$domain
)
);
}
return true;
}
@@ -2541,4 +2559,18 @@ class Manager {
}
return (int) $site_id;
}
/**
* Check if Jetpack is ready for uninstall cleanup.
*
* @param string $current_plugin_slug The current plugin's slug.
*
* @return bool
*/
public static function is_ready_for_cleanup( $current_plugin_slug ) {
$active_plugins = get_option( Plugin_Storage::ACTIVE_PLUGINS_OPTION_NAME );
return empty( $active_plugins ) || ! is_array( $active_plugins )
|| ( count( $active_plugins ) === 1 && array_key_exists( $current_plugin_slug, $active_plugins ) );
}
}

View File

@@ -209,5 +209,4 @@ class Nonce_Handler {
return true;
}
}

View File

@@ -108,5 +108,4 @@ class Package_Version_Tracker {
set_transient( self::CACHED_FAILED_REQUEST_KEY, time(), self::CACHED_FAILED_REQUEST_EXPIRATION );
}
}
}

View File

@@ -12,7 +12,7 @@ namespace Automattic\Jetpack\Connection;
*/
class Package_Version {
const PACKAGE_VERSION = '1.57.0';
const PACKAGE_VERSION = '1.60.1';
const PACKAGE_SLUG = 'connection';

View File

@@ -108,5 +108,4 @@ class Terms_Of_Service {
protected function set_reject() {
\Jetpack_Options::update_option( self::OPTION_NAME, false );
}
}

View File

@@ -73,5 +73,4 @@ class Tokens_Locks {
add_filter( 'ai1wm_export', array( $this, 'aiowpm_set_lock' ), 180 );
add_filter( 'ai1wm_export', array( $this, 'aiowpm_remove_lock' ), 250 );
}
}

View File

@@ -90,6 +90,7 @@ class Urls {
$option_key = self::HTTPS_CHECK_OPTION_PREFIX . $callable;
$parsed_url = wp_parse_url( $new_value );
if ( ! $parsed_url ) {
return $new_value;
}
@@ -98,7 +99,12 @@ class Urls {
} else {
$scheme = '';
}
$scheme_history = get_option( $option_key, array() );
$scheme_history = get_option( $option_key, array() );
if ( ! is_array( $scheme_history ) ) {
$scheme_history = array();
}
$scheme_history[] = $scheme;
// Limit length to self::HTTPS_CHECK_HISTORY.
@@ -183,5 +189,4 @@ class Urls {
public static function main_network_site_url() {
return self::get_protocol_normalized_url( 'main_network_site_url', network_site_url() );
}
}

View File

@@ -81,7 +81,7 @@ class XMLRPC_Async_Call {
public static function do_calls() {
foreach ( self::$clients as $client_blog_id => $blog_clients ) {
if ( $client_blog_id > 0 ) {
$switch_success = switch_to_blog( $client_blog_id, true );
$switch_success = switch_to_blog( $client_blog_id );
if ( ! $switch_success ) {
continue;

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

@@ -119,4 +119,19 @@ class Host {
return '';
}
/**
* Return source query param value from the URL if exists in the allowed sources list.
*
* @return string "source" query param value
*/
public function get_source_query() {
// phpcs:disable WordPress.Security.NonceVerification.Recommended
$allowed_sources = array( 'jetpack-manage' );
if ( isset( $_GET['source'] ) && in_array( $_GET['source'], $allowed_sources, true ) ) {
return sanitize_key( $_GET['source'] );
}
return '';
}
}

View File

@@ -7,9 +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
@@ -194,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';
}

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
@@ -409,5 +411,4 @@ class Status {
return rtrim( $url, ':' );
}
}

View File

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