Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions _inc/lib/debugger/class-jetpack-debug-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,6 @@ public static function debug_data() {
);

/** Sync Debug Information */
/** Load Sync modules */
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-modules.php';
/** Load Sync sender */
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-sender.php';
/** Load Sync functions */
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-functions.php';

$sync_module = Jetpack_Sync_Modules::get_module( 'full-sync' );
if ( $sync_module ) {
$sync_statuses = $sync_module->get_status();
Expand Down
2 changes: 0 additions & 2 deletions class.jetpack-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,6 @@ public function sync( $args, $assoc_args ) {

/* translators: %s is the site URL */
WP_CLI::log( sprintf( __( 'Sync Disabled on %s. Use `wp jetpack sync enable` to enable syncing again.', 'jetpack' ), get_site_url() ) );
require_once dirname( __FILE__ ) . '/sync/class.jetpack-sync-listener.php';
$listener = Jetpack_Sync_Listener::get_instance();
if ( empty( $assoc_args['queue'] ) ) {
$listener->get_sync_queue()->reset();
Expand Down Expand Up @@ -1033,7 +1032,6 @@ public function sync_queue( $args, $assoc_args ) {

switch( $action ) {
case 'peek':
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-queue.php';
$queue = new Jetpack_Sync_Queue( $mapped_queue_name );
$items = $queue->peek( 100 );

Expand Down
3 changes: 0 additions & 3 deletions class.jetpack-xmlrpc-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,6 @@ function unlink_user() {
function sync_object( $args ) {
// e.g. posts, post, 5
list( $module_name, $object_type, $id ) = $args;
require_once dirname( __FILE__ ) . '/sync/class.jetpack-sync-modules.php';
require_once dirname( __FILE__ ) . '/sync/class.jetpack-sync-sender.php';

$sync_module = Jetpack_Sync_Modules::get_module( $module_name );
$codec = Jetpack_Sync_Sender::get_instance()->get_codec();
Expand All @@ -651,7 +649,6 @@ function sync_object( $args ) {
* @return array
*/
function validate_urls_for_idc_mitigation() {
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-functions.php';
return array(
'home' => Jetpack_Sync_Functions::home_url(),
'siteurl' => Jetpack_Sync_Functions::site_url(),
Expand Down
2 changes: 0 additions & 2 deletions class.jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -3298,7 +3298,6 @@ public static function disconnect( $update_activated_state = true ) {
delete_transient( $transient_key );

// Delete all the sync related data. Since it could be taking up space.
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-sender.php';
Jetpack_Sync_Sender::get_instance()->uninstall();

// Disable the Heartbeat cron
Expand Down Expand Up @@ -6125,7 +6124,6 @@ public static function get_sync_error_idc_option( $response = array() ) {
// in a transient to allow for autoloading and caching on subsequent views.
$local_options = get_transient( 'jetpack_idc_local' );
if ( false === $local_options ) {
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-functions.php';
$local_options = array(
'home' => Jetpack_Sync_Functions::home_url(),
'siteurl' => Jetpack_Sync_Functions::site_url(),
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"automattic/jetpack-logo": "@dev",
"automattic/jetpack-constants": "@dev",
"automattic/jetpack-jitm": "@dev",
"automattic/jetpack-asset-tools": "@dev"
"automattic/jetpack-asset-tools": "@dev",
"automattic/jetpack-sync": "@dev"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "0.5.0",
Expand Down
24 changes: 24 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ function jetpack_admin_missing_autoloader() { ?>
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-client.php' );
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-data.php' );
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-client-server.php' );
require_once( JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-actions.php' );
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-user-agent.php' );
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-post-images.php' );
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-error.php' );
Expand All @@ -230,6 +229,8 @@ function jetpack_admin_missing_autoloader() { ?>
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-connection-banner.php' );
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-plan.php' );

Jetpack_Sync_Main::init();

if ( is_admin() ) {
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-admin.php' );
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-affiliate.php' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ protected function get_plugin_updates( $plugin_file ) {
}

protected function get_plugin_action_links( $plugin_file ) {
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-functions.php';
return Jetpack_Sync_Functions::get_plugins_action_links( $plugin_file );
}
}
14 changes: 0 additions & 14 deletions json-endpoints/jetpack/class.jetpack-json-api-sync-endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ protected function result() {
// GET /sites/%s/data-check
class Jetpack_JSON_API_Sync_Check_Endpoint extends Jetpack_JSON_API_Sync_Endpoint {
protected function result() {
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-wp-replicastore.php';
$store = new Jetpack_Sync_WP_Replicastore();
return $store->checksum_all();
}
Expand All @@ -76,7 +75,6 @@ protected function result() {
$columns = null; // go with defaults
}

require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-wp-replicastore.php';
$store = new Jetpack_Sync_WP_Replicastore();

if ( ! isset( $args['strip_non_ascii'] ) ) {
Expand All @@ -93,8 +91,6 @@ class Jetpack_JSON_API_Sync_Modify_Settings_Endpoint extends Jetpack_JSON_API_Sy
protected function result() {
$args = $this->input();

require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-settings.php';

$sync_settings = Jetpack_Sync_Settings::get_settings();

foreach ( $args as $key => $value ) {
Expand Down Expand Up @@ -122,7 +118,6 @@ protected function result() {
// GET /sites/%s/sync/settings
class Jetpack_JSON_API_Sync_Get_Settings_Endpoint extends Jetpack_JSON_API_Sync_Endpoint {
protected function result() {
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-settings.php';

return Jetpack_Sync_Settings::get_settings();
}
Expand All @@ -135,16 +130,13 @@ protected function result() {

$module_name = $args['module_name'];

require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-modules.php';

if ( ! $sync_module = Jetpack_Sync_Modules::get_module( $module_name ) ) {
return new WP_Error( 'invalid_module', 'You specified an invalid sync module' );
}

$object_type = $args['object_type'];
$object_ids = $args['object_ids'];

require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-sender.php';
$codec = Jetpack_Sync_Sender::get_instance()->get_codec();

Jetpack_Sync_Settings::set_is_syncing( true );
Expand All @@ -167,8 +159,6 @@ protected function result() {
return $queue_name;
}

require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-sender.php';

$sender = Jetpack_Sync_Sender::get_instance();
$response = $sender->do_sync_for_queue( new Jetpack_Sync_Queue( $args['queue'] ) );

Expand All @@ -191,14 +181,12 @@ protected function result() {
return new WP_Error( 'invalid_number_of_items', 'Number of items needs to be an integer that is larger than 0 and less then 100', 400 );
}

require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-queue.php';
$queue = new Jetpack_Sync_Queue( $queue_name );

if ( 0 === $queue->size() ) {
return new WP_Error( 'queue_size', 'The queue is empty and there is nothing to send', 400 );
}

require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-sender.php';
$sender = Jetpack_Sync_Sender::get_instance();

// try to give ourselves as much time as possible
Expand Down Expand Up @@ -262,7 +250,6 @@ protected function result() {
if ( is_wp_error( $queue_name ) ) {
return $queue_name;
}
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-queue.php';

if ( ! isset( $request_body['buffer_id'] ) ) {
return new WP_Error( 'missing_buffer_id', 'Please provide a buffer id', 400 );
Expand Down Expand Up @@ -312,7 +299,6 @@ protected function result() {
return new WP_Error( 'invalid_queue', 'Queue name should be sync or full_sync', 400 );
}

require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-queue.php';
$queue = new Jetpack_Sync_Queue( $args['queue'] );

// False means that there was no lock to delete.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function validate_input( $object ) {
}
$this->site_option = isset( $query_args['site_option'] ) ? $query_args['site_option'] : false;

require_once JETPACK__PLUGIN_DIR . '/sync/class.jetpack-sync-defaults.php';
/**
* Filter the list of options that are manageable via the JSON API.
*
Expand Down
1 change: 0 additions & 1 deletion modules/contact-form/grunion-contact-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -1935,7 +1935,6 @@ static function _style_on() {
* @return string HTML for the concat form.
*/
static function parse( $attributes, $content ) {
require_once JETPACK__PLUGIN_DIR . '/sync/class.jetpack-sync-settings.php';
if ( Jetpack_Sync_Settings::is_syncing() ) {
return '';
}
Expand Down
1 change: 0 additions & 1 deletion modules/likes/jetpack-likes-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ function is_post_likeable( $post_id = 0 ) {
* similar logic and filters apply here, too.
*/
function is_likes_visible() {
require_once JETPACK__PLUGIN_DIR . '/sync/class.jetpack-sync-settings.php';
if ( Jetpack_Sync_Settings::is_syncing() ) {
return false;
}
Expand Down
2 changes: 0 additions & 2 deletions modules/related-posts/jetpack-related-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ public function test_for_shortcode( $content ) {
* @returns string
*/
public function get_target_html() {
require_once JETPACK__PLUGIN_DIR . '/sync/class.jetpack-sync-settings.php';
if ( Jetpack_Sync_Settings::is_syncing() ) {
return '';
}
Expand Down Expand Up @@ -232,7 +231,6 @@ public function get_target_html() {
* @returns string
*/
public function get_target_html_unsupported() {
require_once JETPACK__PLUGIN_DIR . '/sync/class.jetpack-sync-settings.php';
if ( Jetpack_Sync_Settings::is_syncing() ) {
return '';
}
Expand Down
1 change: 0 additions & 1 deletion modules/sharedaddy/sharing-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,6 @@ function sharing_process_requests() {
function sharing_display( $text = '', $echo = false ) {
global $post, $wp_current_filter;

require_once JETPACK__PLUGIN_DIR . '/sync/class.jetpack-sync-settings.php';
if ( Jetpack_Sync_Settings::is_syncing() ) {
return $text;
}
Expand Down
15 changes: 15 additions & 0 deletions packages/sync/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "automattic/jetpack-sync",
"description": "Everything needed to allow syncing to the WP.com infrastructure.",
"type": "library",
"license": "GPL-2.0-or-later",
"require": {
"automattic/jetpack-constants": "@dev",
"automattic/jetpack-options": "@dev"
},
"autoload": {
"classmap": [
"/legacy"
]
}
}
Loading