Email Subscribers & Newsletters - Version 4.3.5.1

Version Description

Download this release

Release Info

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

Code changes from version 4.3.5 to 4.3.5.1

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
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' );
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.5.1
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.5.1' );
115
  }
116
 
117
  // Plugin Folder Path.
lite/includes/class-es-common.php CHANGED
@@ -108,9 +108,13 @@ Class ES_Common {
108
  *
109
  * @since 4.0.0
110
  */
111
- public static function prepare_statuses_dropdown_options( $selected = '', $default_label = 'Select Status' ) {
112
 
113
- $default_status[0] = __( $default_label, 'email-subscribers' );
 
 
 
 
114
 
115
  $statuses = self::get_statuses_key_name_map();
116
  $statuses = array_merge( $default_status, $statuses );
108
  *
109
  * @since 4.0.0
110
  */
111
+ public static function prepare_statuses_dropdown_options( $selected = '', $default_label = '' ) {
112
 
113
+ if ( empty( $default_label ) ) {
114
+ $default_label = __( 'Select Status', 'email-subscribers' );
115
+ }
116
+
117
+ $default_status[0] = $default_label;
118
 
119
  $statuses = self::get_statuses_key_name_map();
120
  $statuses = array_merge( $default_status, $statuses );
lite/includes/class-es-install.php CHANGED
@@ -1622,5 +1622,4 @@ if ( ! class_exists( 'ES_Install' ) ) {
1622
  }
1623
 
1624
  ES_Install::init();
1625
- }
1626
-
1622
  }
1623
 
1624
  ES_Install::init();
1625
+ }
 
lite/includes/classes/class-es-contacts-table.php CHANGED
@@ -38,16 +38,27 @@ class ES_Contacts_Table extends WP_List_Table {
38
  */
39
  public $lists_id_name_map = array();
40
 
 
 
 
 
 
 
 
 
 
 
41
  public function __construct() {
42
 
43
- //set_error_handler(array( 'Email_General' , 'es_handle_error'));
44
  parent::__construct( array(
45
- 'singular' => __( 'Contact', 'email-subscribers' ), //singular name of the listed records
46
- 'plural' => __( 'Contacts', 'email-subscribers' ), //plural name of the listed records
47
- 'ajax' => false,//does this table support ajax?
48
  'screen' => 'es_subscribers'
49
  ) );
50
 
 
 
51
  add_filter( 'ig_es_audience_tab_main_navigation', array( $this, 'get_audience_main_tabs' ), 10, 2 );
52
 
53
  // @since 4.3.1
@@ -79,7 +90,14 @@ class ES_Contacts_Table extends WP_List_Table {
79
 
80
  }
81
 
82
-
 
 
 
 
 
 
 
83
  public function get_audience_main_tabs( $active_tab, $audience_main_tabs = array() ) {
84
 
85
  $audience_tab_main_navigation = array(
@@ -201,16 +219,31 @@ class ES_Contacts_Table extends WP_List_Table {
201
  <?php }
202
  }
203
 
 
 
 
 
 
204
  public function load_export() {
205
  $export = new Export_Subscribers();
206
  $export->export_subscribers_page();
207
  }
208
 
 
 
 
 
 
209
  public function load_import() {
210
  $import = new ES_Import_Subscribers();
211
  $import->import_subscribers_page();
212
  }
213
 
 
 
 
 
 
214
  public function load_sync() {
215
  $sync = ES_Handle_Sync_Wp_User::get_instance();
216
  $sync->prepare_sync_user();
@@ -250,6 +283,13 @@ class ES_Contacts_Table extends WP_List_Table {
250
  <?php
251
  }
252
 
 
 
 
 
 
 
 
253
  public function save_contact( $id = 0 ) {
254
  global $wpdb;
255
 
@@ -266,38 +306,39 @@ class ES_Contacts_Table extends WP_List_Table {
266
  $title = __( 'Edit Contact', 'email-subscribers' );
267
  $title_action = '<a href="admin.php?page=es_subscribers&action=new" class="page-title-action">' . __( 'Add New', 'email-subscribers' ) . '</a>';
268
 
269
- $contacts_table = IG_CONTACTS_TABLE;
270
- $query = "SELECT * FROM {$contacts_table} WHERE id = %d";
271
- $contact = $wpdb->get_results( $wpdb->prepare( $query, $id ), ARRAY_A );
272
 
273
- if ( ! empty( $contact[0] ) ) {
274
- $contact = $contact[0];
 
 
275
 
276
- $first_name = ! empty( $contact['first_name'] ) ? $contact['first_name'] : '';
277
- $last_name = ! empty( $contact['last_name'] ) ? $contact['last_name'] : '';
278
- $email = ! empty( $contact['email'] ) ? $contact['email'] : '';
279
- $list_ids = ES()->lists_contacts_db->get_list_ids_by_contact( $id );
280
- $guid = $contact['hash'];
281
- $nonce = esc_attr( ig_es_get_request_data( '_wpnonce' ) );
282
  }
283
  }
284
 
285
  $submitted = ig_es_get_request_data( 'submitted' );
 
286
  if ( 'submitted' === $submitted ) {
287
 
288
  $contact_data = ig_es_get_post_data( 'contact_data', array() );
289
- $is_error = false;
 
290
  if ( ! empty( $contact_data ) ) {
291
 
292
- $email = ! empty( $contact_data['email'] ) ? sanitize_email( $contact_data['email'] ) : '';
293
 
294
  if ( $email ) {
295
 
296
- $list_ids = ! empty( $contact_data['lists'] ) ? $contact_data['lists'] : array();
297
 
298
- if ( count( $list_ids ) > 0 ) {
299
- $first_name = ! empty( $contact_data['first_name'] ) ? sanitize_text_field( $contact_data['first_name'] ) : '';
300
- $last_name = ! empty( $contact_data['last_name'] ) ? sanitize_text_field( $contact_data['last_name'] ) : '';
301
 
302
  if ( ! empty( $first_name ) ) {
303
 
@@ -330,9 +371,9 @@ class ES_Contacts_Table extends WP_List_Table {
330
 
331
  if ( ! $is_error ) {
332
 
333
- $list_ids = ! empty( $list_ids ) ? $list_ids : array( 1 );
334
 
335
- ES()->lists_contacts_db->update_contact_lists( $id, $list_ids );
336
 
337
  if ( $id ) {
338
 
@@ -389,7 +430,6 @@ class ES_Contacts_Table extends WP_List_Table {
389
  'first_name' => $first_name,
390
  'last_name' => $last_name,
391
  'email' => $email,
392
- 'selected_list_ids' => $list_ids,
393
  'guid' => $guid
394
  );
395
 
@@ -522,64 +562,6 @@ class ES_Contacts_Table extends WP_List_Table {
522
  return $result;
523
  }
524
 
525
- public function edit_list( $id ) {
526
- global $wpdb;
527
-
528
- $notificationid = $wpdb->get_results( "SELECT * FROM " . IG_CONTACTS_TABLE . " WHERE id = $id" );
529
-
530
- $title = $notificationid[0]->first_name . ' ' . $notificationid[0]->last_name;
531
- $email = $notificationid[0]->email;
532
- $contact_lists = ES()->lists_contacts_db->get_list_ids_by_contact( $notificationid[0]->id );
533
-
534
- $status = ig_es_get_request_data( 'status' );
535
- if ( 'updated' === $status ) {
536
- $email_address = sanitize_email( ig_es_get_request_data( 'email' ) );
537
-
538
- if ( ! empty( $email_address ) ) {
539
- $this->update_list( $id );
540
- $title = ig_es_get_request_data( 'subscriber_name' );
541
- $contact_lists = ig_es_get_request_data( 'lists' );
542
- $email = $email_address;
543
- }
544
- }
545
-
546
- $id = $notificationid[0]->id;
547
- $guid = $notificationid[0]->hash;
548
- $created = $notificationid[0]->created_at;
549
- $nonce = esc_attr( ig_es_get_request_data( '_wpnonce' ) );
550
-
551
- $data = array(
552
- 'id' => $id,
553
- 'action' => "admin.php?page=es_subscribers&action=edit&subscriber={$id}&_wpnonce={$nonce}&status=updated",
554
- 'name' => $title,
555
- 'email' => $email,
556
- 'created' => $created,
557
- 'guid' => $guid,
558
- 'selected_list_ids' => $contact_lists
559
- );
560
-
561
- $contact_name = ig_es_get_request_data( 'subscriber_name' );
562
- if ( $contact_name ) {
563
- $message = __( 'Contact updated successfully!', 'email-subscribers' );
564
- ES_Common::show_message( $message, 'success' );
565
- }
566
-
567
- $editform = '<div class="wrap">
568
- <h1 class="wp-heading-inline">' . __( 'Edit Contact', 'email-subscribers' ) . '<a href="admin.php?page=es_subscribers&action=new" class="page-title-action">Add New</a></h1>' . Email_Subscribers_Admin::es_feedback() . '
569
- <hr class="wp-header-end">
570
- <div id="poststuff">
571
- <div id="post-body" class="metabox-holder column-1">
572
- <div id="post-body-content">
573
- <div class="meta-box-sortables ui-sortable es-contact-form">'
574
- . $this->prepare_contact_form( $data, false ) .
575
- '</div>
576
- </div>
577
- </div>
578
- </div>
579
- </div>';
580
-
581
- return $editform;
582
- }
583
 
584
  public function prepare_contact_form( $data = array(), $is_new = false ) {
585
 
@@ -590,13 +572,13 @@ class ES_Contacts_Table extends WP_List_Table {
590
  $first_name = ! empty( $data['first_name'] ) ? $data['first_name'] : '';
591
  $last_name = ! empty( $data['last_name'] ) ? $data['last_name'] : '';
592
  $email = ! empty( $data['email'] ) ? $data['email'] : '';
593
- $selected_list_ids = ! empty( $data['selected_list_ids'] ) ? $data['selected_list_ids'] : array();
594
  $send_welcome_email = ! empty( $data['send_welcome_email'] ) ? true : false;
595
 
596
  $lists_id_name_map = ES()->lists_db->get_list_id_name_map();
597
 
598
  if ( count( $lists_id_name_map ) ) {
599
- $list_html = ES_Shortcode::prepare_lists_checkboxes( $lists_id_name_map, array_keys( $lists_id_name_map ), 4, $selected_list_ids, $id, 'contact_data[lists][]' );
 
600
  } else {
601
  $list_html = "<tr><td>" . __( 'No list found', 'email-subscribers' ) . "</td></tr>";
602
  }
@@ -649,24 +631,16 @@ class ES_Contacts_Table extends WP_List_Table {
649
  <?php
650
  }
651
 
652
-
653
  /**
654
- * Returns the count of records in the database.
655
  *
656
- * @return null|string
657
  */
658
- public static function record_count() {
659
- global $wpdb;
660
-
661
- $sql = "SELECT COUNT(*) FROM " . IG_CONTACTS_TABLE;
662
-
663
- return $wpdb->get_var( $sql );
664
  }
665
 
666
 
667
- /** Text displayed when no subscriber data is available */
668
-
669
-
670
  /**
671
  * Render a column when no column specific method exist.
672
  *
@@ -674,6 +648,8 @@ class ES_Contacts_Table extends WP_List_Table {
674
  * @param string $column_name
675
  *
676
  * @return mixed
 
 
677
  */
678
  public function column_default( $item, $column_name ) {
679
  $item = apply_filters( 'es_subscribers_col_data', $item, $column_name );
@@ -689,6 +665,67 @@ class ES_Contacts_Table extends WP_List_Table {
689
  }
690
  }
691
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
692
  public function get_lists_to_show( $contact_id ) {
693
 
694
  $list_str = '';
@@ -711,31 +748,14 @@ class ES_Contacts_Table extends WP_List_Table {
711
  return $list_str;
712
  }
713
 
714
- public function status_label_map( $status ) {
715
-
716
- $statuses = array(
717
- // 'confirmed' => __( 'Confirmed', 'email-subscribers' ),
718
- 'subscribed' => __( 'Subscribed', 'email-subscribers' ),
719
- 'unconfirmed' => __( 'Unconfirmed', 'email-subscribers' ),
720
- 'unsubscribed' => __( 'Unsubscribed', 'email-subscribers' ),
721
- // 'single_opt_in' => __( 'Single Opt In', 'email-subscribers' ),
722
- // 'double_opt_in' => __( 'Double Opt In', 'email-subscribers' )
723
- );
724
-
725
-
726
- if ( ! in_array( $status, array_keys( $statuses ) ) ) {
727
- return '';
728
- }
729
-
730
- return $statuses[ $status ];
731
- }
732
-
733
  /**
734
  * Render the bulk edit checkbox
735
  *
736
  * @param array $item
737
  *
738
  * @return string
 
 
739
  */
740
  function column_cb( $item ) {
741
  return sprintf(
@@ -743,13 +763,14 @@ class ES_Contacts_Table extends WP_List_Table {
743
  );
744
  }
745
 
746
-
747
  /**
748
  * Method for name column
749
  *
750
  * @param array $item an array of DB data
751
  *
752
  * @return string
 
 
753
  */
754
  function column_name( $item ) {
755
  $delete_nonce = wp_create_nonce( 'ig_es_delete_subscriber' );
@@ -769,11 +790,12 @@ class ES_Contacts_Table extends WP_List_Table {
769
  return $title . $this->row_actions( $actions );
770
  }
771
 
772
-
773
  /**
774
  * Associative array of columns
775
  *
776
  * @return array
 
 
777
  */
778
  function get_columns() {
779
  $columns = array(
@@ -791,6 +813,8 @@ class ES_Contacts_Table extends WP_List_Table {
791
  * Columns to make sortable.
792
  *
793
  * @return array
 
 
794
  */
795
  public function get_sortable_columns() {
796
  $sortable_columns = array(
@@ -807,6 +831,8 @@ class ES_Contacts_Table extends WP_List_Table {
807
  * Returns an associative array containing the bulk action
808
  *
809
  * @return array
 
 
810
  */
811
  public function get_bulk_actions() {
812
  $actions = array(
@@ -851,13 +877,23 @@ class ES_Contacts_Table extends WP_List_Table {
851
 
852
  <?php }
853
 
854
-
 
 
 
 
 
 
 
 
855
  public function get_contact_id( $contact ) {
856
  return $contact['id'];
857
  }
858
 
859
  /**
860
  * Handles data query and filter, sorting, and pagination.
 
 
861
  */
862
  public function prepare_items() {
863
 
@@ -895,6 +931,11 @@ class ES_Contacts_Table extends WP_List_Table {
895
  }
896
  }
897
 
 
 
 
 
 
898
  public function prepare_lists_dropdown() {
899
  $data = '<label for="bulk-action-selector-top" class="screen-reader-text">Select bulk action</label><select name="list_id" id="list_id" class="groupsselect" style="display: none">';
900
  $data .= ES_Common::prepare_list_dropdown_options();
@@ -1104,12 +1145,6 @@ class ES_Contacts_Table extends WP_List_Table {
1104
  $query = "UPDATE $ig_contacts_table SET form_id = 0 WHERE form_id = %d";
1105
 
1106
  $wpdb->query( $wpdb->prepare( $query, $form_id ) );
1107
-
1108
- }
1109
-
1110
- public function no_items() {
1111
- _e( 'No contacts avaliable.', 'email-subscribers' );
1112
  }
1113
 
1114
-
1115
  }
38
  */
39
  public $lists_id_name_map = array();
40
 
41
+ /**
42
+ * @var object|ES_DB_Contacts
43
+ */
44
+ public $db;
45
+
46
+ /**
47
+ * ES_Contacts_Table constructor.
48
+ *
49
+ * @since 4.0.0
50
+ */
51
  public function __construct() {
52
 
 
53
  parent::__construct( array(
54
+ 'singular' => __( 'Contact', 'email-subscribers' ),
55
+ 'plural' => __( 'Contacts', 'email-subscribers' ),
56
+ 'ajax' => false,
57
  'screen' => 'es_subscribers'
58
  ) );
59
 
60
+ $this->db = new ES_DB_Contacts();
61
+
62
  add_filter( 'ig_es_audience_tab_main_navigation', array( $this, 'get_audience_main_tabs' ), 10, 2 );
63
 
64
  // @since 4.3.1
90
 
91
  }
92
 
93
+ /**
94
+ * @param $active_tab
95
+ * @param array $audience_main_tabs
96
+ *
97
+ * @return array
98
+ *
99
+ * @since 4.0.0
100
+ */
101
  public function get_audience_main_tabs( $active_tab, $audience_main_tabs = array() ) {
102
 
103
  $audience_tab_main_navigation = array(
219
  <?php }
220
  }
221
 
222
+ /**
223
+ * Load Export Feature
224
+ *
225
+ * @since 4.0.0
226
+ */
227
  public function load_export() {
228
  $export = new Export_Subscribers();
229
  $export->export_subscribers_page();
230
  }
231
 
232
+ /**
233
+ * Load import
234
+ *
235
+ * @since 4.0.0
236
+ */
237
  public function load_import() {
238
  $import = new ES_Import_Subscribers();
239
  $import->import_subscribers_page();
240
  }
241
 
242
+ /**
243
+ * Load Sync
244
+ *
245
+ * @since 4.0.0
246
+ */
247
  public function load_sync() {
248
  $sync = ES_Handle_Sync_Wp_User::get_instance();
249
  $sync->prepare_sync_user();
283
  <?php
284
  }
285
 
286
+ /**
287
+ * Save contact
288
+ *
289
+ * @param int $id
290
+ *
291
+ * @since 4.0.0
292
+ */
293
  public function save_contact( $id = 0 ) {
294
  global $wpdb;
295
 
306
  $title = __( 'Edit Contact', 'email-subscribers' );
307
  $title_action = '<a href="admin.php?page=es_subscribers&action=new" class="page-title-action">' . __( 'Add New', 'email-subscribers' ) . '</a>';
308
 
309
+ $contact = $this->db->get( $id );
310
+
311
+ if ( ! empty( $contact ) ) {
312
 
313
+ $first_name = ig_es_get_data( $contact, 'first_name' );
314
+ $last_name = ig_es_get_data( $contact, 'last_name' );
315
+ $email = sanitize_email( ig_es_get_data( $contact, 'email' ) );
316
+ $guid = ig_es_get_data( $contact, 'hash' );
317
 
318
+ $list_ids = ES()->lists_contacts_db->get_list_ids_by_contact( $id );
319
+
320
+ $nonce = esc_attr( ig_es_get_request_data( '_wpnonce' ) );
 
 
 
321
  }
322
  }
323
 
324
  $submitted = ig_es_get_request_data( 'submitted' );
325
+
326
  if ( 'submitted' === $submitted ) {
327
 
328
  $contact_data = ig_es_get_post_data( 'contact_data', array() );
329
+
330
+ $is_error = false;
331
  if ( ! empty( $contact_data ) ) {
332
 
333
+ $email = sanitize_email( ig_es_get_data( $contact_data, 'email', '', true ) );
334
 
335
  if ( $email ) {
336
 
337
+ $lists = ig_es_get_data( $contact_data, 'lists', array() );
338
 
339
+ if ( count( $lists ) > 0 ) {
340
+ $first_name = ig_es_get_data( $contact_data, 'first_name', '', true );
341
+ $last_name = ig_es_get_data( $contact_data, 'last_name', '', true );
342
 
343
  if ( ! empty( $first_name ) ) {
344
 
371
 
372
  if ( ! $is_error ) {
373
 
374
+ $lists = ! empty( $lists ) ? $lists : array( 1 => 0 );
375
 
376
+ ES()->lists_contacts_db->update_contact_lists( $id, $lists );
377
 
378
  if ( $id ) {
379
 
430
  'first_name' => $first_name,
431
  'last_name' => $last_name,
432
  'email' => $email,
 
433
  'guid' => $guid
434
  );
435
 
562
  return $result;
563
  }
564
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
565
 
566
  public function prepare_contact_form( $data = array(), $is_new = false ) {
567
 
572
  $first_name = ! empty( $data['first_name'] ) ? $data['first_name'] : '';
573
  $last_name = ! empty( $data['last_name'] ) ? $data['last_name'] : '';
574
  $email = ! empty( $data['email'] ) ? $data['email'] : '';
 
575
  $send_welcome_email = ! empty( $data['send_welcome_email'] ) ? true : false;
576
 
577
  $lists_id_name_map = ES()->lists_db->get_list_id_name_map();
578
 
579
  if ( count( $lists_id_name_map ) ) {
580
+ //$list_html = ES_Shortcode::prepare_lists_checkboxes( $lists_id_name_map, array_keys( $lists_id_name_map ), 4, $selected_list_ids, $id, 'contact_data[lists][]' );
581
+ $list_html = $this->prepare_lists_html( $id );
582
  } else {
583
  $list_html = "<tr><td>" . __( 'No list found', 'email-subscribers' ) . "</td></tr>";
584
  }
631
  <?php
632
  }
633
 
 
634
  /**
635
+ * No contacts available
636
  *
637
+ * @since 4.0.0
638
  */
639
+ public function no_items() {
640
+ _e( 'No contacts avaliable.', 'email-subscribers' );
 
 
 
 
641
  }
642
 
643
 
 
 
 
644
  /**
645
  * Render a column when no column specific method exist.
646
  *
648
  * @param string $column_name
649
  *
650
  * @return mixed
651
+ *
652
+ * @since 4.0.0
653
  */
654
  public function column_default( $item, $column_name ) {
655
  $item = apply_filters( 'es_subscribers_col_data', $item, $column_name );
665
  }
666
  }
667
 
668
+ /**
669
+ * Prepare lists html to set status
670
+ *
671
+ * @param int $contact_id
672
+ * @param int $columns
673
+ *
674
+ * @return string
675
+ *
676
+ * @since 4.3.6
677
+ */
678
+ public function prepare_lists_html( $contact_id = 0, $columns = 2 ) {
679
+ $lists = ES()->lists_db->get_id_name_map();
680
+
681
+ $lists_html = '';
682
+ if ( count( $lists ) > 0 ) {
683
+
684
+ $list_contact_status_map = array();
685
+ if ( ! empty( $contact_id ) ) {
686
+ $list_contact_status_map = ES()->lists_contacts_db->get_list_contact_status_map( $contact_id );
687
+ }
688
+
689
+ $lists_html = "<div><table class='ig-es-form-list-html'><tr>";
690
+
691
+ $i = 0;
692
+ foreach ( $lists as $list_id => $list_name ) {
693
+ if ( $i != 0 && ( $i % $columns ) === 0 ) {
694
+ $lists_html .= "</tr><tr>";
695
+ }
696
+
697
+ $selected = ! empty( $list_contact_status_map[ $list_id ] ) ? $list_contact_status_map[ $list_id ] : '';
698
+
699
+ $status_dropdown_html = "<select class='ig-es-statuses-dropdown' name='contact_data[lists][" . $list_id . "]' >";
700
+ $status_dropdown_html .= ES_Common::prepare_statuses_dropdown_options( $selected );
701
+ $status_dropdown_html .= "</select>";
702
+
703
+ $status_span = '';
704
+ if(!empty($list_contact_status_map[$list_id])) {
705
+ $status_span = '<span class="es_list_contact_status ' . $list_contact_status_map[ $list_id ] . '" title="' . ucwords( $list_contact_status_map[ $list_id ] ) . '">';
706
+ }
707
+
708
+ $list_name = strlen( $list_name ) > 15 ? substr( $list_name, 0, 15 ) . '...' : $list_name;
709
+ $lists_html .= "<td>$status_span$list_name</td><td>$status_dropdown_html</td>";
710
+
711
+ $i ++;
712
+ }
713
+
714
+ $lists_html .= "</tr></table></div>";
715
+ }
716
+
717
+ return $lists_html;
718
+ }
719
+
720
+ /**
721
+ * Show lists with it's status
722
+ *
723
+ * @param $contact_id
724
+ *
725
+ * @return string
726
+ *
727
+ * @since 4.0.0
728
+ */
729
  public function get_lists_to_show( $contact_id ) {
730
 
731
  $list_str = '';
748
  return $list_str;
749
  }
750
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
751
  /**
752
  * Render the bulk edit checkbox
753
  *
754
  * @param array $item
755
  *
756
  * @return string
757
+ *
758
+ * @since 4.0.0
759
  */
760
  function column_cb( $item ) {
761
  return sprintf(
763
  );
764
  }
765
 
 
766
  /**
767
  * Method for name column
768
  *
769
  * @param array $item an array of DB data
770
  *
771
  * @return string
772
+ *
773
+ * @since 4.0.0
774
  */
775
  function column_name( $item ) {
776
  $delete_nonce = wp_create_nonce( 'ig_es_delete_subscriber' );
790
  return $title . $this->row_actions( $actions );
791
  }
792
 
 
793
  /**
794
  * Associative array of columns
795
  *
796
  * @return array
797
+ *
798
+ * @since 4.0.0
799
  */
800
  function get_columns() {
801
  $columns = array(
813
  * Columns to make sortable.
814
  *
815
  * @return array
816
+ *
817
+ * @since 4.0.0
818
  */
819
  public function get_sortable_columns() {
820
  $sortable_columns = array(
831
  * Returns an associative array containing the bulk action
832
  *
833
  * @return array
834
+ *
835
+ * @since 4.0.0
836
  */
837
  public function get_bulk_actions() {
838
  $actions = array(
877
 
878
  <?php }
879
 
880
+ /**
881
+ * Get Contact id
882
+ *
883
+ * @param $contact
884
+ *
885
+ * @return mixed
886
+ *
887
+ * @since 4.0.0
888
+ */
889
  public function get_contact_id( $contact ) {
890
  return $contact['id'];
891
  }
892
 
893
  /**
894
  * Handles data query and filter, sorting, and pagination.
895
+ *
896
+ * @since 4.0.0
897
  */
898
  public function prepare_items() {
899
 
931
  }
932
  }
933
 
934
+ /**
935
+ * Prepare list dropdown
936
+ *
937
+ * @since 4.0.0
938
+ */
939
  public function prepare_lists_dropdown() {
940
  $data = '<label for="bulk-action-selector-top" class="screen-reader-text">Select bulk action</label><select name="list_id" id="list_id" class="groupsselect" style="display: none">';
941
  $data .= ES_Common::prepare_list_dropdown_options();
1145
  $query = "UPDATE $ig_contacts_table SET form_id = 0 WHERE form_id = %d";
1146
 
1147
  $wpdb->query( $wpdb->prepare( $query, $form_id ) );
 
 
 
 
 
1148
  }
1149
 
 
1150
  }
lite/includes/classes/class-es-forms-table.php CHANGED
@@ -620,19 +620,6 @@ class ES_Forms_Table extends WP_List_Table {
620
  return $result;
621
  }
622
 
623
- /**
624
- * Returns the count of records in the database.
625
- *
626
- * @return null|string
627
- */
628
- public function record_count() {
629
- global $wpdb;
630
-
631
- $sql = "SELECT COUNT(*) FROM " . IG_FORMS_TABLE;
632
-
633
- return $wpdb->get_var( $sql );
634
- }
635
-
636
  /**
637
  * Render a column when no column specific method exist.
638
  *
620
  return $result;
621
  }
622
 
 
 
 
 
 
 
 
 
 
 
 
 
 
623
  /**
624
  * Render a column when no column specific method exist.
625
  *
lite/includes/classes/class-es-import-subscribers.php CHANGED
@@ -142,7 +142,7 @@ class ES_Import_Subscribers {
142
 
143
  if ( count( $emails ) > 0 ) {
144
 
145
- ES()->contacts_db->do_batch_insert( $contacts_data );
146
 
147
  $contact_ids = ES()->contacts_db->get_contact_ids_by_emails( $emails );
148
  if ( count( $contact_ids ) > 0 ) {
142
 
143
  if ( count( $emails ) > 0 ) {
144
 
145
+ ES()->contacts_db->bulk_insert( $contacts_data );
146
 
147
  $contact_ids = ES()->contacts_db->get_contact_ids_by_emails( $emails );
148
  if ( count( $contact_ids ) > 0 ) {
lite/includes/classes/class-es-lists-table.php CHANGED
@@ -391,20 +391,6 @@ class ES_Lists_Table extends WP_List_Table {
391
  return $result;
392
  }
393
 
394
-
395
- /**
396
- * Returns the count of records in the database.
397
- *
398
- * @return null|string
399
- */
400
- public function record_count() {
401
- global $wpdb;
402
-
403
- $sql = "SELECT COUNT(*) FROM " . IG_LISTS_TABLE;
404
-
405
- return $wpdb->get_var( $sql );
406
- }
407
-
408
  /**
409
  * Render a column when no column specific method exist.
410
  *
391
  return $result;
392
  }
393
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
394
  /**
395
  * Render a column when no column specific method exist.
396
  *
lite/includes/classes/class-es-mailer.php CHANGED
@@ -555,7 +555,7 @@ if ( ! class_exists( 'ES_Mailer' ) ) {
555
 
556
  $response = array();
557
 
558
- if ( is_string( $emails ) ) {
559
  $emails = array( $emails );
560
  }
561
 
555
 
556
  $response = array();
557
 
558
+ if ( ! is_array( $emails ) ) {
559
  $emails = array( $emails );
560
  }
561
 
lite/includes/db/class-es-db-campaigns.php CHANGED
@@ -567,7 +567,7 @@ class ES_DB_Campaigns extends ES_DB {
567
  */
568
  public function delete_campaigns( $ids = array() ) {
569
 
570
- if ( is_string( $ids ) ) {
571
  $ids = array( absint( $ids ) );
572
  }
573
 
567
  */
568
  public function delete_campaigns( $ids = array() ) {
569
 
570
+ if ( ! is_array( $ids ) ) {
571
  $ids = array( absint( $ids ) );
572
  }
573
 
lite/includes/db/class-es-db-contacts.php CHANGED
@@ -524,40 +524,6 @@ class ES_DB_Contacts extends ES_DB {
524
 
525
  }
526
 
527
- /**
528
- * Batch Insert Contacts
529
- *
530
- * @param $contacts
531
- *
532
- * @since 4.0.0
533
- */
534
- public function do_batch_insert( $contacts ) {
535
-
536
- // Prepare a batch of 50 contacts.
537
- $batches = array_chunk( $contacts, 50 );
538
-
539
- $columns = $this->get_columns();
540
- unset( $columns['id'] );
541
- $fields = array_keys( $columns );
542
- foreach ( $batches as $batch ) {
543
- $values = $place_holders = array();
544
- foreach ( $batch as $key => $contact ) {
545
-
546
- $contact = wp_parse_args( $contact, $this->get_column_defaults() );
547
-
548
- $formats = array();
549
- foreach ( $columns as $column => $format ) {
550
- $values[] = $contact[ $column ];
551
- $formats[] = $format;
552
- }
553
-
554
- $place_holders[] = "( " . implode( ', ', $formats ) . " )";
555
- }
556
-
557
- ES_DB::do_insert( IG_CONTACTS_TABLE, $fields, $place_holders, $values );
558
- }
559
- }
560
-
561
  /**
562
  * Get contact id by email
563
  *
@@ -650,7 +616,7 @@ class ES_DB_Contacts extends ES_DB {
650
  //}
651
  }
652
 
653
- $this->do_batch_insert( $contacts );
654
  }
655
 
656
  }
524
 
525
  }
526
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
527
  /**
528
  * Get contact id by email
529
  *
616
  //}
617
  }
618
 
619
+ $this->bulk_insert( $contacts );
620
  }
621
 
622
  }
lite/includes/db/class-es-db-forms.php CHANGED
@@ -83,24 +83,6 @@ class ES_DB_Forms extends ES_DB {
83
  );
84
  }
85
 
86
- /**
87
- * Insert Forms
88
- *
89
- * @param $place_holders
90
- * @param $values
91
- *
92
- * @return bool
93
- *
94
- * @since 4.2.2
95
- */
96
- public function do_forms_insert( $place_holders, $values ) {
97
- $forms_table = IG_FORMS_TABLE;
98
-
99
- $fields = array_keys( $this->get_column_defaults() );
100
-
101
- return ES_DB::do_insert( $forms_table, $fields, $place_holders, $values );
102
- }
103
-
104
  /**
105
  * Get ID Name Map of Forms
106
  *
@@ -133,7 +115,6 @@ class ES_DB_Forms extends ES_DB {
133
  return $id_name_map;
134
  }
135
 
136
-
137
  /**
138
  * Add Form
139
  *
@@ -212,8 +193,8 @@ class ES_DB_Forms extends ES_DB {
212
 
213
  if ( count( $forms ) > 0 ) {
214
 
215
- $place_holders = $values = array();
216
- foreach ( $forms as $form ) {
217
 
218
  $es_af_id = $form['es_af_id'];
219
  $es_af_title = $form['es_af_title'];
@@ -300,21 +281,17 @@ class ES_DB_Forms extends ES_DB {
300
  'desc' => $es_af_desc
301
  );
302
 
303
- $data['name'] = $es_af_title;
304
- $data['body'] = maybe_serialize( $body );
305
- $data['settings'] = maybe_serialize( $settings );
306
- $data['styles'] = null;
307
- $data['created_at'] = ig_get_current_date_time();
308
- $data['updated_at'] = null;
309
- $data['deleted_at'] = null;
310
- $data['af_id'] = $es_af_id;
311
-
312
- array_push( $values, $data['name'], $data['body'], $data['settings'], $data['styles'], $data['created_at'], $data['updated_at'], $data['deleted_at'], $data['af_id'] );
313
- $place_holders[] = "( %s, %s, %s, %s, %s, %s, %s, %d )";
314
-
315
  }
316
 
317
- $this->do_forms_insert( $place_holders, $values );
318
  }
319
  }
320
  }
@@ -341,7 +318,7 @@ class ES_DB_Forms extends ES_DB {
341
  */
342
  public function delete_forms( $ids ) {
343
 
344
- if ( is_string( $ids ) ) {
345
  $ids = array( $ids );
346
  }
347
 
83
  );
84
  }
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  /**
87
  * Get ID Name Map of Forms
88
  *
115
  return $id_name_map;
116
  }
117
 
 
118
  /**
119
  * Add Form
120
  *
193
 
194
  if ( count( $forms ) > 0 ) {
195
 
196
+ $data = array();
197
+ foreach ( $forms as $key => $form ) {
198
 
199
  $es_af_id = $form['es_af_id'];
200
  $es_af_title = $form['es_af_title'];
281
  'desc' => $es_af_desc
282
  );
283
 
284
+ $data[ $key ]['name'] = $es_af_title;
285
+ $data[ $key ]['body'] = maybe_serialize( $body );
286
+ $data[ $key ]['settings'] = maybe_serialize( $settings );
287
+ $data[ $key ]['styles'] = null;
288
+ $data[ $key ]['created_at'] = ig_get_current_date_time();
289
+ $data[ $key ]['updated_at'] = null;
290
+ $data[ $key ]['deleted_at'] = null;
291
+ $data[ $key ]['af_id'] = $es_af_id;
 
 
 
 
292
  }
293
 
294
+ $this->bulk_insert( $data );
295
  }
296
  }
297
  }
318
  */
319
  public function delete_forms( $ids ) {
320
 
321
+ if ( ! is_array( $ids ) ) {
322
  $ids = array( $ids );
323
  }
324
 
lite/includes/db/class-es-db-lists-contacts.php CHANGED
@@ -94,7 +94,7 @@ class ES_DB_Lists_Contacts extends ES_DB {
94
  */
95
  public function add_contact_to_lists( $contact_data = array(), $list_ids = array() ) {
96
 
97
- if ( is_string( $list_ids ) ) {
98
  $list_ids = array( $list_ids );
99
  }
100
 
@@ -176,7 +176,7 @@ class ES_DB_Lists_Contacts extends ES_DB {
176
  return false;
177
  }
178
 
179
- if ( is_string( $contact_ids ) ) {
180
  $contact_ids = array( absint( $contact_ids ) );
181
  }
182
 
@@ -283,23 +283,19 @@ class ES_DB_Lists_Contacts extends ES_DB {
283
  * @return bool
284
  *
285
  * @since 4.3.5
 
286
  */
287
- public function update_contact_lists( $contact_id = 0, $list_ids = array() ) {
288
 
289
- if ( empty( $contact_id ) || empty( $list_ids ) ) {
290
  return false;
291
  }
292
 
293
- if ( is_string( $list_ids ) ) {
294
- $list_ids = array( absint( $list_ids ) );
295
- }
296
-
297
  $contact_id = esc_sql( $contact_id );
298
- $list_ids = esc_sql( $list_ids );
299
 
300
- $this->remove_contacts_from_lists( $contact_id );
301
 
302
- if ( ! empty( $list_ids ) ) {
303
  $optin_type_option = get_option( 'ig_es_optin_type', true );
304
 
305
  $optin_type = 1;
@@ -307,12 +303,24 @@ class ES_DB_Lists_Contacts extends ES_DB {
307
  $optin_type = 2;
308
  }
309
 
310
- $data['contact_id'] = $contact_id;
311
- $data['status'] = 'subscribed';
312
- $data['optin_type'] = $optin_type;
313
- $data['subscribed_at'] = ig_get_current_date_time();
 
 
 
 
 
 
 
 
 
 
 
 
314
 
315
- return ES()->lists_contacts_db->add_contact_to_lists( $data, $list_ids );
316
  }
317
 
318
  return false;
@@ -331,11 +339,11 @@ class ES_DB_Lists_Contacts extends ES_DB {
331
  */
332
  public function remove_contacts_from_lists( $contact_ids = array(), $list_ids = array() ) {
333
 
334
- if ( is_string( $contact_ids ) ) {
335
  $contact_ids = array( absint( $contact_ids ) );
336
  }
337
 
338
- if ( is_string( $list_ids ) ) {
339
  $list_ids = array( absint( $list_ids ) );
340
  }
341
 
@@ -538,7 +546,7 @@ class ES_DB_Lists_Contacts extends ES_DB {
538
  return array();
539
  }
540
 
541
- if ( is_string( $contact_ids ) ) {
542
  $contact_ids = array( $contact_ids );
543
  }
544
 
@@ -575,7 +583,7 @@ class ES_DB_Lists_Contacts extends ES_DB {
575
  public function edit_subscriber_status( $ids = array(), $status = '' ) {
576
  global $wpdb;
577
 
578
- if ( is_string( $ids ) ) {
579
  $ids = array( $ids );
580
  }
581
 
@@ -620,7 +628,7 @@ class ES_DB_Lists_Contacts extends ES_DB {
620
  public function is_status_update_required( $ids = array(), $status = '' ) {
621
  global $wpdb;
622
 
623
- if ( is_string( $ids ) ) {
624
  $ids = array( $ids );
625
  }
626
 
94
  */
95
  public function add_contact_to_lists( $contact_data = array(), $list_ids = array() ) {
96
 
97
+ if ( ! is_array( $list_ids ) ) {
98
  $list_ids = array( $list_ids );
99
  }
100
 
176
  return false;
177
  }
178
 
179
+ if ( ! is_array( $contact_ids ) ) {
180
  $contact_ids = array( absint( $contact_ids ) );
181
  }
182
 
283
  * @return bool
284
  *
285
  * @since 4.3.5
286
+ * @since 4.3.6 Modified lists saving
287
  */
288
+ public function update_contact_lists( $contact_id = 0, $lists = array() ) {
289
 
290
+ if ( empty( $contact_id ) || empty( $lists ) ) {
291
  return false;
292
  }
293
 
 
 
 
 
294
  $contact_id = esc_sql( $contact_id );
295
+ $lists = esc_sql( $lists );
296
 
297
+ if ( ! empty( $lists ) ) {
298
 
 
299
  $optin_type_option = get_option( 'ig_es_optin_type', true );
300
 
301
  $optin_type = 1;
303
  $optin_type = 2;
304
  }
305
 
306
+ // Remove from all lists
307
+ $this->remove_contacts_from_lists( $contact_id );
308
+
309
+ $data = array();
310
+ $key = 0;
311
+ foreach ( $lists as $list_id => $status ) {
312
+ if ( ! empty( $status ) ) {
313
+ $data[ $key ]['list_id'] = $list_id;
314
+ $data[ $key ]['contact_id'] = $contact_id;
315
+ $data[ $key ]['status'] = $status;
316
+ $data[ $key ]['optin_type'] = $optin_type;
317
+ $data[ $key ]['subscribed_at'] = ig_get_current_date_time();
318
+
319
+ $key ++;
320
+ }
321
+ }
322
 
323
+ return ES()->lists_contacts_db->bulk_insert( $data );
324
  }
325
 
326
  return false;
339
  */
340
  public function remove_contacts_from_lists( $contact_ids = array(), $list_ids = array() ) {
341
 
342
+ if ( ! is_array( $contact_ids ) ) {
343
  $contact_ids = array( absint( $contact_ids ) );
344
  }
345
 
346
+ if ( ! is_array( $list_ids ) ) {
347
  $list_ids = array( absint( $list_ids ) );
348
  }
349
 
546
  return array();
547
  }
548
 
549
+ if ( ! is_array( $contact_ids ) ) {
550
  $contact_ids = array( $contact_ids );
551
  }
552
 
583
  public function edit_subscriber_status( $ids = array(), $status = '' ) {
584
  global $wpdb;
585
 
586
+ if ( ! is_array( $ids ) ) {
587
  $ids = array( $ids );
588
  }
589
 
628
  public function is_status_update_required( $ids = array(), $status = '' ) {
629
  global $wpdb;
630
 
631
+ if ( ! is_array( $ids ) ) {
632
  $ids = array( $ids );
633
  }
634
 
lite/includes/db/class-es-db-lists.php CHANGED
@@ -197,7 +197,7 @@ class ES_DB_Lists extends ES_DB {
197
  */
198
  public function add_lists( $lists ) {
199
 
200
- if ( is_string( $lists ) ) {
201
  $lists = array( $lists );
202
  }
203
 
@@ -234,7 +234,7 @@ class ES_DB_Lists extends ES_DB {
234
  */
235
  public function add_list( $list = '' ) {
236
 
237
- if ( empty( $list ) || ! is_string( $list ) ) {
238
  return 0;
239
  }
240
 
@@ -356,7 +356,7 @@ class ES_DB_Lists extends ES_DB {
356
  */
357
  public function delete_lists( $ids ) {
358
 
359
- if ( is_string( $ids ) ) {
360
  $ids = array( $ids );
361
  }
362
 
197
  */
198
  public function add_lists( $lists ) {
199
 
200
+ if ( ! is_array( $lists ) ) {
201
  $lists = array( $lists );
202
  }
203
 
234
  */
235
  public function add_list( $list = '' ) {
236
 
237
+ if ( empty( $list ) || ! is_scalar( $list ) ) {
238
  return 0;
239
  }
240
 
356
  */
357
  public function delete_lists( $ids ) {
358
 
359
+ if ( ! is_array( $ids ) ) {
360
  $ids = array( $ids );
361
  }
362
 
lite/includes/db/class-es-db.php CHANGED
@@ -447,7 +447,9 @@ abstract class ES_DB {
447
  }
448
 
449
  // Get the first value from an array to check data structure
450
- $data = $values[0];
 
 
451
 
452
  // Set default values
453
  $data = wp_parse_args( $data, $this->get_column_defaults() );
447
  }
448
 
449
  // Get the first value from an array to check data structure
450
+ $first_value = array_slice( $values, 0, 1 );
451
+
452
+ $data = array_shift( $first_value );
453
 
454
  // Set default values
455
  $data = wp_parse_args( $data, $this->get_column_defaults() );
lite/public/class-email-subscribers-public.php CHANGED
@@ -321,7 +321,6 @@ class Email_Subscribers_Public {
321
 
322
  }
323
 
324
-
325
  /**
326
  * Allow user to select the list from which they want to unsubscribe
327
  *
321
 
322
  }
323
 
 
324
  /**
325
  * Allow user to select the list from which they want to unsubscribe
326
  *
lite/public/partials/class-es-shortcode.php CHANGED
@@ -266,6 +266,7 @@ class ES_Shortcode {
266
  $i ++;
267
  }
268
  }
 
269
  $lists_html .= '</tr></table></div>';
270
 
271
  return $lists_html;
266
  $i ++;
267
  }
268
  }
269
+
270
  $lists_html .= '</tr></table></div>';
271
 
272
  return $lists_html;
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
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses
11
 
@@ -300,6 +300,11 @@ Refer [here](https://www.icegram.com/documentation/es-faq/).
300
 
301
  == Changelog ==
302
 
 
 
 
 
 
303
  **4.3.5 (04.12.2019)**
304
  * New: Added setting to set cron interval
305
  * New: Added setting to set maximum emails to send on every cron request
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
 
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
306
+ * Fix: WordPress contact sync issue
307
+
308
  **4.3.5 (04.12.2019)**
309
  * New: Added setting to set cron interval
310
  * New: Added setting to set maximum emails to send on every cron request