@@ -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>'; |
@@ -149,7 +149,7 @@ discard block |
||
| 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 | } |
@@ -157,14 +157,14 @@ discard block |
||
| 157 | 157 | $email = sanitize_email( $email ); |
| 158 | 158 | |
| 159 | 159 | // Check for an IP address. |
| 160 | - $user_ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] ); |
|
| 161 | - if ( isset( $merge_vars['OPTIN_IP'] ) ) {
|
|
| 162 | - $user_ip = sanitize_text_field( $merge_vars['OPTIN_IP'] ); |
|
| 160 | + $user_ip = sanitize_text_field( $_SERVER[ 'REMOTE_ADDR' ] ); |
|
| 161 | + if ( isset( $merge_vars[ 'OPTIN_IP' ] ) ) {
|
|
| 162 | + $user_ip = sanitize_text_field( $merge_vars[ 'OPTIN_IP' ] ); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // Build our request data. |
| 166 | - $list_ids = $options[ $type ]['associated-list']; |
|
| 167 | - $list_ids = is_array( $options[ $type ]['associated-list'] ) ? $options[ $type ]['associated-list'] : array( $options[ $type ]['associated-list'] ); |
|
| 166 | + $list_ids = $options[ $type ][ 'associated-list' ]; |
|
| 167 | + $list_ids = is_array( $options[ $type ][ 'associated-list' ] ) ? $options[ $type ][ 'associated-list' ] : array( $options[ $type ][ 'associated-list' ] ); |
|
| 168 | 168 | $id = md5( $email ); |
| 169 | 169 | $data = array( |
| 170 | 170 | 'email_address' => $email, |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | foreach ( $list_ids as $list_id ) {
|
| 178 | 178 | |
| 179 | - $interests = isset( $options[ $type ]['interest-groups'] ) ? $options[ $type ]['interest-groups'] : array(); |
|
| 179 | + $interests = isset( $options[ $type ][ 'interest-groups' ] ) ? $options[ $type ][ 'interest-groups' ] : array(); |
|
| 180 | 180 | $interests = isset( $interests[ $list_id ] ) ? $interests[ $list_id ] : $interests; |
| 181 | 181 | |
| 182 | 182 | // Only re-format and add interest groups if not empty. |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - $data['interests'] = $groups; |
|
| 195 | + $data[ 'interests' ] = $groups; |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | $list_id = apply_filters( 'yikes-mailchimp-checkbox-integration-list-id', $list_id, $data, $type, $integration_vars ); |
| 219 | 219 | |
| 220 | 220 | // Don't send an empty merge fields array. |
| 221 | - if ( empty( $data['merge_fields'] ) ) {
|
|
| 222 | - unset( $data['merge_fields'] ); |
|
| 221 | + if ( empty( $data[ 'merge_fields' ] ) ) {
|
|
| 222 | + unset( $data[ 'merge_fields' ] ); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | // Subscribe the user to the list via the API. |
@@ -249,10 +249,10 @@ discard block |
||
| 249 | 249 | $merge_vars = array(); |
| 250 | 250 | |
| 251 | 251 | if ( ! empty( $user->first_name ) ) {
|
| 252 | - $merge_vars['FNAME'] = $user->first_name; |
|
| 252 | + $merge_vars[ 'FNAME' ] = $user->first_name; |
|
| 253 | 253 | } |
| 254 | 254 | if ( ! empty( $user->last_name ) ) {
|
| 255 | - $merge_vars['LNAME'] = $user->last_name; |
|
| 255 | + $merge_vars[ 'LNAME' ] = $user->last_name; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
@@ -75,14 +75,14 @@ |
||
| 75 | 75 | |
| 76 | 76 | // Create merge variables based on comment data. |
| 77 | 77 | $merge_vars = array( |
| 78 | - 'FNAME' => $comment_data['comment_author'], |
|
| 79 | - 'OPTIN_IP' => $comment_data['comment_author_IP'], |
|
| 78 | + 'FNAME' => $comment_data[ 'comment_author' ], |
|
| 79 | + 'OPTIN_IP' => $comment_data[ 'comment_author_IP' ], |
|
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | 82 | $addl_vars = apply_filters( 'yikes_mailchimp_checkbox_integration_additional_vars', array( 'comment_data' => $comment_data ), $this->type ); |
| 83 | 83 | |
| 84 | 84 | // Subscribe the user. |
| 85 | - $this->subscribe_user_integration( $comment_data['comment_author_email'], $this->type, $merge_vars, $addl_vars ); |
|
| 85 | + $this->subscribe_user_integration( $comment_data[ 'comment_author_email' ], $this->type, $merge_vars, $addl_vars ); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | $yikes_easy_mc_comment_checkbox_class = new Yikes_Easy_MC_Comment_Checkbox_Class(); |
@@ -80,11 +80,11 @@ |
||
| 80 | 80 | |
| 81 | 81 | $user_info = (array) edd_get_payment_meta_user_info( $payment_id ); |
| 82 | 82 | $merge_vars = array(); |
| 83 | - if ( isset( $user_info['first_name'] ) ) { |
|
| 84 | - $merge_vars['FNAME'] = $user_info['first_name']; |
|
| 83 | + if ( isset( $user_info[ 'first_name' ] ) ) { |
|
| 84 | + $merge_vars[ 'FNAME' ] = $user_info[ 'first_name' ]; |
|
| 85 | 85 | } |
| 86 | - if ( isset( $user_info['last_name'] ) ) { |
|
| 87 | - $merge_vars['LNAME'] = $user_info['last_name']; |
|
| 86 | + if ( isset( $user_info[ 'last_name' ] ) ) { |
|
| 87 | + $merge_vars[ 'LNAME' ] = $user_info[ 'last_name' ]; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | $addl_vars = apply_filters( 'yikes_mailchimp_checkbox_integration_additional_vars', array( 'user' => $user_info, 'payment_id' => $payment_id ), $this->type ); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @return array $data CF7 posted data. |
| 49 | 49 | */ |
| 50 | 50 | public function alter_cf7_data( $data = array() ) { |
| 51 | - $data['yikes_mailchimp_checkbox'] = $this->was_checkbox_checked( $this->type ) ? __( 'Yes', 'yikes-inc-easy-mailchimp-extender' ) : __( 'No', 'yikes-inc-easy-mailchimp-extender' ); |
|
| 51 | + $data[ 'yikes_mailchimp_checkbox' ] = $this->was_checkbox_checked( $this->type ) ? __( 'Yes', 'yikes-inc-easy-mailchimp-extender' ) : __( 'No', 'yikes-inc-easy-mailchimp-extender' ); |
|
| 52 | 52 | return $data; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $submission = WPCF7_Submission::get_instance(); |
| 66 | 66 | if ( $submission ) { |
| 67 | 67 | $data = $submission->get_posted_data(); |
| 68 | - $email = isset( $data['your-email'] ) ? $data['your-email'] : ''; |
|
| 68 | + $email = isset( $data[ 'your-email' ] ) ? $data[ 'your-email' ] : ''; |
|
| 69 | 69 | $fields = array( 'email' => $email ); |
| 70 | 70 | $addl_vars = apply_filters( 'yikes_mailchimp_checkbox_integration_additional_vars', array( 'cf7_data' => $data, 'contact_form' => $contact_form ), $this->type ); |
| 71 | 71 | $this->subscribe_user_integration( $email, $this->type, apply_filters( 'yikes-mailchimp-contact-form-7', $fields, $data ), $addl_vars ); |