input( 'tab', 'get' ); $allowed_tabs = array( 'data-seeder', 'database-tools', 'file-logs', 'database-logs', ); if ( in_array( $tab, $allowed_tabs, true ) ) { Template::load( 'admin/tools/' . $tab ); } else { Template::load( 'admin/tools/index' ); } } /** * AJAX: Run a specific migration version. * * POST: * - version: string (e.g. '1.2.9') * - force: '1' or '0' (optional, default 0) */ public static function run_migration(): void { Common::checkCapability( 'manage_options' ); Common::verifyNonce(); $version = static::request()->input( 'version', 'post' ); if ( empty( $version ) ) { wp_send_json_error( array( 'message' => __( 'Migration version is required.', 'ad-fuz' ), ) ); } try { MigrationRunner::runVersion( $version ); wp_send_json_success( array( 'message' => sprintf( /* translators: %s = version number */ __( 'Migration %s applied successfully.', 'ad-fuz' ), $version ), ) ); } catch ( \Throwable $e ) { Common::log_file( array( 'Type' => 'Migration Error', 'Version' => $version, 'Error' => $e->getMessage(), 'Trace' => $e->getTraceAsString(), ) ); wp_send_json_error( array( 'message' => __( 'Migration failed: ', 'ad-fuz' ) . $e->getMessage(), ) ); } } /** * @return string */ protected static function getModel(): string { return ''; } }