Skip to content

Commit

Permalink
Sync Listener: Don't enqueue actions when the site is disconnected (#…
Browse files Browse the repository at this point in the history
…22149)

Co-authored-by: Samiff <samiff@users.noreply.github.com>
Co-authored-by: Foteini Giannaropoulou <giannaropoulou.foteini@gmail.com>

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/1652659733
  • Loading branch information
jeherve authored and matticbot committed Jan 4, 2022
1 parent f252aca commit 0c72907
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
This is an alpha version! The changes listed here are not final.

### Changed
- Listener: Do not enqueue actions when the site is disconnected
- Switch to pcov for code coverage.
- Theme deletions: rely on Core WP hook now that the package requires WP 5.8.
- Updated package textdomain from `jetpack` to `jetpack-sync`.
Expand Down
6 changes: 6 additions & 0 deletions src/class-listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Automattic\Jetpack\Sync;

use Automattic\Jetpack\Connection\Manager as Connection_Manager;
use Automattic\Jetpack\Roles;

/**
Expand Down Expand Up @@ -272,6 +273,11 @@ public function enqueue_action( $current_filter, $args, $queue ) {
return;
}

if ( ! ( new Connection_Manager() )->is_connected() ) {
// Don't enqueue an action if the site is disconnected.
return;
}

/**
* Add an action hook to execute when anything on the whitelist gets sent to the queue to sync.
*
Expand Down

0 comments on commit 0c72907

Please sign in to comment.