scalar( $field ); if ( null !== $value ) { $input[ $field ] = $value; } } list( $settings, $errors ) = ScheduleSettings::validate( $input ); if ( $errors ) { throw new HttpException( 'om_schedule_invalid', esc_html( $errors[0] ), 400 ); } ScheduleSettings::save( $settings ); $next = Scheduler::apply( $settings ); return Response::data( self::payload( $settings, $next, __( 'Schedule saved.', 'migratex' ) ) ); } /** * What the page needs to redraw itself after a save. * * @param array $settings * @return array */ public static function payload( array $settings, ?int $next, string $message ): array { $format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' ); return array( 'message' => $message, 'settings' => $settings, 'next_run' => $next, 'next_human' => null === $next ? '' : wp_date( $format, $next ), 'timezone' => wp_timezone_string(), ); } }