@@ -46,11 +46,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | /** |
@@ -43,7 +43,7 @@ discard block |
||
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 |
||
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 |
||
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 |