Ejemplo n.º 1
0
 /**
  * Callback triggered on post save, used to initiate an outbound sync
  *
  * $post_id - (int) the post to sync
  */
 public function save_post_callback($post_id)
 {
     if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) {
         return;
     }
     $this->controller->export_post($post_id);
 }
Ejemplo n.º 2
0
 /**
  * Exports an individual post
  * all your posts to GitHub
  *
  * ## OPTIONS
  *
  * <post_id|all>
  * : The post ID to export or 'all' for full site
  *
  * <user_id>
  * : The user ID you'd like to save the commit as
  *
  * ## EXAMPLES
  *
  *     wp wpghs export all 1
  *     wp wpghs export 1 1
  *
  * @synopsis <post_id|all> <user_id>
  */
 public function export($args, $assoc_args)
 {
     list($post_id, $user_id) = $args;
     if (!is_numeric($user_id)) {
         WP_CLI::error(__('Invalid user ID', 'wordpress-github-sync'));
     }
     update_option('_wpghs_export_user_id', (int) $user_id);
     if ('all' === $post_id) {
         WP_CLI::line(__('Starting full export to GitHub.', 'wordpress-github-sync'));
         $this->controller->export_all();
     } elseif (is_numeric($post_id)) {
         WP_CLI::line(__('Exporting post ID to GitHub: ', 'wordpress-github-sync') . $post_id);
         $this->controller->export_post((int) $post_id);
     } else {
         WP_CLI::error(__('Invalid post ID', 'wordpress-github-sync'));
     }
 }