Email Subscribers & Newsletters - Version 4.3.6

Version Description

Download this release

Release Info

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

Code changes from version 4.3.5.1 to 4.3.6

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.5.1
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.5.1' );
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.6
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.6' );
115
  }
116
 
117
  // Plugin Folder Path.
lite/admin/class-email-subscribers-admin.php CHANGED
@@ -438,7 +438,7 @@ class Email_Subscribers_Admin {
438
  $icon_url = plugin_dir_url( __FILE__ ) . 'images/icon-64.png';
439
 
440
  $reviewurl = '?es_dismiss_admin_notice=1&option_name=star_notice_done';
441
- $nobugurl = '?es_dismiss_admin_notice=1&option_name=dismiss_star_notice';
442
 
443
  if ( ( $total_contacts >= 10 || $total_email_sent > 2 ) && 'yes' !== $star_rating_dismiss && 'yes' !== $star_rating_done ) {
444
 
@@ -460,7 +460,11 @@ class Email_Subscribers_Admin {
460
  'message' => __( 'Something went wrong', 'email-subscribers' )
461
  );
462
 
463
- $emails = ig_es_get_request_data( 'emails', array() );
 
 
 
 
464
  if ( is_array( $emails ) && count( $emails ) > 0 ) {
465
  $default_list = ES()->lists_db->get_list_by_name( IG_DEFAULT_LIST );
466
  $list_id = $default_list['id'];
438
  $icon_url = plugin_dir_url( __FILE__ ) . 'images/icon-64.png';
439
 
440
  $reviewurl = '?es_dismiss_admin_notice=1&option_name=star_notice_done';
441
+ $nobugurl = '?es_dismiss_admin_notice=1&option_name=dismiss_star_notice';
442
 
443
  if ( ( $total_contacts >= 10 || $total_email_sent > 2 ) && 'yes' !== $star_rating_dismiss && 'yes' !== $star_rating_done ) {
444
 
460
  'message' => __( 'Something went wrong', 'email-subscribers' )
461
  );
462
 
463
+ $emails = ig_es_get_request_data( 'emails', array() );
464
+ $es_from_name = ig_es_get_request_data( 'es_from_name', '' );
465
+ $es_from_email = ig_es_get_request_data( 'es_from_email', '' );
466
+ update_option( 'ig_es_from_name', $es_from_name );
467
+ update_option( 'ig_es_from_email', $es_from_email );
468
  if ( is_array( $emails ) && count( $emails ) > 0 ) {
469
  $default_list = ES()->lists_db->get_list_by_name( IG_DEFAULT_LIST );
470
  $list_id = $default_list['id'];
lite/admin/css/email-subscribers-admin.css CHANGED
@@ -936,7 +936,7 @@ h5.es-badge {
936
  max-width: 50em;
937
  overflow: hidden;
938
  padding: 2em 3em;
939
- height:40em;
940
  /*-webkit-transform: translate(0%,45%);*/
941
  -webkit-transform: translate(0%,7vw);
942
  transform: translate(0%,7vw);
936
  max-width: 50em;
937
  overflow: hidden;
938
  padding: 2em 3em;
939
+ height:50em;
940
  /*-webkit-transform: translate(0%,45%);*/
941
  -webkit-transform: translate(0%,7vw);
942
  transform: translate(0%,7vw);
lite/admin/js/es-onboarding.js CHANGED
@@ -16,12 +16,16 @@ jQuery(document).ready(function() {
16
  emails.push(jQuery(this).val());
17
  }
18
  });
 
 
19
  var params = {
20
  type: 'POST',
21
  url: ajaxurl,
22
  data: {
23
  action: 'send_test_email',
24
- emails: emails
 
 
25
  },
26
  dataType: 'json',
27
  success: function(data, status, xhr) {
16
  emails.push(jQuery(this).val());
17
  }
18
  });
19
+ var es_from_name = jQuery('.es_from_name').val();
20
+ var es_from_email = jQuery('.es_from_email').val();
21
  var params = {
22
  type: 'POST',
23
  url: ajaxurl,
24
  data: {
25
  action: 'send_test_email',
26
+ emails: emails,
27
+ es_from_name: es_from_name,
28
+ es_from_email: es_from_email
29
  },
30
  dataType: 'json',
31
  success: function(data, status, xhr) {
lite/admin/partials/onboarding.php CHANGED
@@ -1,6 +1,8 @@
1
  <div id="slider-wrapper">
2
  <div id="slider">
3
  <div class="sp es-send-email-screen" >
 
 
4
  <h1> 👍 <?php _e('80% done!'); ?></h1>
5
  <strong><?php _e('We automatically:'); ?></strong>
6
  <ol>
@@ -12,8 +14,12 @@
12
  <div class="es-form-wrapper">
13
  <div class="es-form-next"style="padding: 0.5em 0.8em; border-radius: 3px;">
14
  <?php _e(' We will create "<strong>Newsletter Broadcast</strong>" and "<strong>New Post Notification</strong>" campaigns. Next step is to test everything by <strong>sending test campaigns</strong>.<br />We\'ve already added you, but recommend adding another email to test.', 'email-subscribers'); ?>
 
15
  </div>
16
  <form id="es-send-email-form">
 
 
 
17
  <label><strong><?php _e('Add an email to send a test to:', 'email-subscribers'); ?></strong></label><br/>
18
  <input type="email" placeholder="abc@gmail.com" name="es_test_email[]" class="es_email" required style="padding: 0.6em 0.5em; border: 1px solid #dcdcdc; "/>
19
  <a id="button-send" class="button-send"><?php _e('Create and Send test camapigns', 'email-subscribers');?></a>
1
  <div id="slider-wrapper">
2
  <div id="slider">
3
  <div class="sp es-send-email-screen" >
4
+ <?php $from_name = get_option( 'ig_es_from_name');?>
5
+ <?php $from_email = get_option( 'ig_es_from_email');?>
6
  <h1> 👍 <?php _e('80% done!'); ?></h1>
7
  <strong><?php _e('We automatically:'); ?></strong>
8
  <ol>
14
  <div class="es-form-wrapper">
15
  <div class="es-form-next"style="padding: 0.5em 0.8em; border-radius: 3px;">
16
  <?php _e(' We will create "<strong>Newsletter Broadcast</strong>" and "<strong>New Post Notification</strong>" campaigns. Next step is to test everything by <strong>sending test campaigns</strong>.<br />We\'ve already added you, but recommend adding another email to test.', 'email-subscribers'); ?>
17
+ <br/><?php _e('But before test <strong>verify your sender details</strong>', 'email-subscribers'); ?>
18
  </div>
19
  <form id="es-send-email-form">
20
+ <label><strong><?php _e('Sender', 'email-subscribers'); ?></strong></label><br/>
21
+ <input type="text" name="es_from_name" class="es_from_name" value="<?php echo $from_name; ?>" required style="padding: 0.6em 0.5em; border: 1px solid #dcdcdc; "/>
22
+ <input type="email" name="es_from_email" class="es_from_email" value="<?php echo $from_email; ?>"required style="padding: 0.6em 0.5em; border: 1px solid #dcdcdc; "/><br/>
23
  <label><strong><?php _e('Add an email to send a test to:', 'email-subscribers'); ?></strong></label><br/>
24
  <input type="email" placeholder="abc@gmail.com" name="es_test_email[]" class="es_email" required style="padding: 0.6em 0.5em; border: 1px solid #dcdcdc; "/>
25
  <a id="button-send" class="button-send"><?php _e('Create and Send test camapigns', 'email-subscribers');?></a>
lite/includes/class-email-subscribers.php CHANGED
@@ -863,7 +863,10 @@ if ( ! class_exists( 'Email_Subscribers' ) ) {
863
  $plugin = 'email-subscribers-newsletters-starter';
864
  $event_prefix = 'esstarter.';
865
  }
 
 
866
  $ig_es_feedback = new $ig_es_feedback_class( $name, $plugin, $plugin_abbr, $event_prefix, false );
 
867
  $ig_es_feedback->render_deactivate_feedback();
868
  }
869
 
863
  $plugin = 'email-subscribers-newsletters-starter';
864
  $event_prefix = 'esstarter.';
865
  }
866
+
867
+
868
  $ig_es_feedback = new $ig_es_feedback_class( $name, $plugin, $plugin_abbr, $event_prefix, false );
869
+
870
  $ig_es_feedback->render_deactivate_feedback();
871
  }
872
 
lite/includes/class-es-install.php CHANGED
@@ -229,6 +229,9 @@ if ( ! class_exists( 'ES_Install' ) ) {
229
 
230
  self::install();
231
  }
 
 
 
232
  }
233
 
234
  /**
@@ -270,6 +273,7 @@ if ( ! class_exists( 'ES_Install' ) ) {
270
  */
271
  public static function install() {
272
 
 
273
  if ( ! is_blog_installed() ) {
274
  self::$logger->error( 'Blog is not installed.', self::$logger_context );
275
 
@@ -630,6 +634,42 @@ if ( ! class_exists( 'ES_Install' ) ) {
630
  }
631
  }
632
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
633
  /**
634
  * Get default options
635
  *
@@ -650,9 +690,7 @@ if ( ! class_exists( 'ES_Install' ) ) {
650
  $latest_db_version => ig_get_current_date_time()
651
  );
652
 
653
- if ( $admin_email == "" ) {
654
- $admin_email = "support@icegram.com";
655
- }
656
 
657
  $home_url = home_url( '/' );
658
  $optinlink = $home_url . "?es=optin&db={{DBID}}&email={{EMAIL}}&guid={{GUID}}";
@@ -688,8 +726,8 @@ if ( ! class_exists( 'ES_Install' ) ) {
688
  $unsubscribe_error_message = "Urrgh.. Something's wrong..\r\n\r\nAre you sure that email address is on our file? There was some problem in completing your request.\r\n\r\nPlease try again after some time - or contact us if the problem persists.\r\n\r\n";
689
 
690
  $options = array(
691
- 'ig_es_from_name' => array( 'default' => $blogname, 'old_option' => 'ig_es_fromname' ),
692
- 'ig_es_from_email' => array( 'default' => $admin_email, 'old_option' => 'ig_es_fromemail' ),
693
  'ig_es_admin_new_contact_email_subject' => array( 'default' => $new_contact_email_subject, 'old_option' => 'ig_es_admin_new_sub_subject' ),
694
  'ig_es_admin_new_contact_email_content' => array( 'default' => $new_contact_email_content, 'old_option' => 'ig_es_admin_new_sub_content' ),
695
  'ig_es_admin_emails' => array( 'default' => $admin_email, 'old_option' => 'ig_es_adminemail' ),
@@ -1473,43 +1511,59 @@ if ( ! class_exists( 'ES_Install' ) ) {
1473
  *
1474
  * @since 4.3.2
1475
  */
1476
- public static function load_templates() {
1477
  //TODO :: Add template with custom post type
1478
  global $wpdb;
1479
 
1480
- $templates = array();
1481
- $templates = apply_filters( 'ig_es_email_templates', $templates );
 
 
 
 
1482
 
1483
- $prefix = $wpdb->prefix;
1484
- $sSql = "SELECT post_name FROM `" . $prefix . "posts` where post_type = 'es_template'";
1485
- $imported_templ = $wpdb->get_col( $sSql );
1486
 
1487
- if ( is_array( $templates ) && count( $templates ) > 0 ) {
1488
 
1489
- foreach ( $templates as $slug => $template ) {
1490
- if ( in_array( $slug, $imported_templ ) ) {
1491
- continue;
1492
- }
1493
 
1494
- $es_post = array(
1495
- 'post_title' => wp_strip_all_tags( $template['es_templ_heading'] ),
1496
- 'post_content' => $template['es_templ_body'],
1497
- 'post_status' => 'publish',
1498
- 'post_type' => 'es_template',
1499
- 'post_name' => $slug,
1500
- 'meta_input' => array(
1501
- 'es_template_type' => $template['es_email_type'],
1502
- 'es_custom_css' => $template['es_custom_css']
1503
- )
1504
- );
1505
- // Insert the post into the database
1506
- $last_inserted_id = wp_insert_post( $es_post );
1507
 
1508
- // Generate Featured Image
1509
- self::es_generate_featured_image( $template['es_thumbnail'], $last_inserted_id );
1510
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1511
  }
 
 
1512
  }
 
 
1513
  }
1514
 
1515
  /**
229
 
230
  self::install();
231
  }
232
+
233
+ // Do we need to load templates?
234
+ self::load_templates();
235
  }
236
 
237
  /**
273
  */
274
  public static function install() {
275
 
276
+
277
  if ( ! is_blog_installed() ) {
278
  self::$logger->error( 'Blog is not installed.', self::$logger_context );
279
 
634
  }
635
  }
636
 
637
+ /**
638
+ * Get sender details to set in from email and name
639
+ *
640
+ * @return array
641
+ *
642
+ * @since 4.3.6
643
+ */
644
+ public static function get_sender_details() {
645
+ global $ig_es_tracker;
646
+ $active_plugins = $ig_es_tracker::get_active_plugins();
647
+ $sender_details = array();
648
+ $admin_email = get_option( 'admin_email', '' );
649
+ $blog_name = get_option( 'blogname', '' );
650
+
651
+ if ( $admin_email == "" ) {
652
+ $admin_email = "support@icegram.com";
653
+ }
654
+
655
+ $sender_details['name'] = $blog_name;
656
+ $sender_details['email'] = $admin_email;
657
+
658
+ //check if installed WP Mail SMTP
659
+ if ( in_array( 'wp-mail-smtp/wp_mail_smtp.php', $active_plugins ) ) {
660
+ $wp_mail_smtp_settings = get_option( 'wp_mail_smtp', array() );
661
+
662
+ $mail_settings = ig_es_get_data( $wp_mail_smtp_settings, 'mail', array() );
663
+
664
+ if ( ! empty( $mail_settings ) ) {
665
+ $sender_details['name'] = ! empty( $mail_settings['from_name'] ) ? $mail_settings['from_name'] : $sender_details['name'];
666
+ $sender_details['email'] = ! empty( $mail_settings['from_email'] ) ? $mail_settings['from_email'] : $sender_details['email'];
667
+ }
668
+ }
669
+
670
+ return $sender_details;
671
+ }
672
+
673
  /**
674
  * Get default options
675
  *
690
  $latest_db_version => ig_get_current_date_time()
691
  );
692
 
693
+ $sender_details = self::get_sender_details();
 
 
694
 
695
  $home_url = home_url( '/' );
696
  $optinlink = $home_url . "?es=optin&db={{DBID}}&email={{EMAIL}}&guid={{GUID}}";
726
  $unsubscribe_error_message = "Urrgh.. Something's wrong..\r\n\r\nAre you sure that email address is on our file? There was some problem in completing your request.\r\n\r\nPlease try again after some time - or contact us if the problem persists.\r\n\r\n";
727
 
728
  $options = array(
729
+ 'ig_es_from_name' => array( 'default' => $sender_details['name'], 'old_option' => 'ig_es_fromname' ),
730
+ 'ig_es_from_email' => array( 'default' => $sender_details['email'], 'old_option' => 'ig_es_fromemail' ),
731
  'ig_es_admin_new_contact_email_subject' => array( 'default' => $new_contact_email_subject, 'old_option' => 'ig_es_admin_new_sub_subject' ),
732
  'ig_es_admin_new_contact_email_content' => array( 'default' => $new_contact_email_content, 'old_option' => 'ig_es_admin_new_sub_content' ),
733
  'ig_es_admin_emails' => array( 'default' => $admin_email, 'old_option' => 'ig_es_adminemail' ),
1511
  *
1512
  * @since 4.3.2
1513
  */
1514
+ public static function load_templates( $force = false ) {
1515
  //TODO :: Add template with custom post type
1516
  global $wpdb;
1517
 
1518
+ $plan = 'lite';
1519
+ if ( ES()->is_pro() ) {
1520
+ $plan = 'pro';
1521
+ } elseif ( ES()->is_starter() ) {
1522
+ $plan = 'starter';
1523
+ }
1524
 
1525
+ $templates_loaded_for = get_option( 'ig_es_templates_loaded_for', '' );
 
 
1526
 
1527
+ if ( $force || ( $plan !== $templates_loaded_for ) ) {
1528
 
1529
+ $templates = array();
1530
+ $templates = apply_filters( 'ig_es_email_templates', $templates );
 
 
1531
 
1532
+ $sSql = "SELECT post_name FROM {$wpdb->prefix}posts where post_type = 'es_template'";
1533
+
1534
+ $imported_templ = $wpdb->get_col( $sSql );
 
 
 
 
 
 
 
 
 
 
1535
 
1536
+ if ( is_array( $templates ) && count( $templates ) > 0 ) {
 
1537
 
1538
+ foreach ( $templates as $slug => $template ) {
1539
+ if ( in_array( $slug, $imported_templ ) ) {
1540
+ continue;
1541
+ }
1542
+
1543
+ $es_post = array(
1544
+ 'post_title' => wp_strip_all_tags( $template['es_templ_heading'] ),
1545
+ 'post_content' => $template['es_templ_body'],
1546
+ 'post_status' => 'publish',
1547
+ 'post_type' => 'es_template',
1548
+ 'post_name' => $slug,
1549
+ 'meta_input' => array(
1550
+ 'es_template_type' => $template['es_email_type'],
1551
+ 'es_custom_css' => $template['es_custom_css']
1552
+ )
1553
+ );
1554
+ // Insert the post into the database
1555
+ $last_inserted_id = wp_insert_post( $es_post );
1556
+
1557
+ // Generate Featured Image
1558
+ self::es_generate_featured_image( $template['es_thumbnail'], $last_inserted_id );
1559
+
1560
+ }
1561
  }
1562
+
1563
+ update_option( 'ig_es_templates_loaded_for', $plan );
1564
  }
1565
+
1566
+
1567
  }
1568
 
1569
  /**
lite/includes/classes/class-es-export-subscribers.php CHANGED
@@ -164,23 +164,23 @@ class Export_Subscribers {
164
 
165
  switch ( $status ) {
166
  case 'all':
167
- $sql = "SELECT COUNT(*) FROM " . IG_LISTS_CONTACTS_TABLE;
168
  break;
169
 
170
  case 'subscribed':
171
- $sql = $wpdb->prepare( "SELECT COUNT(*) FROM " . IG_LISTS_CONTACTS_TABLE . " WHERE status = %s", 'subscribed' );
172
  break;
173
 
174
  case 'unsubscribed':
175
- $sql = $wpdb->prepare( "SELECT COUNT(email) FROM " . IG_CONTACTS_TABLE . " WHERE status = %s", 'unsubscribed' );
176
  break;
177
 
178
  case 'confirmed':
179
- $sql = $wpdb->prepare( "SELECT COUNT(*) FROM " . IG_LISTS_CONTACTS_TABLE . " WHERE status = %s AND optin_type = %d", 'subscribed', IG_DOUBLE_OPTIN );
180
  break;
181
 
182
  case 'unconfirmed':
183
- $sql = $wpdb->prepare( "SELECT count(contact_id) FROM " . IG_LISTS_CONTACTS_TABLE . " WHERE status = %s", 'unconfirmed' );
184
  break;
185
 
186
  case 'select_list':
@@ -189,7 +189,6 @@ class Export_Subscribers {
189
  break;
190
  }
191
 
192
- return $wpdb->get_var( $sql );
193
  }
194
 
195
 
@@ -237,7 +236,7 @@ class Export_Subscribers {
237
  *
238
  * @return string
239
  */
240
- public function generate_csv( $status = 'all', $list_id = '' ) {
241
 
242
  global $wpdb;
243
 
@@ -245,27 +244,24 @@ class Export_Subscribers {
245
  set_time_limit( IG_SET_TIME_LIMIT );
246
 
247
  $email_subscribe_table = IG_CONTACTS_TABLE;
248
- $contact_lists_table = IG_LISTS_CONTACTS_TABLE;
249
 
 
250
  if ( 'all' === $status ) {
251
- $query = "SELECT * FROM " . IG_LISTS_CONTACTS_TABLE;
252
  } elseif ( 'subscribed' === $status ) {
253
- $query = $wpdb->prepare( "SELECT * FROM {$contact_lists_table} WHERE status = %s", 'subscribed' );
254
  } elseif ( 'unsubscribed' === $status ) {
255
- $query = $wpdb->prepare( "SELECT * FROM {$contact_lists_table} WHERE status = %s", 'unsubscribed' );
256
  } elseif ( 'confirmed' === $status ) {
257
- $query = $wpdb->prepare( "SELECT * FROM {$contact_lists_table} WHERE status = %s AND optin_type = %d ", 'subscribed', IG_DOUBLE_OPTIN );
258
  } elseif ( 'unconfirmed' === $status ) {
259
- $query = $wpdb->prepare( "SELECT * FROM {$contact_lists_table} WHERE status = %s", 'unconfirmed' );
260
  } elseif ( 'select_list' === $status ) {
261
- $query = $wpdb->prepare( "SELECT * FROM {$contact_lists_table} WHERE list_id = %d ", $list_id );
262
- } else {
263
- // If nothing comes, export only 10 contacts
264
- $query = "SELECT * FROM " . IG_LISTS_CONTACTS_TABLE . " LIMIT 0, 10";
265
  }
266
 
267
  $subscribers = array();
268
- $results = $wpdb->get_results( $query, ARRAY_A );
269
 
270
  if ( count( $results ) > 0 ) {
271
  $contact_list_map = array();
164
 
165
  switch ( $status ) {
166
  case 'all':
167
+ return ES()->lists_contacts_db->get_all_contacts_count( 0, false );
168
  break;
169
 
170
  case 'subscribed':
171
+ return ES()->lists_contacts_db->get_subscribed_contacts_count( 0, false );
172
  break;
173
 
174
  case 'unsubscribed':
175
+ return ES()->lists_contacts_db->get_unsubscribed_contacts_count( 0, false );
176
  break;
177
 
178
  case 'confirmed':
179
+ return ES()->lists_contacts_db->get_confirmed_contacts_count( 0, false );
180
  break;
181
 
182
  case 'unconfirmed':
183
+ return ES()->lists_contacts_db->get_unconfirmed_contacts_count( 0, false );
184
  break;
185
 
186
  case 'select_list':
189
  break;
190
  }
191
 
 
192
  }
193
 
194
 
236
  *
237
  * @return string
238
  */
239
+ public function generate_csv( $status = 'all', $list_id = 0 ) {
240
 
241
  global $wpdb;
242
 
244
  set_time_limit( IG_SET_TIME_LIMIT );
245
 
246
  $email_subscribe_table = IG_CONTACTS_TABLE;
 
247
 
248
+ $results = array();
249
  if ( 'all' === $status ) {
250
+ $results = ES()->lists_contacts_db->get_all_contacts();
251
  } elseif ( 'subscribed' === $status ) {
252
+ $results = ES()->lists_contacts_db->get_all_subscribed_contacts();
253
  } elseif ( 'unsubscribed' === $status ) {
254
+ $results = ES()->lists_contacts_db->get_all_unsubscribed_contacts();
255
  } elseif ( 'confirmed' === $status ) {
256
+ $results = ES()->lists_contacts_db->get_all_confirmed_contacts();
257
  } elseif ( 'unconfirmed' === $status ) {
258
+ $results = ES()->lists_contacts_db->get_all_unconfirmed_contacts();
259
  } elseif ( 'select_list' === $status ) {
260
+ $list_id = absint( $list_id );
261
+ $results = ES()->lists_contacts_db->get_all_contacts_from_list( $list_id );
 
 
262
  }
263
 
264
  $subscribers = array();
 
265
 
266
  if ( count( $results ) > 0 ) {
267
  $contact_list_map = array();
lite/includes/classes/class-es-forms-table.php CHANGED
@@ -383,10 +383,14 @@ class ES_Forms_Table extends WP_List_Table {
383
  $status = 'error';
384
  ES_Common::show_message( $message, $status );
385
  }
386
- $url = 'https://www.icegram.com/email-subscribers-starter/?utm_source=in_app&utm_medium=es_form_captcha&utm_campaign=es_upsale';
387
- ?>
388
- <div style=" background-image: linear-gradient(-100deg, rgba(250, 247, 133, 0.4), rgba(250, 247, 133, 0.8) 95%, rgba(250, 247, 133, 0.2)); padding: 10px; width: 35%; border-radius: 1em 0 1em 0; "><?php echo sprintf( __( 'Secure your form and avoid spam signups with Email Subscribers Starter Plan <a target="_blank" style="font-weight: bold; cursor:pointer; text-decoration:none" href="%s">Get started</a>',
389
- 'email-subscribers' ), $url ) ?></div>
 
 
 
 
390
  </form>
391
  </div>
392
  </div>
@@ -726,17 +730,17 @@ class ES_Forms_Table extends WP_List_Table {
726
  }
727
 
728
  /**
729
- * Prepare search box
730
- *
731
  * @param string $text
732
  * @param string $input_id
733
- *
734
- * @since 4.0.0
735
- * @since 4.3.4 Added esc_attr()
736
  */
737
  public function search_box( $text, $input_id ) { ?>
738
  <p class="search-box">
739
- <label class="screen-reader-text" for="<?php echo esc_attr($input_id); ?>"><?php echo esc_attr($text); ?>:</label>
740
  <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/>
741
  <?php submit_button( __( 'Search Forms', 'email-subscribers' ), 'button', false, false, array( 'id' => 'search-submit' ) ); ?>
742
  </p>
383
  $status = 'error';
384
  ES_Common::show_message( $message, $status );
385
  }
386
+
387
+ if ( ! ES()->is_starter() ) {
388
+
389
+ $url = 'https://www.icegram.com/email-subscribers-starter/?utm_source=in_app&utm_medium=es_form_captcha&utm_campaign=es_upsale';
390
+ ?>
391
+ <div style=" background-image: linear-gradient(-100deg, rgba(250, 247, 133, 0.4), rgba(250, 247, 133, 0.8) 95%, rgba(250, 247, 133, 0.2)); padding: 10px; width: 35%; border-radius: 1em 0 1em 0; "><?php echo sprintf( __( 'Secure your form and avoid spam signups with Email Subscribers Starter Plan <a target="_blank" style="font-weight: bold; cursor:pointer; text-decoration:none" href="%s">Get started</a>',
392
+ 'email-subscribers' ), $url ) ?></div>
393
+ <?php } ?>
394
  </form>
395
  </div>
396
  </div>
730
  }
731
 
732
  /**
733
+ * Prepare search box
734
+ *
735
  * @param string $text
736
  * @param string $input_id
737
+ *
738
+ * @since 4.0.0
739
+ * @since 4.3.4 Added esc_attr()
740
  */
741
  public function search_box( $text, $input_id ) { ?>
742
  <p class="search-box">
743
+ <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_attr( $text ); ?>:</label>
744
  <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/>
745
  <?php submit_button( __( 'Search Forms', 'email-subscribers' ), 'button', false, false, array( 'id' => 'search-submit' ) ); ?>
746
  </p>
lite/includes/classes/class-es-handle-post-notification.php CHANGED
@@ -74,7 +74,8 @@ class ES_Handle_Post_Notification {
74
 
75
  if ( ! empty( $post_id ) ) {
76
 
77
- $notifications = ES_DB_Notifications::get_notifications_by_post_id( $post_id );
 
78
  if ( count( $notifications ) > 0 ) {
79
  $existing_contacts = array();
80
  foreach ( $notifications as $notification ) {
@@ -143,9 +144,7 @@ class ES_Handle_Post_Notification {
143
  $delivery_data['campaign_id'] = $notification['id'];
144
  $delivery_data['mailing_queue_id'] = $insert;
145
  ES_DB_Sending_Queue::do_batch_insert( $delivery_data );
146
-
147
  }
148
-
149
  }
150
  }
151
  }
74
 
75
  if ( ! empty( $post_id ) ) {
76
 
77
+ $notifications = ES()->campaigns_db->get_campaigns_by_post_id( $post_id );
78
+
79
  if ( count( $notifications ) > 0 ) {
80
  $existing_contacts = array();
81
  foreach ( $notifications as $notification ) {
144
  $delivery_data['campaign_id'] = $notification['id'];
145
  $delivery_data['mailing_queue_id'] = $insert;
146
  ES_DB_Sending_Queue::do_batch_insert( $delivery_data );
 
147
  }
 
148
  }
149
  }
150
  }
lite/includes/classes/class-es-import-subscribers.php CHANGED
@@ -40,7 +40,7 @@ class ES_Import_Subscribers {
40
  $tmp_file = $_FILES["file"]["tmp_name"];
41
  $file = $_FILES['file']['name'];
42
 
43
- $ext = substr( $file, strrpos( $file, "." ), ( strlen( $file ) - strrpos( $file, "." ) ) );
44
 
45
  if ( $ext == ".csv" ) {
46
 
40
  $tmp_file = $_FILES["file"]["tmp_name"];
41
  $file = $_FILES['file']['name'];
42
 
43
+ $ext = strtolower( substr( $file, strrpos( $file, "." ), ( strlen( $file ) - strrpos( $file, "." ) ) ) );
44
 
45
  if ( $ext == ".csv" ) {
46
 
lite/includes/classes/class-es-lists-table.php CHANGED
@@ -264,7 +264,7 @@ class ES_Lists_Table extends WP_List_Table {
264
  <form method="post" action="admin.php?page=es_lists&action=<?php echo $action; ?>&list=<?php echo $id; ?>&_wpnonce=<?php echo $nonce; ?>">
265
  <div class="row-blog">
266
  <label><?php _e( 'Name', 'email-subscribers' ); ?>: </label>
267
- <input type="text" id="name" name="list_name" value="<?php echo esc_attr($list_name); ?>"/>
268
  </div>
269
  <input type="hidden" name="submitted" value="submitted"/>
270
  <div class="row-blog"><?php submit_button(); ?></div>
@@ -402,13 +402,31 @@ class ES_Lists_Table extends WP_List_Table {
402
  public function column_default( $item, $column_name ) {
403
 
404
  switch ( $column_name ) {
405
- case 'active_contacts':
406
  $count = ES()->lists_contacts_db->get_total_count_by_list( $item['id'], 'subscribed' );
407
  if ( $count > 0 ) {
408
  $url = admin_url( 'admin.php?page=es_subscribers&filter_by_status=subscribed&filter_by_list_id=' . $item['id'] );
409
  $count = sprintf( __( '<a href="%s" target="_blank">%d</a>', 'email-subscribers' ), $url, $count );
410
  }
411
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
412
  return $count;
413
  break;
414
  case 'all_contacts':
@@ -475,16 +493,19 @@ class ES_Lists_Table extends WP_List_Table {
475
  * @return array
476
  */
477
  function get_columns() {
 
478
  $columns = array(
479
- 'cb' => '<input type="checkbox" />',
480
- 'name' => __( 'Name', 'email-subscribers' ),
481
- 'active_contacts' => __( 'Active Contacts', 'email-subscribers' ),
482
- 'all_contacts' => __( 'All Contacts', 'email-subscribers' ),
483
- 'created_at' => __( 'Created', 'email-subscribers' ),
484
- 'export' => __( 'Export', 'email-subscribers' )
 
 
485
  );
486
 
487
- return $columns;
488
  }
489
 
490
 
@@ -516,17 +537,17 @@ class ES_Lists_Table extends WP_List_Table {
516
  }
517
 
518
  /**
519
- * Prepare search box
520
- *
521
  * @param string $text
522
  * @param string $input_id
523
- *
524
- * @since 4.0.0
525
- * @since 4.3.4 Added esc_attr()
526
  */
527
- public function search_box( $text = '', $input_id = '') { ?>
528
  <p class="search-box">
529
- <label class="screen-reader-text" for="<?php echo esc_attr($input_id); ?>"><?php echo esc_attr($text); ?>:</label>
530
  <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/>
531
  <?php submit_button( __( 'Search Lists', 'email-subscribers' ), 'button', false, false, array( 'id' => 'search-submit' ) ); ?>
532
  </p>
264
  <form method="post" action="admin.php?page=es_lists&action=<?php echo $action; ?>&list=<?php echo $id; ?>&_wpnonce=<?php echo $nonce; ?>">
265
  <div class="row-blog">
266
  <label><?php _e( 'Name', 'email-subscribers' ); ?>: </label>
267
+ <input type="text" id="name" name="list_name" value="<?php echo esc_attr( $list_name ); ?>"/>
268
  </div>
269
  <input type="hidden" name="submitted" value="submitted"/>
270
  <div class="row-blog"><?php submit_button(); ?></div>
402
  public function column_default( $item, $column_name ) {
403
 
404
  switch ( $column_name ) {
405
+ case 'subscribed':
406
  $count = ES()->lists_contacts_db->get_total_count_by_list( $item['id'], 'subscribed' );
407
  if ( $count > 0 ) {
408
  $url = admin_url( 'admin.php?page=es_subscribers&filter_by_status=subscribed&filter_by_list_id=' . $item['id'] );
409
  $count = sprintf( __( '<a href="%s" target="_blank">%d</a>', 'email-subscribers' ), $url, $count );
410
  }
411
 
412
+ return $count;
413
+ break;
414
+ case 'unsubscribed':
415
+ $count = ES()->lists_contacts_db->get_total_count_by_list( $item['id'], 'unsubscribed' );
416
+ if ( $count > 0 ) {
417
+ $url = admin_url( 'admin.php?page=es_subscribers&filter_by_status=unsubscribed&filter_by_list_id=' . $item['id'] );
418
+ $count = sprintf( __( '<a href="%s" target="_blank">%d</a>', 'email-subscribers' ), $url, $count );
419
+ }
420
+
421
+ return $count;
422
+ break;
423
+ case 'unconfirmed':
424
+ $count = ES()->lists_contacts_db->get_total_count_by_list( $item['id'], 'unconfirmed' );
425
+ if ( $count > 0 ) {
426
+ $url = admin_url( 'admin.php?page=es_subscribers&filter_by_status=unconfirmed&filter_by_list_id=' . $item['id'] );
427
+ $count = sprintf( __( '<a href="%s" target="_blank">%d</a>', 'email-subscribers' ), $url, $count );
428
+ }
429
+
430
  return $count;
431
  break;
432
  case 'all_contacts':
493
  * @return array
494
  */
495
  function get_columns() {
496
+
497
  $columns = array(
498
+ 'cb' => '<input type="checkbox" />',
499
+ 'name' => __( 'Name', 'email-subscribers' ),
500
+ 'subscribed' => __( 'Subscribed', 'email-subscribers' ),
501
+ 'unsubscribed' => __( 'Unsubscribed', 'email-subscribers' ),
502
+ 'unconfirmed' => __( 'Unconfirmed', 'email-subscribers' ),
503
+ 'all_contacts' => __( 'All Contacts', 'email-subscribers' ),
504
+ 'created_at' => __( 'Created', 'email-subscribers' ),
505
+ 'export' => __( 'Export', 'email-subscribers' )
506
  );
507
 
508
+ return apply_filters( 'ig_es_lists_columns', $columns );
509
  }
510
 
511
 
537
  }
538
 
539
  /**
540
+ * Prepare search box
541
+ *
542
  * @param string $text
543
  * @param string $input_id
544
+ *
545
+ * @since 4.0.0
546
+ * @since 4.3.4 Added esc_attr()
547
  */
548
+ public function search_box( $text = '', $input_id = '' ) { ?>
549
  <p class="search-box">
550
+ <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_attr( $text ); ?>:</label>
551
  <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/>
552
  <?php submit_button( __( 'Search Lists', 'email-subscribers' ), 'button', false, false, array( 'id' => 'search-submit' ) ); ?>
553
  </p>
lite/includes/classes/class-es-reports-data.php CHANGED
@@ -33,9 +33,10 @@ if ( ! class_exists( 'ES_Reports_Data' ) ) {
33
  * @since 4.3.2
34
  * @since 4.3.5 Modified ES_DB_Lists_Contacts::get_total_subscribed_contacts to
35
  * ES()->lists_contacts_db->get_total_subscribed_contacts
 
36
  */
37
  public static function get_total_subscribed_contacts( $days = 0 ) {
38
- return ES()->lists_contacts_db->get_total_subscribed_contacts( $days );
39
  }
40
 
41
  /**
@@ -48,9 +49,10 @@ if ( ! class_exists( 'ES_Reports_Data' ) ) {
48
  * @since 4.3.2
49
  * @since 4.3.5 Modified ES_DB_Lists_Contacts::get_total_unsubscribed_contacts to
50
  * ES()->lists_contacts_db->get_total_unsubscribed_contacts
 
51
  */
52
  public static function get_total_unsubscribed_contacts( $days = 0 ) {
53
- return ES()->lists_contacts_db->get_total_unsubscribed_contacts( $days );
54
  }
55
 
56
  /**
33
  * @since 4.3.2
34
  * @since 4.3.5 Modified ES_DB_Lists_Contacts::get_total_subscribed_contacts to
35
  * ES()->lists_contacts_db->get_total_subscribed_contacts
36
+ * @since 4.3.6 Modified function name from get_subscribed_contacts_count to get_subscribed_contacts_count
37
  */
38
  public static function get_total_subscribed_contacts( $days = 0 ) {
39
+ return ES()->lists_contacts_db->get_subscribed_contacts_count( $days );
40
  }
41
 
42
  /**
49
  * @since 4.3.2
50
  * @since 4.3.5 Modified ES_DB_Lists_Contacts::get_total_unsubscribed_contacts to
51
  * ES()->lists_contacts_db->get_total_unsubscribed_contacts
52
+ * @since 4.3.6 Modified function name from get_total_unsubscribed_contacts to get_unsubscribed_contacts_count
53
  */
54
  public static function get_total_unsubscribed_contacts( $days = 0 ) {
55
+ return ES()->lists_contacts_db->get_unsubscribed_contacts_count( $days );
56
  }
57
 
58
  /**
lite/includes/db/class-es-db-campaigns.php CHANGED
@@ -605,7 +605,63 @@ class ES_DB_Campaigns extends ES_DB {
605
  return array();
606
  }
607
 
608
- return $this->get_column_by('id', 'parent_id', $parent_campaign_id, false);
609
  }
610
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
611
  }
605
  return array();
606
  }
607
 
608
+ return $this->get_column_by( 'id', 'parent_id', $parent_campaign_id, false );
609
  }
610
 
611
+ /**
612
+ * Get Post Notifications (Campaigns) based on post_id
613
+ *
614
+ * @param int $post_id
615
+ *
616
+ * @return array|object|null
617
+ *
618
+ * @since 4.3.6
619
+ */
620
+ public function get_campaigns_by_post_id( $post_id = 0 ) {
621
+
622
+ global $wpdb;
623
+
624
+ $campaigns = array();
625
+
626
+ if ( $post_id > 0 ) {
627
+ $post_type = get_post_type( $post_id );
628
+
629
+ $where = $wpdb->prepare( "status = %d AND type = %s AND (deleted_at IS NULL OR deleted_at = '0000-00-00 00:00:00')", 1, 'post_notification' );
630
+
631
+ if ( "post" === $post_type ) {
632
+ $categories = get_the_category( $post_id );
633
+ $total_categories = count( $categories );
634
+ if ( $total_categories > 0 ) {
635
+ for ( $i = 0; $i < $total_categories; $i ++ ) {
636
+ if ( $i == 0 ) {
637
+ $where .= " and (";
638
+ } else {
639
+ $where .= " or";
640
+ }
641
+
642
+ $category_str = ES_Common::prepare_category_string( $categories[ $i ]->term_id );
643
+
644
+ $where .= " categories LIKE '%" . $category_str . "%'";
645
+ if ( $i == ( $total_categories - 1 ) ) {
646
+ $where .= " OR categories LIKE '%all%'";
647
+ $where .= ")";
648
+ }
649
+ }
650
+ } else {
651
+ //no categories fround for post
652
+ return $campaigns;
653
+ }
654
+ } else {
655
+ $post_type = ES_Common::prepare_custom_post_type_string( $post_type );
656
+ $where .= " and categories LIKE '%" . wp_specialchars_decode( addslashes( $post_type ) ) . "%'";
657
+ }
658
+
659
+ $campaigns = $this->get_by_conditions( $where, ARRAY_A );
660
+ }
661
+
662
+ return $campaigns;
663
+
664
+ }
665
+
666
+
667
  }
lite/includes/db/class-es-db-lists-contacts.php CHANGED
@@ -491,22 +491,13 @@ class ES_DB_Lists_Contacts extends ES_DB {
491
  * @since 4.3.5 Removed static call
492
  */
493
  public function get_total_count_by_list( $list_id = 0, $status = 'subscribed' ) {
494
- global $wpdb;
495
 
496
- $list_id = esc_sql( $list_id );
497
- $status = esc_sql( $status );
498
-
499
- $where = "list_id = %d";
500
- if ( ! empty( $status ) ) {
501
- $where .= " AND status = %s";
502
- if ( 'confirmed' === $status ) {
503
- $where .= " AND optin_type = 2";
504
- }
505
  }
506
 
507
- $where = $wpdb->prepare( $where, $list_id, $status );
508
-
509
- return $this->get_total_contacts( $where );
510
  }
511
 
512
  /**
@@ -517,11 +508,16 @@ class ES_DB_Lists_Contacts extends ES_DB {
517
  * @return string|null
518
  *
519
  * @since 4.3.5
 
520
  */
521
- public function get_total_contacts( $where = '' ) {
522
  global $wpdb;
523
 
524
- $query = "SELECT count(DISTINCT(contact_id)) FROM $this->table_name";
 
 
 
 
525
 
526
  if ( ! empty( $where ) ) {
527
  $query .= " WHERE $where";
@@ -654,21 +650,10 @@ class ES_DB_Lists_Contacts extends ES_DB {
654
  *
655
  * @since 4.3.2
656
  * @since 4.3.5 Removed static call
 
657
  */
658
- public function get_total_subscribed_contacts( $days = 0 ) {
659
-
660
- global $wpdb;
661
-
662
- $where = $wpdb->prepare( "status = %s", 'subscribed' );
663
-
664
- $days = absint( $days );
665
-
666
- if ( $days > 0 ) {
667
- $days = esc_sql( $days );
668
- $where .= $wpdb->prepare( " AND subscribed_at >= DATE_SUB(NOW(), INTERVAL %d DAY)", $days );
669
- }
670
-
671
- return $this->get_total_contacts( $where );
672
  }
673
 
674
  /**
@@ -680,20 +665,270 @@ class ES_DB_Lists_Contacts extends ES_DB {
680
  *
681
  * @since 4.3.2
682
  * @since 4.3.5 Removed static call
 
683
  */
684
- public function get_total_unsubscribed_contacts( $days = 0 ) {
 
 
685
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
686
  global $wpdb;
687
 
688
- $where = $wpdb->prepare( "status = %s", 'unsubscribed' );
689
 
690
- $days = absint( $days );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
691
 
 
692
  if ( $days > 0 ) {
693
- $days = esc_sql( $days );
694
- $where .= $wpdb->prepare( " AND unsubscribed_at >= DATE_SUB(NOW(), INTERVAL %d DAY)", $days );
 
 
 
 
 
 
 
695
  }
696
 
697
- return $this->get_total_contacts( $where );
 
 
 
 
 
 
 
 
 
698
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
699
  }
491
  * @since 4.3.5 Removed static call
492
  */
493
  public function get_total_count_by_list( $list_id = 0, $status = 'subscribed' ) {
494
+ $list_id = absint( $list_id );
495
 
496
+ if ( empty( $list_id ) ) {
497
+ return 0;
 
 
 
 
 
 
 
498
  }
499
 
500
+ return $this->get_contacts( $status, $list_id, 0, true, true );
 
 
501
  }
502
 
503
  /**
508
  * @return string|null
509
  *
510
  * @since 4.3.5
511
+ * @since 4.3.6 Added $distinct
512
  */
513
+ public function get_total_contacts( $where = '', $distinct = true ) {
514
  global $wpdb;
515
 
516
+ if ( $distinct ) {
517
+ $query = "SELECT count(DISTINCT(contact_id)) FROM $this->table_name";
518
+ } else {
519
+ $query = "SELECT count(contact_id) FROM $this->table_name";
520
+ }
521
 
522
  if ( ! empty( $where ) ) {
523
  $query .= " WHERE $where";
650
  *
651
  * @since 4.3.2
652
  * @since 4.3.5 Removed static call
653
+ * @since 4.3.6 Modified method name from get_total_subscribed_contacts to get_subscribed_contacts_count
654
  */
655
+ public function get_subscribed_contacts_count( $days = 0, $distinct = true ) {
656
+ return $this->get_contacts( 'subscribed', 0, $days, true, $distinct );
 
 
 
 
 
 
 
 
 
 
 
 
657
  }
658
 
659
  /**
665
  *
666
  * @since 4.3.2
667
  * @since 4.3.5 Removed static call
668
+ * @since 4.3.6 Changed Method name from get_total_unsubscribed_contacts to get_unsubscribed_contacts_count
669
  */
670
+ public function get_unsubscribed_contacts_count( $days = 0, $distinct = true ) {
671
+ return $this->get_contacts( 'unsubscribed', 0, $days, true, $distinct );
672
+ }
673
 
674
+ /**
675
+ * Get all confirmed contacts
676
+ *
677
+ * @param int $days
678
+ * @param bool $distinct
679
+ *
680
+ * @return array|object|null
681
+ *
682
+ * @since 4.3.6
683
+ */
684
+ public function get_confirmed_contacts_count( $days = 0, $distinct = true ) {
685
+ return $this->get_contacts( 'confirmed', 0, $days, true, $distinct );
686
+ }
687
+
688
+ /**
689
+ * Get all unconfirmed contacts
690
+ *
691
+ * @param int $days
692
+ * @param bool $distinct
693
+ *
694
+ * @return array|object|null
695
+ *
696
+ * @since 4.3.6
697
+ */
698
+ public function get_unconfirmed_contacts_count( $days = 0, $distinct = true ) {
699
+ return $this->get_contacts( 'unconfirmed', 0, $days, true, $distinct );
700
+ }
701
+
702
+ /**
703
+ * Get all contacts count
704
+ *
705
+ * @param int $days
706
+ * @param bool $distinct
707
+ *
708
+ * @return array|object|null
709
+ *
710
+ * @since 4.3.6
711
+ */
712
+ public function get_all_contacts_count( $days = 0, $distinct = true ) {
713
+ return $this->get_contacts( 'all', 0, $days, true, $distinct );
714
+ }
715
+
716
+ /**
717
+ * Get all contacts based on status, list, days, count
718
+ *
719
+ * @param string $status
720
+ * @param int $list_id
721
+ * @param int $days
722
+ * @param bool $count_only
723
+ * @param bool $distinct
724
+ *
725
+ * @return array|object|string|null
726
+ *
727
+ * @since 4.3.6
728
+ */
729
+ public function get_contacts( $status = 'all', $list_id = 0, $days = 0, $count_only = false, $distinct = true ) {
730
  global $wpdb;
731
 
732
+ $expected_statuses = array( 'subscribed', 'unsubscribed', 'unconfirmed', 'confirmed', 'all' );
733
 
734
+ if ( ! in_array( $status, $expected_statuses ) ) {
735
+ return array();
736
+ }
737
+
738
+ $status = esc_sql( $status );
739
+ $list_id = esc_sql( $list_id );
740
+
741
+ $where[] = "1 = %d";
742
+ $args[] = 1;
743
+ if ( ! empty( $status ) ) {
744
+ switch ( $status ) {
745
+ case 'subscribed':
746
+ case 'unsubscribed':
747
+ case 'unconfirmed':
748
+ $where[] = "status = %s";
749
+ $args[] = $status;
750
+ break;
751
+ case 'confirmed':
752
+ $where[] = "status = %s AND optin_type = %d";
753
+ $args[] = $status;
754
+ $args[] = IG_DOUBLE_OPTIN;
755
+ break;
756
+ default:
757
+ $where[] = "1 = 1";
758
+ break;
759
+ }
760
+ }
761
+
762
+ $list_id = absint( $list_id );
763
+ if ( ! empty( $list_id ) ) {
764
+ $list_id = esc_sql( $list_id );
765
+ $where[] = "list_id = %d";
766
+ $args[] = $list_id;
767
+ }
768
 
769
+ $days = absint( $days );
770
  if ( $days > 0 ) {
771
+ $days = esc_sql( $days );
772
+
773
+ if ( 'unsubscribed' === $status ) {
774
+ $where[] = "unsubscribed_at >= DATE_SUB(NOW(), INTERVAL %d DAY)";
775
+ $args[] = $days;
776
+ } elseif ( 'subscribed' === $status ) {
777
+ $where[] = "subscribed_at >= DATE_SUB(NOW(), INTERVAL %d DAY)";
778
+ $args[] = $days;
779
+ }
780
  }
781
 
782
+ if ( count( $where ) > 0 ) {
783
+ $where = implode( " AND ", $where );
784
+ $where = $wpdb->prepare( $where, $args );
785
+ }
786
+
787
+ if ( $count_only ) {
788
+ return $this->get_total_contacts( $where, $distinct );
789
+ } else {
790
+ return $this->get_by_conditions( $where );
791
+ }
792
  }
793
+
794
+ /**
795
+ * Get contacts from list based on status
796
+ *
797
+ * @param string $status
798
+ * @param int $list_id
799
+ *
800
+ * @return array|object|null
801
+ *
802
+ * @since 4.3.6
803
+ */
804
+ public function get_contacts_from_list( $status = 'all', $list_id = 0 ) {
805
+ $list_id = absint( $list_id );
806
+
807
+ if ( empty( $list_id ) ) {
808
+ return array();
809
+ }
810
+
811
+ return $this->get_contacts( $status, $list_id );
812
+ }
813
+
814
+ /**
815
+ * Get Subscribed contacts from list
816
+ *
817
+ * @param int $list_id
818
+ *
819
+ * @return array|object|null
820
+ *
821
+ * @since 4.3.6
822
+ */
823
+ public function get_subscribed_contacts_from_list( $list_id = 0 ) {
824
+ return $this->get_contacts_from_list( 'subscribed', $list_id );
825
+ }
826
+
827
+ /**
828
+ * Get Unsubscribed contacts from list
829
+ *
830
+ * @param int $list_id
831
+ *
832
+ * @return array|object|null
833
+ *
834
+ * @since 4.3.6
835
+ */
836
+ public function get_unsubscribed_contacts_from_list( $list_id = 0 ) {
837
+ return $this->get_contacts_from_list( 'unsubscribed', $list_id );
838
+ }
839
+
840
+ /**
841
+ * Get Confirmed contacts from list
842
+ *
843
+ * @param int $list_id
844
+ *
845
+ * @return array|object|null
846
+ *
847
+ * @since 4.3.6
848
+ */
849
+ public function get_confirmed_contacts_from_list( $list_id = 0 ) {
850
+ return $this->get_contacts_from_list( 'confirmed', $list_id );
851
+ }
852
+
853
+ /**
854
+ * Get Unconfirmed contacts from list
855
+ *
856
+ * @param int $list_id
857
+ *
858
+ * @return array|object|null
859
+ *
860
+ * @since 4.3.6
861
+ */
862
+ public function get_unconfirmed_contacts_from_list( $list_id = 0 ) {
863
+ return $this->get_contacts_from_list( 'unconfirmed', $list_id );
864
+ }
865
+
866
+ /**
867
+ * Get All Contacts from list
868
+ *
869
+ * @param int $list_id
870
+ *
871
+ * @return array|object|null
872
+ *
873
+ * @since 4.3.6
874
+ */
875
+ public function get_all_contacts_from_list( $list_id = 0 ) {
876
+ return $this->get_contacts_from_list( 'all', $list_id );
877
+ }
878
+
879
+ /**
880
+ * Get All Subscribed contacts
881
+ *
882
+ * @return array|object|null
883
+ *
884
+ * @since 4.3.6
885
+ */
886
+ public function get_all_subscribed_contacts() {
887
+ return $this->get_contacts( 'subscribed' );
888
+ }
889
+
890
+ /**
891
+ * Get All Unsubscribed contacts
892
+ *
893
+ * @return array|object|null
894
+ *
895
+ * @since 4.3.6
896
+ */
897
+ public function get_all_unsubscribed_contacts() {
898
+ return $this->get_contacts( 'unsubscribed' );
899
+ }
900
+
901
+ /**
902
+ * Get All Confirmed contacts from list
903
+ *
904
+ * @return array|object|null
905
+ *
906
+ * @since 4.3.6
907
+ */
908
+ public function get_all_confirmed_contacts() {
909
+ return $this->get_contacts( 'confirmed' );
910
+ }
911
+
912
+ /**
913
+ * Get All Unconfirmed contacts
914
+ *
915
+ * @return array|object|null
916
+ *
917
+ * @since 4.3.6
918
+ */
919
+ public function get_all_unconfirmed_contacts() {
920
+ return $this->get_contacts( 'unconfirmed' );
921
+ }
922
+
923
+ /**
924
+ * Get All Contacts
925
+ *
926
+ * @return array|object|null
927
+ *
928
+ * @since 4.3.6
929
+ */
930
+ public function get_all_contacts() {
931
+ return $this->get_contacts( 'all' );
932
+ }
933
+
934
  }
lite/includes/db/class-es-db-notifications.php CHANGED
@@ -17,56 +17,6 @@ class ES_DB_Notifications {
17
 
18
  }
19
 
20
- /**
21
- */
22
- public static function get_notifications_by_post_id( $post_id = 0 ) {
23
-
24
- global $wpdb;
25
-
26
- $notifications = array();
27
-
28
- if ( $post_id > 0 ) {
29
- $post_type = get_post_type( $post_id );
30
-
31
- $campaigns_table = IG_CAMPAIGNS_TABLE;
32
-
33
- $sSql = $wpdb->prepare( "SELECT * FROM $campaigns_table WHERE status = %d AND type = %s AND (deleted_at IS NULL OR deleted_at = '0000-00-00 00:00:00')", 1, 'post_notification' );
34
-
35
- if ( $post_type == "post" ) {
36
- $categories = get_the_category( $post_id );
37
- $total_categories = count( $categories );
38
- if ( $total_categories > 0 ) {
39
- for ( $i = 0; $i < $total_categories; $i ++ ) {
40
- if ( $i == 0 ) {
41
- $sSql .= " and (";
42
- } else {
43
- $sSql .= " or";
44
- }
45
-
46
- // $category_str = ES_Common::prepare_category_string( $categories[ $i ]->cat_name );
47
- $category_str = ES_Common::prepare_category_string( $categories[ $i ]->term_id );
48
- // $sSql .= " categories LIKE '%" . wp_specialchars_decode( addslashes( $category_str ) ) . "%'";
49
- $sSql .= " categories LIKE '%" . $category_str . "%'";
50
- if ( $i == ( $total_categories - 1 ) ) {
51
- $sSql .= " OR categories LIKE '%all%'";
52
- $sSql .= ")";
53
- }
54
- }
55
- } else {
56
- //no categories fround for post
57
- return $notifications;
58
- }
59
- } else {
60
- $post_type = ES_Common::prepare_custom_post_type_string( $post_type );
61
- $sSql .= " and categories LIKE '%" . wp_specialchars_decode( addslashes( $post_type ) ) . "%'";
62
- }
63
- $notifications = $wpdb->get_results( $sSql, ARRAY_A );
64
- }
65
-
66
- return $notifications;
67
-
68
- }
69
-
70
  /**
71
  * Migrate Post Notification Email Template Type
72
  *
17
 
18
  }
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  /**
21
  * Migrate Post Notification Email Template Type
22
  *
lite/includes/es-core-functions.php CHANGED
@@ -578,3 +578,24 @@ if ( ! function_exists( 'ig_es_get_next_future_schedule_date' ) ) {
578
  }
579
  }
580
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
578
  }
579
  }
580
 
581
+ if ( ! function_exists( 'ig_es_array_insert_after' ) ) {
582
+ /**
583
+ * Insert $new in $array after $key
584
+ *
585
+ * @param $array
586
+ * @param $key
587
+ * @param $new
588
+ *
589
+ * @return array
590
+ *
591
+ * @since 4.3.6
592
+ */
593
+ function ig_es_array_insert_after( $array, $key, $new ) {
594
+ $keys = array_keys( $array );
595
+ $index = array_search( $key, $keys );
596
+ $pos = false === $index ? count( $array ) : $index + 1;
597
+
598
+ return array_merge( array_slice( $array, 0, $pos ), $new, array_slice( $array, $pos ) );
599
+ }
600
+ }
601
+
lite/includes/feedback.php CHANGED
@@ -61,7 +61,7 @@ function ig_es_render_general_feedback_widget() {
61
  'width' => 700,
62
  'force' => true,
63
  'confirmButtonText' => __( 'Send', 'email-subscribers' ),
64
- 'consent_text' => __( 'Allow Email Subscribers to track plugin usage. We guarantee no sensitive data is collected.', 'email-subscribers' ),
65
  'name' => ''
66
  );
67
 
61
  'width' => 700,
62
  'force' => true,
63
  'confirmButtonText' => __( 'Send', 'email-subscribers' ),
64
+ 'consent_text' => __( 'Allow Email Subscribers to send plugin settings. It will help us to understand your issue better. We guarantee no sensitive data is collected.', 'email-subscribers' ),
65
  'name' => ''
66
  );
67
 
lite/includes/feedback/class-ig-feedback.php CHANGED
@@ -106,6 +106,11 @@ if ( ! class_exists( 'IG_Feedback_V_1_0_11' ) ) {
106
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
107
  }
108
 
 
 
 
 
 
109
  public function render_deactivate_feedback() {
110
  add_action( 'admin_print_scripts', array( $this, 'js' ), 20 );
111
  add_action( 'admin_print_scripts', array( $this, 'css' ) );
@@ -152,7 +157,6 @@ if ( ! class_exists( 'IG_Feedback_V_1_0_11' ) ) {
152
  *
153
  * @since 1.0.3
154
  */
155
-
156
  public function prepare_widget_params( $params = array() ) {
157
 
158
  $default_params = array(
106
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
107
  }
108
 
109
+ /**
110
+ * Render Deactivation feedback Form
111
+ *
112
+ * @since 1.0.0
113
+ */
114
  public function render_deactivate_feedback() {
115
  add_action( 'admin_print_scripts', array( $this, 'js' ), 20 );
116
  add_action( 'admin_print_scripts', array( $this, 'css' ) );
157
  *
158
  * @since 1.0.3
159
  */
 
160
  public function prepare_widget_params( $params = array() ) {
161
 
162
  $default_params = array(
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
8
- Stable tag: 4.3.5.1
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses
11
 
@@ -46,8 +46,7 @@ I am very satisfied with this easy and complete plugin/widget. In 5 minutes or l
46
  * Send broadcasts.
47
  * Sent **email status** and when it was viewed.
48
  * Support **localization or internationalization**.
49
- * **Include/exclude categories** while sending a newsletter or post notification.
50
- * **Ability to control user access** (Roles and Capabilities).
51
  * Easy **Integration with free plugins [Icegram](https://wordpress.org/plugins/icegram/) and [Rainmaker](https://wordpress.org/plugins/icegram-rainmaker/)**
52
 
53
  > **Best Email Subscriber Plugin!!** -
@@ -300,6 +299,12 @@ Refer [here](https://www.icegram.com/documentation/es-faq/).
300
 
301
  == Changelog ==
302
 
 
 
 
 
 
 
303
  **4.3.5.1 (07.12.2019)**
304
  * Update: Improved edit contact
305
  * Fix: Contacts removed from the list when new subscriber subscribed to the list
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
8
+ Stable tag: 4.3.6
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses
11
 
46
  * Send broadcasts.
47
  * Sent **email status** and when it was viewed.
48
  * Support **localization or internationalization**.
49
+ * **Include categories** while sending a post notification.
 
50
  * Easy **Integration with free plugins [Icegram](https://wordpress.org/plugins/icegram/) and [Rainmaker](https://wordpress.org/plugins/icegram-rainmaker/)**
51
 
52
  > **Best Email Subscriber Plugin!!** -
299
 
300
  == Changelog ==
301
 
302
+ **4.3.6 (12.12.2019)**
303
+ * Update: Improve on boarding
304
+ * Fix: Count shows zero (0) even if contacts available in list
305
+ * Fix: File with ".CSV" (uppercase) extension was not working with import contacts.
306
+ * Fix: Incorrect unsubscribed contacts count
307
+
308
  **4.3.5.1 (07.12.2019)**
309
  * Update: Improved edit contact
310
  * Fix: Contacts removed from the list when new subscriber subscribed to the list