@@ -5,18 +5,18 @@ discard block |
||
| 5 | 5 | * @since 6.0.3 |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -class YIKES_Mailchimp_Visual_Composer_Extension {
|
|
| 8 | +class YIKES_Mailchimp_Visual_Composer_Extension { |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Constructor |
| 12 | 12 | * |
| 13 | 13 | * @since 6.0.3 |
| 14 | 14 | */ |
| 15 | - function __construct() {
|
|
| 15 | + function __construct() { |
|
| 16 | 16 | |
| 17 | 17 | add_action( 'admin_init', array( $this, 'extend_visual_composer' ) ); |
| 18 | 18 | |
| 19 | - if ( function_exists( 'vc_add_shortcode_param' ) ) {
|
|
| 19 | + if ( function_exists( 'vc_add_shortcode_param' ) ) { |
|
| 20 | 20 | vc_add_shortcode_param( 'yikes_mailchimp_logo', array( $this, 'yikes_mailchimp_logo_vc_section' ) ); |
| 21 | 21 | } |
| 22 | 22 | } |
@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @since 6.0.3 |
| 28 | 28 | */ |
| 29 | - public function extend_visual_composer() {
|
|
| 29 | + public function extend_visual_composer() { |
|
| 30 | 30 | |
| 31 | - if ( ! function_exists( 'vc_map' ) ) {
|
|
| 31 | + if ( ! function_exists( 'vc_map' ) ) { |
|
| 32 | 32 | return; |
| 33 | 33 | } |
| 34 | 34 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @since 6.0.3 |
| 100 | 100 | */ |
| 101 | - public function yikes_mailchimp_logo_vc_section() {
|
|
| 101 | + public function yikes_mailchimp_logo_vc_section() { |
|
| 102 | 102 | return '<img style="width:250px;display:block;margin:0 auto;" src="' . YIKES_MC_URL . 'includes/images/Mailchimp_Assets/mailchimp-logo.png" title="' . __( 'Easy Forms for Mailchimp', 'yikes-inc-easy-mailchimp-extender' ) . '" />'; |
| 103 | 103 | } |
| 104 | 104 | |
@@ -107,17 +107,17 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @since 6.0.3 |
| 109 | 109 | */ |
| 110 | - public function yikes_mailchimp_retreive_user_created_forms() {
|
|
| 110 | + public function yikes_mailchimp_retreive_user_created_forms() { |
|
| 111 | 111 | $interface = yikes_easy_mailchimp_extender_get_form_interface(); |
| 112 | 112 | $all_forms = $interface->get_all_forms(); |
| 113 | 113 | |
| 114 | 114 | $lists = array(); |
| 115 | - if ( ! empty( $all_forms ) ) {
|
|
| 115 | + if ( ! empty( $all_forms ) ) { |
|
| 116 | 116 | // build an array to pass to our javascript |
| 117 | - foreach ( $all_forms as $id => $form ) {
|
|
| 117 | + foreach ( $all_forms as $id => $form ) { |
|
| 118 | 118 | $lists[ $form['form_name'] ] = $id; |
| 119 | 119 | } |
| 120 | - } else {
|
|
| 120 | + } else { |
|
| 121 | 121 | $lists[ __( 'Please Import Some Mailchimp Lists', 'yikes-inc-easy-mailchimp-extender' ) ] = '-'; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -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,19 +74,19 @@ 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 = 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 |
||
| 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', '' ); |
@@ -145,11 +145,11 @@ discard block |
||
| 145 | 145 | * @param array $merge_vars The array of form data to send. |
| 146 | 146 | * @param array $integration_vars An array of additional information that can be used to filter the subscribe request. |
| 147 | 147 | */ |
| 148 | - public function subscribe_user_integration( $email, $type, $merge_vars, $integration_vars = array() ) {
|
|
| 148 | + public function subscribe_user_integration( $email, $type, $merge_vars, $integration_vars = array() ) { |
|
| 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 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | // Check for an IP address. |
| 160 | 160 | $user_ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] ); |
| 161 | - if ( isset( $merge_vars['OPTIN_IP'] ) ) {
|
|
| 161 | + if ( isset( $merge_vars['OPTIN_IP'] ) ) { |
|
| 162 | 162 | $user_ip = sanitize_text_field( $merge_vars['OPTIN_IP'] ); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -174,19 +174,19 @@ discard block |
||
| 174 | 174 | 'ip_signup' => $user_ip, |
| 175 | 175 | ); |
| 176 | 176 | |
| 177 | - foreach ( $list_ids as $list_id ) {
|
|
| 177 | + foreach ( $list_ids as $list_id ) { |
|
| 178 | 178 | |
| 179 | 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. |
| 183 | - if ( ! empty( $interests ) ) {
|
|
| 183 | + if ( ! empty( $interests ) ) { |
|
| 184 | 184 | $groups = array(); |
| 185 | 185 | |
| 186 | 186 | // Need to reformat interest groups array as $interest_group_ID => true. |
| 187 | - foreach ( $interests as $interest ) {
|
|
| 188 | - if ( is_array( $interest ) ) {
|
|
| 189 | - foreach ( $interest as $group_id ) {
|
|
| 187 | + foreach ( $interests as $interest ) { |
|
| 188 | + if ( is_array( $interest ) ) { |
|
| 189 | + foreach ( $interest as $group_id ) { |
|
| 190 | 190 | $groups[ $group_id ] = true; |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -218,14 +218,14 @@ 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'] ) ) {
|
|
| 221 | + if ( empty( $data['merge_fields'] ) ) { |
|
| 222 | 222 | unset( $data['merge_fields'] ); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | // Subscribe the user to the list via the API. |
| 226 | 226 | $response = yikes_get_mc_api_manager()->get_list_handler()->member_subscribe( $list_id, $id, $data ); |
| 227 | 227 | |
| 228 | - if ( is_wp_error( $response ) ) {
|
|
| 228 | + if ( is_wp_error( $response ) ) { |
|
| 229 | 229 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
| 230 | 230 | $error_logging->maybe_write_to_log( |
| 231 | 231 | $response->get_error_code(), |
@@ -243,15 +243,15 @@ discard block |
||
| 243 | 243 | * |
| 244 | 244 | * @param WP_User $user A WP User. |
| 245 | 245 | */ |
| 246 | - public function user_merge_vars( WP_User $user ) {
|
|
| 246 | + public function user_merge_vars( WP_User $user ) { |
|
| 247 | 247 | |
| 248 | 248 | // Setup our array. |
| 249 | 249 | $merge_vars = array(); |
| 250 | 250 | |
| 251 | - if ( ! empty( $user->first_name ) ) {
|
|
| 251 | + if ( ! empty( $user->first_name ) ) { |
|
| 252 | 252 | $merge_vars['FNAME'] = $user->first_name; |
| 253 | 253 | } |
| 254 | - if ( ! empty( $user->last_name ) ) {
|
|
| 254 | + if ( ! empty( $user->last_name ) ) { |
|
| 255 | 255 | $merge_vars['LNAME'] = $user->last_name; |
| 256 | 256 | } |
| 257 | 257 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | * |
| 276 | 276 | * @return bool True if the checkbox was checked. |
| 277 | 277 | */ |
| 278 | - public function was_checkbox_checked( $type ) {
|
|
| 278 | + public function was_checkbox_checked( $type ) { |
|
| 279 | 279 | return isset( $_POST[ 'yikes_mailchimp_checkbox_' . $type ] ) && '1' === filter_var( $_POST[ 'yikes_mailchimp_checkbox_' . $type ], FILTER_SANITIZE_STRING ); |
| 280 | 280 | } |
| 281 | 281 | } |
@@ -22,8 +22,11 @@ |
||
| 22 | 22 | ?> |
| 23 | 23 | </span> |
| 24 | 24 | </h3> |
| 25 | -<?php else : ?> |
|
| 26 | - <h3><span><?php _e( 'General Settings' , 'yikes-inc-easy-mailchimp-extender' ); ?></span><?php echo $api_connection; ?></h3> |
|
| 25 | +<?php else { |
|
| 26 | + : ?> |
|
| 27 | + <h3><span><?php _e( 'General Settings' , 'yikes-inc-easy-mailchimp-extender' ); |
|
| 28 | +} |
|
| 29 | +?></span><?php echo $api_connection; ?></h3> |
|
| 27 | 30 | <?php endif; ?> |
| 28 | 31 | |
| 29 | 32 | <div class="inside"> |