From 963dbd41e38bade26afb821cac4daa94b007774c Mon Sep 17 00:00:00 2001 From: Ian Dunn Date: Thu, 7 Nov 2019 13:43:09 -0800 Subject: [PATCH] Views: Modularize success/error notices for DRYness. --- plugins/wporg-5ftf/includes/pledge-form.php | 5 +-- plugins/wporg-5ftf/views/form-pledge-new.php | 17 +++------- .../views/partial-result-messages.php | 34 +++++++++++++++++++ 3 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 plugins/wporg-5ftf/views/partial-result-messages.php diff --git a/plugins/wporg-5ftf/includes/pledge-form.php b/plugins/wporg-5ftf/includes/pledge-form.php index e9daa69..0612576 100755 --- a/plugins/wporg-5ftf/includes/pledge-form.php +++ b/plugins/wporg-5ftf/includes/pledge-form.php @@ -23,7 +23,7 @@ add_shortcode( '5ftf_pledge_form_manage', __NAMESPACE__ . '\render_form_manage' function render_form_new() { $action = isset( $_GET['action'] ) ? filter_input( INPUT_GET, 'action' ) : filter_input( INPUT_POST, 'action' ); $data = get_form_submission(); - $messages = []; + $errors = []; $pledge = null; $complete = false; $directory_url = get_permalink( get_page_by_path( 'pledges' ) ); @@ -33,7 +33,7 @@ function render_form_new() { $pledge_id = process_form_new(); if ( is_wp_error( $pledge_id ) ) { - $messages = array_merge( $messages, $pledge_id->get_error_messages() ); + $errors = array_merge( $errors, $pledge_id->get_error_messages() ); } elseif ( is_int( $pledge_id ) ) { $complete = true; } @@ -43,6 +43,7 @@ function render_form_new() { $unverified_token = filter_input( INPUT_GET, 'auth_token', FILTER_SANITIZE_STRING ); $email_confirmed = process_pledge_confirmation_email( $pledge_id, $action, $unverified_token ); $pledge = get_post( $pledge_id ); + } elseif ( filter_input( INPUT_GET, 'resend_pledge_confirmation' ) ) { $pledge_id = filter_input( INPUT_GET, 'pledge_id', FILTER_VALIDATE_INT ); $complete = true; diff --git a/plugins/wporg-5ftf/views/form-pledge-new.php b/plugins/wporg-5ftf/views/form-pledge-new.php index 0310e14..a5686e5 100755 --- a/plugins/wporg-5ftf/views/form-pledge-new.php +++ b/plugins/wporg-5ftf/views/form-pledge-new.php @@ -9,6 +9,9 @@ use WP_Post; * @var bool $complete * @var string $directory_url */ + +require __DIR__ . '/partial-result-messages.php'; + ?> - - -
- -

- -
- - - -
+

@@ -53,7 +46,7 @@ use WP_Post; -
+ + +
+ +
+ +

+ +

+ +
+ + + +
+ +

+ +

+ +
+ +