Completed
Pull Request — staging (#799)
by Viktor
05:05
created
public/partials/ajax/class.public_ajax.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,16 +11,16 @@  discard block
 block discarded – undo
11 11
 	 */
12 12
 	public function __construct() {
13 13
 		// ajax process form submission
14
-		add_action( 'wp_ajax_nopriv_process_form_submission', array( $this , 'process_form_submission' ), 10 );
15
-		add_action( 'wp_ajax_process_form_submission', array( $this , 'process_form_submission' ), 10 );
14
+		add_action( 'wp_ajax_nopriv_process_form_submission', array( $this, 'process_form_submission' ), 10 );
15
+		add_action( 'wp_ajax_process_form_submission', array( $this, 'process_form_submission' ), 10 );
16 16
 
17 17
 		// ajax send update emails
18
-		add_action( 'wp_ajax_nopriv_easy_forms_send_email', array( $this , 'sendUpdateProfileEmail' ), 10 );
19
-		add_action( 'wp_ajax_easy_forms_send_email', array( $this , 'sendUpdateProfileEmail' ), 10 );
18
+		add_action( 'wp_ajax_nopriv_easy_forms_send_email', array( $this, 'sendUpdateProfileEmail' ), 10 );
19
+		add_action( 'wp_ajax_easy_forms_send_email', array( $this, 'sendUpdateProfileEmail' ), 10 );
20 20
 
21 21
 		// increase submission count for a given form on successful submit
22
-		add_action( 'wp_ajax_nopriv_increase_submission_count' , array( $this , 'increase_submission_count' ), 10 );
23
-		add_action( 'wp_ajax_increase_submission_count' , array( $this , 'increase_submission_count' ), 10 );
22
+		add_action( 'wp_ajax_nopriv_increase_submission_count', array( $this, 'increase_submission_count' ), 10 );
23
+		add_action( 'wp_ajax_increase_submission_count', array( $this, 'increase_submission_count' ), 10 );
24 24
 	}
25 25
 
26 26
 	/*
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * Increase the submission count for a given form.
38 38
 	 */
39 39
 	public function increase_submission_count() {
40
-		$form_id   = intval( $_POST['form_id'] );
40
+		$form_id   = intval( $_POST[ 'form_id' ] );
41 41
 		$interface = yikes_easy_mailchimp_extender_get_form_interface();
42 42
 		$form      = $interface->get_form( $form_id );
43 43
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		}
48 48
 
49 49
 		// Update the form.
50
-		$submission_count = isset( $form['submissions'] ) ? $form['submissions'] + 1 : 1;
50
+		$submission_count = isset( $form[ 'submissions' ] ) ? $form[ 'submissions' ] + 1 : 1;
51 51
 		$interface->update_form_field( $form_id, 'submissions', $submission_count );
52 52
 
53 53
 		exit();
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
 		@since v6.0.4.1
59 59
 	*/
60 60
 	public function sendUpdateProfileEmail() {
61
-		$user_email    = filter_var( $_POST['user_email'], FILTER_SANITIZE_STRING );
61
+		$user_email    = filter_var( $_POST[ 'user_email' ], FILTER_SANITIZE_STRING );
62 62
 		$user_id       = md5( $user_email );
63
-		$list_id       = filter_var( $_POST['list_id'], FILTER_SANITIZE_STRING );
64
-		$form_id       = filter_var( $_POST['form_id'], FILTER_SANITIZE_NUMBER_INT );
65
-		$page_id       = filter_var( $_POST['page_id'], FILTER_SANITIZE_NUMBER_INT );
63
+		$list_id       = filter_var( $_POST[ 'list_id' ], FILTER_SANITIZE_STRING );
64
+		$form_id       = filter_var( $_POST[ 'form_id' ], FILTER_SANITIZE_NUMBER_INT );
65
+		$page_id       = filter_var( $_POST[ 'page_id' ], FILTER_SANITIZE_NUMBER_INT );
66 66
 		$full_site_url = get_bloginfo( 'url' );
67 67
 		$manager       = yikes_get_mc_api_manager();
68 68
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 				'class.public_ajax.php'
80 80
 			);
81 81
 			$is_error = true;
82
-			$errors[] = $list_details->get_error_message();
82
+			$errors[ ] = $list_details->get_error_message();
83 83
 		}
84 84
 
85 85
 		// Subscriber details API call.
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 			$error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging();
89 89
 			$error_logging->maybe_write_to_log( $subscriber_account_details->get_error_code(), __( 'Send Update Profile Email - Get Member Info.', 'yikes-inc-easy-mailchimp-extender' ), 'class.public_ajax.php' );
90 90
 			$is_error = true;
91
-			$errors[] = $subscriber_account_details->get_error_message();
91
+			$errors[ ] = $subscriber_account_details->get_error_message();
92 92
 		}
93 93
 
94 94
 		// Form details API call.
@@ -96,22 +96,22 @@  discard block
 block discarded – undo
96 96
 		if ( ! empty( $interface ) && method_exists( $interface, 'get_form' ) && ! empty( $form_id ) ) {
97 97
 			$form_data = $interface->get_form( $form_id );
98 98
 			if ( ! empty( $form_data ) ) {
99
-				if ( isset( $form_data['error_messages'] ) ) {
99
+				if ( isset( $form_data[ 'error_messages' ] ) ) {
100 100
 
101
-					if ( isset( $form_data['error_messages']['email-body'] ) && ! empty( $form_data['error_messages']['email-body'] ) ) {
102
-						$email_body = apply_filters( 'the_content', $form_data['error_messages']['email-body'] );
101
+					if ( isset( $form_data[ 'error_messages' ][ 'email-body' ] ) && ! empty( $form_data[ 'error_messages' ][ 'email-body' ] ) ) {
102
+						$email_body = apply_filters( 'the_content', $form_data[ 'error_messages' ][ 'email-body' ] );
103 103
 					}
104 104
 
105
-					if ( isset( $form_data['error_messages']['email-subject'] ) && ! empty( $form_data['error_messages']['email-subject'] ) ) {
106
-						$email_subject = $form_data['error_messages']['email-subject'];
105
+					if ( isset( $form_data[ 'error_messages' ][ 'email-subject' ] ) && ! empty( $form_data[ 'error_messages' ][ 'email-subject' ] ) ) {
106
+						$email_subject = $form_data[ 'error_messages' ][ 'email-subject' ];
107 107
 					}
108 108
 
109
-					if ( isset( $form_data['error_messages']['update-email-success'] ) && ! empty( $form_data['error_messages']['update-email-success'] ) ) {
110
-						$update_email_success_message = $form_data['error_messages']['update-email-success'];
109
+					if ( isset( $form_data[ 'error_messages' ][ 'update-email-success' ] ) && ! empty( $form_data[ 'error_messages' ][ 'update-email-success' ] ) ) {
110
+						$update_email_success_message = $form_data[ 'error_messages' ][ 'update-email-success' ];
111 111
 					}
112 112
 
113
-					if ( isset( $form_data['error_messages']['update-email-failure'] ) && ! empty( $form_data['error_messages']['update-email-failure'] ) ) {
114
-						$update_email_failed_message = $form_data['error_messages']['update-email-failure'];
113
+					if ( isset( $form_data[ 'error_messages' ][ 'update-email-failure' ] ) && ! empty( $form_data[ 'error_messages' ][ 'update-email-failure' ] ) ) {
114
+						$update_email_failed_message = $form_data[ 'error_messages' ][ 'update-email-failure' ];
115 115
 					}
116 116
 				}
117 117
 			}
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 		}
133 133
 
134 134
 		// Construct the headers & email message content.
135
-		$subscriber_id    = $subscriber_account_details['unique_email_id'];
136
-		$update_link_href = str_replace( '/subscribe', '/profile', $list_details['subscribe_url_long'] );
135
+		$subscriber_id    = $subscriber_account_details[ 'unique_email_id' ];
136
+		$update_link_href = str_replace( '/subscribe', '/profile', $list_details[ 'subscribe_url_long' ] );
137 137
 		$update_link_href = add_query_arg( 'e', $subscriber_id, $update_link_href );
138 138
 		$update_link_tag  = '<a href="' . $update_link_href . '">';
139
-		$headers          = 'From: ' . $list_details['campaign_defaults']['from_name'] . ' <' . $list_details['campaign_defaults']['from_email'] . '>' . "\r\n";
139
+		$headers          = 'From: ' . $list_details[ 'campaign_defaults' ][ 'from_name' ] . ' <' . $list_details[ 'campaign_defaults' ][ 'from_email' ] . '>' . "\r\n";
140 140
 		$headers         .= 'Content-type: text/html';
141 141
 
142 142
 		if ( ! isset( $email_subject ) ) {
@@ -178,22 +178,22 @@  discard block
 block discarded – undo
178 178
 		$email_body = str_replace( '[subscriber_id]', $subscriber_id, $email_body );
179 179
 
180 180
 		// We let the user use [form_name] for the form's name so replace [form_name] with the form's name.
181
-		$email_body = str_replace( '[form_name]', $form_data['form_name'], $email_body );
181
+		$email_body = str_replace( '[form_name]', $form_data[ 'form_name' ], $email_body );
182 182
 
183 183
 		/* Confirm that the email was sent */
184 184
 		if ( wp_mail( $user_email, apply_filters( 'yikes-mailchimp-update-email-subject', $email_subject ), apply_filters( 'yikes-mailchimp-update-email-content', $email_body, $update_link_href ), $headers ) ) {
185 185
 
186 186
 			$update_email_success_message = apply_filters( 'yikes-mailchimp-update-email-success-message', $update_email_success_message, $form_id, $user_email );
187
-			$submission_settings          = isset( $form_data['submission_settings'] ) ? $form_data['submission_settings'] : null;
187
+			$submission_settings          = isset( $form_data[ 'submission_settings' ] ) ? $form_data[ 'submission_settings' ] : null;
188 188
 			$redirect_settings            = Yikes_Inc_Easy_MailChimp_Extender_Process_Submission_Handler::handle_submission_response_success_redirect( $form_id, $submission_settings, $page_id );
189 189
 
190 190
 			wp_send_json_success(
191 191
 				array(
192 192
 					'response_text'  => '<div class="yikes-easy-mc-success-message">' . $update_email_success_message . '</div>',
193
-					'redirection'    => $redirect_settings['redirection'],
194
-					'redirect'       => $redirect_settings['redirect'],
195
-					'redirect_timer' => $redirect_settings['redirect_timer'],
196
-					'new_window'     => $redirect_settings['new_window'],
193
+					'redirection'    => $redirect_settings[ 'redirection' ],
194
+					'redirect'       => $redirect_settings[ 'redirect' ],
195
+					'redirect_timer' => $redirect_settings[ 'redirect_timer' ],
196
+					'new_window'     => $redirect_settings[ 'new_window' ],
197 197
 				)
198 198
 			);
199 199
 		} else {
Please login to merge, or discard this patch.
public/classes/checkbox-integrations.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
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
 
53
-		$list_ids = $checkbox_options[ $type ]['associated-list'];
53
+		$list_ids = $checkbox_options[ $type ][ 'associated-list' ];
54 54
 		$list_ids = is_array( $list_ids ) ? $list_ids : array( $list_ids );
55 55
 
56 56
 		// Go through each list...
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 			$data = $response->get_error_data();
85 85
 
86 86
 			// If the error response is a 404, they are not subscribed.
87
-			if ( isset( $data['status'] ) && 404 === (int) $data['status'] ) {
87
+			if ( isset( $data[ 'status' ] ) && 404 === (int) $data[ 'status' ] ) {
88 88
 				return false;
89 89
 			} else {
90 90
 				$error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging();
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 		}
101 101
 
102 102
 		// Look at the status from the API.
103
-		$subscribed = 'subscribed' === $response['status'];
103
+		$subscribed = 'subscribed' === $response[ 'status' ];
104 104
 
105 105
 		return apply_filters( 'yikes-mailchimp-integration-is-user-subscribed', $subscribed, $type );
106 106
 	}
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
 
115 115
 		// Get our options.
116 116
 		$checkbox_options = get_option( 'optin-checkbox-init', array() );
117
-		$has_list_ids     = isset( $checkbox_options[ $this->type ]['associated-list'] ) && '-' !== $checkbox_options[ $this->type ]['associated-list'];
118
-		$has_list_ids     = $has_list_ids && ! in_array( '-', $checkbox_options[ $this->type ]['associated-list'], true );
117
+		$has_list_ids     = isset( $checkbox_options[ $this->type ][ 'associated-list' ] ) && '-' !== $checkbox_options[ $this->type ][ 'associated-list' ];
118
+		$has_list_ids     = $has_list_ids && ! in_array( '-', $checkbox_options[ $this->type ][ 'associated-list' ], true );
119 119
 
120 120
 		if ( $has_list_ids ) {
121
-			$label    = isset( $checkbox_options[ $this->type ]['label'] ) && ! empty( $checkbox_options[ $this->type ]['label'] ) ? trim( $checkbox_options[ $this->type ]['label'] ) : __( 'Sign me up for your mailing list.', 'yikes-inc-easy-mailchimp-extender' );
122
-			$checked  = 'true' === $checkbox_options[ $this->type ]['precheck'] ? 'checked="checked"' : '';
121
+			$label    = isset( $checkbox_options[ $this->type ][ 'label' ] ) && ! empty( $checkbox_options[ $this->type ][ 'label' ] ) ? trim( $checkbox_options[ $this->type ][ 'label' ] ) : __( 'Sign me up for your mailing list.', 'yikes-inc-easy-mailchimp-extender' );
122
+			$checked  = 'true' === $checkbox_options[ $this->type ][ 'precheck' ] ? 'checked="checked"' : '';
123 123
 			$before   = apply_filters( 'yikes-mailchimp-before-checkbox-html', '' );
124 124
 			$content  = '<p id="yikes-easy-mailchimp-' . esc_attr( $this->type ) . '-checkbox" class="yikes-easy-mailchimp-' . esc_attr( $this->type ) . '-checkbox">';
125 125
 			$content .= '<label>';
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		$options = get_option( 'optin-checkbox-init', '' );
149 149
 
150 150
 		// Make sure we have a list ID.
151
-		if ( ! isset( $options[ $type ] ) || ! isset( $options[ $type ]['associated-list'] ) ) {
151
+		if ( ! isset( $options[ $type ] ) || ! isset( $options[ $type ][ 'associated-list' ] ) ) {
152 152
 			// @todo: Throw some kind of error?
153 153
 			return;
154 154
 		}
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
 		$email = sanitize_email( $email );
157 157
 
158 158
 		// Check for an IP address.
159
-		$user_ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] );
160
-		if ( isset( $merge_vars['OPTIN_IP'] ) ) {
161
-			$user_ip = sanitize_text_field( $merge_vars['OPTIN_IP'] );
159
+		$user_ip = sanitize_text_field( $_SERVER[ 'REMOTE_ADDR' ] );
160
+		if ( isset( $merge_vars[ 'OPTIN_IP' ] ) ) {
161
+			$user_ip = sanitize_text_field( $merge_vars[ 'OPTIN_IP' ] );
162 162
 		}
163 163
 
164 164
 		// Build our request data.
165
-		$list_ids = $options[ $type ]['associated-list'];
166
-		$list_ids = is_array( $options[ $type ]['associated-list'] ) ? $options[ $type ]['associated-list'] : array( $options[ $type ]['associated-list'] );
165
+		$list_ids = $options[ $type ][ 'associated-list' ];
166
+		$list_ids = is_array( $options[ $type ][ 'associated-list' ] ) ? $options[ $type ][ 'associated-list' ] : array( $options[ $type ][ 'associated-list' ] );
167 167
 		$id       = md5( $email );
168 168
 		$data     = array(
169 169
 			'email_address' => $email,
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 
176 176
 		foreach ( $list_ids as $list_id ) {
177 177
 
178
-			$interests = isset( $options[ $type ]['interest-groups'] ) ? $options[ $type ]['interest-groups'] : array();
178
+			$interests = isset( $options[ $type ][ 'interest-groups' ] ) ? $options[ $type ][ 'interest-groups' ] : array();
179 179
 			$interests = isset( $interests[ $list_id ] ) ? $interests[ $list_id ] : $interests;
180 180
 
181 181
 			// Only re-format and add interest groups if not empty.
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 					}
192 192
 				}
193 193
 
194
-				$data['interests'] = $groups;
194
+				$data[ 'interests' ] = $groups;
195 195
 			}
196 196
 
197 197
 			/**
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
 			$list_id = apply_filters( 'yikes-mailchimp-checkbox-integration-list-id', $list_id, $data, $type );
218 218
 
219 219
 			// Don't send an empty merge fields array.
220
-			if ( empty( $data['merge_fields'] ) ) {
221
-				unset( $data['merge_fields'] );
220
+			if ( empty( $data[ 'merge_fields' ] ) ) {
221
+				unset( $data[ 'merge_fields' ] );
222 222
 			}
223 223
 
224 224
 			// Subscribe the user to the list via the API.
@@ -248,10 +248,10 @@  discard block
 block discarded – undo
248 248
 		$merge_vars = array();
249 249
 
250 250
 		if ( ! empty( $user->first_name ) ) {
251
-			$merge_vars['FNAME'] = $user->first_name;
251
+			$merge_vars[ 'FNAME' ] = $user->first_name;
252 252
 		}
253 253
 		if ( ! empty( $user->last_name ) ) {
254
-			$merge_vars['LNAME'] = $user->last_name;
254
+			$merge_vars[ 'LNAME' ] = $user->last_name;
255 255
 		}
256 256
 
257 257
 		/**
Please login to merge, or discard this patch.
Braces   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,19 +74,19 @@  discard block
 block discarded – undo
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      = sanitize_email( $email );
79 79
 		$email_hash = md5( $email );
80 80
 
81 81
 		// Check the API to see the status.
82 82
 		$response = yikes_get_mc_api_manager()->get_list_handler()->get_member( $list_id, $email_hash, false );
83
-		if ( is_wp_error( $response ) ) {
83
+		if ( is_wp_error( $response ) ) {
84 84
 			$data = $response->get_error_data();
85 85
 
86 86
 			// If the error response is a 404, they are not subscribed.
87
-			if ( isset( $data['status'] ) && 404 === (int) $data['status'] ) {
87
+			if ( isset( $data['status'] ) && 404 === (int) $data['status'] ) {
88 88
 				return false;
89
-			} else {
89
+			} else {
90 90
 				$error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging();
91 91
 				$error_logging->maybe_write_to_log(
92 92
 					$response->get_error_code(),
@@ -110,14 +110,14 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @return string The HTML for the checkbox.
112 112
 	 */
113
-	public function yikes_get_checkbox() {
113
+	public function yikes_get_checkbox() {
114 114
 
115 115
 		// Get our options.
116 116
 		$checkbox_options = get_option( 'optin-checkbox-init', array() );
117 117
 		$has_list_ids     = isset( $checkbox_options[ $this->type ]['associated-list'] ) && '-' !== $checkbox_options[ $this->type ]['associated-list'];
118 118
 		$has_list_ids     = $has_list_ids && ! in_array( '-', $checkbox_options[ $this->type ]['associated-list'], true );
119 119
 
120
-		if ( $has_list_ids ) {
120
+		if ( $has_list_ids ) {
121 121
 			$label    = isset( $checkbox_options[ $this->type ]['label'] ) && ! empty( $checkbox_options[ $this->type ]['label'] ) ? trim( $checkbox_options[ $this->type ]['label'] ) : __( 'Sign me up for your mailing list.', 'yikes-inc-easy-mailchimp-extender' );
122 122
 			$checked  = 'true' === $checkbox_options[ $this->type ]['precheck'] ? 'checked="checked"' : '';
123 123
 			$before   = apply_filters( 'yikes-mailchimp-before-checkbox-html', '' );
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
 	 * @param string $type       The integration type.
145 145
 	 * @param array  $merge_vars The array of form data to send.
146 146
 	 */
147
-	public function subscribe_user_integration( $email, $type, $merge_vars ) {
147
+	public function subscribe_user_integration( $email, $type, $merge_vars ) {
148 148
 		$options = get_option( 'optin-checkbox-init', '' );
149 149
 
150 150
 		// Make sure we have a list ID.
151
-		if ( ! isset( $options[ $type ] ) || ! isset( $options[ $type ]['associated-list'] ) ) {
151
+		if ( ! isset( $options[ $type ] ) || ! isset( $options[ $type ]['associated-list'] ) ) {
152 152
 			// @todo: Throw some kind of error?
153 153
 			return;
154 154
 		}
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
 		// Check for an IP address.
159 159
 		$user_ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] );
160
-		if ( isset( $merge_vars['OPTIN_IP'] ) ) {
160
+		if ( isset( $merge_vars['OPTIN_IP'] ) ) {
161 161
 			$user_ip = sanitize_text_field( $merge_vars['OPTIN_IP'] );
162 162
 		}
163 163
 
@@ -173,19 +173,19 @@  discard block
 block discarded – undo
173 173
 			'ip_signup'     => $user_ip,
174 174
 		);
175 175
 
176
-		foreach ( $list_ids as $list_id ) {
176
+		foreach ( $list_ids as $list_id ) {
177 177
 
178 178
 			$interests = isset( $options[ $type ]['interest-groups'] ) ? $options[ $type ]['interest-groups'] : array();
179 179
 			$interests = isset( $interests[ $list_id ] ) ? $interests[ $list_id ] : $interests;
180 180
 
181 181
 			// Only re-format and add interest groups if not empty.
182
-			if ( ! empty( $interests ) ) {
182
+			if ( ! empty( $interests ) ) {
183 183
 				$groups = array();
184 184
 
185 185
 				// Need to reformat interest groups array as $interest_group_ID => true.
186
-				foreach ( $interests as $interest ) {
187
-					if ( is_array( $interest ) ) {
188
-						foreach ( $interest as $group_id ) {
186
+				foreach ( $interests as $interest ) {
187
+					if ( is_array( $interest ) ) {
188
+						foreach ( $interest as $group_id ) {
189 189
 							$groups[ $group_id ] = true;
190 190
 						}
191 191
 					}
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
 			$list_id = apply_filters( 'yikes-mailchimp-checkbox-integration-list-id', $list_id, $data, $type );
218 218
 
219 219
 			// Don't send an empty merge fields array.
220
-			if ( empty( $data['merge_fields'] ) ) {
220
+			if ( empty( $data['merge_fields'] ) ) {
221 221
 				unset( $data['merge_fields'] );
222 222
 			}
223 223
 
224 224
 			// Subscribe the user to the list via the API.
225 225
 			$response = yikes_get_mc_api_manager()->get_list_handler()->member_subscribe( $list_id, $id, $data );
226 226
 
227
-			if ( is_wp_error( $response ) ) {
227
+			if ( is_wp_error( $response ) ) {
228 228
 				$error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging();
229 229
 				$error_logging->maybe_write_to_log(
230 230
 					$response->get_error_code(),
@@ -242,15 +242,15 @@  discard block
 block discarded – undo
242 242
 	 *
243 243
 	 * @param WP_User $user A WP User.
244 244
 	 */
245
-	public function user_merge_vars( WP_User $user ) {
245
+	public function user_merge_vars( WP_User $user ) {
246 246
 
247 247
 		// Setup our array.
248 248
 		$merge_vars = array();
249 249
 
250
-		if ( ! empty( $user->first_name ) ) {
250
+		if ( ! empty( $user->first_name ) ) {
251 251
 			$merge_vars['FNAME'] = $user->first_name;
252 252
 		}
253
-		if ( ! empty( $user->last_name ) ) {
253
+		if ( ! empty( $user->last_name ) ) {
254 254
 			$merge_vars['LNAME'] = $user->last_name;
255 255
 		}
256 256
 
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @return bool True if the checkbox was checked.
276 276
 	 */
277
-	public function was_checkbox_checked( $type ) {
277
+	public function was_checkbox_checked( $type ) {
278 278
 		return isset( $_POST[ 'yikes_mailchimp_checkbox_' . $type ] ) && '1' === filter_var( $_POST[ 'yikes_mailchimp_checkbox_' . $type ], FILTER_SANITIZE_STRING );
279 279
 	}
280 280
 }
Please login to merge, or discard this patch.
yikes-inc-easy-mailchimp-extender.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
  * 	@since 6.1.3
44 44
  */
45 45
 if ( ! defined( 'YIKES_MC_VERSION' ) ) {
46
-	define( 'YIKES_MC_VERSION' , '6.4.11' );
46
+	define( 'YIKES_MC_VERSION', '6.4.11' );
47 47
 }
48 48
 
49 49
 /**
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
  * 	@since 6.0.0
53 53
  */
54 54
 if ( ! defined( 'YIKES_MC_PATH' ) ) {
55
-	define( 'YIKES_MC_PATH' , plugin_dir_path( __FILE__ ) );
55
+	define( 'YIKES_MC_PATH', plugin_dir_path( __FILE__ ) );
56 56
 }
57 57
 
58 58
 /**
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
  * 	@since 6.0.0
62 62
  */
63 63
 if ( ! defined( 'YIKES_MC_URL' ) ) {
64
-	define( 'YIKES_MC_URL' , plugin_dir_url( __FILE__ ) );
64
+	define( 'YIKES_MC_URL', plugin_dir_url( __FILE__ ) );
65 65
 }
66 66
 
67 67
 // Include our autoloader
Please login to merge, or discard this patch.