Exemplo n.º 1
0
/**
 * Print Errors
 *
 * Prints all stored errors. Ensures errors show up on the appropriate form;
 * For use during donation process. If errors exist, they are returned.
 *
 * @since 1.0
 * @uses  give_get_errors()
 * @uses  give_clear_errors()
 *
 * @param int $form_id
 *
 * @return void
 */
function give_print_errors($form_id)
{
    $errors = give_get_errors();
    $request_form_id = isset($_REQUEST['form-id']) ? intval($_REQUEST['form-id']) : 0;
    //Sanity checks first: Ensure that gateway returned errors display on the appropriate form
    if (!isset($_POST['give_ajax']) && $request_form_id !== $form_id) {
        return;
    }
    if ($errors) {
        $classes = apply_filters('give_error_class', array('give_errors'));
        echo '<div class="' . implode(' ', $classes) . '">';
        // Loop error codes and display errors
        foreach ($errors as $error_id => $error) {
            echo '<div class="give_error" id="give_error_' . $error_id . '"><p><strong>' . __('Error', 'give') . '</strong>: ' . $error . '</p></div>';
        }
        echo '</div>';
        give_clear_errors();
    }
}
Exemplo n.º 2
0
/**
 * Print Errors
 *
 * Prints all stored errors. For use during checkout.
 * If errors exist, they are returned.
 *
 * @since 1.0
 * @uses  give_get_errors()
 * @uses  give_clear_errors()
 *
 * @param int $form_id
 *
 * @return void
 */
function give_print_errors($form_id)
{
    $errors = give_get_errors();
    //Ensure errors show up on the appropriate form
    if (!isset($_POST['give_ajax']) && isset($_POST['give-form-id']) && intval($_POST['give-form-id']) !== $form_id) {
        return;
    } elseif (!isset($_POST['give_ajax']) && isset($_REQUEST['form_id']) && intval($_REQUEST['form_id']) !== $form_id) {
        return;
    }
    if ($errors) {
        $classes = apply_filters('give_error_class', array('give_errors'));
        echo '<div class="' . implode(' ', $classes) . '">';
        // Loop error codes and display errors
        foreach ($errors as $error_id => $error) {
            echo '<div class="give_error" id="give_error_' . $error_id . '"><p><strong>' . __('Error', 'give') . '</strong>: ' . $error . '</p></div>';
        }
        echo '</div>';
        give_clear_errors();
    }
}
Exemplo n.º 3
0
 public function test_clear_errors()
 {
     $errors = give_clear_errors();
     $this->assertFalse(Give()->session->get('give_errors'));
 }
Exemplo n.º 4
0
 /**
  * Test that a error is displayed when the email is already taken.
  * Test that a error is displayed when the payment email is incorrect.
  *
  * @since 1.3.2
  */
 public function test_process_register_form_payment_email_incorrect()
 {
     $_POST['give_register_submit'] = 1;
     $_POST['give_user_pass'] = '';
     $_POST['give_user_pass2'] = '';
     give_process_register_form(array('give_register_submit' => 1, 'give_user_login' => 'random_username', 'give_user_email' => '*****@*****.**', 'give_payment_email' => 'someotheradminexample.org'));
     $this->assertArrayHasKey('email_unavailable', give_get_errors());
     $this->assertArrayHasKey('payment_email_invalid', give_get_errors());
     // Clear errors for other test
     give_clear_errors();
 }