Email Subscribers & Newsletters - Version 4.1.10

Version Description

(31.07.2019) = * Update: Added viewed count on reports page * Fix: Shortcodes were not working in email templates * Fix: Viewed status was not getting updated * Fix: Migration issues in reports

Download this release

Release Info

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

Code changes from version 4.1.9 to 4.1.10

admin/images/email-subscribers-pricing-back.png DELETED
Binary file
admin/images/email-subscribers-pricing.png CHANGED
Binary file
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.1.9
7
  * Author: Icegram
8
  * Author URI: https://www.icegram.com/
9
  * Requires at least: 3.9
@@ -24,7 +24,7 @@ if ( ! defined( 'WPINC' ) ) {
24
  * Define constants
25
  */
26
  define( 'ES_PLUGIN_DIR', dirname( __FILE__ ) );
27
- define( 'ES_PLUGIN_VERSION', '4.1.9' );
28
  define( 'ES_PLUGIN_BASE_NAME', plugin_basename( __FILE__ ) );
29
 
30
  if ( ! defined( 'ES_PLUGIN_FILE' ) ) {
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.1.10
7
  * Author: Icegram
8
  * Author URI: https://www.icegram.com/
9
  * Requires at least: 3.9
24
  * Define constants
25
  */
26
  define( 'ES_PLUGIN_DIR', dirname( __FILE__ ) );
27
+ define( 'ES_PLUGIN_VERSION', '4.1.10' );
28
  define( 'ES_PLUGIN_BASE_NAME', plugin_basename( __FILE__ ) );
29
 
30
  if ( ! defined( 'ES_PLUGIN_FILE' ) ) {
includes/admin/class-es-cron.php CHANGED
@@ -29,13 +29,13 @@ class ES_Cron {
29
  }
30
 
31
  // It's not a cron request. Say Goodbye!
32
- if('cron' !== $es_request) {
33
  return;
34
  }
35
 
36
- $ig_es_disable_wp_cron = get_option( 'ig_es_disable_wp_cron', 'no');
37
 
38
- if( $is_wp_cron && 'yes' === $ig_es_disable_wp_cron ) {
39
  return;
40
  }
41
 
@@ -85,12 +85,12 @@ class ES_Cron {
85
  }
86
 
87
  /**
88
- * - Get GUID from sentdetails report which are in queue
89
- * - Get subscribers from the deliverreport table based on fetched guid
90
  * - Prepare email content
91
- * - Send emails based on fetch subscribers
92
- * - Update status in sentdetails table
93
- * - Update status in deliver report table
94
  */
95
 
96
  // Get GUID from sentdetails report which are in queue
@@ -116,15 +116,12 @@ class ES_Cron {
116
  $ids[] = $email['id'];
117
  }
118
 
119
- $updated = ES_DB_Sending_Queue::update_sent_status( $ids, 'Sending' );
 
 
120
 
121
- if ( $updated ) {
122
- ES_Mailer::prepare_and_send_email( $emails, $notification );
123
- ES_DB_Sending_Queue::update_sent_status( $ids, 'Sent' );
124
- }
125
-
126
- $total_remaining_emails = ES_DB_Sending_Queue::get_total_emails_to_be_sent_by_hash( $notification_guid );
127
- $remainig_emails_to_be_sent = ES_DB_Sending_Queue::get_total_emails_to_be_sent();
128
 
129
  // No emails left for the $notification_guid??? Send admin notification for the
130
  // Completion of a job
@@ -142,7 +139,7 @@ class ES_Cron {
142
  if ( ! empty( $template ) ) {
143
  $subject = get_option( 'ig_es_cron_admin_email_subject', __( 'Campaign Sent!', 'email-subscribers' ) );
144
  $notification = ES_DB_Mailing_Queue::get_notification_by_hash( $notification_guid );
145
- if( isset( $notification['subject'] ) ){
146
  $subject = str_replace( '{{SUBJECT}}', $notification['subject'], $subject );
147
  }
148
 
@@ -157,7 +154,7 @@ class ES_Cron {
157
  }
158
 
159
  $response['total_emails_sent'] = $total_emails;
160
- $response['es_remaining_email_count'] = $remainig_emails_to_be_sent;
161
  $response['message'] = 'EMAILS_SENT';
162
  $response['status'] = 'SUCCESS';
163
  // update last cron run time
29
  }
30
 
31
  // It's not a cron request. Say Goodbye!
32
+ if ( 'cron' !== $es_request ) {
33
  return;
34
  }
35
 
36
+ $ig_es_disable_wp_cron = get_option( 'ig_es_disable_wp_cron', 'no' );
37
 
38
+ if ( $is_wp_cron && 'yes' === $ig_es_disable_wp_cron ) {
39
  return;
40
  }
41
 
85
  }
86
 
87
  /**
88
+ * - Get GUID from ig_es_mailing_queue table which are in queue
89
+ * - Get contacts from the ig_es_sending_queue table based on fetched guid
90
  * - Prepare email content
91
+ * - Send emails based on fetched contacts
92
+ * - Update status in ig_es_mailing_queue table
93
+ * - Update status in ig_es_sending_queue table
94
  */
95
 
96
  // Get GUID from sentdetails report which are in queue
116
  $ids[] = $email['id'];
117
  }
118
 
119
+ ES_DB_Sending_Queue::update_sent_status($ids, 'Sending');
120
+ // Send out emails
121
+ ES_Mailer::prepare_and_send_email( $emails, $notification );
122
 
123
+ $total_remaining_emails = ES_DB_Sending_Queue::get_total_emails_to_be_sent_by_hash( $notification_guid );
124
+ $remaining_emails_to_be_sent = ES_DB_Sending_Queue::get_total_emails_to_be_sent();
 
 
 
 
 
125
 
126
  // No emails left for the $notification_guid??? Send admin notification for the
127
  // Completion of a job
139
  if ( ! empty( $template ) ) {
140
  $subject = get_option( 'ig_es_cron_admin_email_subject', __( 'Campaign Sent!', 'email-subscribers' ) );
141
  $notification = ES_DB_Mailing_Queue::get_notification_by_hash( $notification_guid );
142
+ if ( isset( $notification['subject'] ) ) {
143
  $subject = str_replace( '{{SUBJECT}}', $notification['subject'], $subject );
144
  }
145
 
154
  }
155
 
156
  $response['total_emails_sent'] = $total_emails;
157
+ $response['es_remaining_email_count'] = $remaining_emails_to_be_sent;
158
  $response['message'] = 'EMAILS_SENT';
159
  $response['status'] = 'SUCCESS';
160
  // update last cron run time
includes/admin/class-es-reports-table.php CHANGED
@@ -108,10 +108,15 @@ class ES_Reports_Table extends WP_List_Table {
108
  global $wpdb;
109
 
110
  $emails = ES_DB_Sending_Queue::get_emails_by_hash( $id );
 
 
111
 
112
  ?>
113
  <div class="wrap">
114
  <div class="tool-box">
 
 
 
115
  <form name="frm_es_display" method="post">
116
  <table width="100%" class="widefat" id="straymanage">
117
  <thead>
@@ -147,7 +152,7 @@ class ES_Reports_Table extends WP_List_Table {
147
  $email_id = ! empty( $email['email'] ) ? $email['email'] : ( ! empty( $email['es_deliver_emailmail'] ) ? $email['es_deliver_emailmail'] : '' );
148
  $status = ! empty( $email['status'] ) ? $email['status'] : ( ! empty( $email['es_deliver_sentstatus'] ) ? $email['es_deliver_sentstatus'] : '' );
149
  $sent_at = ! empty( $email['sent_at'] ) ? $email['sent_at'] : ( ! empty( $email['es_deliver_sentdate'] ) ? $email['es_deliver_sentdate'] : '' );
150
- $opened = ! empty( $email['sent_at'] ) ? $email['sent_at'] : ( ! empty( $email['es_deliver_status'] ) && $email['es_deliver_status'] === 'Viewed' ? 1 : 0 );
151
  $opened_at = ! empty( $email['opened_at'] ) ? $email['opened_at'] : ( ! empty( $email['es_deliver_viewdate'] ) ? $email['es_deliver_viewdate'] : '' );
152
 
153
  ?>
108
  global $wpdb;
109
 
110
  $emails = ES_DB_Sending_Queue::get_emails_by_hash( $id );
111
+ $email_viewed_count = ES_DB_Sending_Queue::get_viewed_count_by_hash( $id );
112
+ $total_email_sent = ES_DB_Sending_Queue::get_total_email_count_by_hash( $id );
113
 
114
  ?>
115
  <div class="wrap">
116
  <div class="tool-box">
117
+ <div class="tablenav">
118
+ <div class="alignleft" style="padding-bottom:10px;"><?php echo 'Viewed ' . $email_viewed_count . '/' .$total_email_sent; ?></div>
119
+ </div>
120
  <form name="frm_es_display" method="post">
121
  <table width="100%" class="widefat" id="straymanage">
122
  <thead>
152
  $email_id = ! empty( $email['email'] ) ? $email['email'] : ( ! empty( $email['es_deliver_emailmail'] ) ? $email['es_deliver_emailmail'] : '' );
153
  $status = ! empty( $email['status'] ) ? $email['status'] : ( ! empty( $email['es_deliver_sentstatus'] ) ? $email['es_deliver_sentstatus'] : '' );
154
  $sent_at = ! empty( $email['sent_at'] ) ? $email['sent_at'] : ( ! empty( $email['es_deliver_sentdate'] ) ? $email['es_deliver_sentdate'] : '' );
155
+ $opened = ! empty( $email['opened'] ) ? $email['opened'] : ( ! empty( $email['es_deliver_status'] ) && $email['es_deliver_status'] === 'Viewed' ? 1 : 0 );
156
  $opened_at = ! empty( $email['opened_at'] ) ? $email['opened_at'] : ( ! empty( $email['es_deliver_viewdate'] ) ? $email['es_deliver_viewdate'] : '' );
157
 
158
  ?>
includes/class-email-subscribers.php CHANGED
@@ -423,7 +423,8 @@ class Email_Subscribers {
423
 
424
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
425
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
426
- $this->loader->add_action( 'init', $plugin_public, 'es_email_subscribe_init' );
 
427
  $this->loader->add_action( 'ig_es_add_contact', $plugin_public, 'add_contact', 10, 2 );
428
 
429
  }
423
 
424
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
425
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
426
+ $this->loader->add_action( 'init', $plugin_public, 'es_email_subscribe_init');
427
+ $this->loader->add_action( 'wp_loaded', $plugin_public, 'es_email_subscribe_wp_loaded');
428
  $this->loader->add_action( 'ig_es_add_contact', $plugin_public, 'add_contact', 10, 2 );
429
 
430
  }
includes/class-es-mailer.php CHANGED
@@ -57,6 +57,8 @@ class ES_Mailer {
57
 
58
  if ( $send ) {
59
  ES_DB_Sending_Queue::update_sent_status( $mail['id'], 'Sent' );
 
 
60
  }
61
 
62
  }
57
 
58
  if ( $send ) {
59
  ES_DB_Sending_Queue::update_sent_status( $mail['id'], 'Sent' );
60
+ } else {
61
+ ES_DB_Sending_Queue::update_sent_status( $mail['id'], 'In Queue' );
62
  }
63
 
64
  }
includes/db/class-es-db-sending-queue.php CHANGED
@@ -425,4 +425,56 @@ class ES_DB_Sending_Queue {
425
  $wpdb->query( $query );
426
  }
427
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
428
  }
425
  $wpdb->query( $query );
426
  }
427
 
428
+ // Query to get total viewed emails per report
429
+ public static function get_viewed_count_by_hash( $hash = "" ) {
430
+
431
+ global $wpdb;
432
+
433
+ $result = 0;
434
+
435
+ if( $hash != "" ) {
436
+ $query = $wpdb->prepare("SELECT COUNT(*) AS count
437
+ FROM ".IG_SENDING_QUEUE_TABLE ."
438
+ WHERE opened = 1 AND mailing_queue_hash = %s", array( $hash ) );
439
+ $result = $wpdb->get_var( $query );
440
+ if( $result === 0 ){
441
+ $es_deliver_report_table = EMAIL_SUBSCRIBERS_STATS_TABLE;
442
+ $result = $wpdb->get_var( "SHOW TABLES LIKE '{$es_deliver_report_table}' " );
443
+ if ( $result === $es_deliver_report_table ) {
444
+ $query = $wpdb->prepare( "SELECT COUNT(*) AS count FROM {$es_deliver_report_table} WHERE es_deliver_status = 'Viewed' AND es_deliver_sentguid = %s", array( $hash ) );
445
+ $emails = $wpdb->get_results( $query, ARRAY_A );
446
+ }
447
+ }
448
+
449
+ }
450
+
451
+ return $result;
452
+
453
+ }
454
+
455
+ public static function get_total_email_count_by_hash( $hash = "" ) {
456
+
457
+ global $wpdb;
458
+
459
+ $result = 0;
460
+
461
+ if( $hash != "" ) {
462
+ $query = $wpdb->prepare("SELECT COUNT(*) AS count
463
+ FROM ".IG_SENDING_QUEUE_TABLE ."
464
+ WHERE mailing_queue_hash = %s", array( $hash ) );
465
+ $result = $wpdb->get_var( $query );
466
+ if( $result === 0 ){
467
+ $es_deliver_report_table = EMAIL_SUBSCRIBERS_STATS_TABLE;
468
+ $result = $wpdb->get_var( "SHOW TABLES LIKE '{$es_deliver_report_table}' " );
469
+ if ( $result === $es_deliver_report_table ) {
470
+ $query = $wpdb->prepare( "SELECT COUNT(*) AS count FROM {$es_deliver_report_table} WHERE es_deliver_sentguid = %s", array( $hash ) );
471
+ $emails = $wpdb->get_results( $query, ARRAY_A );
472
+ }
473
+ }
474
+ }
475
+
476
+ return $result;
477
+
478
+ }
479
+
480
  }
includes/upgrade/class-es-background-process.php CHANGED
@@ -101,11 +101,9 @@ abstract class ES_Background_Process extends WP_Background_Process {
101
  $logger->info( '--------------------- Started To Run Task Again---------------------', array( 'source' => 'es_update' ) );
102
  foreach ( $batch->data as $key => $value ) {
103
  $is_value_exists = true;
104
- //$task_transient = $value . '_processed';
105
- $ig_es_update_processed_tasks = get_option( 'ig_es_processed_update_tasks', array() );
106
  $task = false; // By default it's set to false
107
  $logger->info( '-------- Checking Transient For: ' . $value, array( 'source' => 'es_update' ) );
108
- //if ( false === get_transient( $task_transient ) ) {
109
  if ( ! in_array( $value, $ig_es_update_processed_tasks ) ) {
110
  $is_value_exists = false;
111
  $logger->info( '------- Running Task: >>>>> ' . $value, array( 'source' => 'es_update' ) );
@@ -122,7 +120,6 @@ abstract class ES_Background_Process extends WP_Background_Process {
122
  $ig_es_update_processed_tasks[] = $value;
123
  update_option( 'ig_es_update_processed_tasks', $ig_es_update_processed_tasks );
124
  }
125
- //set_transient( $task_transient, true, MINUTE_IN_SECONDS * 100 );
126
  unset( $batch->data[ $key ] );
127
  }
128
 
101
  $logger->info( '--------------------- Started To Run Task Again---------------------', array( 'source' => 'es_update' ) );
102
  foreach ( $batch->data as $key => $value ) {
103
  $is_value_exists = true;
104
+ $ig_es_update_processed_tasks = get_option( 'ig_es_update_processed_tasks', array() );
 
105
  $task = false; // By default it's set to false
106
  $logger->info( '-------- Checking Transient For: ' . $value, array( 'source' => 'es_update' ) );
 
107
  if ( ! in_array( $value, $ig_es_update_processed_tasks ) ) {
108
  $is_value_exists = false;
109
  $logger->info( '------- Running Task: >>>>> ' . $value, array( 'source' => 'es_update' ) );
120
  $ig_es_update_processed_tasks[] = $value;
121
  update_option( 'ig_es_update_processed_tasks', $ig_es_update_processed_tasks );
122
  }
 
123
  unset( $batch->data[ $key ] );
124
  }
125
 
includes/upgrade/es-update-functions.php CHANGED
@@ -506,12 +506,12 @@ function ig_es_update_400_migrate_notifications() {
506
 
507
  function ig_es_update_400_migrate_reports_data() {
508
 
509
- @ini_set( 'max_execution_time', 0 );
510
  /**
511
  * - Migrate individual notification data from es_deliverreport to ig_es_sending_queue table
512
  * es_deliverreport => ig_es_sending_queue
513
  */
514
- ES_DB_Sending_Queue::migrate_reports_data();
 
515
 
516
  }
517
 
506
 
507
  function ig_es_update_400_migrate_reports_data() {
508
 
 
509
  /**
510
  * - Migrate individual notification data from es_deliverreport to ig_es_sending_queue table
511
  * es_deliverreport => ig_es_sending_queue
512
  */
513
+ //@ini_set( 'max_execution_time', 0 );
514
+ //ES_DB_Sending_Queue::migrate_reports_data();
515
 
516
  }
517
 
public/class-email-subscribers-public.php CHANGED
@@ -126,12 +126,14 @@ class Email_Subscribers_Public {
126
 
127
  }
128
 
 
 
 
129
  public function es_email_subscribe_init() {
130
 
131
  global $wpdb;
132
-
133
  //initialize
134
- new ES_Cron();
135
  new ES_Handle_Subscription();
136
  new ES_Shortcode();
137
 
126
 
127
  }
128
 
129
+ public function es_email_subscribe_wp_loaded() {
130
+ new ES_Cron();
131
+ }
132
  public function es_email_subscribe_init() {
133
 
134
  global $wpdb;
 
135
  //initialize
136
+ // new ES_Cron();
137
  new ES_Handle_Subscription();
138
  new ES_Shortcode();
139
 
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.2.2
8
- Stable tag: 4.1.9
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses
11
 
@@ -305,6 +305,12 @@ Use our free plugin [Email Subscribers - Group Selector](https://wordpress.org/p
305
 
306
  == Changelog ==
307
 
 
 
 
 
 
 
308
  = 4.1.9 (25.07.2019) =
309
  * Update: Admin notification will be sent out only after contacts confirm their subscription
310
  * Update: Show Post Notifications categories in campaigns view
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.2.2
8
+ Stable tag: 4.1.10
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses
11
 
305
 
306
  == Changelog ==
307
 
308
+ = 4.1.10 (31.07.2019) =
309
+ * Update: Added viewed count on reports page
310
+ * Fix: Shortcodes were not working in email templates
311
+ * Fix: Viewed status was not getting updated
312
+ * Fix: Migration issues in reports
313
+
314
  = 4.1.9 (25.07.2019) =
315
  * Update: Admin notification will be sent out only after contacts confirm their subscription
316
  * Update: Show Post Notifications categories in campaigns view