version(); } /** * Maybe let's run the migration. * * @return void */ public function maybeRun() { if ( ! $this->shouldMigrate() ) { return; } // run the migration. $this->run(); // update the migration complete on admin_init complete, after all migrations have run. add_action( 'admin_init', [ $this, 'complete' ], 999999 ); } /** * Should we run this migration? * * @return boolean */ public function shouldMigrate(): bool { // check if we already have done this migration. return version_compare( $this->currentVersion(), $this->getLastMigrationVersion(), '!=' ); } /** * Run the migration * * @return void */ protected function run() { } /** * Save migrated post content without kses mangling it. * * Migrations re-save content that already passed a privileged save plus * plugin-generated block markup, so kses must not run — admin_init also * fires on logged-out admin-ajax requests, where kses would strip