コード例 #1
0
 /**
  * Migrates records from the legacy custom tables into custom post type
  *
  * ## OPTIONS
  *
  * ## EXAMPLES
  *
  *     wp rest-api-log migrate
  *
  */
 function migrate()
 {
     WP_CLI::Line("Getting log entries that need to be migrated...");
     $db = new WP_REST_API_Log_DB();
     $ids = $db->get_log_ids_to_migrate();
     $count = count($ids);
     if (0 === $count) {
         WP_CLI::Line("There are no more log entries that need to be migrated.");
         return;
     }
     $progress_bar = WP_CLI\Utils\make_progress_bar("Migrating {$count} entries:", $count, 1);
     $progress_bar->display();
     foreach ($ids as $id) {
         $db->migrate_db_record($id);
         $progress_bar->tick();
     }
     $progress_bar->finish();
     WP_CLI::Success("Log entries migrated");
 }