/** * @subcommand migrate-attachments * @synopsis [--delete-local] */ public function migrate_attachments_to_s3($args, $args_assoc) { $attachments = new WP_Query(array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => 'all')); WP_CLI::line(sprintf('Attempting to move %d attachments to S3', $attachments->found_posts)); foreach ($attachments->posts as $attachment) { $this->migrate_attachment_to_s3(array($attachment->ID), $args_assoc); } WP_CLI::success('Moved all attachment to S3. If you wish to update references in your database run: '); WP_CLI::line(''); $old_upload_dir = S3_Uploads::get_instance()->get_original_upload_dir(); $upload_dir = wp_upload_dir(); WP_CLI::Line(sprintf('wp search-replace "%s" "%s"', $old_upload_dir['baseurl'], $upload_dir['baseurl'])); }
/** * Migrates records from the legacy custom tables into custom post type * * ## OPTIONS * * [<days_old>] * Delete entries older than this many days, defaults to whatever you * have configured in the plugin settings * * --dry-run * Shows number of entries that would be deleted but does not * delete them * * ## EXAMPLES * * wp rest-api-log purge * * wp rest-api-log purge 90 * * @synopsis [<days_old>] [--dry-run] */ function purge($positional_args, $assoc_args = array()) { $days_old = absint(!empty($positional_args[0]) ? $positional_args[0] : 0); $dry_run = !empty($assoc_args['dry-run']); WP_CLI::Line("Purging old REST API log entries..."); $log = new WP_REST_API_Log(); $number_deleted = $log->purge_old_records($days_old, $dry_run); WP_CLI::Success(sprintf("%d entries purged", $number_deleted)); }