validate(); return; } $this->validateLegacyRequest($formId); } /** * The legacy validator reports through the session error store, so it is cleared before and * after the run: before, so an earlier failed attempt in the same session cannot bleed in; * after, because the errors now live on the exception. * * @since 4.16.7.1 * * @throws DonationFormFieldErrorsException */ private function validateLegacyRequest(int $formId): void { if (absint($_POST['give-form-id'] ?? 0) !== $formId) { throw new DonationFormFieldErrorsException( new WP_Error( 'give_invalid_donation_form', __('The donation form ID is invalid. Please reload the page and try again.', 'give') ) ); } give_clear_errors(); $validData = give_donation_form_validate_fields(); /** This action is documented in includes/process-donation.php */ do_action('give_checkout_error_checks', $validData, give_clean($_POST)); $errors = give_get_errors(); give_clear_errors(); if (!$errors) { return; } $wpError = new WP_Error(); foreach ($errors as $errorId => $error) { $wpError->add($errorId, is_array($error) ? $error['message'] : $error); } throw new DonationFormFieldErrorsException($wpError); } }