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

Introduce new wp-cli command: push_post

Pushes out posts to the pre-selected sitegroups/sites. More args to be
added later.

see #38
parent 987f2800
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,27 @@ WP_CLI::add_command( 'syndication', 'Syndication_CLI_Command' ); ...@@ -5,6 +5,27 @@ WP_CLI::add_command( 'syndication', 'Syndication_CLI_Command' );
class Syndication_CLI_Command extends WP_CLI_Command { class Syndication_CLI_Command extends WP_CLI_Command {
var $enabled_verbosity = false; var $enabled_verbosity = false;
function push_post( $args, $assoc_args ) {
$assoc_args = wp_parse_args( $assoc_args, array(
'post_id' => 0,
) );
$post_id = intval( $assoc_args[ 'post_id' ] );
$post = get_post( $post_id );
if ( ! $post ) {
WP_CLI::error( __( 'Invalid post_id', 'push-syndication' ) );
}
$server = $this->_get_syndication_server();
$sites = $server->get_sites_by_post_ID( $post_id );
if ( empty( $sites ) ) {
WP_CLI::error( __( 'Post has no selected sitegroups / sites', 'push-syndication' ) );
}
$server->push_content( $sites );
}
function pull_site( $args, $assoc_args ) { function pull_site( $args, $assoc_args ) {
$assoc_args = wp_parse_args( $assoc_args, array( $assoc_args = wp_parse_args( $assoc_args, array(
'site_id' => 0, 'site_id' => 0,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment