Skip to content
Snippets Groups Projects
Commit 565acba1 authored by Mohammad Jangda's avatar Mohammad Jangda
Browse files

Make the push_post command more verbose

see #38
parent 29d7925f
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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 ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment