Add upstream

This commit is contained in:
root
2019-10-24 00:12:05 +02:00
parent 85d41e4216
commit ac980f592c
3504 changed files with 1049983 additions and 29971 deletions

View File

@@ -0,0 +1,25 @@
<?php
/**
* Legacy global scope functions.
*
* @package global-functions
*/
if ( ! defined( 'ABSPATH' ) ) {
return;
}
// Add here, after the condition above, any code that should only run when WordPress is running.
// Autoload will load everything even when PHPCS is running and we don't want to run these
// in such case because they will fatal, for example, due to 'add_action' being undefined.
/**
* Load necessary functions.
*/
function jetpack_compat_require_defined_functions() {
jetpack_require_lib( 'tracks/client' );
}
add_action( 'plugins_loaded', 'jetpack_compat_require_defined_functions' );

View File

@@ -0,0 +1,90 @@
<?php
/**
* Jetpack Client
*
* Deprecated methods for Jetpack to act as client with wpcom, provided for back-compatibility.
*
* @category Connection
* @package Client
*/
use Automattic\Jetpack\Connection\Client;
/**
* Class Jetpack_Client
*
* @deprecated Use Automattic\Jetpack\Connection\Client
*/
class Jetpack_Client {
/**
* Jetpack API version.
*
* @deprecated use Automattic\Jetpack\Connection\Client::WPCOM_JSON_API_VERSION
*/
const WPCOM_JSON_API_VERSION = '1.1';
/**
* Perform remote request.
*
* @deprecated use Automattic\Jetpack\Connection\Client::remote_request
*
* @param array $args Arguments.
* @param null $body Request body.
*
* @return array|WP_Error
*/
public static function remote_request( $args, $body = null ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Connection\Client' );
return Client::remote_request( $args, $body );
}
/**
* Request to wpcom using the blog id.
*
* @deprecated use Automattic\Jetpack\Connection\Client::wpcom_json_api_request_as_blog
*
* @param string $path Endpoint path.
* @param string $version Endpoint version.
* @param array $args Arguments.
* @param null $body Request body.
* @param string $base_api_path Endpoint base prefix.
*
* @return Array|WP_Error
*/
public static function wpcom_json_api_request_as_blog(
$path,
$version = self::WPCOM_JSON_API_VERSION,
$args = array(),
$body = null,
$base_api_path = 'rest'
) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Connection\Client' );
return Client::wpcom_json_api_request_as_blog( $path, $version, $args, $body, $base_api_path );
}
/**
* Wrapper for wp_remote_request(). Turns off SSL verification for certain SSL errors.
* This is lame, but many, many, many hosts have misconfigured SSL.
*
* @deprecated use Automattic\Jetpack\Connection\Client::_wp_remote_request
*
* When Jetpack is registered, the jetpack_fallback_no_verify_ssl_certs option is set to the current time if:
* 1. a certificate error is found AND
* 2. not verifying the certificate works around the problem.
*
* The option is checked on each request.
*
* @internal
* @see Jetpack::fix_url_for_bad_hosts()
*
* @param String $url the request URL.
* @param Array $args request arguments.
* @param Boolean $set_fallback whether to allow flagging this request to use a fallback certficate override.
* @return array|WP_Error WP HTTP response on success
*/
public static function _wp_remote_request( $url, $args, $set_fallback = false ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Connection\Client' );
return Client::_wp_remote_request( $url, $args, $set_fallback );
}
}

View File

@@ -0,0 +1,359 @@
<?php
/**
* A compatibility shim for the sync actions class.
*
* @package jetpack-compat
*/
use Automattic\Jetpack\Sync\Actions;
/**
* Class Jetpack_Sync_Actions
*
* @deprecated Use Automattic\Jetpack\Sync\Actions
*/
class Jetpack_Sync_Actions extends Automattic\Jetpack\Sync\Actions {
/**
* Initializes the class.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::init
*/
public static function init() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::init();
}
/**
* Adds a shutdown sender callback.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::add_sender_shutdown
*/
public static function add_sender_shutdown() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::add_sender_shutdown();
}
/**
* Returns false or true based on whether this class should initialize the sender
* in current circumstances.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::should_initialize_sender
*
* @return Boolean should the object initialize sender?
*/
public static function should_initialize_sender() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::should_initialize_sender();
}
/**
* Returns false or true based on whether sync is allowed.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::sync_allowed
*
* @return Boolean is sync allowed?
*/
public static function sync_allowed() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::sync_allowed();
}
/**
* Returns false or true based on whether sync via cron is allowed.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::sync_via_cron_allowed
*
* @return Boolean is sync via cron allowed?
*/
public static function sync_via_cron_allowed() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::sync_via_cron_allowed();
}
/**
* Filters a boolean value that determines whether blacklisted posts should be prevented
* from being publicized.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::prevent_publicize_blacklisted_posts
*
* @param Boolean $should_publicize initial setting value.
* @param WP_Post $post the post object.
* @return Boolean whether to prevent publicizing.
*/
public static function prevent_publicize_blacklisted_posts( $should_publicize, $post ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::prevent_publicize_blacklisted_posts( $should_publicize, $post );
}
/**
* Set the importing flag to true.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::set_is_importing_true
*/
public static function set_is_importing_true() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::set_is_importing_true();
}
/**
* Send the sync data.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::send_data
*
* @param Mixed $data the sync data.
* @param String $codec_name the codec slug.
* @param Integer $sent_timestamp the current server timestamp.
* @param Integer $queue_id the queue identifier.
* @param Integer $checkout_duration time spent retrieving items.
* @param Integer $preprocess_duration Time spent converting items into data.
* @return WP_Response the response object.
*/
public static function send_data( $data, $codec_name, $sent_timestamp, $queue_id, $checkout_duration, $preprocess_duration ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::send_data( $data, $codec_name, $sent_timestamp, $queue_id, $checkout_duration, $preprocess_duration );
}
/**
* Commence initial sync.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::do_initial_sync
*/
public static function do_initial_sync() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::do_initial_sync();
}
/**
* Commence full sync.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::do_full_sync
*
* @param Array $modules the modules list.
* @return Boolean whether the sync was initialized.
*/
public static function do_full_sync( $modules = null ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::do_full_sync( $modules );
}
/**
* Schedule cron sessions.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::jetpack_cron_schedule
*
* @param Array $schedules the schedules to add.
*/
public static function jetpack_cron_schedule( $schedules ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::jetpack_cron_schedule( $schedules );
}
/**
* Commence cron sync.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::do_cron_sync
*/
public static function do_cron_sync() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::do_cron_sync();
}
/**
* Commence cron full sync.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::do_cron_full_sync
*/
public static function do_cron_full_sync() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::do_cron_full_sync();
}
/**
* Commence cron sync of a specific type of object.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::do_cron_sync_by_type
*
* @param Array $type the type of object to sync.
*/
public static function do_cron_sync_by_type( $type ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::do_cron_sync_by_type();
}
/**
* Initalize the listener of the object.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::initialize_listener
*/
public static function initialize_listener() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::initialize_listener();
}
/**
* Initalize the sender of the object.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::initialize_sender
*/
public static function initialize_sender() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::initialize_sender();
}
/**
* Initalize the woocommerce listeners.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::initialize_woocommerce
*/
public static function initialize_woocommerce() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::initialize_woocommerce();
}
/**
* Add the woocommerce sync module.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::add_woocommerce_sync_module
*
* @param Array $sync_modules an array of modules.
*/
public static function add_woocommerce_sync_module( $sync_modules ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::add_woocommerce_sync_module( $sync_modules );
}
/**
* Initalize the WP Super Cache listener.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::initialize_wp_super_cache
*/
public static function initialize_wp_super_cache() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::initialize_wp_super_cache();
}
/**
* Add the WP Super Cache sync module.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::add_wp_super_cache_sync_module
*
* @param Array $sync_modules the list to be amended.
*/
public static function add_wp_super_cache_sync_module( $sync_modules ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::add_wp_super_cache_sync_module( $sync_modules );
}
/**
* Sanitizes the filtered sync cron schedule.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::sanitize_filtered_sync_cron_schedule
*
* @param String $schedule the cron schedule to sanitize.
* @return String sanitized cron schedule.
*/
public static function sanitize_filtered_sync_cron_schedule( $schedule ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::sanitize_filtered_sync_cron_schedule( $schedule );
}
/**
* Returns the time offset for a the start schedule.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::get_start_time_offset
*
* @param String $schedule the schedule string.
* @param String $hook hook slug.
* @return Integer start time offset.
*/
public static function get_start_time_offset( $schedule = '', $hook = '' ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::get_start_time_offset( $schedule, $hook );
}
/**
* If needed, schedule a cron sync.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::maybe_schedule_sync_cron
*
* @param String $schedule the schedule string.
* @param String $hook hook slug.
*/
public static function maybe_schedule_sync_cron( $schedule, $hook ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::maybe_schedule_sync_cron( $schedule, $hook );
}
/**
* Clears cron jobs scheduled for sync.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::clear_sync_cron_jobs
*/
public static function clear_sync_cron_jobs() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::clear_sync_cron_jobs();
}
/**
* Initialize cron jobs for sync.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::init_sync_cron_jobs
*/
public static function init_sync_cron_jobs() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::init_sync_cron_jobs();
}
/**
* Cleans up schedules on plugin upgrade.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::cleanup_on_upgrade
*
* @param String $new_version the new version.
* @param String $old_version the old version.
*/
public static function cleanup_on_upgrade( $new_version = null, $old_version = null ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::cleanup_on_upgrade( $new_version, $old_version );
}
/**
* Clears cron jobs scheduled for sync.
*
* @deprecated \Automattic\Jetpack\Sync\Actions::get_sync_status
*
* @param Array $fields sync fields to get status of.
*/
public static function get_sync_status( $fields = null ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Actions' );
return Actions::get_sync_status( $fields );
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* A compatibility shim for the sync modules class.
*
* @package jetpack-compat
*/
use Automattic\Jetpack\Sync\Modules;
/**
* Class Jetpack_Sync_Modules
*
* @deprecated Use Automattic\Jetpack\Sync\Modules
*/
class Jetpack_Sync_Modules {
/**
* Returns the sync module object.
*
* @param String $module_name the module name.
* @return Automattic\Jetpack\Sync\Modules\Module the module object.
*/
public static function get_module( $module_name ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Modules' );
return Modules::get_module( $module_name );
}
}

View File

@@ -0,0 +1,102 @@
<?php
use Automattic\Jetpack\Sync\Settings;
/**
* Class Jetpack_Sync_Settings
*
* @deprecated Use Automattic\Jetpack\Sync\Settings
*/
class Jetpack_Sync_Settings {
static function get_settings() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
return Settings::get_settings();
}
static function get_setting( $setting ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
return Settings::get_setting( $setting );
}
static function update_settings( $new_settings ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
Settings::update_settings( $new_settings );
}
static function is_network_setting( $setting ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
return Settings::is_network_setting( $setting );
}
static function get_blacklisted_post_types_sql() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
return Settings::get_blacklisted_post_types_sql();
}
static function get_whitelisted_post_meta_sql() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
return Settings::get_whitelisted_post_meta_sql();
}
static function get_whitelisted_comment_meta_sql() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
return Settings::get_whitelisted_comment_meta_sql();
}
static function get_comments_filter_sql() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
return Settings::get_comments_filter_sql();
}
static function reset_data() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
Settings::reset_data();
}
static function set_importing( $is_importing ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
Settings::set_importing( $is_importing );
}
static function is_importing() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
Settings::is_importing();
}
static function is_sync_enabled() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
Settings::is_sync_enabled();
}
static function set_doing_cron( $is_doing_cron ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
Settings::set_doing_cron( $is_doing_cron );
}
static function is_doing_cron() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
Settings::is_doing_cron();
}
static function is_syncing() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
return Settings::is_syncing();
}
static function set_is_syncing( $is_syncing ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
Settings::set_is_syncing( $is_syncing );
}
static function is_sending() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
Settings::is_sending();
}
static function set_is_sending( $is_sending ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Sync\Settings' );
Settings::set_is_sending( $is_sending );
}
}

View File

@@ -0,0 +1,21 @@
<?php
use Automattic\Jetpack\Tracking;
class JetpackTracking {
static function enqueue_tracks_scripts() {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Tracking' );
$tracking = new Tracking();
return $tracking->enqueue_tracks_scripts();
}
static function record_user_event( $event_type, $data = array(), $user = null ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Tracking' );
$tracking = new Tracking();
return $tracking->record_user_event( $event_type, $data, $user );
}
}

View File

@@ -0,0 +1,21 @@
<?php
/**
* @deprecated 7.5.0 use Automattic\Jetpack\Tracking->tracks_get_identity instead
*/
function jetpack_tracks_get_identity( $user_id ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Tracking->tracks_get_identity' );
$tracking = new Automattic\Jetpack\Tracking( 'jetpack', Jetpack::connection() );
return $tracking->tracks_get_identity( $user_id );
}
/**
* @deprecated 7.5.0 use Automattic\Jetpack\Tracking->tracks_record_event instead
*/
function jetpack_tracks_record_event( $user, $event_name, $properties = array(), $event_timestamp_millis = false ) {
_deprecated_function( __METHOD__, 'jetpack-7.5', 'Automattic\Jetpack\Tracking->tracks_record_event' );
$tracking = new Automattic\Jetpack\Tracking( 'jetpack', Jetpack::connection() );
return $tracking->tracks_record_event( $user, $event_name, $properties, $event_timestamp_millis );
}