Email Subscribers & Newsletters - Version 4.3.12

Version Description

Download this release

Release Info

Developer Icegram
Plugin Icon 128x128 Email Subscribers & Newsletters
Version 4.3.12
Comparing to
See all releases

Code changes from version 4.3.11 to 4.3.12

email-subscribers.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Email Subscribers & Newsletters
4
  * Plugin URI: https://www.icegram.com/
5
  * Description: Add subscription forms on website, send HTML newsletters & automatically notify subscribers about new blog posts once it is published.
6
- * Version: 4.3.11
7
  * Author: Icegram
8
  * Author URI: https://www.icegram.com/
9
  * Requires at least: 3.9
@@ -111,7 +111,7 @@ if ( $is_premium ) {
111
  /* ***************************** Initial Compatibility Work (End) ******************* */
112
 
113
  if ( ! defined( 'ES_PLUGIN_VERSION' ) ) {
114
- define( 'ES_PLUGIN_VERSION', '4.3.11' );
115
  }
116
 
117
  // Plugin Folder Path.
3
  * Plugin Name: Email Subscribers & Newsletters
4
  * Plugin URI: https://www.icegram.com/
5
  * Description: Add subscription forms on website, send HTML newsletters & automatically notify subscribers about new blog posts once it is published.
6
+ * Version: 4.3.12
7
  * Author: Icegram
8
  * Author URI: https://www.icegram.com/
9
  * Requires at least: 3.9
111
  /* ***************************** Initial Compatibility Work (End) ******************* */
112
 
113
  if ( ! defined( 'ES_PLUGIN_VERSION' ) ) {
114
+ define( 'ES_PLUGIN_VERSION', '4.3.12' );
115
  }
116
 
117
  // Plugin Folder Path.
lite/admin/js/email-subscribers-admin.js CHANGED
@@ -183,14 +183,15 @@
183
  $.ajax({
184
  method: 'POST',
185
  url: ajaxurl,
186
- async: false,
187
  data: params,
188
  success: function(response) {
189
  if (response !== '') {
190
  response = JSON.parse(response);
191
  if (response.hasOwnProperty('total')) {
192
  var total = response.total;
193
- $('#ig_es_total_contacts').text(response.total);
 
194
  if (total == 0) {
195
  $('#ig_es_campaign_submit_button').attr("disabled", true);
196
  } else {
183
  $.ajax({
184
  method: 'POST',
185
  url: ajaxurl,
186
+ async: true,
187
  data: params,
188
  success: function(response) {
189
  if (response !== '') {
190
  response = JSON.parse(response);
191
  if (response.hasOwnProperty('total')) {
192
  var total = response.total;
193
+ var total_contacts_text = "<b>Total Contacts: " + total + "</b>";
194
+ $('#ig_es_total_contacts').html(total_contacts_text);
195
  if (total == 0) {
196
  $('#ig_es_campaign_submit_button').attr("disabled", true);
197
  } else {
lite/includes/class-es-common.php CHANGED
@@ -41,7 +41,8 @@ Class ES_Common {
41
  * @since 4.0.0
42
  */
43
  public static function es_process_template_body( $content, $tmpl_id = 0, $campaign_id = 0 ) {
44
- $content = convert_chars( convert_smilies( wptexturize( $content ) ) );
 
45
  if ( isset( $GLOBALS['wp_embed'] ) ) {
46
  $content = $GLOBALS['wp_embed']->autoembed( $content );
47
  }
@@ -1224,11 +1225,7 @@ Class ES_Common {
1224
  public static function generate_hash( $length ) {
1225
 
1226
  $length = ( $length ) ? $length : 12;
1227
- $auth_key = '';
1228
- if ( defined( 'AUTH_KEY' ) ) {
1229
- $auth_key = AUTH_KEY;
1230
- }
1231
 
1232
- return substr( md5( $auth_key . wp_rand( $length, 64 ) ), 0, $length );
1233
  }
1234
  }
41
  * @since 4.0.0
42
  */
43
  public static function es_process_template_body( $content, $tmpl_id = 0, $campaign_id = 0 ) {
44
+ $content = convert_smilies( wptexturize( $content ) );
45
+
46
  if ( isset( $GLOBALS['wp_embed'] ) ) {
47
  $content = $GLOBALS['wp_embed']->autoembed( $content );
48
  }
1225
  public static function generate_hash( $length ) {
1226
 
1227
  $length = ( $length ) ? $length : 12;
 
 
 
 
1228
 
1229
+ return substr( md5( uniqid() . uniqid() . wp_rand( $length, 64 ) ), 0, $length );
1230
  }
1231
  }
lite/includes/classes/class-es-admin-settings.php CHANGED
@@ -62,7 +62,7 @@ class ES_Admin_Settings {
62
  'ig_es_disable_wp_cron'
63
  );
64
 
65
- $texarea_fields_to_sanitize = array(
66
  'ig_es_unsubscribe_link_content',
67
  'ig_es_subscription_success_message',
68
  'ig_es_subscription_error_messsage',
@@ -87,7 +87,7 @@ class ES_Admin_Settings {
87
 
88
  if ( in_array( $key, $text_fields_to_sanitize ) ) {
89
  $value = sanitize_text_field( $value );
90
- } elseif ( in_array( $key, $texarea_fields_to_sanitize ) ) {
91
  $value = wp_kses_post( $value );
92
  } elseif ( in_array( $key, $email_fields_to_sanitize ) ) {
93
  $value = sanitize_email( $value );
@@ -755,30 +755,51 @@ class ES_Admin_Settings {
755
 
756
  }
757
 
 
 
 
 
 
 
 
758
  public static function mailers_html() {
759
  $html = '';
760
- $es_email_type = get_option( 'ig_es_email_type' );
761
- $selected_mailer_settings = get_option( 'ig_es_mailer_settings' );
762
- $selected_mailer = $selected_mailer_settings['mailer'];
763
- $default_mailer = ( $es_email_type === 'php_html_mail' || $es_email_type === 'php_plaintext_mail' || $selected_mailer === 'phpmail' ) ? 'phpmail' : $selected_mailer;
764
- $pepipost_doc_block = '';
765
- $mailers = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
766
  'wpmail' => array( 'name' => 'WP Mail', 'logo' => ES_PLUGIN_URL . 'lite/admin/images/wpmail.png' ),
767
  'phpmail' => array( 'name' => 'PHP mail', 'logo' => ES_PLUGIN_URL . 'lite/admin/images/phpmail.png' ),
768
  'pepipost' => array( 'name' => 'Pepipost', 'logo' => ES_PLUGIN_URL . 'lite/admin/images/pepipost.png', 'docblock' => $pepipost_doc_block ),
769
  );
770
 
771
- $mailers = apply_filters( 'ig_es_mailers', $mailers );
772
- $default_mailer = ( array_key_exists( $default_mailer, $mailers ) ) ? $default_mailer : 'wpmail';
773
 
774
  foreach ( $mailers as $key => $mailer ) {
775
  $class = ( $key === 'pepipost' ) ? 'es_recommended' : '';
776
  $html .= '<label><div class="es-mailer-logo ' . $class . '"><div class="es-logo-wrapper"><img src="' . $mailer['logo'] . '" alt="Default (none)"></div>';
777
- $html .= '<input type="radio" class="es_mailer" name="ig_es_mailer_settings[mailer]" value="' . $key . '" ' . checked( $default_mailer, $key, false ) . '>' . $mailer['name'] . '</input></div></label>';
778
  }
779
 
780
  return $html;
781
-
782
  }
783
 
784
  public static function pepipost_doc_block() {
62
  'ig_es_disable_wp_cron'
63
  );
64
 
65
+ $textarea_fields_to_sanitize = array(
66
  'ig_es_unsubscribe_link_content',
67
  'ig_es_subscription_success_message',
68
  'ig_es_subscription_error_messsage',
87
 
88
  if ( in_array( $key, $text_fields_to_sanitize ) ) {
89
  $value = sanitize_text_field( $value );
90
+ } elseif ( in_array( $key, $textarea_fields_to_sanitize ) ) {
91
  $value = wp_kses_post( $value );
92
  } elseif ( in_array( $key, $email_fields_to_sanitize ) ) {
93
  $value = sanitize_email( $value );
755
 
756
  }
757
 
758
+ /**
759
+ * Prepare Mailers Setting
760
+ *
761
+ * @return string
762
+ *
763
+ * @modify 4.3.12
764
+ */
765
  public static function mailers_html() {
766
  $html = '';
767
+ $es_email_type = get_option( 'ig_es_email_type', '' );
768
+ $selected_mailer_settings = get_option( 'ig_es_mailer_settings', array() );
769
+
770
+ $selected_mailer = '';
771
+ if ( ! empty( $selected_mailer_settings ) && ! empty( $selected_mailer_settings['mailer'] ) ) {
772
+ $selected_mailer = $selected_mailer_settings['mailer'];
773
+ } else {
774
+ $php_email_type_values = array(
775
+ 'php_html_mail',
776
+ 'php_plaintext_mail',
777
+ 'phpmail'
778
+ );
779
+
780
+ if ( in_array( $es_email_type, $php_email_type_values ) ) {
781
+ $selected_mailer = 'phpmail';
782
+ }
783
+ }
784
+
785
+ $pepipost_doc_block = '';
786
+
787
+ $mailers = array(
788
  'wpmail' => array( 'name' => 'WP Mail', 'logo' => ES_PLUGIN_URL . 'lite/admin/images/wpmail.png' ),
789
  'phpmail' => array( 'name' => 'PHP mail', 'logo' => ES_PLUGIN_URL . 'lite/admin/images/phpmail.png' ),
790
  'pepipost' => array( 'name' => 'Pepipost', 'logo' => ES_PLUGIN_URL . 'lite/admin/images/pepipost.png', 'docblock' => $pepipost_doc_block ),
791
  );
792
 
793
+ $mailers = apply_filters( 'ig_es_mailers', $mailers );
794
+ $selected_mailer = ( array_key_exists( $selected_mailer, $mailers ) ) ? $selected_mailer : 'wpmail';
795
 
796
  foreach ( $mailers as $key => $mailer ) {
797
  $class = ( $key === 'pepipost' ) ? 'es_recommended' : '';
798
  $html .= '<label><div class="es-mailer-logo ' . $class . '"><div class="es-logo-wrapper"><img src="' . $mailer['logo'] . '" alt="Default (none)"></div>';
799
+ $html .= '<input type="radio" class="es_mailer" name="ig_es_mailer_settings[mailer]" value="' . $key . '" ' . checked( $selected_mailer, $key, false ) . '>' . $mailer['name'] . '</input></div></label>';
800
  }
801
 
802
  return $html;
 
803
  }
804
 
805
  public static function pepipost_doc_block() {
lite/includes/classes/class-es-forms-table.php CHANGED
@@ -140,7 +140,7 @@ class ES_Forms_Table extends WP_List_Table {
140
  if ( 'submitted' === $submitted ) {
141
 
142
  $nonce = ig_es_get_request_data( '_wpnonce' );
143
- $form_data = ig_es_get_request_data( 'form_data' );
144
  $lists = ig_es_get_request_data( 'lists' );
145
 
146
  $form_data['lists'] = $lists;
@@ -185,7 +185,7 @@ class ES_Forms_Table extends WP_List_Table {
185
  if ( 'submitted' === $submitted ) {
186
 
187
  $nonce = ig_es_get_request_data( '_wpnonce' );
188
- $form_data = ig_es_get_request_data( 'form_data' );
189
  $lists = ig_es_get_request_data( 'lists' );
190
 
191
  $form_data['lists'] = $lists;
@@ -463,8 +463,8 @@ class ES_Forms_Table extends WP_List_Table {
463
  $list_required = true;
464
  $list_ids = ! empty( $data['lists'] ) ? $data['lists'] : array();
465
  $af_id = ! empty( $data['af_id'] ) ? $data['af_id'] : 0;
466
- $gdpr_consent = ! empty( $data['gdpr_consent'] ) ? $data['gdpr_consent'] : "no";
467
- $gdpr_consent_text = ! empty( $data['gdpr_consent_text'] ) ? $data['gdpr_consent_text'] : "";
468
 
469
  $body = array(
470
  array(
140
  if ( 'submitted' === $submitted ) {
141
 
142
  $nonce = ig_es_get_request_data( '_wpnonce' );
143
+ $form_data = ig_es_get_request_data( 'form_data', array(), false );
144
  $lists = ig_es_get_request_data( 'lists' );
145
 
146
  $form_data['lists'] = $lists;
185
  if ( 'submitted' === $submitted ) {
186
 
187
  $nonce = ig_es_get_request_data( '_wpnonce' );
188
+ $form_data = ig_es_get_request_data( 'form_data', array(), false );
189
  $lists = ig_es_get_request_data( 'lists' );
190
 
191
  $form_data['lists'] = $lists;
463
  $list_required = true;
464
  $list_ids = ! empty( $data['lists'] ) ? $data['lists'] : array();
465
  $af_id = ! empty( $data['af_id'] ) ? $data['af_id'] : 0;
466
+ $gdpr_consent = ! empty( $data['gdpr_consent'] ) ? sanitize_text_field( $data['gdpr_consent'] ) : "no";
467
+ $gdpr_consent_text = ! empty( $data['gdpr_consent_text'] ) ? wp_kses_post( $data['gdpr_consent_text'] ) : "";
468
 
469
  $body = array(
470
  array(
lite/includes/classes/class-es-handle-sync-wp-user.php CHANGED
@@ -6,9 +6,11 @@ class ES_Handle_Sync_Wp_User {
6
 
7
  public function __construct() {
8
  // Sync upcoming WordPress users
9
- add_action( 'user_register', array( $this, 'sync_registered_wp_user' ) );
10
  add_action( 'ig_es_sync_users_tabs_wordpress', array( $this, 'sync_wordpress_users_settings' ) );
 
 
11
  add_action( 'edit_user_profile_update', array( $this, 'update_es_contact' ) );
 
12
  }
13
 
14
  public function sync_wordpress_users_settings( $wordpress_tab ) {
@@ -92,72 +94,123 @@ class ES_Handle_Sync_Wp_User {
92
  <?php
93
  }
94
 
95
-
 
 
 
 
 
 
96
  public function sync_registered_wp_user( $user_id ) {
97
  $ig_es_sync_wp_users = get_option( 'ig_es_sync_wp_users', array() );
98
 
99
- if ( empty( $ig_es_sync_wp_users ) ) {
100
- $ig_es_sync_wp_users = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
- $ig_es_sync_wp_users = maybe_unserialize( $ig_es_sync_wp_users );
104
 
105
- $ig_es_registered = ( ! empty( $ig_es_sync_wp_users['es_registered'] ) ) ? $ig_es_sync_wp_users['es_registered'] : 'NO';
106
 
107
- if ( 'YES' === $ig_es_registered ) {
108
- $list_id = $ig_es_sync_wp_users['es_registered_group'];
109
- //get user info
110
- $user_info = get_userdata( $user_id );
111
- if ( ! ( $user_info instanceof WP_User ) ) {
112
- return false;
113
- }
114
 
115
- $user_first_name = $user_info->display_name;
116
 
117
- $email = $user_info->user_email;
118
- if ( empty( $user_first_name ) ) {
119
- $user_first_name = ES_Common::get_name_from_email( $email );
 
 
 
 
 
 
 
 
120
  }
121
- //prepare data
122
- $data = array(
123
- 'first_name' => $user_first_name,
124
- 'email' => $email,
125
- 'source' => 'wp',
126
- 'status' => 'verified',
127
- 'hash' => ES_Common::generate_guid(),
128
- 'created_at' => ig_get_current_date_time(),
129
- 'wp_user_id' => $user_id
130
- );
131
-
132
- do_action( 'ig_es_add_contact', $data, $list_id );
133
  }
134
 
135
- return true;
136
  }
137
 
138
- public function update_es_contact( $user_id ) {
 
 
 
 
 
 
 
 
139
  $ig_es_sync_wp_users = get_option( 'ig_es_sync_wp_users', array() );
140
 
141
- if ( empty( $ig_es_sync_wp_users ) ) {
142
- $ig_es_sync_wp_users = array();
143
- }
144
 
145
- $ig_es_sync_wp_users = maybe_unserialize( $ig_es_sync_wp_users );
146
 
147
- $ig_es_registered = ( ! empty( $ig_es_sync_wp_users['es_registered'] ) ) ? $ig_es_sync_wp_users['es_registered'] : 'NO';
148
 
149
- if ( 'YES' === $ig_es_registered ) {
150
 
151
- $user_info = get_userdata( $user_id );
152
- if ( ! ( $user_info instanceof WP_User ) ) {
153
- return;
154
- }
155
- //check if user exist with this email
156
- $es_contact_id = ES()->contacts_db->get_contact_id_by_email( $user_info->user_email );
157
- if ( $es_contact_id ) {
158
- $contact['email'] = $_POST['email'];
159
- $contact['first_name'] = $_POST['display_name'];
160
- ES()->contacts_db->update_contact( $es_contact_id, $contact );
 
 
 
 
 
 
161
  }
162
  }
163
 
6
 
7
  public function __construct() {
8
  // Sync upcoming WordPress users
 
9
  add_action( 'ig_es_sync_users_tabs_wordpress', array( $this, 'sync_wordpress_users_settings' ) );
10
+
11
+ add_action( 'user_register', array( $this, 'sync_registered_wp_user' ) );
12
  add_action( 'edit_user_profile_update', array( $this, 'update_es_contact' ) );
13
+ add_action( 'delete_user', array( $this, 'delete_contact' ), 10, 1 );
14
  }
15
 
16
  public function sync_wordpress_users_settings( $wordpress_tab ) {
94
  <?php
95
  }
96
 
97
+ /**
98
+ * @param $user_id
99
+ *
100
+ * @since 4.0
101
+ *
102
+ * @modify 4.3.12
103
+ */
104
  public function sync_registered_wp_user( $user_id ) {
105
  $ig_es_sync_wp_users = get_option( 'ig_es_sync_wp_users', array() );
106
 
107
+ if ( ! empty( $ig_es_sync_wp_users ) ) {
108
+
109
+ $ig_es_sync_wp_users = maybe_unserialize( $ig_es_sync_wp_users );
110
+
111
+ $ig_es_registered = ( ! empty( $ig_es_sync_wp_users['es_registered'] ) ) ? $ig_es_sync_wp_users['es_registered'] : 'NO';
112
+
113
+ if ( 'YES' === $ig_es_registered ) {
114
+ $list_id = $ig_es_sync_wp_users['es_registered_group'];
115
+ //get user info
116
+ $user_info = get_userdata( $user_id );
117
+ if ( $user_info instanceof WP_User ) {
118
+ $user_first_name = $user_info->display_name;
119
+
120
+ $email = $user_info->user_email;
121
+ if ( empty( $user_first_name ) ) {
122
+ $user_first_name = ES_Common::get_name_from_email( $email );
123
+ }
124
+ //prepare data
125
+ $data = array(
126
+ 'first_name' => $user_first_name,
127
+ 'email' => $email,
128
+ 'source' => 'wp',
129
+ 'status' => 'verified',
130
+ 'hash' => ES_Common::generate_guid(),
131
+ 'created_at' => ig_get_current_date_time(),
132
+ 'wp_user_id' => $user_id
133
+ );
134
+
135
+ do_action( 'ig_es_add_contact', $data, $list_id );
136
+ }
137
+
138
+ }
139
  }
140
+ }
141
+
142
+ /**
143
+ * Update ES Contact detail
144
+ *
145
+ * @param $user_id
146
+ *
147
+ * @since 4.0
148
+ *
149
+ * @modify 4.3.12
150
+ */
151
+ public function update_es_contact( $user_id ) {
152
+ $ig_es_sync_wp_users = get_option( 'ig_es_sync_wp_users', array() );
153
 
154
+ if ( ! empty( $ig_es_sync_wp_users ) ) {
155
 
156
+ $ig_es_sync_wp_users = maybe_unserialize( $ig_es_sync_wp_users );
157
 
158
+ $ig_es_registered = ( ! empty( $ig_es_sync_wp_users['es_registered'] ) ) ? $ig_es_sync_wp_users['es_registered'] : 'NO';
 
 
 
 
 
 
159
 
160
+ if ( 'YES' === $ig_es_registered ) {
161
 
162
+ $user_info = get_userdata( $user_id );
163
+ if ( ! ( $user_info instanceof WP_User ) ) {
164
+ return;
165
+ }
166
+ //check if user exist with this email
167
+ $es_contact_id = ES()->contacts_db->get_contact_id_by_email( $user_info->user_email );
168
+ if ( $es_contact_id ) {
169
+ $contact['email'] = $_POST['email'];
170
+ $contact['first_name'] = $_POST['display_name'];
171
+ ES()->contacts_db->update_contact( $es_contact_id, $contact );
172
+ }
173
  }
 
 
 
 
 
 
 
 
 
 
 
 
174
  }
175
 
176
+
177
  }
178
 
179
+ /**
180
+ * Delete contact from ES when user deleted from WordPress
181
+ *
182
+ * @param $user_id
183
+ *
184
+ * @since 4.3.12
185
+ */
186
+ public function delete_contact( $user_id = 0 ) {
187
+
188
  $ig_es_sync_wp_users = get_option( 'ig_es_sync_wp_users', array() );
189
 
190
+ if ( ! empty( $ig_es_sync_wp_users ) ) {
 
 
191
 
192
+ $ig_es_sync_wp_users = maybe_unserialize( $ig_es_sync_wp_users );
193
 
194
+ $ig_es_registered = ( ! empty( $ig_es_sync_wp_users['es_registered'] ) ) ? $ig_es_sync_wp_users['es_registered'] : 'NO';
195
 
196
+ if ( 'YES' === $ig_es_registered ) {
197
 
198
+ if ( ! empty( $user_id ) ) {
199
+ global $wpdb;
200
+
201
+ $user = get_user_by( 'ID', $user_id );
202
+
203
+ if ( $user instanceof WP_User ) {
204
+ $email = $user->user_email;
205
+
206
+ $where = $wpdb->prepare( "email = %s", $email );
207
+ $contact_id = ES()->contacts_db->get_column_by_condition( 'id', $where );
208
+
209
+ if ( $contact_id ) {
210
+ ES()->contacts_db->delete_contacts_by_ids( $contact_id );
211
+ }
212
+ }
213
+ }
214
  }
215
  }
216
 
lite/includes/classes/class-es-mailer.php CHANGED
@@ -257,12 +257,12 @@ if ( ! class_exists( 'ES_Mailer' ) ) {
257
  $subject = $this->get_confirmation_email_subject();
258
  $content = $this->get_confirmation_email_content();
259
 
260
- $content = str_replace( "{{LINK}}", "{{SUBSCRIBE-LINK}}", $content );
261
-
262
  if ( empty( $subject ) || empty( $content ) ) {
263
  return false;
264
  }
265
 
 
 
266
  $this->add_unsubscribe_link = false;
267
  $this->add_tracking_pixel = false;
268
 
@@ -286,9 +286,17 @@ if ( ! class_exists( 'ES_Mailer' ) ) {
286
  * @return string
287
  *
288
  * @since 4.3.2
 
 
289
  */
290
  public function get_confirmation_email_subject() {
291
- return stripslashes( get_option( 'ig_es_confirmation_mail_subject', '' ) );
 
 
 
 
 
 
292
  }
293
 
294
  /**
@@ -654,13 +662,27 @@ if ( ! class_exists( 'ES_Mailer' ) ) {
654
 
655
  $message->headers = $headers;
656
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
657
  $message->body = preg_replace( '/data-json=".*?"/is', '', $message->body );
658
  $message->body = preg_replace( '/ +/s', ' ', $message->body );
659
 
660
  $message->subject = $this->replace_merge_tags( $message->subject, $merge_tags );
661
 
662
  // Can Track Clicks? Replace Links
663
- $message->body = $this->replace_links( $message->body );
664
 
665
  // Unsubscribe Text
666
  $unsubscribe_message = $this->get_unsubscribe_text();
@@ -737,7 +759,7 @@ if ( ! class_exists( 'ES_Mailer' ) ) {
737
  */
738
  public function prepare_content( $content, $merge_tags = array(), $nl2br = false ) {
739
  // Convert text equivalent of smilies to images.
740
- $content = convert_chars( convert_smilies( wptexturize( $content ) ) );
741
 
742
  if ( isset( $GLOBALS['wp_embed'] ) ) {
743
  $content = $GLOBALS['wp_embed']->autoembed( $content );
@@ -809,14 +831,13 @@ if ( ! class_exists( 'ES_Mailer' ) ) {
809
  $total_contacts = ES()->contacts_db->get_total_contacts();
810
  $site_url = home_url( '/' );
811
 
812
- $contact_id = ig_es_get_data( $merge_tags, 'contact_id', 0 );
813
-
814
  $name = ig_es_get_data( $merge_tags, 'name', '' );
815
- $email = ig_es_get_data( $merge_tags, 'email', '' );
816
  $first_name = ig_es_get_data( $merge_tags, 'first_name', '' );
817
  $last_name = ig_es_get_data( $merge_tags, 'last_name', '' );
818
- $hash = ig_es_get_data( $merge_tags, 'hash', '' );
819
  $list_name = ig_es_get_data( $merge_tags, 'list_name', '' );
 
 
 
820
  $campaign_id = ig_es_get_data( $merge_tags, 'campaign_id', 0 );
821
  $message_id = ig_es_get_data( $merge_tags, 'message_id', 0 );
822
 
@@ -914,6 +935,7 @@ if ( ! class_exists( 'ES_Mailer' ) ) {
914
 
915
  // get all links from the basecontent
916
  preg_match_all( '# href=(\'|")?(https?[^\'"]+)(\'|")?#', $content, $links );
 
917
  $links = $links[2];
918
 
919
  if ( empty( $links ) ) {
@@ -922,8 +944,10 @@ if ( ! class_exists( 'ES_Mailer' ) ) {
922
 
923
  $inserted_links = array();
924
 
925
- $campaign_id = ! empty( $data['campaign_id'] ) ? $data['campaign_id'] : 0;
926
- $message_id = ! empty( $data['message_id'] ) ? $data['message_id'] : 0;
 
 
927
 
928
  foreach ( $links as $link ) {
929
 
@@ -934,7 +958,8 @@ if ( ! class_exists( 'ES_Mailer' ) ) {
934
  }
935
 
936
  $inserted_links[ $link ] = $index;
937
- $result = ES()->links_db->get_link_by_campaign_id( $link, $campaign_id, $message_id, $index );
 
938
 
939
  if ( is_array( $result ) && count( $result ) > 0 ) {
940
  $hash = $result[0]['hash'];
@@ -953,7 +978,11 @@ if ( ! class_exists( 'ES_Mailer' ) ) {
953
  ES()->links_db->insert( $link_data );
954
  }
955
 
956
- $data['link_hash'] = $hash;
 
 
 
 
957
 
958
  $new_link = $this->prepare_link( $data );
959
 
@@ -1088,6 +1117,7 @@ if ( ! class_exists( 'ES_Mailer' ) ) {
1088
  * @since 4.3.2
1089
  */
1090
  public function prepare_link( $data = array() ) {
 
1091
  /**
1092
  * We are getting different data like action, message_id, campaign_id, contact_id, guid, email etc in $data
1093
  */
257
  $subject = $this->get_confirmation_email_subject();
258
  $content = $this->get_confirmation_email_content();
259
 
 
 
260
  if ( empty( $subject ) || empty( $content ) ) {
261
  return false;
262
  }
263
 
264
+ $content = str_replace( "{{LINK}}", "{{SUBSCRIBE-LINK}}", $content );
265
+
266
  $this->add_unsubscribe_link = false;
267
  $this->add_tracking_pixel = false;
268
 
286
  * @return string
287
  *
288
  * @since 4.3.2
289
+ *
290
+ * @modify 4.3.12
291
  */
292
  public function get_confirmation_email_subject() {
293
+ $subject = stripslashes( get_option( 'ig_es_confirmation_mail_subject', '' ) );
294
+
295
+ if ( empty( $subject ) ) {
296
+ $subject = __( 'Thanks!', 'email-subscribers' );
297
+ }
298
+
299
+ return $subject;
300
  }
301
 
302
  /**
662
 
663
  $message->headers = $headers;
664
 
665
+ //$email = ig_es_get_data( $merge_tags, 'email', '' );
666
+ $hash = ig_es_get_data( $merge_tags, 'hash', '' );
667
+ $campaign_id = ig_es_get_data( $merge_tags, 'campaign_id', 0 );
668
+ $contact_id = ig_es_get_data( $merge_tags, 'contact_id', 0 );
669
+ $message_id = ig_es_get_data( $merge_tags, 'message_id', 0 );
670
+
671
+ $link_data = array(
672
+ 'message_id' => $message_id,
673
+ 'campaign_id' => $campaign_id,
674
+ 'contact_id' => $contact_id,
675
+ 'email' => $email,
676
+ 'guid' => $hash
677
+ );
678
+
679
  $message->body = preg_replace( '/data-json=".*?"/is', '', $message->body );
680
  $message->body = preg_replace( '/ +/s', ' ', $message->body );
681
 
682
  $message->subject = $this->replace_merge_tags( $message->subject, $merge_tags );
683
 
684
  // Can Track Clicks? Replace Links
685
+ $message->body = $this->replace_links( $message->body, $link_data );
686
 
687
  // Unsubscribe Text
688
  $unsubscribe_message = $this->get_unsubscribe_text();
759
  */
760
  public function prepare_content( $content, $merge_tags = array(), $nl2br = false ) {
761
  // Convert text equivalent of smilies to images.
762
+ $content = convert_smilies( wptexturize( $content ) );
763
 
764
  if ( isset( $GLOBALS['wp_embed'] ) ) {
765
  $content = $GLOBALS['wp_embed']->autoembed( $content );
831
  $total_contacts = ES()->contacts_db->get_total_contacts();
832
  $site_url = home_url( '/' );
833
 
 
 
834
  $name = ig_es_get_data( $merge_tags, 'name', '' );
 
835
  $first_name = ig_es_get_data( $merge_tags, 'first_name', '' );
836
  $last_name = ig_es_get_data( $merge_tags, 'last_name', '' );
 
837
  $list_name = ig_es_get_data( $merge_tags, 'list_name', '' );
838
+ $hash = ig_es_get_data( $merge_tags, 'hash', '' );
839
+ $email = ig_es_get_data( $merge_tags, 'email', '' );
840
+ $contact_id = ig_es_get_data( $merge_tags, 'contact_id', 0 );
841
  $campaign_id = ig_es_get_data( $merge_tags, 'campaign_id', 0 );
842
  $message_id = ig_es_get_data( $merge_tags, 'message_id', 0 );
843
 
935
 
936
  // get all links from the basecontent
937
  preg_match_all( '# href=(\'|")?(https?[^\'"]+)(\'|")?#', $content, $links );
938
+
939
  $links = $links[2];
940
 
941
  if ( empty( $links ) ) {
944
 
945
  $inserted_links = array();
946
 
947
+ $campaign_id = ! empty( $link_data['campaign_id'] ) ? $link_data['campaign_id'] : 0;
948
+ $message_id = ! empty( $link_data['message_id'] ) ? $link_data['message_id'] : 0;
949
+ $contact_id = ! empty( $link_data['contact_id'] ) ? $link_data['contact_id'] : 0;
950
+
951
 
952
  foreach ( $links as $link ) {
953
 
958
  }
959
 
960
  $inserted_links[ $link ] = $index;
961
+
962
+ $result = ES()->links_db->get_link_by_campaign_id( $link, $campaign_id, $message_id, $index );
963
 
964
  if ( is_array( $result ) && count( $result ) > 0 ) {
965
  $hash = $result[0]['hash'];
978
  ES()->links_db->insert( $link_data );
979
  }
980
 
981
+ $data = array(
982
+ 'action' => 'click',
983
+ 'link_hash' => $hash,
984
+ 'contact_id' => $contact_id
985
+ );
986
 
987
  $new_link = $this->prepare_link( $data );
988
 
1117
  * @since 4.3.2
1118
  */
1119
  public function prepare_link( $data = array() ) {
1120
+
1121
  /**
1122
  * We are getting different data like action, message_id, campaign_id, contact_id, guid, email etc in $data
1123
  */
lite/includes/classes/class-es-newsletters.php CHANGED
@@ -140,6 +140,7 @@ class ES_Newsletters {
140
  <div class="es_settings_right_pan">
141
  <div class="es_settings_field">
142
  <label><?php _e( 'Recipients', 'email-subscribers' ) ?><br/><select name="broadcast_data[list_ids]" id="ig_es_broadcast_list_ids"><?php echo $lists ?></select></label>
 
143
  </div>
144
  <hr>
145
  <div class="es_settings_field">
@@ -147,6 +148,7 @@ class ES_Newsletters {
147
  <input class="es_secondary_btn" type="submit" id="ig_es_preview_broadcast" value="<?php _e( 'Preview this email in browser', 'email-subscribers' ) ?>">
148
  <input type="hidden" name="es_broadcast_preview" id="es_broadcast_preview">
149
  </label>
 
150
  </div>
151
  <?php do_action( 'ig_es_after_broadcast_right_pan_settings' ); ?>
152
  </div>
140
  <div class="es_settings_right_pan">
141
  <div class="es_settings_field">
142
  <label><?php _e( 'Recipients', 'email-subscribers' ) ?><br/><select name="broadcast_data[list_ids]" id="ig_es_broadcast_list_ids"><?php echo $lists ?></select></label>
143
+ <span class="helper" id="ig_es_total_contacts"></span>
144
  </div>
145
  <hr>
146
  <div class="es_settings_field">
148
  <input class="es_secondary_btn" type="submit" id="ig_es_preview_broadcast" value="<?php _e( 'Preview this email in browser', 'email-subscribers' ) ?>">
149
  <input type="hidden" name="es_broadcast_preview" id="es_broadcast_preview">
150
  </label>
151
+
152
  </div>
153
  <?php do_action( 'ig_es_after_broadcast_right_pan_settings' ); ?>
154
  </div>
lite/includes/classes/class-es-tools.php CHANGED
@@ -38,8 +38,8 @@ class ES_Tools {
38
 
39
  $email = sanitize_email( ig_es_get_request_data( 'es_test_email' ) );
40
 
41
- $subject = ig_es_get_request_data( 'subject', '' );
42
- $content = ig_es_get_request_data( 'content', '' );
43
 
44
  if ( ! empty( $email ) ) {
45
 
38
 
39
  $email = sanitize_email( ig_es_get_request_data( 'es_test_email' ) );
40
 
41
+ $subject = ig_es_get_post_data( 'subject', '' );
42
+ $content = wp_kses_post(ig_es_get_request_data( 'content', '', false ));
43
 
44
  if ( ! empty( $email ) ) {
45
 
lite/includes/db/class-es-db-contacts.php CHANGED
@@ -325,21 +325,25 @@ class ES_DB_Contacts extends ES_DB {
325
  * @return bool|int
326
  *
327
  * @since 4.2.4
 
 
328
  */
329
  public function delete_contacts_by_ids( $ids = array() ) {
330
- global $wpdb;
331
 
332
  $ids = $this->prepare_for_in_query( $ids );
333
 
334
  $where = "id IN ($ids)";
335
 
336
- $this->delete_by_condition( $where );
337
 
338
- $ig_lists_contacts_table = IG_LISTS_CONTACTS_TABLE;
 
339
 
340
- $query = "DELETE FROM $ig_lists_contacts_table WHERE contact_id IN ($ids)";
 
 
 
341
 
342
- return $wpdb->query( $query );
343
  }
344
 
345
  /**
325
  * @return bool|int
326
  *
327
  * @since 4.2.4
328
+ *
329
+ * @modify 4.3.12
330
  */
331
  public function delete_contacts_by_ids( $ids = array() ) {
 
332
 
333
  $ids = $this->prepare_for_in_query( $ids );
334
 
335
  $where = "id IN ($ids)";
336
 
337
+ $delete = $this->delete_by_condition( $where );
338
 
339
+ if ( $delete ) {
340
+ $where = "contact_id IN ($ids)";
341
 
342
+ return ES()->lists_contacts_db->delete_by_condition( $where );
343
+ }
344
+
345
+ return false;
346
 
 
347
  }
348
 
349
  /**
lite/public/class-email-subscribers-public.php CHANGED
@@ -261,8 +261,8 @@ class Email_Subscribers_Public {
261
  $link = ES()->links_db->get_by_hash( $hash );
262
 
263
  if ( ! empty( $link ) ) {
264
- $campaign_id = ! empty( $data['campaign_id'] ) ? $data['campaign_id'] : 0;
265
- $message_id = ! empty( $data['message_id'] ) ? $data['message_id'] : 0;
266
  $contact_id = ! empty( $data['contact_id'] ) ? $data['contact_id'] : 0;
267
  $link_id = ! empty( $link['id'] ) ? $link['id'] : 0;
268
 
261
  $link = ES()->links_db->get_by_hash( $hash );
262
 
263
  if ( ! empty( $link ) ) {
264
+ $campaign_id = ! empty( $link['campaign_id'] ) ? $link['campaign_id'] : 0;
265
+ $message_id = ! empty( $link['message_id'] ) ? $link['message_id'] : 0;
266
  $contact_id = ! empty( $data['contact_id'] ) ? $data['contact_id'] : 0;
267
  $link_id = ! empty( $link['id'] ) ? $link['id'] : 0;
268
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Author URI: https://www.icegram.com/
5
  Tags: subscription, newsletter, email marketing, post notification, email newsletter form, email signup, email widget, newsletter signup, subscribe, subscription form, bulk emails, signup form, list builder, lead generation, welcome email, contacts
6
  Requires at least: 3.9
7
  Tested up to: 5.3.2
8
- Stable tag: 4.3.11
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses
11
 
@@ -257,6 +257,15 @@ Refer [here](https://www.icegram.com/documentation/es-faq/).
257
 
258
  == Changelog ==
259
 
 
 
 
 
 
 
 
 
 
260
  **4.3.11 (12.02.2020)**
261
 
262
  * New: Now, one can add consent checkbox in subscription form
5
  Tags: subscription, newsletter, email marketing, post notification, email newsletter form, email signup, email widget, newsletter signup, subscribe, subscription form, bulk emails, signup form, list builder, lead generation, welcome email, contacts
6
  Requires at least: 3.9
7
  Tested up to: 5.3.2
8
+ Stable tag: 4.3.12
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses
11
 
257
 
258
  == Changelog ==
259
 
260
+ **4.3.12 (17.02.2020)**
261
+
262
+ * Update: Added support for HTML in GDPR consent text
263
+ * Update: Now, contact will be deleted upon the deletion of WordPress user if WordPress sync is on.
264
+ * Update: Removed .SVG images from templates as it's blocked by Gmail
265
+ * Fix: Confirmation email did not go out if the subject is empty
266
+ * Fix: **{{LIST}}** keyword did not work in the welcome email
267
+ * Fix: Email Sending options was not saved properly
268
+
269
  **4.3.11 (12.02.2020)**
270
 
271
  * New: Now, one can add consent checkbox in subscription form