From b3c073050279fbba6a412dc5e6af6ec4e2981bf2 Mon Sep 17 00:00:00 2001 From: Mohammad Jangda <batmoo@gmail.com> Date: Tue, 15 Oct 2013 05:39:32 +0000 Subject: [PATCH] Introduce new wp-cli command: push_post Pushes out posts to the pre-selected sitegroups/sites. More args to be added later. see #38 --- includes/class-wp-cli.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/includes/class-wp-cli.php b/includes/class-wp-cli.php index a68d005..708c5a5 100644 --- a/includes/class-wp-cli.php +++ b/includes/class-wp-cli.php @@ -5,6 +5,27 @@ WP_CLI::add_command( 'syndication', 'Syndication_CLI_Command' ); class Syndication_CLI_Command extends WP_CLI_Command { 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 ) { $assoc_args = wp_parse_args( $assoc_args, array( 'site_id' => 0, -- GitLab