diff --git a/includes/class-wp-cli.php b/includes/class-wp-cli.php index 708c5a55723220c99b586f706d7b2a2d980342a9..3270f82623afe90b6a1c282d4daf32d438a6c4a1 100644 --- a/includes/class-wp-cli.php +++ b/includes/class-wp-cli.php @@ -16,6 +16,8 @@ class Syndication_CLI_Command extends WP_CLI_Command { WP_CLI::error( __( 'Invalid post_id', 'push-syndication' ) ); } + $this->_make_em_talk_push(); + $server = $this->_get_syndication_server(); $sites = $server->get_sites_by_post_ID( $post_id ); @@ -86,6 +88,29 @@ class Syndication_CLI_Command extends WP_CLI_Command { }, 10, 5 ); } + private function _make_em_talk_push() { + if ( $this->enabled_verbosity ) + return; + + $this->enabled_verbosity = true; + + add_filter( 'syn_pre_push_post_sites', function( $sites, $post_id, $slave_states ) { + WP_CLI::line( sprintf( "Processing post_id #%d (%s)", $post_id, get_the_title( $post_id ) ) ); + WP_CLI::line( sprintf( "-- pushing to %s sites and deleting from %s sites", number_format( count( $sites['selected_sites'] ) ), number_format( count( $sites['removed_sites'] ) ) ) ); + + return $sites; + }, 10, 3 ); + + add_action( 'syn_post_push_new_post', function( $result, $post_ID, $site, $transport_type, $client, $info ) { + WP_CLI::line( sprintf( '-- Added remote post #%d (%s)', $post_ID, $site->post_title ) ); + }, 10, 6 ); + + add_action( 'syn_post_push_edit_post', function( $result, $post_ID, $site, $transport_type, $client, $info ) { + WP_CLI::line( sprintf( '-- Updated remote post #%d (%s)', $post_ID, $site->post_title ) ); + }, 10, 6 ); + + } + private function _get_syndication_server() { global $push_syndication_server; return $push_syndication_server; diff --git a/includes/class-wp-push-syndication-server.php b/includes/class-wp-push-syndication-server.php index c661f20b8b1468943ddc052682161f2c99af3f15..40c35ee10329f37fe342ba544e9a38c9adea570a 100644 --- a/includes/class-wp-push-syndication-server.php +++ b/includes/class-wp-push-syndication-server.php @@ -835,6 +835,8 @@ class WP_Push_Syndication_Server { $slave_post_states = get_post_meta( $post_ID, '_syn_slave_post_states', true ); $slave_post_states = !empty( $slave_post_states ) ? $slave_post_states : array() ; + $sites = apply_filters( 'syn_pre_push_post_sites', $sites, $post_ID, $slave_post_states ); + if( !empty( $sites['selected_sites'] ) ) { foreach( $sites['selected_sites'] as $site ) {