From d7d08c936e778527f38392ee13c40e416f41e003 Mon Sep 17 00:00:00 2001 From: CodeProKid Date: Tue, 4 Sep 2018 10:40:30 -0600 Subject: [PATCH] Prevents tasks from being synced by Jetpack --- src/Register.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Register.php b/src/Register.php index 7bed600..568728b 100644 --- a/src/Register.php +++ b/src/Register.php @@ -17,6 +17,10 @@ public function setup() { // Registers the "task" post type add_action( 'init', [ $this, 'register_post_type' ] ); + // Disable syncing in Jetpack + add_filter( 'option_jetpack_sync_settings_post_types_blacklist', [ $this, 'blacklist_post_type' ] ); + add_filter( 'default_option_jetpack_sync_settings_post_types_blacklist', [ $this, 'blacklist_post_type' ] ); + } /** @@ -116,4 +120,22 @@ public function register_post_type() { } + /** + * Blacklists the wpqt-task post type from being synced in Jetpack + * + * @param array|false $post_types Either the false default or an existing array of blacklisted + * post types + * + * @return array + * @access public + */ + public function blacklist_post_type( $post_types ) { + if ( is_array( $post_types ) ) { + $post_types[] = 'wpqt-task'; + } else { + $post_types = [ 'wpqt-task' ]; + } + return $post_types; + } + }