@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @subpackage Yikes_Inc_Easy_Mailchimp_Extender/includes |
| 26 | 26 | * @author YIKES Inc. <[email protected]> |
| 27 | 27 | */ |
| 28 | -class Yikes_Inc_Easy_Mailchimp_Extender {
|
|
| 28 | +class Yikes_Inc_Easy_Mailchimp_Extender { |
|
| 29 | 29 | /** |
| 30 | 30 | * The loader that's responsible for maintaining and registering all hooks that power |
| 31 | 31 | * the plugin. |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @param Yikes_Inc_Easy_Mailchimp_Extender_Form_Interface $form_interface |
| 72 | 72 | */ |
| 73 | - public function __construct( Yikes_Inc_Easy_Mailchimp_Extender_Form_Interface $form_interface ) {
|
|
| 73 | + public function __construct( Yikes_Inc_Easy_Mailchimp_Extender_Form_Interface $form_interface ) { |
|
| 74 | 74 | $this->version = YIKES_MC_VERSION; |
| 75 | 75 | $this->form_interface = $form_interface; |
| 76 | 76 | $this->load_dependencies(); |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @since 1.0.0 |
| 94 | 94 | * @access private |
| 95 | 95 | */ |
| 96 | - private function load_dependencies() {
|
|
| 96 | + private function load_dependencies() { |
|
| 97 | 97 | /** |
| 98 | 98 | * The class responsible for orchestrating the actions and filters of the |
| 99 | 99 | * core plugin. |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @since 1.0.0 |
| 122 | 122 | * @access private |
| 123 | 123 | */ |
| 124 | - private function define_admin_hooks() {
|
|
| 124 | + private function define_admin_hooks() { |
|
| 125 | 125 | $plugin_admin = new Yikes_Inc_Easy_Mailchimp_Forms_Admin( $this->get_yikes_inc_easy_mailchimp_extender(), $this->get_version(), $this->form_interface ); |
| 126 | 126 | $plugin_admin->hooks(); |
| 127 | 127 | $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | * @since 1.0.0 |
| 135 | 135 | * @access private |
| 136 | 136 | */ |
| 137 | - private function define_public_hooks() {
|
|
| 137 | + private function define_public_hooks() { |
|
| 138 | 138 | $plugin_public = new Yikes_Inc_Easy_Mailchimp_Extender_Public( $this->get_yikes_inc_easy_mailchimp_extender(), $this->get_version() ); |
| 139 | 139 | } |
| 140 | 140 | /** |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * |
| 143 | 143 | * @since 1.0.0 |
| 144 | 144 | */ |
| 145 | - public function run() {
|
|
| 145 | + public function run() { |
|
| 146 | 146 | $this->loader->run(); |
| 147 | 147 | } |
| 148 | 148 | /** |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @since 1.0.0 |
| 153 | 153 | * @return string The name of the plugin. |
| 154 | 154 | */ |
| 155 | - public function get_yikes_inc_easy_mailchimp_extender() {
|
|
| 155 | + public function get_yikes_inc_easy_mailchimp_extender() { |
|
| 156 | 156 | return $this->yikes_inc_easy_mailchimp_extender; |
| 157 | 157 | } |
| 158 | 158 | /** |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * @since 1.0.0 |
| 162 | 162 | * @return Yikes_Inc_Easy_Mailchimp_Extender_Loader Orchestrates the hooks of the plugin. |
| 163 | 163 | */ |
| 164 | - public function get_loader() {
|
|
| 164 | + public function get_loader() { |
|
| 165 | 165 | return $this->loader; |
| 166 | 166 | } |
| 167 | 167 | /** |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * @since 1.0.0 |
| 171 | 171 | * @return string The version number of the plugin. |
| 172 | 172 | */ |
| 173 | - public function get_version() {
|
|
| 173 | + public function get_version() { |
|
| 174 | 174 | return $this->version; |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | $this->api_key = $api_key; |
| 74 | 74 | $parts = $this->get_api_key_parts(); |
| 75 | - $this->key = $parts['key']; |
|
| 76 | - $this->dc = $parts['dc']; |
|
| 75 | + $this->key = $parts[ 'key' ]; |
|
| 76 | + $this->dc = $parts[ 'dc' ]; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | $parts = explode( '-', $this->api_key ); |
| 99 | 99 | |
| 100 | 100 | return array( |
| 101 | - 'key' => $parts[0], |
|
| 102 | - 'dc' => isset( $parts[1] ) ? $parts[1] : '', |
|
| 101 | + 'key' => $parts[ 0 ], |
|
| 102 | + 'dc' => isset( $parts[ 1 ] ) ? $parts[ 1 ] : '', |
|
| 103 | 103 | ); |
| 104 | 104 | } |
| 105 | 105 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @return Yikes_Inc_Easy_Mailchimp_API |
| 144 | 144 | */ |
| 145 | 145 | public function get_api( $version = '' ) { |
| 146 | - $version = $version ?: $this->get_default_api_version(); |
|
| 146 | + $version = $version ? : $this->get_default_api_version(); |
|
| 147 | 147 | |
| 148 | 148 | if ( ! array_key_exists( $version, $this->api ) || null === $this->api[ $version ] ) { |
| 149 | 149 | $this->api[ $version ] = new Yikes_Inc_Easy_Mailchimp_API( $this->get_datacenter(), $this->get_api_key(), $version ); |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | // required..* |
| 18 | 18 | include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 19 | 19 | /* Visual Composer */ |
| 20 | - if( is_plugin_active( 'js_composer/js_composer.php' ) ) { |
|
| 20 | + if ( is_plugin_active( 'js_composer/js_composer.php' ) ) { |
|
| 21 | 21 | new YIKES_Mailchimp_Visual_Composer_Extension(); |
| 22 | 22 | } |
| 23 | 23 | } |
@@ -11,16 +11,16 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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,26 +178,26 @@ discard block |
||
| 178 | 178 | $email_body = str_replace( array( '[subscriber_id]', '[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( array( '[form_name]', '[FORM_NAME]' ), $form_data['form_name'], $email_body ); |
|
| 181 | + $email_body = str_replace( array( '[form_name]', '[FORM_NAME]' ), $form_data[ 'form_name' ], $email_body ); |
|
| 182 | 182 | |
| 183 | 183 | // We let the user use [fname] and [lname] so replace those. |
| 184 | - $email_body = str_replace( array( '[fname]', '[FNAME]' ), isset( $subscriber_account_details['merge_fields']['FNAME'] ) ? $subscriber_account_details['merge_fields']['FNAME'] : '', $email_body ); |
|
| 185 | - $email_body = str_replace( array( '[lname]', '[LNAME]' ), isset( $subscriber_account_details['merge_fields']['LNAME'] ) ? $subscriber_account_details['merge_fields']['LNAME'] : '', $email_body ); |
|
| 184 | + $email_body = str_replace( array( '[fname]', '[FNAME]' ), isset( $subscriber_account_details[ 'merge_fields' ][ 'FNAME' ] ) ? $subscriber_account_details[ 'merge_fields' ][ 'FNAME' ] : '', $email_body ); |
|
| 185 | + $email_body = str_replace( array( '[lname]', '[LNAME]' ), isset( $subscriber_account_details[ 'merge_fields' ][ 'LNAME' ] ) ? $subscriber_account_details[ 'merge_fields' ][ 'LNAME' ] : '', $email_body ); |
|
| 186 | 186 | |
| 187 | 187 | /* Confirm that the email was sent */ |
| 188 | 188 | 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 ) ) { |
| 189 | 189 | |
| 190 | 190 | $update_email_success_message = apply_filters( 'yikes-mailchimp-update-email-success-message', $update_email_success_message, $form_id, $user_email ); |
| 191 | - $submission_settings = isset( $form_data['submission_settings'] ) ? $form_data['submission_settings'] : null; |
|
| 191 | + $submission_settings = isset( $form_data[ 'submission_settings' ] ) ? $form_data[ 'submission_settings' ] : null; |
|
| 192 | 192 | $redirect_settings = Yikes_Inc_Easy_Mailchimp_Extender_Process_Submission_Handler::handle_submission_response_success_redirect( $form_id, $submission_settings, $page_id ); |
| 193 | 193 | |
| 194 | 194 | wp_send_json_success( |
| 195 | 195 | array( |
| 196 | 196 | 'response_text' => '<div class="yikes-easy-mc-success-message">' . $update_email_success_message . '</div>', |
| 197 | - 'redirection' => $redirect_settings['redirection'], |
|
| 198 | - 'redirect' => $redirect_settings['redirect'], |
|
| 199 | - 'redirect_timer' => $redirect_settings['redirect_timer'], |
|
| 200 | - 'new_window' => $redirect_settings['new_window'], |
|
| 197 | + 'redirection' => $redirect_settings[ 'redirection' ], |
|
| 198 | + 'redirect' => $redirect_settings[ 'redirect' ], |
|
| 199 | + 'redirect_timer' => $redirect_settings[ 'redirect_timer' ], |
|
| 200 | + 'new_window' => $redirect_settings[ 'new_window' ], |
|
| 201 | 201 | ) |
| 202 | 202 | ); |
| 203 | 203 | } else { |
@@ -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 | /** |
@@ -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 | } |
@@ -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 ); |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | - display installation stuff here |
| 4 | 4 | - php version, wp version, plugin version and debug log |
| 5 | 5 | --> |
| 6 | -<h3><span><?php _e( 'Debug Settings' , 'yikes-inc-easy-mailchimp-extender' ); ?></span></h3> |
|
| 6 | +<h3><span><?php _e( 'Debug Settings', 'yikes-inc-easy-mailchimp-extender' ); ?></span></h3> |
|
| 7 | 7 | |
| 8 | 8 | <div class="inside"> |
| 9 | 9 | |
@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | <?php settings_fields( 'yikes_inc_easy_mc_debug_settings_page' ); ?> |
| 14 | 14 | |
| 15 | - <label for="yikes-mailchimp-debug-status"><strong><?php _e( 'Enable Debugging' , 'yikes-inc-easy-mailchimp-extender' ); ?></strong> |
|
| 16 | - <input type="checkbox" name="yikes-mailchimp-debug-status" id="yikes-mailchimp-debug-status" value="1" <?php checked( get_option( 'yikes-mailchimp-debug-status' , '' ) , '1' ); ?>> |
|
| 15 | + <label for="yikes-mailchimp-debug-status"><strong><?php _e( 'Enable Debugging', 'yikes-inc-easy-mailchimp-extender' ); ?></strong> |
|
| 16 | + <input type="checkbox" name="yikes-mailchimp-debug-status" id="yikes-mailchimp-debug-status" value="1" <?php checked( get_option( 'yikes-mailchimp-debug-status', '' ), '1' ); ?>> |
|
| 17 | 17 | </label> |
| 18 | - <p class="description"><?php _e( "If you encounter an issue with Easy Forms for Mailchimp you can toggle on debugging to display advanced error messages and start logging errors." , 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
| 18 | + <p class="description"><?php _e( "If you encounter an issue with Easy Forms for Mailchimp you can toggle on debugging to display advanced error messages and start logging errors.", 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
| 19 | 19 | |
| 20 | 20 | <?php submit_button(); ?> |
| 21 | 21 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | ) |
| 35 | 35 | ); |
| 36 | 36 | ?> |
| 37 | - <h2><?php _e( "Debug Log" , 'yikes-inc-easy-mailchimp-extender' ); ?> <a href="<?php echo $url; ?>" class="button-secondary"><?php _e( 'Clear Log', 'yikes-inc-easy-mailchimp-extender' ); ?></a></h2> |
|
| 37 | + <h2><?php _e( "Debug Log", 'yikes-inc-easy-mailchimp-extender' ); ?> <a href="<?php echo $url; ?>" class="button-secondary"><?php _e( 'Clear Log', 'yikes-inc-easy-mailchimp-extender' ); ?></a></h2> |
|
| 38 | 38 | |
| 39 | 39 | <table class="widefat" id="yikes-mailchimp-error-log"> |
| 40 | 40 | <!-- table header --> |