From bbe2c358bf03136297767e5b057d63d0727a906f Mon Sep 17 00:00:00 2001 From: Peter Sorensen Date: Thu, 11 Dec 2025 09:15:39 -0800 Subject: [PATCH 1/5] adds dt_should_push_network_post action --- .../classes/InternalConnections/NetworkSiteConnection.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/classes/InternalConnections/NetworkSiteConnection.php b/includes/classes/InternalConnections/NetworkSiteConnection.php index e2bbd9dbc..447327117 100644 --- a/includes/classes/InternalConnections/NetworkSiteConnection.php +++ b/includes/classes/InternalConnections/NetworkSiteConnection.php @@ -81,6 +81,11 @@ public function push( $post, $args = array() ) { } $post_id = $post->ID; + $should_push = apply_filters( 'dt_should_push_network_post', true, $post, $args, $this ); + if ( ! $should_push ) { + return new \WP_Error( 'post-not-allowed-to-push', esc_html__( 'Post is configured to not be pushed via dt_should_push_network_post filter.', 'distributor' ) ); + } + $args = wp_parse_args( $args, array( From 62564097b950ce1ede80576fb034405d4ec17109 Mon Sep 17 00:00:00 2001 From: Peter Sorensen Date: Thu, 11 Dec 2025 09:36:32 -0800 Subject: [PATCH 2/5] adds doc block for filter --- .../InternalConnections/NetworkSiteConnection.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/includes/classes/InternalConnections/NetworkSiteConnection.php b/includes/classes/InternalConnections/NetworkSiteConnection.php index 447327117..12a9324f8 100644 --- a/includes/classes/InternalConnections/NetworkSiteConnection.php +++ b/includes/classes/InternalConnections/NetworkSiteConnection.php @@ -81,6 +81,18 @@ public function push( $post, $args = array() ) { } $post_id = $post->ID; + /** + * Allow bypassing of post distribution. + * + * @hook dt_should_push_network_post + * + * @param {bool} true If Distributor should push the post. + * @param {WP_Post} $post The post object. + * @param {array} $args The arguments passed into wp_insert_post(). + * @param {NetworkSiteConnection} $this The Distributor connection being pushed to. + * + * @return {bool} If Distributor should push the post. + */ $should_push = apply_filters( 'dt_should_push_network_post', true, $post, $args, $this ); if ( ! $should_push ) { return new \WP_Error( 'post-not-allowed-to-push', esc_html__( 'Post is configured to not be pushed via dt_should_push_network_post filter.', 'distributor' ) ); From f345b514be8f9906ee1bca869060d8821ef00ebc Mon Sep 17 00:00:00 2001 From: Peter Sorensen Date: Thu, 11 Dec 2025 09:59:57 -0800 Subject: [PATCH 3/5] adds hook to bypass external push --- .../WordPressExternalConnection.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/includes/classes/ExternalConnections/WordPressExternalConnection.php b/includes/classes/ExternalConnections/WordPressExternalConnection.php index 75f3a7f0c..d9120593e 100644 --- a/includes/classes/ExternalConnections/WordPressExternalConnection.php +++ b/includes/classes/ExternalConnections/WordPressExternalConnection.php @@ -494,6 +494,22 @@ public function push( $post, $args = array() ) { $post_type = $dt_post->get_post_type(); $path = self::$namespace; + /** + * Allow bypassing of external post distribution. + * + * @hook dt_should_push_external_post + * + * @param {bool} true If Distributor should push the post. + * @param {WP_Post} $post The post object. + * @param {array} $args The arguments passed into wp_insert_post(). + * @param {WordPressExternalConnection} $this The Distributor connection being pushed to. + * + */ + $should_push = apply_filters( 'dt_should_push_external_post', true, $post, $args, $this ); + if ( ! $should_push ) { + return new \WP_Error( 'post-not-allowed-to-push', esc_html__( 'Post is configured to not be pushed via dt_should_push_external_post filter.', 'distributor' ) ); + } + /* * First let's get the actual route. We don't know the "plural" of our post type */ From 4f54fa1885cd84ddcbae7482b27e7bed4a7cd7b0 Mon Sep 17 00:00:00 2001 From: Peter Sorensen Date: Thu, 11 Dec 2025 10:55:18 -0800 Subject: [PATCH 4/5] phpcs --- .../ExternalConnections/WordPressExternalConnection.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/classes/ExternalConnections/WordPressExternalConnection.php b/includes/classes/ExternalConnections/WordPressExternalConnection.php index d9120593e..865e32c6f 100644 --- a/includes/classes/ExternalConnections/WordPressExternalConnection.php +++ b/includes/classes/ExternalConnections/WordPressExternalConnection.php @@ -503,7 +503,8 @@ public function push( $post, $args = array() ) { * @param {WP_Post} $post The post object. * @param {array} $args The arguments passed into wp_insert_post(). * @param {WordPressExternalConnection} $this The Distributor connection being pushed to. - * + * + * @return {bool} If Distributor should push the post. */ $should_push = apply_filters( 'dt_should_push_external_post', true, $post, $args, $this ); if ( ! $should_push ) { From 63a89e57e03dbb211cc545a45272ed80be288de6 Mon Sep 17 00:00:00 2001 From: Peter Sorensen Date: Thu, 11 Dec 2025 10:56:22 -0800 Subject: [PATCH 5/5] phpcs --- .../classes/ExternalConnections/WordPressExternalConnection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/classes/ExternalConnections/WordPressExternalConnection.php b/includes/classes/ExternalConnections/WordPressExternalConnection.php index 865e32c6f..0546a3566 100644 --- a/includes/classes/ExternalConnections/WordPressExternalConnection.php +++ b/includes/classes/ExternalConnections/WordPressExternalConnection.php @@ -503,7 +503,7 @@ public function push( $post, $args = array() ) { * @param {WP_Post} $post The post object. * @param {array} $args The arguments passed into wp_insert_post(). * @param {WordPressExternalConnection} $this The Distributor connection being pushed to. - * + * * @return {bool} If Distributor should push the post. */ $should_push = apply_filters( 'dt_should_push_external_post', true, $post, $args, $this );