Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,23 @@ 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.
*
* @return {bool} If Distributor should push the post.
*/
$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
*/
Expand Down
17 changes: 17 additions & 0 deletions includes/classes/InternalConnections/NetworkSiteConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,23 @@ 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' ) );
}

$args = wp_parse_args(
$args,
array(
Expand Down
Loading