Skip to content
Closed
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
25 changes: 24 additions & 1 deletion sync/class.jetpack-sync-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static function add_sender_shutdown() {
*/
if ( apply_filters( 'jetpack_sync_sender_should_load',
(
( isset( $_SERVER["REQUEST_METHOD"] ) && 'POST' === $_SERVER['REQUEST_METHOD'] )
( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' === $_SERVER['REQUEST_METHOD'] )
||
current_user_can( 'manage_options' )
||
Expand All @@ -78,6 +78,17 @@ static function add_sender_shutdown() {
defined( 'PHPUNIT_JETPACK_TESTSUITE' )
)
) ) {
if ( Jetpack_Sync_Settings::get_setting( 'async_sender' ) ) {
if ( ! isset( $_GET['jetpack_sync_async_sender'] ) ) {
self::async_sender();
return;
}
}

if ( isset( $_GET['jetpack_sync_async_sender'] ) ) {
ignore_user_abort(true );
}

self::initialize_sender();
add_action( 'shutdown', array( self::$sender, 'do_sync' ) );
add_action( 'shutdown', array( self::$sender, 'do_full_sync' ) );
Expand Down Expand Up @@ -441,6 +452,18 @@ static function get_sync_status() {
)
);
}

static function async_sender() {
$url = add_query_arg( 'jetpack_sync_async_sender', true, site_url() );
$args = array(
'timeout' => 0.01,
'blocking' => false,
/** This filter is documented in wp-includes/class-wp-http-streams.php */
'sslverify' => apply_filters( 'https_local_ssl_verify', false )
);

wp_remote_post( $url, $args );
}
}

// Check for WooCommerce support
Expand Down
1 change: 1 addition & 0 deletions sync/class.jetpack-sync-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Jetpack_Sync_Settings {
'max_queue_size_full_sync'=> true,
'sync_via_cron' => true,
'cron_sync_time_limit' => true,
'async_sender' => false,
);

static $is_importing;
Expand Down