@@ -8,45 +8,45 @@ discard block |
||
8 | 8 | global $form_submitted, $process_submission_response; |
9 | 9 | |
10 | 10 | // confirm we have a form id to work with |
11 | -$form_id = ( ! empty( $_POST['yikes-mailchimp-submitted-form'] ) ) ? $_POST['yikes-mailchimp-submitted-form'] : false; |
|
12 | -if( ! $form_id ) { |
|
11 | +$form_id = ( ! empty( $_POST[ 'yikes-mailchimp-submitted-form' ] ) ) ? $_POST[ 'yikes-mailchimp-submitted-form' ] : false; |
|
12 | +if ( ! $form_id ) { |
|
13 | 13 | return; |
14 | 14 | } |
15 | 15 | |
16 | -$form_settings = Yikes_Inc_Easy_Mailchimp_Extender_Public::yikes_retrieve_form_settings( $_POST['yikes-mailchimp-submitted-form'] ); |
|
16 | +$form_settings = Yikes_Inc_Easy_Mailchimp_Extender_Public::yikes_retrieve_form_settings( $_POST[ 'yikes-mailchimp-submitted-form' ] ); |
|
17 | 17 | |
18 | 18 | // Process our form submissions (non ajax forms) |
19 | -if ( ! isset( $_POST['yikes_easy_mc_new_subscriber'] ) || ! wp_verify_nonce( $_POST['yikes_easy_mc_new_subscriber'], 'yikes_easy_mc_form_submit' ) ) { |
|
19 | +if ( ! isset( $_POST[ 'yikes_easy_mc_new_subscriber' ] ) || ! wp_verify_nonce( $_POST[ 'yikes_easy_mc_new_subscriber' ], 'yikes_easy_mc_form_submit' ) ) { |
|
20 | 20 | |
21 | - $process_submission_response = '<p><small class="form_submission_error">' . __( "Error : Sorry, the nonce security check didn't pass. Please reload the page and try again. You may want to try clearing your browser cache as a last attempt." , 'yikes-inc-easy-mailchimp-extender' ) . '</small></p>'; |
|
21 | + $process_submission_response = '<p><small class="form_submission_error">' . __( "Error : Sorry, the nonce security check didn't pass. Please reload the page and try again. You may want to try clearing your browser cache as a last attempt.", 'yikes-inc-easy-mailchimp-extender' ) . '</small></p>'; |
|
22 | 22 | return; |
23 | 23 | |
24 | 24 | } else { |
25 | 25 | |
26 | 26 | /* Check for Honeypot filled */ |
27 | - $honey_pot_filled = ( isset( $_POST['yikes-mailchimp-honeypot'] ) && $_POST['yikes-mailchimp-honeypot'] != '' ) ? true : false; |
|
27 | + $honey_pot_filled = ( isset( $_POST[ 'yikes-mailchimp-honeypot' ] ) && $_POST[ 'yikes-mailchimp-honeypot' ] != '' ) ? true : false; |
|
28 | 28 | // if it was filled out, return an error... |
29 | 29 | if ( $honey_pot_filled ) { |
30 | - $process_submission_response = '<p><small class="form_submission_error">' . __( "Error: It looks like the honeypot was filled out and the form was not properly be submitted." , 'yikes-inc-easy-mailchimp-extender' ) . '</small></p>'; |
|
30 | + $process_submission_response = '<p><small class="form_submission_error">' . __( "Error: It looks like the honeypot was filled out and the form was not properly be submitted.", 'yikes-inc-easy-mailchimp-extender' ) . '</small></p>'; |
|
31 | 31 | return; |
32 | 32 | } |
33 | 33 | |
34 | 34 | // Check reCAPTCHA Response |
35 | - if( isset( $_POST['g-recaptcha-response'] ) ) { |
|
36 | - $url = esc_url_raw( 'https://www.google.com/recaptcha/api/siteverify?secret=' . get_option( 'yikes-mc-recaptcha-secret-key' , '' ) . '&response=' . $_POST['g-recaptcha-response'] . '&remoteip=' . $_SERVER["REMOTE_ADDR"] ); |
|
35 | + if ( isset( $_POST[ 'g-recaptcha-response' ] ) ) { |
|
36 | + $url = esc_url_raw( 'https://www.google.com/recaptcha/api/siteverify?secret=' . get_option( 'yikes-mc-recaptcha-secret-key', '' ) . '&response=' . $_POST[ 'g-recaptcha-response' ] . '&remoteip=' . $_SERVER[ "REMOTE_ADDR" ] ); |
|
37 | 37 | $response = wp_remote_get( $url ); |
38 | - $response_body = json_decode( $response['body'] , true ); |
|
38 | + $response_body = json_decode( $response[ 'body' ], true ); |
|
39 | 39 | |
40 | 40 | // if we've hit an error, lets return the error! |
41 | - if( $response_body['success'] != 1 ) { |
|
41 | + if ( $response_body[ 'success' ] != 1 ) { |
|
42 | 42 | $recaptcha_error = array(); // empty array to store error messages |
43 | - foreach( $response_body['error-codes'] as $error_code ) { |
|
44 | - if( $error_code == 'missing-input-response' ) { |
|
43 | + foreach ( $response_body[ 'error-codes' ] as $error_code ) { |
|
44 | + if ( $error_code == 'missing-input-response' ) { |
|
45 | 45 | $error_code = __( 'Please check the reCAPTCHA field.', 'yikes-inc-easy-mailchimp-extender' ); |
46 | 46 | } |
47 | - $recaptcha_error[] = $error_code; |
|
47 | + $recaptcha_error[ ] = $error_code; |
|
48 | 48 | } |
49 | - $process_submission_response .= "<p class='yikes-easy-mc-error-message'>" . apply_filters( 'yikes-mailchimp-recaptcha-required-error', __( 'Error' , 'yikes-inc-easy-mailchimp-extender' ) . ': ' . implode( ' ' , $recaptcha_error ) ) . "</p>"; |
|
49 | + $process_submission_response .= "<p class='yikes-easy-mc-error-message'>" . apply_filters( 'yikes-mailchimp-recaptcha-required-error', __( 'Error', 'yikes-inc-easy-mailchimp-extender' ) . ': ' . implode( ' ', $recaptcha_error ) ) . "</p>"; |
|
50 | 50 | return; |
51 | 51 | } |
52 | 52 | } |
@@ -56,20 +56,20 @@ discard block |
||
56 | 56 | * No HTML5 validation, and don't want to use jQuery for non-ajax forms |
57 | 57 | */ |
58 | 58 | $missing_required_checkbox_interest_groups = array(); |
59 | - foreach( $form_settings['fields'] as $merge_tag => $field_data ) { |
|
60 | - if( is_numeric( $merge_tag ) ) { |
|
59 | + foreach ( $form_settings[ 'fields' ] as $merge_tag => $field_data ) { |
|
60 | + if ( is_numeric( $merge_tag ) ) { |
|
61 | 61 | // check if the checkbox group was set to required, if so return an error |
62 | - if( isset( $field_data['require'] ) && $field_data['require'] == 1 ) { |
|
63 | - if( $field_data['type'] == 'checkboxes' ) { |
|
64 | - if( ! isset( $_POST[$merge_tag] ) ) { |
|
65 | - $missing_required_checkbox_interest_groups[] = $merge_tag; |
|
62 | + if ( isset( $field_data[ 'require' ] ) && $field_data[ 'require' ] == 1 ) { |
|
63 | + if ( $field_data[ 'type' ] == 'checkboxes' ) { |
|
64 | + if ( ! isset( $_POST[ $merge_tag ] ) ) { |
|
65 | + $missing_required_checkbox_interest_groups[ ] = $merge_tag; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | - if( ! empty( $missing_required_checkbox_interest_groups ) ) { |
|
72 | + if ( ! empty( $missing_required_checkbox_interest_groups ) ) { |
|
73 | 73 | $process_submission_response = '<p class="yikes-easy-mc-error-message">' . apply_filters( 'yikes-mailchimp-interest-group-required-top-error', sprintf( _n( 'It looks like you forgot to fill in a required field.', 'It looks like you forgot to fill in %s required fields.', count( $missing_required_checkbox_interest_groups ), 'yikes-inc-easy-mailchimp-extender' ), count( $missing_required_checkbox_interest_groups ) ), count( $missing_required_checkbox_interest_groups ), $form_id ) . '</p>'; |
74 | 74 | return; |
75 | 75 | } |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | |
80 | 80 | // loop to push variables to our array |
81 | 81 | foreach ( $_POST as $merge_tag => $value ) { |
82 | - if( $merge_tag != 'yikes_easy_mc_new_subscriber' && $merge_tag != '_wp_http_referer' ) { |
|
82 | + if ( $merge_tag != 'yikes_easy_mc_new_subscriber' && $merge_tag != '_wp_http_referer' ) { |
|
83 | 83 | // check if the current iteration has a 'date_format' key set |
84 | 84 | // (aka - date/birthday fields) |
85 | - if( isset( $form_settings['fields'][$merge_tag]['date_format'] ) ) { |
|
85 | + if ( isset( $form_settings[ 'fields' ][ $merge_tag ][ 'date_format' ] ) ) { |
|
86 | 86 | // check if EU date format |
87 | - if( $form_settings['fields'][$merge_tag]['date_format'] == 'DD/MM/YYYY' ) { |
|
87 | + if ( $form_settings[ 'fields' ][ $merge_tag ][ 'date_format' ] == 'DD/MM/YYYY' ) { |
|
88 | 88 | // convert '/' to '.' and to UNIX timestamp |
89 | 89 | $value = ( '' != $value ) ? date( 'Y-m-d', strtotime( str_replace( '/', '.', $value ) ) ) : ''; |
90 | 90 | } else { |
@@ -92,23 +92,23 @@ discard block |
||
92 | 92 | $value = ( '' != $value ) ? date( 'Y-m-d', strtotime( $value ) ) : ''; |
93 | 93 | } |
94 | 94 | } |
95 | - if( is_numeric( $merge_tag ) ) { // this is is an interest group! |
|
96 | - $merge_variables['groupings'][] = array( 'id' => $merge_tag , 'groups' => ( is_array( $value ) ) ? $value : array( $value ) ); |
|
95 | + if ( is_numeric( $merge_tag ) ) { // this is is an interest group! |
|
96 | + $merge_variables[ 'groupings' ][ ] = array( 'id' => $merge_tag, 'groups' => ( is_array( $value ) ) ? $value : array( $value ) ); |
|
97 | 97 | } else { // or else it's just a standard merge variable |
98 | - $merge_variables[$merge_tag] = $value; |
|
98 | + $merge_variables[ $merge_tag ] = $value; |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | 103 | // store the opt-in time |
104 | - $merge_variables['optin_time'] = current_time( 'Y-m-d H:i:s', 1 ); |
|
104 | + $merge_variables[ 'optin_time' ] = current_time( 'Y-m-d H:i:s', 1 ); |
|
105 | 105 | |
106 | 106 | // Submit our form data |
107 | - $api_key = trim( get_option( 'yikes-mc-api-key' , '' ) ); |
|
107 | + $api_key = trim( get_option( 'yikes-mc-api-key', '' ) ); |
|
108 | 108 | $dash_position = strpos( $api_key, '-' ); |
109 | 109 | |
110 | 110 | // setup the end point |
111 | - if( $dash_position !== false ) { |
|
111 | + if ( $dash_position !== false ) { |
|
112 | 112 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/subscribe.json'; |
113 | 113 | } |
114 | 114 | |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | * Allow users to check for submit value |
137 | 137 | * and pass back an error to the user |
138 | 138 | */ |
139 | - if( isset( $merge_variables['error'] ) ) { |
|
140 | - $process_submission_response = apply_filters( 'yikes-mailchimp-frontend-content' , $merge_variables['message'] ); |
|
139 | + if ( isset( $merge_variables[ 'error' ] ) ) { |
|
140 | + $process_submission_response = apply_filters( 'yikes-mailchimp-frontend-content', $merge_variables[ 'message' ] ); |
|
141 | 141 | return; |
142 | 142 | } |
143 | 143 | |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | $subscribe_response = wp_remote_post( $api_endpoint, array( |
147 | 147 | 'body' => apply_filters( 'yikes-mailchimp-user-subscribe-api-request', array( |
148 | 148 | 'apikey' => $api_key, |
149 | - 'id' => $_POST['yikes-mailchimp-associated-list-id'], |
|
150 | - 'email' => array( 'email' => sanitize_email( $_POST['EMAIL'] ) ), |
|
149 | + 'id' => $_POST[ 'yikes-mailchimp-associated-list-id' ], |
|
150 | + 'email' => array( 'email' => sanitize_email( $_POST[ 'EMAIL' ] ) ), |
|
151 | 151 | 'merge_vars' => $merge_variables, |
152 | - 'double_optin' => $form_settings['optin_settings']['optin'], |
|
152 | + 'double_optin' => $form_settings[ 'optin_settings' ][ 'optin' ], |
|
153 | 153 | 'update_existing' => 0, // always set to 0 (when 0, users cannot update. when 1, users can click a link to send an email where they can then update their details) |
154 | - 'send_welcome' => $form_settings['optin_settings']['send_welcome_email'], |
|
155 | - 'replace_interests' => ( isset( $form_settings['submission_settings']['replace_interests'] ) ) ? $form_settings['submission_settings']['replace_interests'] : 1, // defaults to replace |
|
156 | - ), $form_id, $_POST['yikes-mailchimp-associated-list-id'], $_POST['EMAIL'] ), |
|
154 | + 'send_welcome' => $form_settings[ 'optin_settings' ][ 'send_welcome_email' ], |
|
155 | + 'replace_interests' => ( isset( $form_settings[ 'submission_settings' ][ 'replace_interests' ] ) ) ? $form_settings[ 'submission_settings' ][ 'replace_interests' ] : 1, // defaults to replace |
|
156 | + ), $form_id, $_POST[ 'yikes-mailchimp-associated-list-id' ], $_POST[ 'EMAIL' ] ), |
|
157 | 157 | 'timeout' => 10, |
158 | 158 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
159 | 159 | ) ); |
@@ -161,66 +161,66 @@ discard block |
||
161 | 161 | $subscribe_response = json_decode( wp_remote_retrieve_body( $subscribe_response ), true ); |
162 | 162 | |
163 | 163 | // check for any errors |
164 | - if( isset( $subscribe_response['error'] ) ) { |
|
164 | + if ( isset( $subscribe_response[ 'error' ] ) ) { |
|
165 | 165 | |
166 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
166 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
167 | 167 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
168 | 168 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
169 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $subscribe_response['error'], __( "Subscribe New User" , 'yikes-inc-easy-mailchimp-extender' ), "process_form_submission.php" ); |
|
169 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $subscribe_response[ 'error' ], __( "Subscribe New User", 'yikes-inc-easy-mailchimp-extender' ), "process_form_submission.php" ); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | $update_account_details_link = ''; |
173 | - switch( $subscribe_response['code'] ) { |
|
173 | + switch ( $subscribe_response[ 'code' ] ) { |
|
174 | 174 | // user already subscribed |
175 | 175 | case '214': |
176 | - $update_account_details_link = ( $form_settings['optin_settings']['update_existing_user'] == 1 ) ? apply_filters( 'yikes-easy-mailchimp-update-existing-subscriber-text', sprintf( __( ' To update your MailChimp profile, please %s.', 'yikes-inc-easy-mailchimp-extender' ), '<a class="send-update-email" data-list-id="' . $_POST['yikes-mailchimp-associated-list-id'] . '" data-user-email="' . sanitize_email( $_POST['EMAIL'] ) . '" href="#">' . __( 'click to send yourself an update link', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' ), '<a class="send-update-email" data-list-id="' . $_POST['yikes-mailchimp-associated-list-id'] . '" data-user-email="' . sanitize_email( $_POST['EMAIL'] ) . '" href="#">' . __( 'click to send yourself an update link', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' ) : false; |
|
177 | - if( $update_account_details_link ) { |
|
176 | + $update_account_details_link = ( $form_settings[ 'optin_settings' ][ 'update_existing_user' ] == 1 ) ? apply_filters( 'yikes-easy-mailchimp-update-existing-subscriber-text', sprintf( __( ' To update your MailChimp profile, please %s.', 'yikes-inc-easy-mailchimp-extender' ), '<a class="send-update-email" data-list-id="' . $_POST[ 'yikes-mailchimp-associated-list-id' ] . '" data-user-email="' . sanitize_email( $_POST[ 'EMAIL' ] ) . '" href="#">' . __( 'click to send yourself an update link', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' ), '<a class="send-update-email" data-list-id="' . $_POST[ 'yikes-mailchimp-associated-list-id' ] . '" data-user-email="' . sanitize_email( $_POST[ 'EMAIL' ] ) . '" href="#">' . __( 'click to send yourself an update link', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' ) : false; |
|
177 | + if ( $update_account_details_link ) { |
|
178 | 178 | // if update account details is set, we need to include our script to send out the update email |
179 | - wp_enqueue_script( 'update-existing-subscriber.js', YIKES_MC_URL . 'public/js/yikes-update-existing-subscriber.js' , array( 'jquery' ), 'all' ); |
|
179 | + wp_enqueue_script( 'update-existing-subscriber.js', YIKES_MC_URL . 'public/js/yikes-update-existing-subscriber.js', array( 'jquery' ), 'all' ); |
|
180 | 180 | wp_localize_script( 'update-existing-subscriber.js', 'update_subscriber_details_data', array( |
181 | 181 | 'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ), |
182 | 182 | 'preloader_url' => apply_filters( 'yikes-mailchimp-preloader', esc_url_raw( admin_url( 'images/wpspin_light.gif' ) ) ), |
183 | 183 | ) ); |
184 | 184 | } |
185 | - if( ! empty( $form_settings['error_messages']['already-subscribed'] ) ) { |
|
186 | - $process_submission_response = '<p class="yikes-easy-mc-error-message">' . $form_settings['error_messages']['already-subscribed'] . ' ' . $update_account_details_link . '</p>'; |
|
185 | + if ( ! empty( $form_settings[ 'error_messages' ][ 'already-subscribed' ] ) ) { |
|
186 | + $process_submission_response = '<p class="yikes-easy-mc-error-message">' . $form_settings[ 'error_messages' ][ 'already-subscribed' ] . ' ' . $update_account_details_link . '</p>'; |
|
187 | 187 | } else { |
188 | - $process_submission_response = '<p class="yikes-easy-mc-error-message">' . $subscribe_response['error'] . ' ' . $update_account_details_link . '</p>'; |
|
188 | + $process_submission_response = '<p class="yikes-easy-mc-error-message">' . $subscribe_response[ 'error' ] . ' ' . $update_account_details_link . '</p>'; |
|
189 | 189 | } |
190 | 190 | break; |
191 | 191 | // missing a required field |
192 | 192 | case '250': |
193 | 193 | // get all merge variables in array, loop and str_replace error code with field name |
194 | - $api_key = trim( get_option( 'yikes-mc-api-key' , '' ) ); |
|
194 | + $api_key = trim( get_option( 'yikes-mc-api-key', '' ) ); |
|
195 | 195 | $dash_position = strpos( $api_key, '-' ); |
196 | - if( $dash_position !== false ) { |
|
196 | + if ( $dash_position !== false ) { |
|
197 | 197 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/merge-vars.json'; |
198 | 198 | } |
199 | 199 | $merge_variables = wp_remote_post( $api_endpoint, array( |
200 | 200 | 'body' => array( |
201 | 201 | 'apikey' => $api_key, |
202 | - 'id' => array( $_POST['yikes-mailchimp-associated-list-id'] ) , |
|
202 | + 'id' => array( $_POST[ 'yikes-mailchimp-associated-list-id' ] ), |
|
203 | 203 | ), |
204 | 204 | 'timeout' => 10, |
205 | 205 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ), |
206 | 206 | ) ); |
207 | 207 | $merge_variables = json_decode( wp_remote_retrieve_body( $merge_variables ), true ); |
208 | - if( isset( $merge_variables['error'] ) ) { |
|
209 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
208 | + if ( isset( $merge_variables[ 'error' ] ) ) { |
|
209 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
210 | 210 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
211 | 211 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
212 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $merge_variables['error'], __( "Get Merge Variables" , 'yikes-inc-easy-mailchimp-extender' ), "process_form_submission.php" ); |
|
212 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $merge_variables[ 'error' ], __( "Get Merge Variables", 'yikes-inc-easy-mailchimp-extender' ), "process_form_submission.php" ); |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | // re-store our data |
216 | - $merge_variables = $merge_variables['data'][0]['merge_vars']; |
|
216 | + $merge_variables = $merge_variables[ 'data' ][ 0 ][ 'merge_vars' ]; |
|
217 | 217 | $merge_variable_name_array = array(); |
218 | - foreach( $merge_variables as $merge_var ) { |
|
219 | - $merge_variables_name_array[$merge_var['tag']] = $merge_var['name']; |
|
218 | + foreach ( $merge_variables as $merge_var ) { |
|
219 | + $merge_variables_name_array[ $merge_var[ 'tag' ] ] = $merge_var[ 'name' ]; |
|
220 | 220 | } |
221 | - $error_message = $subscribe_response['error']; |
|
221 | + $error_message = $subscribe_response[ 'error' ]; |
|
222 | 222 | // replace tag with name in the error message. |
223 | - foreach( $merge_variables_name_array as $tag => $name ) { |
|
223 | + foreach ( $merge_variables_name_array as $tag => $name ) { |
|
224 | 224 | $error_message = str_replace( $tag, $name, $error_message ); |
225 | 225 | } |
226 | 226 | $process_submission_response = '<p class="yikes-easy-mc-error-message">' . $error_message . '.</p>'; |
@@ -228,18 +228,18 @@ discard block |
||
228 | 228 | // [email protected] is not allowed |
229 | 229 | case '-99': |
230 | 230 | // generic error |
231 | - $process_submission_response = '<p class="yikes-easy-mc-error-message">' . str_replace( ' and cannot be imported', '', str_replace( 'List_RoleEmailMember:', '', $subscribe_response['error'] ) ) . '</p>'; |
|
231 | + $process_submission_response = '<p class="yikes-easy-mc-error-message">' . str_replace( ' and cannot be imported', '', str_replace( 'List_RoleEmailMember:', '', $subscribe_response[ 'error' ] ) ) . '</p>'; |
|
232 | 232 | break; |
233 | 233 | // invalid email (or no email at all) |
234 | 234 | case '-100': |
235 | - $process_submission_response = ( ! empty( $form_settings['error_messages']['invalid-email'] ) ) ? '<p class="yikes-easy-mc-error-message">' . $form_settings['error_messages']['invalid-email'] . '</p>' : '<p class="yikes-easy-mc-error-message">' . __( 'Please provide a valid email address.', 'yikes-inc-easy-mailchimp-extender' ) . '</p>'; |
|
235 | + $process_submission_response = ( ! empty( $form_settings[ 'error_messages' ][ 'invalid-email' ] ) ) ? '<p class="yikes-easy-mc-error-message">' . $form_settings[ 'error_messages' ][ 'invalid-email' ] . '</p>' : '<p class="yikes-easy-mc-error-message">' . __( 'Please provide a valid email address.', 'yikes-inc-easy-mailchimp-extender' ) . '</p>'; |
|
236 | 236 | break; |
237 | 237 | default: |
238 | 238 | // generic error |
239 | - if( ! empty( $form_settings['error_messages']['general-error'] ) ) { |
|
240 | - $process_submission_response = '<p class="yikes-easy-mc-error-message">' . $form_settings['error_messages']['general-error'] . '</p>'; |
|
239 | + if ( ! empty( $form_settings[ 'error_messages' ][ 'general-error' ] ) ) { |
|
240 | + $process_submission_response = '<p class="yikes-easy-mc-error-message">' . $form_settings[ 'error_messages' ][ 'general-error' ] . '</p>'; |
|
241 | 241 | } else { |
242 | - $process_submission_response = '<p class="yikes-easy-mc-error-message">' . $subscribe_response['error'] . '</p>'; |
|
242 | + $process_submission_response = '<p class="yikes-easy-mc-error-message">' . $subscribe_response[ 'error' ] . '</p>'; |
|
243 | 243 | } |
244 | 244 | break; |
245 | 245 | } |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | $form_submitted = 1; |
251 | 251 | |
252 | 252 | // Display the success message |
253 | - if( ! empty( $form_settings['error_messages']['success'] ) ) { |
|
254 | - $process_submission_response = '<p class="yikes-easy-mc-success-message">' . apply_filters( 'yikes-mailchimp-success-response', stripslashes( esc_html( $form_settings['error_messages']['success'] ) ), $form_id, $merge_variables ) . '</p>'; |
|
253 | + if ( ! empty( $form_settings[ 'error_messages' ][ 'success' ] ) ) { |
|
254 | + $process_submission_response = '<p class="yikes-easy-mc-success-message">' . apply_filters( 'yikes-mailchimp-success-response', stripslashes( esc_html( $form_settings[ 'error_messages' ][ 'success' ] ) ), $form_id, $merge_variables ) . '</p>'; |
|
255 | 255 | // echo stripslashes( esc_html( $error_messages['success'] ) ); |
256 | 256 | } else { |
257 | - $default_success_response = ( 1 === $form_settings['optin_settings']['optin'] ) ? __( 'Thank you for subscribing! Check your email for the confirmation message.' , 'yikes-inc-easy-mailchimp-extender' ) : __( 'Thank you for subscribing!' , 'yikes-inc-easy-mailchimp-extender' ); |
|
257 | + $default_success_response = ( 1 === $form_settings[ 'optin_settings' ][ 'optin' ] ) ? __( 'Thank you for subscribing! Check your email for the confirmation message.', 'yikes-inc-easy-mailchimp-extender' ) : __( 'Thank you for subscribing!', 'yikes-inc-easy-mailchimp-extender' ); |
|
258 | 258 | $process_submission_response = '<p class="yikes-easy-mc-success-message">' . apply_filters( 'yikes-mailchimp-success-response', $default_success_response, $form_id, $merge_variables ) . '</p>'; |
259 | 259 | // echo $default_success_response; |
260 | 260 | } |
@@ -267,8 +267,8 @@ discard block |
||
267 | 267 | * optional @form - the ID of the form to filter |
268 | 268 | * @since 6.0.0 |
269 | 269 | */ |
270 | - do_action( 'yikes-mailchimp-after-submission' , $merge_variables ); |
|
271 | - do_action( 'yikes-mailchimp-after-submission-' . $form_id , $merge_variables ); |
|
270 | + do_action( 'yikes-mailchimp-after-submission', $merge_variables ); |
|
271 | + do_action( 'yikes-mailchimp-after-submission-' . $form_id, $merge_variables ); |
|
272 | 272 | |
273 | 273 | /* |
274 | 274 | * Non-AJAX redirects now handled in class-yikes-inc-easy-mailchimp-extender-public.php |
@@ -286,23 +286,23 @@ discard block |
||
286 | 286 | * @$notifications - the notification array |
287 | 287 | * @since 6.0.0 |
288 | 288 | */ |
289 | - do_action( 'yikes-mailchimp-form-submission' , $_POST['EMAIL'] , $merge_variables , $form_id , $form_settings['notifications'] ); |
|
290 | - do_action( 'yikes-mailchimp-form-submission-' . $form_id , $_POST['EMAIL'] , $merge_variables , $form_id , $form_settings['notifications'] ); |
|
289 | + do_action( 'yikes-mailchimp-form-submission', $_POST[ 'EMAIL' ], $merge_variables, $form_id, $form_settings[ 'notifications' ] ); |
|
290 | + do_action( 'yikes-mailchimp-form-submission-' . $form_id, $_POST[ 'EMAIL' ], $merge_variables, $form_id, $form_settings[ 'notifications' ] ); |
|
291 | 291 | |
292 | 292 | /* |
293 | 293 | * Increase the submission count for this form |
294 | 294 | * on a successful submission |
295 | 295 | * @since 6.0.0 |
296 | 296 | */ |
297 | - $form_settings['submissions']++; |
|
297 | + $form_settings[ 'submissions' ]++; |
|
298 | 298 | $wpdb->update( |
299 | 299 | $wpdb->prefix . 'yikes_easy_mc_forms', |
300 | 300 | array( |
301 | - 'submissions' => $form_settings['submissions'], |
|
301 | + 'submissions' => $form_settings[ 'submissions' ], |
|
302 | 302 | ), |
303 | 303 | array( 'ID' => $form_id ), |
304 | 304 | array( |
305 | - '%d', // send welcome email |
|
305 | + '%d', // send welcome email |
|
306 | 306 | ), |
307 | 307 | array( '%d' ) |
308 | 308 | ); |