@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | /** |
| 10 | 10 | * Main Checkbox Integration class. |
| 11 | 11 | */ |
| 12 | -class Yikes_Easy_MC_Checkbox_Integration_Class {
|
|
| 12 | +class Yikes_Easy_MC_Checkbox_Integration_Class { |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * The integration type. |
@@ -28,10 +28,10 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return bool Whether the current user is subscribed to a list. |
| 30 | 30 | */ |
| 31 | - public function is_user_already_subscribed( $type, $email = '' ) {
|
|
| 31 | + public function is_user_already_subscribed( $type, $email = '' ) { |
|
| 32 | 32 | // Make sure we have an email address to use. |
| 33 | - if ( empty( $email ) ) {
|
|
| 34 | - if ( ! is_user_logged_in() ) {
|
|
| 33 | + if ( empty( $email ) ) { |
|
| 34 | + if ( ! is_user_logged_in() ) { |
|
| 35 | 35 | return false; |
| 36 | 36 | } |
| 37 | 37 | |
@@ -40,13 +40,13 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // Ensure we have a valid email. |
| 43 | - if ( ! is_email( $email ) ) {
|
|
| 43 | + if ( ! is_email( $email ) ) { |
|
| 44 | 44 | return false; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // Convert the integration type to a list ID. |
| 48 | 48 | $checkbox_options = get_option( 'optin-checkbox-init', '' ); |
| 49 | - if ( empty( $checkbox_options ) || ! isset( $checkbox_options[ $type ] ) || ! isset( $checkbox_options[ $type ]['associated-list'] ) ) {
|
|
| 49 | + if ( empty( $checkbox_options ) || ! isset( $checkbox_options[ $type ] ) || ! isset( $checkbox_options[ $type ]['associated-list'] ) ) { |
|
| 50 | 50 | return false; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | $list_ids = is_array( $list_ids ) ? $list_ids : array( $list_ids ); |
| 55 | 55 | |
| 56 | 56 | // Go through each list... |
| 57 | - foreach ( $list_ids as $list_id ) {
|
|
| 58 | - if ( ! $this->is_user_subscribed( $email, $list_id, $type ) ) {
|
|
| 57 | + foreach ( $list_ids as $list_id ) { |
|
| 58 | + if ( ! $this->is_user_subscribed( $email, $list_id, $type ) ) { |
|
| 59 | 59 | return false; |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -74,18 +74,18 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return bool Whether the email is subscribed to the list. |
| 76 | 76 | */ |
| 77 | - public function is_user_subscribed( $email, $list_id, $type ) {
|
|
| 77 | + public function is_user_subscribed( $email, $list_id, $type ) { |
|
| 78 | 78 | $email_hash = md5( $email ); |
| 79 | 79 | |
| 80 | 80 | // Check the API to see the status. |
| 81 | 81 | $response = yikes_get_mc_api_manager()->get_list_handler()->get_member( $list_id, $email_hash, false ); |
| 82 | - if ( is_wp_error( $response ) ) {
|
|
| 82 | + if ( is_wp_error( $response ) ) { |
|
| 83 | 83 | $data = $response->get_error_data(); |
| 84 | 84 | |
| 85 | 85 | // If the error response is a 404, they are not subscribed. |
| 86 | - if ( isset( $data['status'] ) && 404 === (int) $data['status'] ) {
|
|
| 86 | + if ( isset( $data['status'] ) && 404 === (int) $data['status'] ) { |
|
| 87 | 87 | return false; |
| 88 | - } else {
|
|
| 88 | + } else { |
|
| 89 | 89 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
| 90 | 90 | $error_logging->maybe_write_to_log( |
| 91 | 91 | $response->get_error_code(), |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @return string The HTML for the checkbox. |
| 111 | 111 | */ |
| 112 | - public function yikes_get_checkbox() {
|
|
| 112 | + public function yikes_get_checkbox() { |
|
| 113 | 113 | |
| 114 | 114 | // Enqueue our checkbox styles whenever the checkbox is displayed. |
| 115 | 115 | wp_enqueue_style( 'yikes-easy-mailchimp-checkbox-integration-styles', plugin_dir_url( __FILE__ ) . '../css/yikes-inc-easy-mailchimp-checkbox-integration.min.css' ); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $has_list_ids = isset( $checkbox_options[ $this->type ]['associated-list'] ) && '-' !== $checkbox_options[ $this->type ]['associated-list']; |
| 120 | 120 | $has_list_ids = $has_list_ids && ! in_array( '-', $checkbox_options[ $this->type ]['associated-list'], true ); |
| 121 | 121 | |
| 122 | - if ( $has_list_ids ) {
|
|
| 122 | + if ( $has_list_ids ) { |
|
| 123 | 123 | $checked = 'true' === $checkbox_options[ $this->type ]['precheck'] ? 'checked="checked"' : ''; |
| 124 | 124 | $before = apply_filters( 'yikes-mailchimp-before-checkbox-html', '' ); |
| 125 | 125 | $content = '<p id="yikes-easy-mailchimp-' . esc_attr( $this->type ) . '-checkbox" class="yikes-easy-mailchimp-' . esc_attr( $this->type ) . '-checkbox">'; |
@@ -145,18 +145,18 @@ discard block |
||
| 145 | 145 | * @param string $type The integration type. |
| 146 | 146 | * @param array $merge_vars The array of form data to send. |
| 147 | 147 | */ |
| 148 | - public function subscribe_user_integration( $email, $type, $merge_vars ) {
|
|
| 148 | + public function subscribe_user_integration( $email, $type, $merge_vars ) { |
|
| 149 | 149 | $options = get_option( 'optin-checkbox-init', '' ); |
| 150 | 150 | |
| 151 | 151 | // Make sure we have a list ID. |
| 152 | - if ( ! isset( $options[ $type ] ) || ! isset( $options[ $type ]['associated-list'] ) ) {
|
|
| 152 | + if ( ! isset( $options[ $type ] ) || ! isset( $options[ $type ]['associated-list'] ) ) { |
|
| 153 | 153 | // @todo: Throw some kind of error? |
| 154 | 154 | return; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | // Check for an IP address. |
| 158 | 158 | $user_ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] ); |
| 159 | - if ( isset( $merge_vars['OPTIN_IP'] ) ) {
|
|
| 159 | + if ( isset( $merge_vars['OPTIN_IP'] ) ) { |
|
| 160 | 160 | $user_ip = sanitize_text_field( $merge_vars['OPTIN_IP'] ); |
| 161 | 161 | } |
| 162 | 162 | |
@@ -172,19 +172,19 @@ discard block |
||
| 172 | 172 | 'ip_signup' => $user_ip, |
| 173 | 173 | ); |
| 174 | 174 | |
| 175 | - foreach ( $list_ids as $list_id ) {
|
|
| 175 | + foreach ( $list_ids as $list_id ) { |
|
| 176 | 176 | |
| 177 | 177 | $interests = isset( $options[ $type ]['interest-groups'] ) ? $options[ $type ]['interest-groups'] : array(); |
| 178 | 178 | $interests = isset( $interests[ $list_id ] ) ? $interests[ $list_id ] : $interests; |
| 179 | 179 | |
| 180 | 180 | // Only re-format and add interest groups if not empty. |
| 181 | - if ( ! empty( $interests ) ) {
|
|
| 181 | + if ( ! empty( $interests ) ) { |
|
| 182 | 182 | $groups = array(); |
| 183 | 183 | |
| 184 | 184 | // Need to reformat interest groups array as $interest_group_ID => true. |
| 185 | - foreach ( $interests as $interest ) {
|
|
| 186 | - if ( is_array( $interest ) ) {
|
|
| 187 | - foreach ( $interest as $group_id ) {
|
|
| 185 | + foreach ( $interests as $interest ) { |
|
| 186 | + if ( is_array( $interest ) ) { |
|
| 187 | + foreach ( $interest as $group_id ) { |
|
| 188 | 188 | $groups[ $group_id ] = true; |
| 189 | 189 | } |
| 190 | 190 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | // Subscribe the user to the list via the API. |
| 219 | 219 | $response = yikes_get_mc_api_manager()->get_list_handler()->member_subscribe( $list_id, $id, $data ); |
| 220 | - if ( is_wp_error( $response ) ) {
|
|
| 220 | + if ( is_wp_error( $response ) ) { |
|
| 221 | 221 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
| 222 | 222 | $error_logging->maybe_write_to_log( |
| 223 | 223 | $response->get_error_code(), |
@@ -235,15 +235,15 @@ discard block |
||
| 235 | 235 | * |
| 236 | 236 | * @param WP_User $user A WP User. |
| 237 | 237 | */ |
| 238 | - public function user_merge_vars( WP_User $user ) {
|
|
| 238 | + public function user_merge_vars( WP_User $user ) { |
|
| 239 | 239 | |
| 240 | 240 | // Setup our array. |
| 241 | 241 | $merge_vars = array(); |
| 242 | 242 | |
| 243 | - if ( ! empty( $user->first_name ) ) {
|
|
| 243 | + if ( ! empty( $user->first_name ) ) { |
|
| 244 | 244 | $merge_vars['FNAME'] = $user->first_name; |
| 245 | 245 | } |
| 246 | - if ( ! empty( $user->last_name ) ) {
|
|
| 246 | + if ( ! empty( $user->last_name ) ) { |
|
| 247 | 247 | $merge_vars['LNAME'] = $user->last_name; |
| 248 | 248 | } |
| 249 | 249 | |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | * |
| 268 | 268 | * @return bool True if the checkbox was checked. |
| 269 | 269 | */ |
| 270 | - public function was_checkbox_checked( $type ) {
|
|
| 270 | + public function was_checkbox_checked( $type ) { |
|
| 271 | 271 | return isset( $_POST[ 'yikes_mailchimp_checkbox_' . $type ] ) && '1' === (string) filter_var( $_POST[ 'yikes_mailchimp_checkbox_' . $type ], FILTER_SANITIZE_STRING ); |
| 272 | 272 | } |
| 273 | 273 | } |
@@ -255,13 +255,13 @@ discard block |
||
| 255 | 255 | $this->handle_updating_existing_user_link_message = __( 'To update your MailChimp profile, please click to send yourself an update link', 'yikes-inc-easy-mailchimp-extender' ); |
| 256 | 256 | $this->handle_empty_required_field_message = __( 'A required field is missing.', 'yikes-inc-easy-mailchimp-extender' ); |
| 257 | 257 | $this->handle_empty_required_interest_group_message = __( 'A required interest group is missing.', 'yikes-inc-easy-mailchimp-extender' ); |
| 258 | - $this->handle_nonce_message = __( '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' ); |
|
| 258 | + $this->handle_nonce_message = __( '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' ); |
|
| 259 | 259 | $this->handle_non_filled_recaptcha_message_message = __( 'Please check the reCAPTCHA field.', 'yikes-inc-easy-mailchimp-extender' ); |
| 260 | 260 | $this->generic_recaptcha_error_message = __( 'Please refresh the page and try again.', 'yikes-inc-easy-mailchimp-extender' ); |
| 261 | 261 | |
| 262 | 262 | // Define our success messages |
| 263 | - $this->default_response_single_optin_success_message = __( 'Thank you for subscribing!' , 'yikes-inc-easy-mailchimp-extender' ); |
|
| 264 | - $this->default_response_double_optin_success_message = __( 'Thank you for subscribing. Check your email for the confirmation message.' , 'yikes-inc-easy-mailchimp-extender' ); |
|
| 263 | + $this->default_response_single_optin_success_message = __( 'Thank you for subscribing!', 'yikes-inc-easy-mailchimp-extender' ); |
|
| 264 | + $this->default_response_double_optin_success_message = __( 'Thank you for subscribing. Check your email for the confirmation message.', 'yikes-inc-easy-mailchimp-extender' ); |
|
| 265 | 265 | $this->existing_subscriber_profile_update_message = __( 'Thank you for already being a subscriber! Your profile info has been updated.', 'yikes-inc-easy-mailchimp-extender' ); |
| 266 | 266 | } |
| 267 | 267 | |
@@ -373,16 +373,16 @@ discard block |
||
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | // Check if the current iteration has a 'date_format' key set (i.e. date/birthday fields) |
| 376 | - if ( isset( $form_fields[ $merge_tag ]['date_format'] ) ) { |
|
| 377 | - $sanitized = $this->handle_date_format_merge_values( $sanitized, $form_fields[ $merge_tag ]['date_format'] ); |
|
| 376 | + if ( isset( $form_fields[ $merge_tag ][ 'date_format' ] ) ) { |
|
| 377 | + $sanitized = $this->handle_date_format_merge_values( $sanitized, $form_fields[ $merge_tag ][ 'date_format' ] ); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | $merge_variables[ $merge_tag ] = $sanitized; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | // Make sure we send the lower-cased, sanitized email so it matches the one we're sending in the body of the request. |
| 384 | - if ( isset( $merge_variables['EMAIL'] ) ) { |
|
| 385 | - $merge_variables['EMAIL'] = $this->email; |
|
| 384 | + if ( isset( $merge_variables[ 'EMAIL' ] ) ) { |
|
| 385 | + $merge_variables[ 'EMAIL' ] = $this->email; |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | if ( count( $pieces ) === 3 ) { |
| 460 | 460 | |
| 461 | 461 | // $pieces[1] = MM. $pieces[0] = DD. $date = MM/DD/YYYY |
| 462 | - $date = $pieces[1] . '/' . $pieces[0] . '/' . $pieces[2]; |
|
| 462 | + $date = $pieces[ 1 ] . '/' . $pieces[ 0 ] . '/' . $pieces[ 2 ]; |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | return $date; |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | if ( count( $pieces ) === 2 ) { |
| 485 | 485 | |
| 486 | 486 | // $pieces[1] = MM. $pieces[0] = DD. $birthday = MM/DD |
| 487 | - $birthday = $pieces[1] . '/' . $pieces[0]; |
|
| 487 | + $birthday = $pieces[ 1 ] . '/' . $pieces[ 0 ]; |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | return $birthday; |
@@ -517,8 +517,8 @@ discard block |
||
| 517 | 517 | // Loop through the interest groups and create a single array like {group_id} => false |
| 518 | 518 | foreach ( $interest_groupings as $group_data ) { |
| 519 | 519 | |
| 520 | - foreach ( $group_data['items'] as $item ) { |
|
| 521 | - $groups[$item['id']] = false; |
|
| 520 | + foreach ( $group_data[ 'items' ] as $item ) { |
|
| 521 | + $groups[ $item[ 'id' ] ] = false; |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | } |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | do_action( "yikes-mailchimp-form-submission-{$this->form_id}", $this->email, $merge_variables, $this->form_id, $notifications ); |
| 632 | 632 | |
| 633 | 633 | // Get the optin value |
| 634 | - $optin = isset( $optin_settings['optin'] ) ? (int) $optin_settings['optin'] : 0; |
|
| 634 | + $optin = isset( $optin_settings[ 'optin' ] ) ? (int) $optin_settings[ 'optin' ] : 0; |
|
| 635 | 635 | |
| 636 | 636 | if ( 1 === $optin ) { |
| 637 | 637 | |
@@ -661,13 +661,13 @@ discard block |
||
| 661 | 661 | |
| 662 | 662 | // Construct our success array variables |
| 663 | 663 | $return_success_array = array( |
| 664 | - 'hide' => $submission_settings['hide_form_post_signup'], |
|
| 664 | + 'hide' => $submission_settings[ 'hide_form_post_signup' ], |
|
| 665 | 665 | 'error' => 0, |
| 666 | 666 | 'response' => $response_message, |
| 667 | - 'redirection' => $redirect_array['redirection'], |
|
| 668 | - 'redirect' => $redirect_array['redirect'], |
|
| 669 | - 'new_window' => $redirect_array['new_window'], |
|
| 670 | - 'redirect_timer' => $redirect_array['redirect_timer'], |
|
| 667 | + 'redirection' => $redirect_array[ 'redirection' ], |
|
| 668 | + 'redirect' => $redirect_array[ 'redirect' ], |
|
| 669 | + 'new_window' => $redirect_array[ 'new_window' ], |
|
| 670 | + 'redirect_timer' => $redirect_array[ 'redirect_timer' ], |
|
| 671 | 671 | ); |
| 672 | 672 | |
| 673 | 673 | // Return success array |
@@ -689,12 +689,12 @@ discard block |
||
| 689 | 689 | $details = ''; |
| 690 | 690 | |
| 691 | 691 | // Loop through the error data and retrieve any fields and messages |
| 692 | - if ( isset( $error_data['data'] ) ) { |
|
| 693 | - foreach ( $error_data['data'] as $datum ) { |
|
| 694 | - if ( ! isset( $datum['field'], $datum['message'] ) ) { |
|
| 692 | + if ( isset( $error_data[ 'data' ] ) ) { |
|
| 693 | + foreach ( $error_data[ 'data' ] as $datum ) { |
|
| 694 | + if ( ! isset( $datum[ 'field' ], $datum[ 'message' ] ) ) { |
|
| 695 | 695 | continue; |
| 696 | 696 | } |
| 697 | - $details .= sprintf( '<br>Error with %1$s field: <strong>%2$s</strong>', $form_fields[ $datum['field'] ]['label'], $datum['message'] ); |
|
| 697 | + $details .= sprintf( '<br>Error with %1$s field: <strong>%2$s</strong>', $form_fields[ $datum[ 'field' ] ][ 'label' ], $datum[ 'message' ] ); |
|
| 698 | 698 | } |
| 699 | 699 | } |
| 700 | 700 | |
@@ -737,21 +737,21 @@ discard block |
||
| 737 | 737 | $missing_fields = array(); |
| 738 | 738 | |
| 739 | 739 | // Loop through submitted form data |
| 740 | - foreach( $data as $merge_tag => $value ) { |
|
| 740 | + foreach ( $data as $merge_tag => $value ) { |
|
| 741 | 741 | |
| 742 | 742 | // Skip interest groups |
| 743 | - if ( isset( $form_fields[ $merge_tag ]['group_id'] ) ) { |
|
| 743 | + if ( isset( $form_fields[ $merge_tag ][ 'group_id' ] ) ) { |
|
| 744 | 744 | continue; |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | // check if this field is required |
| 748 | - if ( isset( $form_fields[ $merge_tag ] ) && isset( $form_fields[ $merge_tag ]['require'] ) && $form_fields[ $merge_tag ]['require'] === '1' ) { |
|
| 748 | + if ( isset( $form_fields[ $merge_tag ] ) && isset( $form_fields[ $merge_tag ][ 'require' ] ) && $form_fields[ $merge_tag ][ 'require' ] === '1' ) { |
|
| 749 | 749 | |
| 750 | 750 | // Check if the field(s) are empty |
| 751 | 751 | if ( is_array( $value ) ) { |
| 752 | 752 | |
| 753 | 753 | // Loop through the data and check if any are empty |
| 754 | - foreach( $value as $field => $val ) { |
|
| 754 | + foreach ( $value as $field => $val ) { |
|
| 755 | 755 | |
| 756 | 756 | /** |
| 757 | 757 | * 'yikes-mailchimp-ignore-required-array-field' |
@@ -770,13 +770,13 @@ discard block |
||
| 770 | 770 | |
| 771 | 771 | // Set the merge label (e.g. MMERGE6) as the key so we don't get the same field multiple times |
| 772 | 772 | // (e.g. For arrays, like an address, where multiple address fields are empty) |
| 773 | - $missing_fields[ $form_fields[ $merge_tag ]['merge'] ] = $form_fields[ $merge_tag ]; |
|
| 773 | + $missing_fields[ $form_fields[ $merge_tag ][ 'merge' ] ] = $form_fields[ $merge_tag ]; |
|
| 774 | 774 | } |
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | } else if ( empty( $value ) ) { |
| 778 | 778 | $field_is_missing = true; |
| 779 | - $missing_fields[ $form_fields[ $merge_tag ]['merge'] ] = $form_fields[ $merge_tag ]; |
|
| 779 | + $missing_fields[ $form_fields[ $merge_tag ][ 'merge' ] ] = $form_fields[ $merge_tag ]; |
|
| 780 | 780 | } |
| 781 | 781 | } |
| 782 | 782 | } |
@@ -826,7 +826,7 @@ discard block |
||
| 826 | 826 | foreach ( $form_fields as $merge_tag => $field_data ) { |
| 827 | 827 | |
| 828 | 828 | // If an interest group and it's required |
| 829 | - if ( isset( $field_data['group_id'] ) && isset( $field_data['require'] ) && $field_data['require'] === '1' ) { |
|
| 829 | + if ( isset( $field_data[ 'group_id' ] ) && isset( $field_data[ 'require' ] ) && $field_data[ 'require' ] === '1' ) { |
|
| 830 | 830 | |
| 831 | 831 | // Check if it was submitted (meaning, check if it's set in our $data array) |
| 832 | 832 | if ( ! isset( $data[ 'group-' . $merge_tag ] ) ) { |
@@ -888,30 +888,30 @@ discard block |
||
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | // Construct the API URL |
| 891 | - $url = esc_url_raw( 'https://www.google.com/recaptcha/api/siteverify?secret=' . get_option( 'yikes-mc-recaptcha-secret-key', '' ) . '&response=' . $recaptcha_response . '&remoteip=' . $_SERVER['REMOTE_ADDR'] ); |
|
| 891 | + $url = esc_url_raw( 'https://www.google.com/recaptcha/api/siteverify?secret=' . get_option( 'yikes-mc-recaptcha-secret-key', '' ) . '&response=' . $recaptcha_response . '&remoteip=' . $_SERVER[ 'REMOTE_ADDR' ] ); |
|
| 892 | 892 | $response = wp_remote_get( $url ); |
| 893 | - $response_body = json_decode( $response['body'], true ); |
|
| 893 | + $response_body = json_decode( $response[ 'body' ], true ); |
|
| 894 | 894 | |
| 895 | 895 | // Set up errors array |
| 896 | 896 | $recaptcha_errors = array(); |
| 897 | 897 | |
| 898 | 898 | // if we've hit an error, lets return the error! |
| 899 | - if ( true !== $response_body['success'] ) { |
|
| 899 | + if ( true !== $response_body[ 'success' ] ) { |
|
| 900 | 900 | |
| 901 | - if( isset( $response_body['error-codes'] ) ) { |
|
| 901 | + if ( isset( $response_body[ 'error-codes' ] ) ) { |
|
| 902 | 902 | |
| 903 | 903 | // Loop through response error codes |
| 904 | - foreach ( $response_body['error-codes'] as $error_code ) { |
|
| 904 | + foreach ( $response_body[ 'error-codes' ] as $error_code ) { |
|
| 905 | 905 | if ( 'missing-input-response' === $error_code ) { |
| 906 | 906 | $error_code = $this->handle_non_filled_recaptcha_message; |
| 907 | 907 | } |
| 908 | 908 | |
| 909 | 909 | // Add our error_code to the errors array |
| 910 | - $recaptcha_errors[] = $error_code; |
|
| 910 | + $recaptcha_errors[ ] = $error_code; |
|
| 911 | 911 | } |
| 912 | 912 | |
| 913 | 913 | } else { |
| 914 | - $recaptcha_errors[] = $this->generic_recaptcha_error_message; |
|
| 914 | + $recaptcha_errors[ ] = $this->generic_recaptcha_error_message; |
|
| 915 | 915 | } |
| 916 | 916 | |
| 917 | 917 | /** |
@@ -1019,7 +1019,7 @@ discard block |
||
| 1019 | 1019 | * @param array | $fields_array | An array of fields to loop through and make sure they're not null |
| 1020 | 1020 | */ |
| 1021 | 1021 | public function handle_empty_fields_generic( $fields_array ) { |
| 1022 | - foreach( $fields_array as $field ) { |
|
| 1022 | + foreach ( $fields_array as $field ) { |
|
| 1023 | 1023 | if ( $field === null ) { |
| 1024 | 1024 | return $this->yikes_fail( $hide = 0, $error = 1, $this->handle_empty_fields_generic_message ); |
| 1025 | 1025 | } |
@@ -1085,7 +1085,7 @@ discard block |
||
| 1085 | 1085 | |
| 1086 | 1086 | // Append our 'send-update-email' link and text |
| 1087 | 1087 | $response .= $link_start_tag; |
| 1088 | - $response .= $this->handle_updating_existing_user_link_message; |
|
| 1088 | + $response .= $this->handle_updating_existing_user_link_message; |
|
| 1089 | 1089 | $response .= $link_close_tag; |
| 1090 | 1090 | |
| 1091 | 1091 | // Check for a user-defined message |
@@ -1108,14 +1108,14 @@ discard block |
||
| 1108 | 1108 | */ |
| 1109 | 1109 | protected function check_for_user_defined_response_message( $slug, $response_text, $data = false ) { |
| 1110 | 1110 | |
| 1111 | - switch( $slug ) { |
|
| 1111 | + switch ( $slug ) { |
|
| 1112 | 1112 | case 'already-subscribed': |
| 1113 | 1113 | |
| 1114 | 1114 | // Check if this error message exists |
| 1115 | - if ( isset( $this->error_messages['already-subscribed'] ) && ! empty( $this->error_messages['already-subscribed'] ) ) { |
|
| 1115 | + if ( isset( $this->error_messages[ 'already-subscribed' ] ) && ! empty( $this->error_messages[ 'already-subscribed' ] ) ) { |
|
| 1116 | 1116 | |
| 1117 | 1117 | // Check if the substring (that we replace) '[email]' is located in the string and replace it |
| 1118 | - $response_text = str_replace( '[email]', $this->email, $this->error_messages['already-subscribed'] ); |
|
| 1118 | + $response_text = str_replace( '[email]', $this->email, $this->error_messages[ 'already-subscribed' ] ); |
|
| 1119 | 1119 | } |
| 1120 | 1120 | |
| 1121 | 1121 | /** |
@@ -1134,13 +1134,13 @@ discard block |
||
| 1134 | 1134 | case 'update-link': |
| 1135 | 1135 | |
| 1136 | 1136 | // Check if this error message exists |
| 1137 | - if ( $data !== false && isset( $this->error_messages['update-link'] ) && ! empty( $this->error_messages['update-link'] ) ) { |
|
| 1137 | + if ( $data !== false && isset( $this->error_messages[ 'update-link' ] ) && ! empty( $this->error_messages[ 'update-link' ] ) ) { |
|
| 1138 | 1138 | |
| 1139 | 1139 | // Check if the substring (that we replace) '[link]' is located in the string and replace it |
| 1140 | - $response_text = str_replace( '[link]', $data['link_start_tag'], $this->error_messages['update-link'] ); |
|
| 1140 | + $response_text = str_replace( '[link]', $data[ 'link_start_tag' ], $this->error_messages[ 'update-link' ] ); |
|
| 1141 | 1141 | |
| 1142 | 1142 | // Remove [/link] |
| 1143 | - $response_text = str_replace( '[/link]', $data['link_close_tag'], $response_text ); |
|
| 1143 | + $response_text = str_replace( '[/link]', $data[ 'link_close_tag' ], $response_text ); |
|
| 1144 | 1144 | } |
| 1145 | 1145 | |
| 1146 | 1146 | /** |
@@ -1159,8 +1159,8 @@ discard block |
||
| 1159 | 1159 | case 'success': |
| 1160 | 1160 | |
| 1161 | 1161 | // 'success' is the user-defined success message for double opt-in |
| 1162 | - if ( isset( $this->error_messages['success'] ) && ! empty( $this->error_messages['success'] ) ) { |
|
| 1163 | - $response_text = $this->error_messages['success']; |
|
| 1162 | + if ( isset( $this->error_messages[ 'success' ] ) && ! empty( $this->error_messages[ 'success' ] ) ) { |
|
| 1163 | + $response_text = $this->error_messages[ 'success' ]; |
|
| 1164 | 1164 | } |
| 1165 | 1165 | |
| 1166 | 1166 | /** |
@@ -1179,8 +1179,8 @@ discard block |
||
| 1179 | 1179 | |
| 1180 | 1180 | case 'success-single-optin': |
| 1181 | 1181 | |
| 1182 | - if ( isset( $this->error_messages['success-single-optin'] ) && ! empty( $this->error_messages['success-single-optin'] ) ) { |
|
| 1183 | - $response_text = $this->error_messages['success-single-optin']; |
|
| 1182 | + if ( isset( $this->error_messages[ 'success-single-optin' ] ) && ! empty( $this->error_messages[ 'success-single-optin' ] ) ) { |
|
| 1183 | + $response_text = $this->error_messages[ 'success-single-optin' ]; |
|
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | 1186 | /** |
@@ -1199,8 +1199,8 @@ discard block |
||
| 1199 | 1199 | |
| 1200 | 1200 | case 'success-resubscribed': |
| 1201 | 1201 | |
| 1202 | - if ( isset( $this->error_messages['success-resubscribed'] ) && ! empty( $this->error_messages['success-resubscribed'] ) ) { |
|
| 1203 | - $response_text = $this->error_messages['success-resubscribed']; |
|
| 1202 | + if ( isset( $this->error_messages[ 'success-resubscribed' ] ) && ! empty( $this->error_messages[ 'success-resubscribed' ] ) ) { |
|
| 1203 | + $response_text = $this->error_messages[ 'success-resubscribed' ]; |
|
| 1204 | 1204 | } |
| 1205 | 1205 | |
| 1206 | 1206 | /** |
@@ -1222,8 +1222,8 @@ discard block |
||
| 1222 | 1222 | $original_response_text = $response_text; |
| 1223 | 1223 | $user_defined_response_text = ''; |
| 1224 | 1224 | |
| 1225 | - if ( isset( $this->error_messages['general-error'] ) && ! empty( $this->error_messages['general-error'] ) ) { |
|
| 1226 | - $user_defined_response_text = $this->error_messages['general-error']; |
|
| 1225 | + if ( isset( $this->error_messages[ 'general-error' ] ) && ! empty( $this->error_messages[ 'general-error' ] ) ) { |
|
| 1226 | + $user_defined_response_text = $this->error_messages[ 'general-error' ]; |
|
| 1227 | 1227 | } |
| 1228 | 1228 | |
| 1229 | 1229 | /** |
@@ -1285,7 +1285,7 @@ discard block |
||
| 1285 | 1285 | } else { |
| 1286 | 1286 | global $process_submission_response; |
| 1287 | 1287 | |
| 1288 | - $process_submission_response = isset( $success_array['response'] ) ? $success_array['response'] : ''; // DEFAULT SUCCESS? |
|
| 1288 | + $process_submission_response = isset( $success_array[ 'response' ] ) ? $success_array[ 'response' ] : ''; // DEFAULT SUCCESS? |
|
| 1289 | 1289 | $process_submission_response = $this->wrap_form_submission_response( $process_submission_response, $is_success = true ); |
| 1290 | 1290 | } |
| 1291 | 1291 | } |
@@ -1338,8 +1338,8 @@ discard block |
||
| 1338 | 1338 | // Add additional fields we've been supplied |
| 1339 | 1339 | if ( ! empty( $additional_fields ) ) { |
| 1340 | 1340 | |
| 1341 | - foreach( $additional_fields as $key => $value ) { |
|
| 1342 | - $response_array[$key] = $value; |
|
| 1341 | + foreach ( $additional_fields as $key => $value ) { |
|
| 1342 | + $response_array[ $key ] = $value; |
|
| 1343 | 1343 | } |
| 1344 | 1344 | } |
| 1345 | 1345 | |
@@ -1370,20 +1370,20 @@ discard block |
||
| 1370 | 1370 | ); |
| 1371 | 1371 | |
| 1372 | 1372 | // Let's confirm we have a value before trying to use it |
| 1373 | - $redirect_setting = isset( $submission_settings['redirect_on_submission'] ) ? $submission_settings['redirect_on_submission'] : false; |
|
| 1373 | + $redirect_setting = isset( $submission_settings[ 'redirect_on_submission' ] ) ? $submission_settings[ 'redirect_on_submission' ] : false; |
|
| 1374 | 1374 | |
| 1375 | 1375 | // Check the redirect flag |
| 1376 | 1376 | if ( '1' === $redirect_setting ) { |
| 1377 | 1377 | |
| 1378 | 1378 | // Supply return array with default value of 1 |
| 1379 | - $redirect_array['redirection'] = apply_filters( 'yikes-mailchimp-redirection', 1, $form_id, $page_data ); |
|
| 1379 | + $redirect_array[ 'redirection' ] = apply_filters( 'yikes-mailchimp-redirection', 1, $form_id, $page_data ); |
|
| 1380 | 1380 | |
| 1381 | 1381 | // Let's confirm we have redirect_page/custom_redirect_url/new_window values |
| 1382 | - $redirect_page_setting = isset( $submission_settings['redirect_page'] ) ? $submission_settings['redirect_page'] : false; |
|
| 1383 | - $custom_redirect_setting = isset( $submission_settings['custom_redirect_url'] ) ? $submission_settings['custom_redirect_url'] : false; |
|
| 1384 | - $redirect_new_window = isset( $submission_settings['redirect_new_window'] ) ? $submission_settings['redirect_new_window'] : false; |
|
| 1382 | + $redirect_page_setting = isset( $submission_settings[ 'redirect_page' ] ) ? $submission_settings[ 'redirect_page' ] : false; |
|
| 1383 | + $custom_redirect_setting = isset( $submission_settings[ 'custom_redirect_url' ] ) ? $submission_settings[ 'custom_redirect_url' ] : false; |
|
| 1384 | + $redirect_new_window = isset( $submission_settings[ 'redirect_new_window' ] ) ? $submission_settings[ 'redirect_new_window' ] : false; |
|
| 1385 | 1385 | |
| 1386 | - $redirect_array['new_window'] = apply_filters( 'yikes-mailchimp-redirect-new-window', $redirect_new_window, $form_id, $page_data ); |
|
| 1386 | + $redirect_array[ 'new_window' ] = apply_filters( 'yikes-mailchimp-redirect-new-window', $redirect_new_window, $form_id, $page_data ); |
|
| 1387 | 1387 | |
| 1388 | 1388 | // Check if we're redirecting to a custom_url or just the redirect_page |
| 1389 | 1389 | $redirect_url = 'custom_url' !== $redirect_page_setting ? get_permalink( $redirect_page_setting ) : $custom_redirect_setting; |
@@ -1408,9 +1408,9 @@ discard block |
||
| 1408 | 1408 | */ |
| 1409 | 1409 | $redirect_timer = apply_filters( 'yikes-mailchimp-redirect-timer', $default_redirect_time_ms, $form_id, $page_data ); |
| 1410 | 1410 | |
| 1411 | - $redirect_array['redirect_timer'] = $redirect_timer; |
|
| 1411 | + $redirect_array[ 'redirect_timer' ] = $redirect_timer; |
|
| 1412 | 1412 | |
| 1413 | - $redirect_array['redirect'] = $redirect_url; |
|
| 1413 | + $redirect_array[ 'redirect' ] = $redirect_url; |
|
| 1414 | 1414 | } |
| 1415 | 1415 | |
| 1416 | 1416 | return $redirect_array; |