> Argument schemas. */ public static function step_args(): array { return [ 'step' => [ 'type' => 'integer', 'required' => true, 'minimum' => 0, 'maximum' => self::LAST_STEP, 'sanitize_callback' => 'rest_sanitize_request_arg', 'validate_callback' => 'rest_validate_request_arg', ], 'data' => Controller::object_arg(), ]; } /** * Argument schema of `POST /wizard/complete`. * * @return array> Argument schemas. */ public static function complete_args(): array { return [ 'submit_indexnow' => Controller::bool_arg( false ), ]; } /** * Saves one wizard step. * * @param WP_REST_Request $request The request. * @return array|WP_Error Keys `settings` and `flush_needed`, or a 400. */ public function step( WP_REST_Request $request ) { $data = $request->get_param( 'data' ); $saved = Controller::save_sections( is_array( $data ) ? $data : [] ); if ( is_wp_error( $saved ) ) { return $saved; } $step = (int) $request->get_param( 'step' ); $reached = (int) Options::get( 'general.wizard_step', 0 ); if ( $step > $reached ) { Options::set( 'general.wizard_step', $step ); } return [ 'settings' => Options::all(), 'flush_needed' => (bool) $saved['flush_needed'], ]; } /** * Marks the wizard finished and reports where the site stands. * * @param WP_REST_Request $request The request. * @return array Keys `audit` and `indexnow_queued`. */ public function complete( WP_REST_Request $request ): array { Options::update_section( 'general', [ 'wizard_completed' => true, 'wizard_step' => self::LAST_STEP, ] ); Cache::invalidate_all(); Loopback::flush(); Controller::forget_derived_data(); update_option( Controller::FLUSH_OPTION, 1 ); $queued = null; if ( (bool) $request->get_param( 'submit_indexnow' ) ) { $indexnow = Controller::module( 'indexnow', Modules\IndexNow::class ); $queued = $indexnow instanceof Modules\IndexNow ? $indexnow->submit_all() : 0; } return [ 'audit' => Runner::run( true ), 'indexnow_queued' => $queued, ]; } }