Commit b7ebd39e authored by Erick Hitter's avatar Erick Hitter
Browse files

Filter Jetpack Sync post-type blacklist to ensure plugin is always excluded

Since plugin's data changes frequently and is only valuable locally, exclude it from Jetpack Sync.

Fixes #86
parent dba6362b
......@@ -29,6 +29,10 @@ class Cron_Options_CPT extends Singleton {
// Data storage
add_action( 'init', array( $this, 'register_post_type' ) );
// Prevent Jetpack from syncing plugin's CPT entries
add_filter( 'option_jetpack_sync_settings_post_types_blacklist', array( $this, 'exclude_from_jetpack_sync' ), 999 );
add_filter( 'default_option_jetpack_sync_settings_post_types_blacklist', array( $this, 'exclude_from_jetpack_sync' ), 999 );
// Lock for post insertion, to guard against endless event creation when `wp_next_scheduled()` is misused
Lock::prime_lock( self::LOCK );
......@@ -58,6 +62,23 @@ class Cron_Options_CPT extends Singleton {
}
}
/**
* Block Jetpack Sync from capturing plugin's data
*
* Data changes frequently and is of no value in any remote context
*/
public function exclude_from_jetpack_sync( $option_value ) {
if ( ! is_array( $option_value ) ) {
$option_value = array();
}
if ( ! in_array( self::POST_TYPE, $option_value ) ) {
$option_value[] = self::POST_TYPE;
}
return $option_value;
}
/**
* PLUGIN FUNCTIONALITY
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment