Email Subscribers & Newsletters - Version 4.1.14

Version Description

(28.08.2019) = * New: Import First Name & Last Name * Update: Added "Send Welcome email" option to send out Welcome Email. * Fix: Multiple Welcome & Admin email notification on clicking confirmation link multiple times

Download this release

Release Info

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

Code changes from version 4.1.13 to 4.1.14

admin/images/email-subscribers-pricing.png CHANGED
Binary file
admin/images/es-esaf-integration.png DELETED
Binary file
admin/partials/sample.csv CHANGED
@@ -1,2 +1,4 @@
1
- Name,Email
2
- abc,abc@xyz.com
 
 
1
+ First Name, Last Name, Email
2
+ John, Doe, john@example.com
3
+ Mark, T, mark.t@example.com
4
+ Tracy, Thomas, tracy@example.com
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.13
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.13' );
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.14
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.14' );
28
  define( 'ES_PLUGIN_BASE_NAME', plugin_basename( __FILE__ ) );
29
 
30
  if ( ! defined( 'ES_PLUGIN_FILE' ) ) {
includes/admin/class-es-admin-settings.php CHANGED
@@ -80,12 +80,12 @@ class ES_Admin_Settings {
80
  foreach ( $options as $key => $value ) {
81
  if ( substr( $key, 0, 6 ) === 'ig_es_' ) {
82
 
83
- $value = stripslashes_deep($value);
84
 
85
  if ( in_array( $key, $text_fields_to_sanitize ) ) {
86
  $value = sanitize_text_field( $value );
87
  } elseif ( in_array( $key, $texarea_fields_to_sanitize ) ) {
88
- $value = wp_kses_post($value);
89
  } elseif ( in_array( $key, $email_fields_to_sanitize ) ) {
90
  $value = sanitize_email( $value );
91
  }
@@ -108,33 +108,33 @@ class ES_Admin_Settings {
108
  <h1 class="wp-heading-inline">Settings</h1>
109
  <form action="" method="post" id="email_tabs_form" class="ig-settings-form rcorners">
110
 
111
- <?php settings_fields( 'email_subscribers_settings' );
112
  $es_settings_tabs = array(
113
- 'general' => array('icon' => 'admin-generic', 'name' => __( 'General', 'email-subscribers' ) ),
114
- 'signup_confirmation'=> array('icon' => 'groups', 'name' => __( 'Notifications', 'email-subscribers' ) ),
115
- 'email_sending'=> array('icon' => 'schedule', 'name' => __( 'Email Sending', 'email-subscribers' ) ),
116
- 'security_settings'=> array('icon' => 'lock', 'name' => __( 'Security', 'email-subscribers' ) ),
117
  );
118
- $es_settings_tabs = apply_filters('ig_es_settings_tabs', $es_settings_tabs);
119
  ?>
120
 
121
  <div id="es-settings-tabs">
122
  <div id="menu-tab-listing" class="">
123
  <ul class="main-tab-nav">
124
- <?php
125
- foreach ($es_settings_tabs as $key => $value) {
126
- ?>
127
- <li class="ig-menu-tab"><a href="#tabs-<?php echo $key?>"><i class="dashicons dashicons-<?php echo $value['icon']?>"></i>&nbsp;<?php echo $value['name'] ?></a></li>
128
  <?php
 
 
 
 
129
  }
130
- ?>
131
  </ul>
132
  </div>
133
  <div id="menu-tab-content">
134
- <?php $settings = self::get_registered_settings();
135
- foreach ($settings as $key => $value) {
136
  ?>
137
- <div id="tabs-<?php echo $key?>"><?php $this->render_settings_fields( $value ); ?></div>
138
  <?php
139
  }
140
  ?>
@@ -649,11 +649,11 @@ class ES_Admin_Settings {
649
 
650
  function render_settings_fields( $fields ) {
651
 
652
- $html = "<table class='form-table'>";
653
- $html .= "<tbody>";
654
  $button_html = '';
655
  foreach ( $fields as $field ) {
656
- if(!empty($field['name'])){
657
  $html .= "<tr><th scope='row'>";
658
  $html .= $field['name'];
659
 
@@ -662,7 +662,7 @@ class ES_Admin_Settings {
662
  $helper = $field['info'];
663
  $html .= "<br />" . sprintf( '<span class="helper">%s</span>', $helper ); // Show it
664
  }
665
- $button_html = "<tr><td></td>" ;
666
 
667
  $html .= "</th>";
668
  }
@@ -680,8 +680,10 @@ class ES_Admin_Settings {
680
 
681
  $html .= "</td></tr>";
682
  }
683
- $button_html = (!empty($button_html)) ? "<tr>" : $button_html;
684
- $html .= $button_html."<td class='es-settings-submit-btn'>";
 
 
685
  $html .= '<input type="hidden" name="submitted" value="submitted"/>';
686
  $html .= '<input type="hidden" name="submit_action" value="ig-es-save-admin-settings"/>';
687
  $nonce = wp_create_nonce( 'es-update-settings' );
80
  foreach ( $options as $key => $value ) {
81
  if ( substr( $key, 0, 6 ) === 'ig_es_' ) {
82
 
83
+ $value = stripslashes_deep( $value );
84
 
85
  if ( in_array( $key, $text_fields_to_sanitize ) ) {
86
  $value = sanitize_text_field( $value );
87
  } elseif ( in_array( $key, $texarea_fields_to_sanitize ) ) {
88
+ $value = wp_kses_post( $value );
89
  } elseif ( in_array( $key, $email_fields_to_sanitize ) ) {
90
  $value = sanitize_email( $value );
91
  }
108
  <h1 class="wp-heading-inline">Settings</h1>
109
  <form action="" method="post" id="email_tabs_form" class="ig-settings-form rcorners">
110
 
111
+ <?php settings_fields( 'email_subscribers_settings' );
112
  $es_settings_tabs = array(
113
+ 'general' => array( 'icon' => 'admin-generic', 'name' => __( 'General', 'email-subscribers' ) ),
114
+ 'signup_confirmation' => array( 'icon' => 'groups', 'name' => __( 'Notifications', 'email-subscribers' ) ),
115
+ 'email_sending' => array( 'icon' => 'schedule', 'name' => __( 'Email Sending', 'email-subscribers' ) ),
116
+ 'security_settings' => array( 'icon' => 'lock', 'name' => __( 'Security', 'email-subscribers' ) ),
117
  );
118
+ $es_settings_tabs = apply_filters( 'ig_es_settings_tabs', $es_settings_tabs );
119
  ?>
120
 
121
  <div id="es-settings-tabs">
122
  <div id="menu-tab-listing" class="">
123
  <ul class="main-tab-nav">
 
 
 
 
124
  <?php
125
+ foreach ( $es_settings_tabs as $key => $value ) {
126
+ ?>
127
+ <li class="ig-menu-tab"><a href="#tabs-<?php echo $key ?>"><i class="dashicons dashicons-<?php echo $value['icon'] ?>"></i>&nbsp;<?php echo $value['name'] ?></a></li>
128
+ <?php
129
  }
130
+ ?>
131
  </ul>
132
  </div>
133
  <div id="menu-tab-content">
134
+ <?php $settings = self::get_registered_settings();
135
+ foreach ( $settings as $key => $value ) {
136
  ?>
137
+ <div id="tabs-<?php echo $key ?>"><?php $this->render_settings_fields( $value ); ?></div>
138
  <?php
139
  }
140
  ?>
649
 
650
  function render_settings_fields( $fields ) {
651
 
652
+ $html = "<table class='form-table'>";
653
+ $html .= "<tbody>";
654
  $button_html = '';
655
  foreach ( $fields as $field ) {
656
+ if ( ! empty( $field['name'] ) ) {
657
  $html .= "<tr><th scope='row'>";
658
  $html .= $field['name'];
659
 
662
  $helper = $field['info'];
663
  $html .= "<br />" . sprintf( '<span class="helper">%s</span>', $helper ); // Show it
664
  }
665
+ $button_html = "<tr><td></td>";
666
 
667
  $html .= "</th>";
668
  }
680
 
681
  $html .= "</td></tr>";
682
  }
683
+
684
+ $button_html = empty( $button_html ) ? "<tr>" : $button_html;
685
+
686
+ $html .= $button_html . "<td class='es-settings-submit-btn'>";
687
  $html .= '<input type="hidden" name="submitted" value="submitted"/>';
688
  $html .= '<input type="hidden" name="submit_action" value="ig-es-save-admin-settings"/>';
689
  $nonce = wp_create_nonce( 'es-update-settings' );
includes/admin/class-es-import-subscribers.php CHANGED
@@ -23,6 +23,11 @@ class ES_Import_Subscribers {
23
 
24
  if ( isset( $_POST["submit"] ) ) {
25
 
 
 
 
 
 
26
  if ( isset( $_FILES["file"] ) ) {
27
 
28
  if ( is_uploaded_file( $_FILES["file"]["tmp_name"] ) ) {
@@ -62,24 +67,32 @@ class ES_Import_Subscribers {
62
  $i = 0;
63
  while ( ( $data = fgetcsv( $handle ) ) !== false ) {
64
 
65
- $data = array_combine( $headers, $data );
66
- $name = isset( $data['Name'] ) ? trim( $data['Name'] ) : '';
67
- $email = isset( $data['Email'] ) ? sanitize_email(trim( $data['Email'] )) : '';
68
 
69
  if ( empty( $email ) ) {
70
  $invalid_emails_count ++;
71
  continue;
72
  }
73
 
74
- if ( empty( $name ) ) {
75
- $name = ES_Common::get_name_from_email( $email );
76
- }
77
 
78
- if ( !in_array( $email, $existing_contacts ) ) {
 
 
79
 
80
- $names = ES_Common::prepare_first_name_last_name( $name );
81
- $first_name = sanitize_text_field($names['first_name']);
82
- $last_name = sanitize_text_field($names['last_name']);
 
 
 
 
 
 
 
 
 
83
 
84
  $guid = ES_Common::generate_guid();
85
 
@@ -94,7 +107,7 @@ class ES_Import_Subscribers {
94
  $existing_contacts[] = $email;
95
  } else {
96
  $existing_contacts_count ++;
97
- }
98
 
99
  $emails[] = $email;
100
  $imported_subscribers_count ++;
@@ -106,7 +119,7 @@ class ES_Import_Subscribers {
106
 
107
  $contact_ids = ES_DB_Contacts::get_contact_ids_by_emails( $emails );
108
  if ( count( $contact_ids ) > 0 ) {
109
- ES_DB_Lists_Contacts::delete_contacts_from_list($list_id, $contact_ids);
110
  ES_DB_Lists_Contacts::do_import_contacts_into_list( $list_id, $contact_ids, $status, 1, $current_date_time );
111
  }
112
 
@@ -206,6 +219,7 @@ class ES_Import_Subscribers {
206
  </tbody>
207
  </table>
208
  <p style="padding-top:10px;">
 
209
  <input type="submit" name="submit" class="button-primary" value=<?php _e( "Import", 'email-subscribers' ); ?>>
210
  </p>
211
  </form>
@@ -225,8 +239,8 @@ class ES_Import_Subscribers {
225
  <div class="wrap">
226
  <h2> <?php _e( 'Audience > Import Contacts', 'email-subscribers' );
227
 
228
- ES_Common::prepare_main_header_navigation($audience_tab_main_navigation);
229
- ?>
230
 
231
  </h2>
232
  <?php $this->import_report_callback(); ?>
23
 
24
  if ( isset( $_POST["submit"] ) ) {
25
 
26
+ if (! isset( $_POST['import_contacts'] ) || ! wp_verify_nonce( $_POST['import_contacts'], 'import-contacts' ) ) {
27
+ $message = __( "Sorry, you do not have permission to import contacts.", 'email-subscribers' );
28
+ ES_Common::show_message( $message, 'error' );
29
+ }
30
+
31
  if ( isset( $_FILES["file"] ) ) {
32
 
33
  if ( is_uploaded_file( $_FILES["file"]["tmp_name"] ) ) {
67
  $i = 0;
68
  while ( ( $data = fgetcsv( $handle ) ) !== false ) {
69
 
70
+ $data = array_combine( $headers, $data );
71
+ $email = isset( $data['Email'] ) ? sanitize_email( trim( $data['Email'] ) ) : '';
 
72
 
73
  if ( empty( $email ) ) {
74
  $invalid_emails_count ++;
75
  continue;
76
  }
77
 
78
+ if ( ! in_array( $email, $existing_contacts ) ) {
 
 
79
 
80
+ $name = isset( $data['Name'] ) ? trim( $data['Name'] ) : '';
81
+ $first_name = isset( $data['First Name'] ) ? sanitize_text_field( trim( $data['First Name'] ) ) : '';
82
+ $last_name = isset( $data['Last Name'] ) ? sanitize_text_field( trim( $data['Last Name'] ) ) : '';
83
 
84
+ // If we don't get the first_name & last_name, consider Name field.
85
+ // If name empty, get the name from Email
86
+ if ( empty( $first_name ) && empty( $last_name ) ) {
87
+
88
+ if ( empty( $name ) ) {
89
+ $name = ES_Common::get_name_from_email( $email );
90
+ }
91
+
92
+ $names = ES_Common::prepare_first_name_last_name( $name );
93
+ $first_name = sanitize_text_field( $names['first_name'] );
94
+ $last_name = sanitize_text_field( $names['last_name'] );
95
+ }
96
 
97
  $guid = ES_Common::generate_guid();
98
 
107
  $existing_contacts[] = $email;
108
  } else {
109
  $existing_contacts_count ++;
110
+ }
111
 
112
  $emails[] = $email;
113
  $imported_subscribers_count ++;
119
 
120
  $contact_ids = ES_DB_Contacts::get_contact_ids_by_emails( $emails );
121
  if ( count( $contact_ids ) > 0 ) {
122
+ ES_DB_Lists_Contacts::delete_contacts_from_list( $list_id, $contact_ids );
123
  ES_DB_Lists_Contacts::do_import_contacts_into_list( $list_id, $contact_ids, $status, 1, $current_date_time );
124
  }
125
 
219
  </tbody>
220
  </table>
221
  <p style="padding-top:10px;">
222
+ <?php wp_nonce_field( 'import-contacts', 'import_contacts' ); ?>
223
  <input type="submit" name="submit" class="button-primary" value=<?php _e( "Import", 'email-subscribers' ); ?>>
224
  </p>
225
  </form>
239
  <div class="wrap">
240
  <h2> <?php _e( 'Audience > Import Contacts', 'email-subscribers' );
241
 
242
+ ES_Common::prepare_main_header_navigation( $audience_tab_main_navigation );
243
+ ?>
244
 
245
  </h2>
246
  <?php $this->import_report_callback(); ?>
includes/admin/class-es-newsletters.php CHANGED
@@ -62,28 +62,7 @@ class ES_Newsletters {
62
 
63
  ES_Common::show_message( $message, 'success' );
64
 
65
- // **************** Quick Feedback - Start ********************/
66
- global $ig_es_feedback;
67
-
68
- if ( $ig_es_feedback->can_show_feedback_widget() ) {
69
-
70
- $event = 'broadcast.created';
71
- if ( ! $ig_es_feedback->is_event_transient_set( $ig_es_feedback->event_prefix . $event ) ) {
72
-
73
- $params = array(
74
- 'type' => 'emoji',
75
- 'event' => $event,
76
- 'title' => "How's your experience sending broadcast?",
77
- 'position' => 'top-end',
78
- 'width' => 300,
79
- 'delay' => 2, // seconds
80
- 'confirmButtonText' => __( 'Send', 'email-subscribers' )
81
- );
82
- ES_Common::render_feedback_widget( $params );
83
- }
84
- }
85
-
86
- // **************** Quick Feedback - End ********************/
87
  }
88
 
89
  }
62
 
63
  ES_Common::show_message( $message, 'success' );
64
 
65
+ do_action('ig_es_broadcast_created');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  }
67
 
68
  }
includes/admin/class-es-subscribers-table.php CHANGED
@@ -187,13 +187,14 @@ class ES_Subscribers_Table extends WP_List_Table {
187
 
188
  $first_name = $action = $last_name = $email = $guid = $created = '';
189
  $list_ids = array();
 
190
 
191
  if ( $id === 0 ) {
192
  $title = __( 'Add New Contact', 'email-subscribers' );
193
  $title_action = '<a href="admin.php?page=es_lists&action=manage-lists" class="page-title-action es-imp-button">' . __( 'Manage Lists', 'email-subscribers' ) . '</a>';
194
 
195
  } else {
196
-
197
  $title = __( 'Edit Contact', 'email-subscribers' );
198
  $title_action = '<a href="admin.php?page=es_subscribers&action=new" class="page-title-action">' . __( 'Add New', 'email-subscribers' ) . '</a>';
199
 
@@ -209,40 +210,17 @@ class ES_Subscribers_Table extends WP_List_Table {
209
  $email = ! empty( $contact['email'] ) ? $contact['email'] : '';
210
  $list_ids = ES_DB_Lists_Contacts::get_list_ids_by_contact( $id );
211
  $guid = $contact['hash'];
212
- $created = $contact['created_at'];
213
  $nonce = esc_attr( Email_Subscribers::get_request( '_wpnonce' ) );
214
- $action = "admin.php?page=es_subscribers&action=edit&subscriber={$id}&_wpnonce={$nonce}&status=updated";
215
  }
216
  }
217
 
218
  $submitted = Email_Subscribers::get_request( 'submitted' );
219
- if ( 'submitted' === $submitted ) {
220
- $contact_data = ! empty( $_POST['contact_data'] ) ? $_POST['contact_data'] : array();
221
-
222
- $email = ! empty( $contact_data['email'] ) ? sanitize_email( $contact_data['email'] ) : '';
223
- $first_name = ! empty( $contact_data['first_name'] ) ? sanitize_text_field( $contact_data['first_name'] ) : '';
224
- $last_name = ! empty( $contact_data['last_name'] ) ? sanitize_text_field( $contact_data['last_name'] ) : '';
225
- $list_ids = ! empty( $contact_data['lists'] ) ? $contact_data['lists'] : array();
226
- }
227
-
228
- $data = array(
229
- 'id' => $id,
230
- 'first_name' => $first_name,
231
- 'last_name' => $last_name,
232
- 'email' => $email,
233
- 'selected_list_ids' => $list_ids,
234
- 'guid' => $guid,
235
- //'action' => $action,
236
- //'created' => $created,
237
- );
238
-
239
- $submitted = Email_Subscribers::get_request( 'submitted' );
240
-
241
  if ( 'submitted' === $submitted ) {
242
  $contact_data = ! empty( $_POST['contact_data'] ) ? $_POST['contact_data'] : array();
243
 
244
  $is_error = false;
245
  if ( ! empty( $contact_data ) ) {
 
246
  $email = ! empty( $contact_data['email'] ) ? sanitize_email( $contact_data['email'] ) : '';
247
 
248
  if ( $email ) {
@@ -250,7 +228,6 @@ class ES_Subscribers_Table extends WP_List_Table {
250
  $list_ids = ! empty( $contact_data['lists'] ) ? $contact_data['lists'] : array();
251
 
252
  if ( count( $list_ids ) > 0 ) {
253
-
254
  $first_name = ! empty( $contact_data['first_name'] ) ? sanitize_text_field( $contact_data['first_name'] ) : '';
255
  $last_name = ! empty( $contact_data['last_name'] ) ? sanitize_text_field( $contact_data['last_name'] ) : '';
256
 
@@ -263,9 +240,7 @@ class ES_Subscribers_Table extends WP_List_Table {
263
  );
264
 
265
  // Add contact
266
- $is_new = true;
267
  if ( $id ) {
268
- $is_new = false;
269
  $this->update_contact( $id, $contact );
270
  } else {
271
  $id = ES_DB_Contacts::get_contact_id_by_email( $email );
@@ -295,23 +270,25 @@ class ES_Subscribers_Table extends WP_List_Table {
295
 
296
  if ( $is_new ) {
297
 
298
- // Get comma(,) separated list name based on ids
299
- $list_name = ES_Common::prepare_list_name_by_ids( $list_ids );
300
 
301
- $name = ES_Common::prepare_name_from_first_name_last_name($contact['first_name'], $contact['last_name']);
 
 
302
 
303
- $template_data = array(
304
- 'email' => $contact['email'],
305
- 'db_id' => $id,
306
- 'name' => $name,
307
- 'first_name' => $contact['first_name'],
308
- 'last_name' => $contact['last_name'],
309
- 'guid' => $contact['hash'],
310
- 'list_name' => $list_name
311
- );
312
 
313
- // Send Welcome Email
314
- ES_Mailer::send_welcome_email($contact['email'], $template_data);
 
315
 
316
  $message = __( 'Contact has been added successfully!', 'email-subscribers' );
317
  } else {
@@ -339,6 +316,15 @@ class ES_Subscribers_Table extends WP_List_Table {
339
  }
340
  }
341
 
 
 
 
 
 
 
 
 
 
342
  ?>
343
 
344
  <div class="wrap">
@@ -348,7 +334,7 @@ class ES_Subscribers_Table extends WP_List_Table {
348
  <div id="post-body" class="metabox-holder column-1">
349
  <div id="post-body-content">
350
  <div class="meta-box-sortables ui-sortable es-contact-form">
351
- <?php echo $this->prepare_contact_form( $data ); ?>
352
  </div>
353
  </div>
354
  </div>
@@ -367,12 +353,7 @@ class ES_Subscribers_Table extends WP_List_Table {
367
  *
368
  * @return mixed
369
  */
370
- public
371
- function get_subscribers(
372
- $per_page = 5,
373
- $page_number = 1,
374
- $do_count_only = false
375
- ) {
376
  global $wpdb;
377
 
378
  $order_by = Email_Subscribers::get_request( 'orderby' );
@@ -446,9 +427,9 @@ class ES_Subscribers_Table extends WP_List_Table {
446
  if ( ! $do_count_only ) {
447
 
448
  // Prepare Order by clause
449
- $order = ! empty( $order ) ? strtolower($order) : 'desc';
450
- $expected_order_values = array('asc', 'desc');
451
- if(!in_array($order, $expected_order_values)) {
452
  $order = 'desc';
453
  }
454
 
@@ -474,10 +455,7 @@ class ES_Subscribers_Table extends WP_List_Table {
474
  return $result;
475
  }
476
 
477
- public
478
- function edit_list(
479
- $id
480
- ) {
481
  global $wpdb;
482
 
483
  $notificationid = $wpdb->get_results( "SELECT * FROM " . IG_CONTACTS_TABLE . " WHERE id = $id" );
@@ -523,7 +501,7 @@ class ES_Subscribers_Table extends WP_List_Table {
523
  <div id="post-body" class="metabox-holder column-1">
524
  <div id="post-body-content">
525
  <div class="meta-box-sortables ui-sortable es-contact-form">'
526
- . $this->prepare_contact_form( $data ) .
527
  '</div>
528
  </div>
529
  </div>
@@ -533,16 +511,17 @@ class ES_Subscribers_Table extends WP_List_Table {
533
  return $editform;
534
  }
535
 
536
- public function prepare_contact_form( $data = array() ) {
537
 
538
- $id = ! empty( $data['id'] ) ? $data['id'] : '';
539
- $created = ! empty( $data['created'] ) ? $data['created'] : '';
540
- $guid = ! empty( $data['guid'] ) ? $data['guid'] : '';
541
- $action = ! empty( $data['action'] ) ? $data['action'] : '#';
542
- $first_name = ! empty( $data['first_name'] ) ? $data['first_name'] : '';
543
- $last_name = ! empty( $data['last_name'] ) ? $data['last_name'] : '';
544
- $email = ! empty( $data['email'] ) ? $data['email'] : '';
545
- $selected_list_ids = ! empty( $data['selected_list_ids'] ) ? $data['selected_list_ids'] : array();
 
546
 
547
  $lists_id_name_map = ES_DB_Lists::get_list_id_name_map();
548
 
@@ -570,6 +549,15 @@ class ES_Subscribers_Table extends WP_List_Table {
570
  <td><label><b><?php _e( 'Email', 'email-subscribers' ); ?></b></label></td>
571
  <td><input type="email" id="email" name="contact_data[email]" value="<?php echo $email; ?>"/></td>
572
  </tr>
 
 
 
 
 
 
 
 
 
573
  <tr class="form-field">
574
  <td><label><b><?php _e( 'List(s)', 'email-subscribers' ); ?></b></label></td>
575
  <td>
@@ -981,7 +969,7 @@ class ES_Subscribers_Table extends WP_List_Table {
981
  }
982
 
983
  // loop over the array of record IDs and delete them
984
- $edited = ES_DB_Contacts::edit_subscriber_status( $subscriber_ids, $status );
985
 
986
  if ( $edited ) {
987
  $message = __( 'Status has been changed successfully!', 'email-subscribers' );
187
 
188
  $first_name = $action = $last_name = $email = $guid = $created = '';
189
  $list_ids = array();
190
+ $is_new = true;
191
 
192
  if ( $id === 0 ) {
193
  $title = __( 'Add New Contact', 'email-subscribers' );
194
  $title_action = '<a href="admin.php?page=es_lists&action=manage-lists" class="page-title-action es-imp-button">' . __( 'Manage Lists', 'email-subscribers' ) . '</a>';
195
 
196
  } else {
197
+ $is_new = false;
198
  $title = __( 'Edit Contact', 'email-subscribers' );
199
  $title_action = '<a href="admin.php?page=es_subscribers&action=new" class="page-title-action">' . __( 'Add New', 'email-subscribers' ) . '</a>';
200
 
210
  $email = ! empty( $contact['email'] ) ? $contact['email'] : '';
211
  $list_ids = ES_DB_Lists_Contacts::get_list_ids_by_contact( $id );
212
  $guid = $contact['hash'];
 
213
  $nonce = esc_attr( Email_Subscribers::get_request( '_wpnonce' ) );
 
214
  }
215
  }
216
 
217
  $submitted = Email_Subscribers::get_request( 'submitted' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  if ( 'submitted' === $submitted ) {
219
  $contact_data = ! empty( $_POST['contact_data'] ) ? $_POST['contact_data'] : array();
220
 
221
  $is_error = false;
222
  if ( ! empty( $contact_data ) ) {
223
+
224
  $email = ! empty( $contact_data['email'] ) ? sanitize_email( $contact_data['email'] ) : '';
225
 
226
  if ( $email ) {
228
  $list_ids = ! empty( $contact_data['lists'] ) ? $contact_data['lists'] : array();
229
 
230
  if ( count( $list_ids ) > 0 ) {
 
231
  $first_name = ! empty( $contact_data['first_name'] ) ? sanitize_text_field( $contact_data['first_name'] ) : '';
232
  $last_name = ! empty( $contact_data['last_name'] ) ? sanitize_text_field( $contact_data['last_name'] ) : '';
233
 
240
  );
241
 
242
  // Add contact
 
243
  if ( $id ) {
 
244
  $this->update_contact( $id, $contact );
245
  } else {
246
  $id = ES_DB_Contacts::get_contact_id_by_email( $email );
270
 
271
  if ( $is_new ) {
272
 
273
+ if ( ! empty( $contact_data['send_welcome_email'] ) ) {
 
274
 
275
+ // Get comma(,) separated list name based on ids
276
+ $list_name = ES_Common::prepare_list_name_by_ids( $list_ids );
277
+ $name = ES_Common::prepare_name_from_first_name_last_name( $contact['first_name'], $contact['last_name'] );
278
 
279
+ $template_data = array(
280
+ 'email' => $contact['email'],
281
+ 'db_id' => $id,
282
+ 'name' => $name,
283
+ 'first_name' => $contact['first_name'],
284
+ 'last_name' => $contact['last_name'],
285
+ 'guid' => $contact['hash'],
286
+ 'list_name' => $list_name
287
+ );
288
 
289
+ // Send Welcome Email
290
+ ES_Mailer::send_welcome_email( $contact['email'], $template_data );
291
+ }
292
 
293
  $message = __( 'Contact has been added successfully!', 'email-subscribers' );
294
  } else {
316
  }
317
  }
318
 
319
+ $data = array(
320
+ 'id' => $id,
321
+ 'first_name' => $first_name,
322
+ 'last_name' => $last_name,
323
+ 'email' => $email,
324
+ 'selected_list_ids' => $list_ids,
325
+ 'guid' => $guid
326
+ );
327
+
328
  ?>
329
 
330
  <div class="wrap">
334
  <div id="post-body" class="metabox-holder column-1">
335
  <div id="post-body-content">
336
  <div class="meta-box-sortables ui-sortable es-contact-form">
337
+ <?php echo $this->prepare_contact_form( $data, $is_new ); ?>
338
  </div>
339
  </div>
340
  </div>
353
  *
354
  * @return mixed
355
  */
356
+ public function get_subscribers( $per_page = 5, $page_number = 1, $do_count_only = false ) {
 
 
 
 
 
357
  global $wpdb;
358
 
359
  $order_by = Email_Subscribers::get_request( 'orderby' );
427
  if ( ! $do_count_only ) {
428
 
429
  // Prepare Order by clause
430
+ $order = ! empty( $order ) ? strtolower( $order ) : 'desc';
431
+ $expected_order_values = array( 'asc', 'desc' );
432
+ if ( ! in_array( $order, $expected_order_values ) ) {
433
  $order = 'desc';
434
  }
435
 
455
  return $result;
456
  }
457
 
458
+ public function edit_list( $id ) {
 
 
 
459
  global $wpdb;
460
 
461
  $notificationid = $wpdb->get_results( "SELECT * FROM " . IG_CONTACTS_TABLE . " WHERE id = $id" );
501
  <div id="post-body" class="metabox-holder column-1">
502
  <div id="post-body-content">
503
  <div class="meta-box-sortables ui-sortable es-contact-form">'
504
+ . $this->prepare_contact_form( $data, false ) .
505
  '</div>
506
  </div>
507
  </div>
511
  return $editform;
512
  }
513
 
514
+ public function prepare_contact_form( $data = array(), $is_new = false ) {
515
 
516
+ $id = ! empty( $data['id'] ) ? $data['id'] : '';
517
+ $created = ! empty( $data['created'] ) ? $data['created'] : '';
518
+ $guid = ! empty( $data['guid'] ) ? $data['guid'] : '';
519
+ $action = ! empty( $data['action'] ) ? $data['action'] : '#';
520
+ $first_name = ! empty( $data['first_name'] ) ? $data['first_name'] : '';
521
+ $last_name = ! empty( $data['last_name'] ) ? $data['last_name'] : '';
522
+ $email = ! empty( $data['email'] ) ? $data['email'] : '';
523
+ $selected_list_ids = ! empty( $data['selected_list_ids'] ) ? $data['selected_list_ids'] : array();
524
+ $send_welcome_email = ! empty( $data['send_welcome_email'] ) ? true : false;
525
 
526
  $lists_id_name_map = ES_DB_Lists::get_list_id_name_map();
527
 
549
  <td><label><b><?php _e( 'Email', 'email-subscribers' ); ?></b></label></td>
550
  <td><input type="email" id="email" name="contact_data[email]" value="<?php echo $email; ?>"/></td>
551
  </tr>
552
+
553
+ <?php if ( $is_new ) { ?>
554
+ <tr class="form-field">
555
+ <td><label><b><?php _e( 'Send Welcome Email?', 'email-subscribers' ); ?></b></label></td>
556
+ <td><input type="checkbox" id="ig-es-contact-welcome-email" name="contact_data[send_welcome_email]" <?php if ( $send_welcome_email ) {
557
+ echo "checked='checked'";
558
+ } ?> /></td>
559
+ </tr>
560
+ <?php } ?>
561
  <tr class="form-field">
562
  <td><label><b><?php _e( 'List(s)', 'email-subscribers' ); ?></b></label></td>
563
  <td>
969
  }
970
 
971
  // loop over the array of record IDs and delete them
972
+ $edited = ES_DB_Lists_Contacts::edit_subscriber_status( $subscriber_ids, $status );
973
 
974
  if ( $edited ) {
975
  $message = __( 'Status has been changed successfully!', 'email-subscribers' );
includes/class-email-subscribers.php CHANGED
@@ -74,7 +74,7 @@ class Email_Subscribers {
74
  public function __construct() {
75
  global $ig_es_feedback, $ig_es_tracker;
76
 
77
- $feedback_version = '1.0.8';
78
 
79
  require_once plugin_dir_path( __FILE__ ) . 'class-email-subscribers-activator.php';
80
  require_once plugin_dir_path( __FILE__ ) . 'class-email-subscribers-deactivator.php';
74
  public function __construct() {
75
  global $ig_es_feedback, $ig_es_tracker;
76
 
77
+ $feedback_version = '1.0.9';
78
 
79
  require_once plugin_dir_path( __FILE__ ) . 'class-email-subscribers-activator.php';
80
  require_once plugin_dir_path( __FILE__ ) . 'class-email-subscribers-deactivator.php';
includes/class-es-common.php CHANGED
@@ -514,9 +514,10 @@ Class ES_Common {
514
  }
515
 
516
 
517
- public static function convert_name_to_id( $category ){
518
- if( strpos($category, '{T}') === false ){
519
  $category = wp_specialchars_decode( addslashes( $category ) );
 
520
  return get_cat_ID( $category );
521
  } else {
522
  return $category;
@@ -919,9 +920,14 @@ Class ES_Common {
919
 
920
  $feedback = $ig_es_feedback;
921
 
 
 
 
 
922
  $default_params = array(
923
  'set_transient' => true,
924
- 'force' => false
 
925
  );
926
 
927
  $params = wp_parse_args( $params, $default_params );
@@ -941,9 +947,13 @@ Class ES_Common {
941
 
942
  $feedback_data = $feedback->get_event_feedback_data( $feedback->plugin_abbr, $event );
943
  if ( count( $feedback_data ) > 0 ) {
 
944
  $feedback_data = array_reverse( $feedback_data );
945
  $last_feedback_given_on = $feedback_data[0]['created_on'];
946
- if ( strtotime( $last_feedback_given_on ) > strtotime( '-45 days' ) ) {
 
 
 
947
  $can_show = false;
948
  }
949
  }
@@ -957,6 +967,14 @@ Class ES_Common {
957
  $feedback->render_emoji( $params );
958
  } elseif ( 'feedback' === $params['type'] ) {
959
  $feedback->render_general_feedback( $params );
 
 
 
 
 
 
 
 
960
  }
961
  }
962
  }
@@ -1005,12 +1023,12 @@ Class ES_Common {
1005
  * @param array $list_ids
1006
  *
1007
  * @return string
1008
- *
1009
- * @since 4.1.13
1010
  */
1011
  public static function prepare_list_name_by_ids( $list_ids = array() ) {
1012
  $list_name = '';
1013
- if ( is_array($list_ids) && count( $list_ids ) > 0 ) {
1014
  $lists_id_name_map = ES_DB_Lists::get_list_id_name_map();
1015
  $lists_name = array();
1016
  foreach ( $list_ids as $list_id ) {
@@ -1025,4 +1043,36 @@ Class ES_Common {
1025
  return $list_name;
1026
  }
1027
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1028
  }
514
  }
515
 
516
 
517
+ public static function convert_name_to_id( $category ) {
518
+ if ( strpos( $category, '{T}' ) === false ) {
519
  $category = wp_specialchars_decode( addslashes( $category ) );
520
+
521
  return get_cat_ID( $category );
522
  } else {
523
  return $category;
920
 
921
  $feedback = $ig_es_feedback;
922
 
923
+ if ( ! $feedback->can_show_feedback_widget() ) {
924
+ return;
925
+ }
926
+
927
  $default_params = array(
928
  'set_transient' => true,
929
+ 'force' => false,
930
+ 'show_once' => false
931
  );
932
 
933
  $params = wp_parse_args( $params, $default_params );
947
 
948
  $feedback_data = $feedback->get_event_feedback_data( $feedback->plugin_abbr, $event );
949
  if ( count( $feedback_data ) > 0 ) {
950
+ $show_once = $params['show_once'];
951
  $feedback_data = array_reverse( $feedback_data );
952
  $last_feedback_given_on = $feedback_data[0]['created_on'];
953
+
954
+ // If event feedback given within 45 days or show event only once?
955
+ // Don't show now
956
+ if ( $show_once || ( strtotime( $last_feedback_given_on ) > strtotime( '-45 days' ) ) ) {
957
  $can_show = false;
958
  }
959
  }
967
  $feedback->render_emoji( $params );
968
  } elseif ( 'feedback' === $params['type'] ) {
969
  $feedback->render_general_feedback( $params );
970
+ } elseif ( 'fb' === $params['type'] ) {
971
+
972
+ /**
973
+ * We are not calling home for this event and we want to show
974
+ * this Widget only once. So, we are storing feedback data now.
975
+ */
976
+ $feedback->set_feedback_data( 'ig_es', $event );
977
+ $feedback->render_fb_widget( $params );
978
  }
979
  }
980
  }
1023
  * @param array $list_ids
1024
  *
1025
  * @return string
1026
+ *
1027
+ * @since 4.1.13
1028
  */
1029
  public static function prepare_list_name_by_ids( $list_ids = array() ) {
1030
  $list_name = '';
1031
+ if ( is_array( $list_ids ) && count( $list_ids ) > 0 ) {
1032
  $lists_id_name_map = ES_DB_Lists::get_list_id_name_map();
1033
  $lists_name = array();
1034
  foreach ( $list_ids as $list_id ) {
1043
  return $list_name;
1044
  }
1045
 
1046
+ /**
1047
+ * Get all pages of Email Subscribers plugin
1048
+ *
1049
+ * @param array $excludes
1050
+ *
1051
+ * @return array
1052
+ *
1053
+ * @since 4.1.14
1054
+ */
1055
+ public static function get_all_es_admin_screens( $excludes = array() ) {
1056
+
1057
+ $screens = array(
1058
+ 'toplevel_page_es_dashboard',
1059
+ 'email-subscribers_page_es_subscribers',
1060
+ 'email-subscribers_page_es_lists',
1061
+ 'email-subscribers_page_es_forms',
1062
+ 'email-subscribers_page_es_campaigns',
1063
+ 'email-subscribers_page_es_reports',
1064
+ 'email-subscribers_page_es_settings',
1065
+ 'email-subscribers_page_es_general_information',
1066
+ 'email-subscribers_page_es_pricing'
1067
+ );
1068
+
1069
+ $screens = apply_filters( 'ig_es_admin_screens', $screens );
1070
+
1071
+ if ( count( $excludes ) > 0 ) {
1072
+ $screens = array_diff( $screens, $excludes );
1073
+ }
1074
+
1075
+ return $screens;
1076
+ }
1077
+
1078
  }
includes/db/class-es-db-contacts.php CHANGED
@@ -114,12 +114,12 @@ class ES_DB_Contacts {
114
  return $contact_hash[0];
115
  }
116
 
117
- public static function check_contact( $id = '', $email = '' ) {
118
  global $wpdb;
119
 
120
- $query = "SELECT count(*) FROM " . IG_CONTACTS_TABLE . " WHERE id = %d AND email = %s";
121
  $sql = $wpdb->prepare( $query, $id, $email );
122
- $contact_count = $wpdb->get_var( $sql );
123
 
124
  return $contact_count;
125
  }
@@ -261,34 +261,11 @@ class ES_DB_Contacts {
261
  }
262
  }
263
 
264
- public static function edit_subscriber_status( $ids, $status ) {
265
- global $wpdb;
266
-
267
- $ids = implode( ',', array_map( 'absint', $ids ) );
268
-
269
- $current_date = ig_get_current_date_time();
270
-
271
- if ( 'subscribed' === $status ) {
272
- $sql = "UPDATE " . IG_LISTS_CONTACTS_TABLE . " SET status = %s, subscribed_at = %s WHERE contact_id IN ($ids)";
273
- $query = $wpdb->prepare( $sql, array( $status, $current_date ) );
274
- } elseif ( 'unsubscribed' === $status ) {
275
- $sql = "UPDATE " . IG_LISTS_CONTACTS_TABLE . " SET status = %s, unsubscribed_at = %s WHERE contact_id IN ($ids)";
276
- $query = $wpdb->prepare( $sql, array( $status, $current_date ) );
277
- } elseif ( 'unconfirmed' === $status ) {
278
- $sql = "UPDATE " . IG_LISTS_CONTACTS_TABLE . " SET status = %s, optin_type = %d, subscribed_at = NULL, unsubscribed_at = NULL WHERE contact_id IN ($ids)";
279
- $query = $wpdb->prepare( $sql, array( $status, IG_DOUBLE_OPTIN ) );
280
- }
281
-
282
- return $wpdb->query( $query );
283
-
284
- }
285
-
286
  public static function edit_subscriber_status_global( $ids, $unsubscribed ) {
287
  global $wpdb;
288
 
289
  $ids = implode( ',', array_map( 'absint', $ids ) );
290
 
291
-
292
  $sql = "UPDATE " . IG_CONTACTS_TABLE . " SET unsubscribed = %d WHERE id IN ($ids)";
293
  $query = $wpdb->prepare( $sql, array( $unsubscribed ) );
294
 
@@ -532,9 +509,6 @@ class ES_DB_Contacts {
532
  }
533
  }
534
  }
535
-
536
  }
537
-
538
  }
539
-
540
  }
114
  return $contact_hash[0];
115
  }
116
 
117
+ public static function is_contact_exists( $id = '', $email = '' ) {
118
  global $wpdb;
119
 
120
+ $query = "SELECT * FROM " . IG_CONTACTS_TABLE . " WHERE id = %d AND email = %s";
121
  $sql = $wpdb->prepare( $query, $id, $email );
122
+ $contact_count = $wpdb->get_results( $sql, ARRAY_A );
123
 
124
  return $contact_count;
125
  }
261
  }
262
  }
263
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  public static function edit_subscriber_status_global( $ids, $unsubscribed ) {
265
  global $wpdb;
266
 
267
  $ids = implode( ',', array_map( 'absint', $ids ) );
268
 
 
269
  $sql = "UPDATE " . IG_CONTACTS_TABLE . " SET unsubscribed = %d WHERE id IN ($ids)";
270
  $query = $wpdb->prepare( $sql, array( $unsubscribed ) );
271
 
509
  }
510
  }
511
  }
 
512
  }
 
513
  }
 
514
  }
includes/db/class-es-db-lists-contacts.php CHANGED
@@ -234,5 +234,75 @@ class ES_DB_Lists_Contacts {
234
  return $map;
235
  }
236
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
 
238
  }
234
  return $map;
235
  }
236
 
237
+ /**
238
+ * Update list wise subscription status based on contact ids
239
+ *
240
+ * @param $ids array
241
+ * @param $status string
242
+ *
243
+ * @return bool|int
244
+ *
245
+ * @since 4.1.14
246
+ */
247
+ public static function edit_subscriber_status( $ids, $status ) {
248
+ global $wpdb;
249
+
250
+ if ( is_int( $ids ) ) {
251
+ $ids = array( $ids );
252
+ }
253
+
254
+ $ids = implode( ',', array_map( 'absint', $ids ) );
255
+
256
+ $current_date = ig_get_current_date_time();
257
+ $ig_lists_contact_table = IG_LISTS_CONTACTS_TABLE;
258
+
259
+ if ( 'subscribed' === $status ) {
260
+ $sql = "UPDATE {$ig_lists_contact_table} SET status = %s, subscribed_at = %s WHERE contact_id IN ($ids)";
261
+ $query = $wpdb->prepare( $sql, array( $status, $current_date ) );
262
+ } elseif ( 'unsubscribed' === $status ) {
263
+ $sql = "UPDATE {$ig_lists_contact_table} SET status = %s, unsubscribed_at = %s WHERE contact_id IN ($ids)";
264
+ $query = $wpdb->prepare( $sql, array( $status, $current_date ) );
265
+ } elseif ( 'unconfirmed' === $status ) {
266
+ $sql = "UPDATE {$ig_lists_contact_table} SET status = %s, optin_type = %d, subscribed_at = NULL, unsubscribed_at = NULL WHERE contact_id IN ($ids)";
267
+ $query = $wpdb->prepare( $sql, array( $status, IG_DOUBLE_OPTIN ) );
268
+ }
269
+
270
+ return $wpdb->query( $query );
271
+
272
+ }
273
+
274
+ /**
275
+ * Check whether status update required
276
+ *
277
+ * @param $contact_ids
278
+ * @param $status
279
+ *
280
+ * @return bool
281
+ *
282
+ * @since 4.1.14
283
+ */
284
+ public static function is_status_update_required( $ids, $status ) {
285
+ global $wpdb;
286
+
287
+ $response = false;
288
+ if ( is_int( $ids ) ) {
289
+ $ids = array( $ids );
290
+ }
291
+
292
+ $ig_lists_contact_table = IG_LISTS_CONTACTS_TABLE;
293
+
294
+ $ids = implode( ',', array_map( 'absint', $ids ) );
295
+
296
+ $sql = "SELECT count(*) as total FROM {$ig_lists_contact_table} WHERE contact_id IN ($ids) && status != %s";
297
+ $query = $wpdb->prepare( $sql, array( $status ) );
298
+
299
+ $total = $wpdb->get_var( $query );
300
+
301
+ if($total > 0) {
302
+ $response = true;
303
+ }
304
+
305
+ return $response;
306
+ }
307
 
308
  }
includes/feedback.php CHANGED
@@ -28,62 +28,79 @@ if ( ! function_exists( 'ig_es_get_additional_info' ) ) {
28
 
29
  }
30
 
31
-
32
  add_filter( 'ig_es_additional_feedback_meta_info', 'ig_es_get_additional_info', 10, 2 );
33
 
34
-
35
- function ig_es_render_feedback_widget() {
 
 
36
 
37
  if ( is_admin() ) {
38
- global $ig_es_feedback;
39
 
40
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
41
  return;
42
  }
 
43
  $screen = get_current_screen();
44
  $screen_id = $screen ? $screen->id : '';
45
 
46
- $show_on_screens = array(
47
- 'email-subscribers_page_es_subscribers',
48
- 'email-subscribers_page_es_forms',
49
- 'email-subscribers_page_es_campaigns',
50
- 'email-subscribers_page_es_reports',
51
- 'email-subscribers_page_es_settings',
52
- );
53
 
54
- if ( ! in_array( $screen_id, $show_on_screens, true ) ) {
55
  return;
56
  }
57
 
58
- if ( ! $ig_es_feedback->can_show_feedback_widget() ) {
59
- return;
60
- }
61
 
62
- $event = 'plugin.experience';
63
- if ( ! $ig_es_feedback->is_event_transient_set( $ig_es_feedback->event_prefix . $event ) ) {
 
 
 
 
 
 
 
 
 
64
 
65
- $total_contacts = ES_DB_Contacts::get_total_subscribers();
 
 
66
 
67
- if ( $total_contacts > 10 ) {
68
 
69
- $params = array(
70
- 'type' => 'emoji',
71
- 'event' => $event,
72
- 'title' => "How's your experience with Email Subscribers?",
73
- 'position' => 'top-end',
74
- 'width' => 300,
75
- 'confirmButtonText' => __( 'Send', 'email-subscribers' )
76
- );
77
 
78
- ES_Common::render_feedback_widget( $params );
79
- }
80
- }
81
 
82
- }
 
 
 
 
 
 
 
 
83
 
 
84
  }
85
 
86
- function ig_es_render_general_feedback_widget() {
 
 
 
 
 
 
 
87
 
88
  if ( is_admin() ) {
89
 
@@ -91,44 +108,39 @@ function ig_es_render_general_feedback_widget() {
91
  return;
92
  }
93
 
94
- global $ig_es_feedback;
95
-
96
  $screen = get_current_screen();
97
  $screen_id = $screen ? $screen->id : '';
98
 
99
- $show_on_screens = array(
100
- 'toplevel_page_es_dashboard',
101
- 'email-subscribers_page_es_subscribers',
102
- 'email-subscribers_page_es_lists',
103
- 'email-subscribers_page_es_forms',
104
- 'email-subscribers_page_es_campaigns',
105
- 'email-subscribers_page_es_reports',
106
- 'email-subscribers_page_es_settings',
107
- 'email-subscribers_page_es_general_information',
108
- 'email-subscribers_page_es_pricing'
109
- );
110
 
111
  if ( ! in_array( $screen_id, $show_on_screens ) ) {
112
  return;
113
  }
114
 
115
- $event = 'plugin.feedback';
116
 
117
- $params = array(
118
- 'type' => 'feedback',
119
- 'event' => $event,
120
- 'title' => "Have feedback or question for us?",
121
- 'position' => 'center',
122
- 'width' => 700,
123
- 'force' => true,
124
- 'confirmButtonText' => __( 'Send', 'email-subscribers' ),
125
- 'consent_text' => __( 'Allow Email Subscribers to track plugin usage. We guarantee no sensitive data is collected.', 'email-subscribers' ),
126
- 'name' => ''
127
- );
128
 
129
- ES_Common::render_feedback_widget( $params );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  }
 
131
  }
132
 
133
- //add_action( 'admin_footer', 'ig_es_render_feedback_widget' );
134
- add_action( 'admin_footer', 'ig_es_render_general_feedback_widget' );
28
 
29
  }
30
 
 
31
  add_filter( 'ig_es_additional_feedback_meta_info', 'ig_es_get_additional_info', 10, 2 );
32
 
33
+ /**
34
+ * Render general feedback on click of "Feedback" button from ES sidebar
35
+ */
36
+ function ig_es_render_general_feedback_widget() {
37
 
38
  if ( is_admin() ) {
 
39
 
40
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
41
  return;
42
  }
43
+
44
  $screen = get_current_screen();
45
  $screen_id = $screen ? $screen->id : '';
46
 
47
+ // Get all Email Subscribers Screen
48
+ $show_on_screens = ES_Common::get_all_es_admin_screens();
 
 
 
 
 
49
 
50
+ if ( ! in_array( $screen_id, $show_on_screens ) ) {
51
  return;
52
  }
53
 
54
+ $event = 'plugin.feedback';
 
 
55
 
56
+ $params = array(
57
+ 'type' => 'feedback',
58
+ 'event' => $event,
59
+ 'title' => "Have feedback or question for us?",
60
+ 'position' => 'center',
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
 
68
+ ES_Common::render_feedback_widget( $params );
69
+ }
70
+ }
71
 
72
+ add_action( 'admin_footer', 'ig_es_render_general_feedback_widget' );
73
 
74
+ /**
75
+ * Render Broadcast Created feedback widget.
76
+ *
77
+ * @since 4.1.14
78
+ */
79
+ function ig_es_render_broadcast_created_feedback_widget() {
 
 
80
 
81
+ $event = 'broadcast.created';
 
 
82
 
83
+ $params = array(
84
+ 'type' => 'emoji',
85
+ 'event' => $event,
86
+ 'title' => "How's your experience sending broadcast?",
87
+ 'position' => 'top-end',
88
+ 'width' => 300,
89
+ 'delay' => 2, // seconds
90
+ 'confirmButtonText' => __( 'Send', 'email-subscribers' )
91
+ );
92
 
93
+ ES_Common::render_feedback_widget( $params );
94
  }
95
 
96
+ add_action( 'ig_es_broadcast_created', 'ig_es_render_broadcast_created_feedback_widget' );
97
+
98
+ /**
99
+ * Render Broadcast Created feedback widget.
100
+ *
101
+ * @since 4.1.14
102
+ */
103
+ function ig_es_render_fb_widget() {
104
 
105
  if ( is_admin() ) {
106
 
108
  return;
109
  }
110
 
 
 
111
  $screen = get_current_screen();
112
  $screen_id = $screen ? $screen->id : '';
113
 
114
+ $show_on_screens = ES_Common::get_all_es_admin_screens();
 
 
 
 
 
 
 
 
 
 
115
 
116
  if ( ! in_array( $screen_id, $show_on_screens ) ) {
117
  return;
118
  }
119
 
120
+ $total_contacts = ES_DB_Contacts::get_total_subscribers();
121
 
122
+ // Got 25 contacts?
123
+ // It's time to Join Email Subscribers Secret Club on Facebook
124
+ if ( $total_contacts >= 25 ) {
 
 
 
 
 
 
 
 
125
 
126
+ $event = 'join.fb';
127
+
128
+ $params = array(
129
+ 'type' => 'fb',
130
+ 'title' => __( 'Not a member yet?', 'email-subscribers' ),
131
+ 'event' => $event,
132
+ 'html' => '<div style="text-align:center;"> ' . __( 'Join', 'email-subscribers' ) . '<strong> ' . __( 'Email Subscribers Secret Club', 'email-subscribers' ) . '</strong> ' . __( 'on Facebook', 'email-subscribers' ) . '</div>',
133
+ 'position' => 'bottom-center',
134
+ 'width' => 500,
135
+ 'delay' => 2, // seconds
136
+ 'confirmButtonText' => '<i class="dashicons dashicons-es dashicons-facebook"></i> ' . __( 'Join Now', 'email-subscribers' ),
137
+ 'show_once' => true
138
+ );
139
+
140
+ ES_Common::render_feedback_widget( $params );
141
+ }
142
  }
143
+
144
  }
145
 
146
+ add_action( 'admin_footer', 'ig_es_render_fb_widget' );
 
includes/feedback/{class-ig-feedback-v-1-0-8.php → class-ig-feedback-v-1-0-9.php} RENAMED
@@ -4,21 +4,21 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  exit; // Exit if accessed directly.
5
  }
6
 
7
- if ( ! class_exists( 'IG_Feedback_V_1_0_8' ) ) {
8
  /**
9
  * IG Feedback
10
  *
11
  * The IG Feedback class adds functionality to get quick interactive feedback from users.
12
  * There are different types of feedabck widget like Stars, Emoji, Thubms Up/ Down, Number etc.
13
  *
14
- * @class IG_Feedback_V_1_0_7
15
  * @package feedback
16
  * @copyright Copyright (c) 2019, Icegram
17
  * @license https://opensource.org/licenses/gpl-license GNU Public License
18
  * @author Icegram
19
  * @since 1.0.0
20
  */
21
- class IG_Feedback_V_1_0_8 {
22
 
23
  /**
24
  * The API URL where we will send feedback data.
@@ -544,6 +544,75 @@ if ( ! class_exists( 'IG_Feedback_V_1_0_8' ) ) {
544
 
545
  }
546
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
547
  /**
548
  * Get Feedback API url
549
  *
@@ -1022,7 +1091,7 @@ if ( ! class_exists( 'IG_Feedback_V_1_0_8' ) ) {
1022
  *
1023
  * @since 1.0.1
1024
  */
1025
- public function set_feedback_data( $plugin_abbr, $event, $data ) {
1026
 
1027
  $feedback_option = $plugin_abbr . '_feedback_data';
1028
 
@@ -1094,10 +1163,10 @@ if ( ! class_exists( 'IG_Feedback_V_1_0_8' ) ) {
1094
 
1095
  /**
1096
  * Get contact email
1097
- *
1098
- * @return string
1099
- *
1100
- * @since 1.0.8
1101
  */
1102
  public function get_contact_email() {
1103
 
4
  exit; // Exit if accessed directly.
5
  }
6
 
7
+ if ( ! class_exists( 'IG_Feedback_V_1_0_9' ) ) {
8
  /**
9
  * IG Feedback
10
  *
11
  * The IG Feedback class adds functionality to get quick interactive feedback from users.
12
  * There are different types of feedabck widget like Stars, Emoji, Thubms Up/ Down, Number etc.
13
  *
14
+ * @class IG_Feedback_V_1_0_9
15
  * @package feedback
16
  * @copyright Copyright (c) 2019, Icegram
17
  * @license https://opensource.org/licenses/gpl-license GNU Public License
18
  * @author Icegram
19
  * @since 1.0.0
20
  */
21
+ class IG_Feedback_V_1_0_9 {
22
 
23
  /**
24
  * The API URL where we will send feedback data.
544
 
545
  }
546
 
547
+ /**
548
+ * Render Facebook Widget
549
+ *
550
+ * @since 1.0.9
551
+ */
552
+ public function render_fb_widget( $params ) {
553
+
554
+ $params = $this->prepare_widget_params( $params );
555
+
556
+ $title = $params['title'];
557
+ $slug = sanitize_title( $title );
558
+ $event = $this->event_prefix . $params['event'];
559
+ $html = ! empty( $params['html'] ) ? $params['html'] : '';
560
+
561
+ ?>
562
+
563
+ <script>
564
+
565
+ Swal.mixin({
566
+ type: 'question',
567
+ footer: '<?php echo $this->footer; ?>',
568
+ position: '<?php echo $params['position']; ?>',
569
+ width: <?php echo $params['width']; ?>,
570
+ animation: false,
571
+ focusConfirm: false,
572
+ allowEscapeKey: true,
573
+ showCloseButton: '<?php echo $params['showCloseButton']; ?>',
574
+ allowOutsideClick: '<?php echo $params['allowOutsideClick']; ?>',
575
+ showLoaderOnConfirm: true,
576
+ confirmButtonText: '<?php echo $params['confirmButtonText']; ?>',
577
+ backdrop: '<?php echo (int) $params['backdrop']; ?>'
578
+ }).queue([
579
+ {
580
+ title: '<p class="ig-feedback-title"><?php echo esc_js( $params['title'] ); ?></p>',
581
+ html: '<?php echo $html; ?>',
582
+ customClass: {
583
+ popup: 'animated fadeInUpBig'
584
+ },
585
+
586
+ preConfirm: () => {
587
+ window.open(
588
+ 'https://www.facebook.com/groups/2298909487017349/',
589
+ '_blank' // <- This is what makes it open in a new window.
590
+ );
591
+ }
592
+ }
593
+ ]).then(response => {
594
+
595
+ if (response.hasOwnProperty('value')) {
596
+
597
+ Swal.fire({
598
+ type: 'success',
599
+ width: <?php echo $params['width']; ?>,
600
+ title: "Thank You!",
601
+ showConfirmButton: false,
602
+ position: '<?php echo $params['position']; ?>',
603
+ timer: 1500,
604
+ animation: false
605
+ });
606
+ }
607
+
608
+
609
+ });
610
+
611
+ </script>
612
+
613
+ <?php
614
+ }
615
+
616
  /**
617
  * Get Feedback API url
618
  *
1091
  *
1092
  * @since 1.0.1
1093
  */
1094
+ public function set_feedback_data( $plugin_abbr, $event, $data = array() ) {
1095
 
1096
  $feedback_option = $plugin_abbr . '_feedback_data';
1097
 
1163
 
1164
  /**
1165
  * Get contact email
1166
+ *
1167
+ * @return string
1168
+ *
1169
+ * @since 1.0.8
1170
  */
1171
  public function get_contact_email() {
1172
 
includes/feedback/{class-ig-tracker-v-1-0-8.php → class-ig-tracker-v-1-0-9.php} RENAMED
@@ -4,15 +4,15 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  exit; // Exit if accessed directly.
5
  }
6
 
7
- if ( ! class_exists( 'IG_Tracker_V_1_0_8' ) ) {
8
 
9
  /**
10
- * Class IG_Tracker_V_1_0_8
11
  *
12
  * Icegram tracker handler class is responsible for sending anonymous plugin
13
  * data to Icegram servers for users that actively allowed data tracking.
14
  *
15
- * @class IG_Tracker_V_1_0_8
16
  * @package feedback
17
  * @copyright Copyright (c) 2019, Icegram
18
  * @license https://opensource.org/licenses/gpl-license GNU Public License
@@ -20,7 +20,7 @@ if ( ! class_exists( 'IG_Tracker_V_1_0_8' ) ) {
20
  * @since 1.0.0
21
  *
22
  */
23
- class IG_Tracker_V_1_0_8 {
24
 
25
  /**
26
  * Get Active, Inactive or all plugins info
4
  exit; // Exit if accessed directly.
5
  }
6
 
7
+ if ( ! class_exists( 'IG_Tracker_V_1_0_9' ) ) {
8
 
9
  /**
10
+ * Class IG_Tracker_V_1_0_9
11
  *
12
  * Icegram tracker handler class is responsible for sending anonymous plugin
13
  * data to Icegram servers for users that actively allowed data tracking.
14
  *
15
+ * @class IG_Tracker_V_1_0_9
16
  * @package feedback
17
  * @copyright Copyright (c) 2019, Icegram
18
  * @license https://opensource.org/licenses/gpl-license GNU Public License
20
  * @since 1.0.0
21
  *
22
  */
23
+ class IG_Tracker_V_1_0_9 {
24
 
25
  /**
26
  * Get Active, Inactive or all plugins info
public/class-email-subscribers-public.php CHANGED
@@ -129,6 +129,7 @@ class Email_Subscribers_Public {
129
  public function es_email_subscribe_wp_loaded() {
130
  new ES_Cron();
131
  }
 
132
  public function es_email_subscribe_init() {
133
 
134
  global $wpdb;
@@ -137,60 +138,74 @@ class Email_Subscribers_Public {
137
  new ES_Handle_Subscription();
138
  new ES_Shortcode();
139
 
140
- $option = ! empty( $_REQUEST['es'] ) ? $_REQUEST['es'] : '';
141
  $db_id = ! empty( $_REQUEST['db'] ) ? $_REQUEST['db'] : '';
142
- $email = ! empty( $_REQUEST['email'] ) ? $_REQUEST['email'] : '';
143
- $guid = ! empty( $_REQUEST['guid'] ) ? $_REQUEST['guid'] : '';
144
 
145
  $email = str_replace( ' ', '+', $email );
146
 
147
  if ( ! empty( $option ) ) {
148
  if ( ( 'optin' === $option || 'unsubscribe' === $option ) && ! empty( $db_id ) ) {
149
  //check if contact exist with id and email
150
- $check = ES_DB_Contacts::check_contact( $db_id, $email );
151
- if ( $check ) {
 
152
  $ids = array( $db_id );
153
  $status = $subject = $content = '';
154
  $unsubscribed = 0;
155
  if ( $option === 'optin' ) {
156
  $status = 'subscribed';
157
  $message = get_option( 'ig_es_subscription_success_message' );
158
- //$message = get_option( 'ig_es_subscription_error_messsage' );
159
  } elseif ( $option === 'unsubscribe' ) {
160
  $status = 'unsubscribed';
161
  $unsubscribed = 1;
162
  $message = get_option( 'ig_es_unsubscribe_success_message' );
163
- //$message = get_option( 'ig_es_unsubscribe_error_message' );
164
  }
165
 
166
- ES_DB_Contacts::edit_subscriber_status( $ids, $status );
 
167
  ES_DB_Contacts::edit_subscriber_status_global( $ids, $unsubscribed );
168
 
169
- if ( 'optin' === $option ) {
170
 
171
- $contact = ES_DB_Contacts::get_subsribers_email_name_map( array( $email ) );
172
- $data = array(
173
- 'name' => ! empty( $contact[ $email ] ) ? $contact[ $email ]['name'] : '',
174
- 'first_name' => ! empty( $contact[ $email ] ) ? $contact[ $email ]['first_name'] : '',
175
- 'last_name' => ! empty( $contact[ $email ] ) ? $contact[ $email ]['last_name'] : '',
176
- 'email' => $email,
177
- 'db_id' => $db_id,
178
- 'guid' => $guid
179
- );
180
 
181
- $enable_welcome_email = get_option( 'ig_es_enable_welcome_email', 'no' );
 
182
 
183
- if ( $enable_welcome_email === 'yes' ) {
184
- $content = ES_Mailer::prepare_welcome_email( $data );
185
- $subject = ES_Mailer::prepare_welcome_email_subject( $data );
186
- ES_Mailer::send( $email, $subject, $content );
187
- }
 
 
 
 
 
 
188
 
189
- $lists = ES_DB_Lists::get_all_lists_name_by_contact( $db_id );
190
- $list_name = implode( ", ", $lists );
191
 
192
- $data['list_name'] = $list_name;
193
- ES_Common::send_signup_notification_to_admins( $data );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  }
195
 
196
  do_action( 'es_redirect_to_optin_page', $option );
@@ -198,6 +213,7 @@ class Email_Subscribers_Public {
198
  $message = __( 'Sorry, we couldn\'t find you. Please contact admin.', 'email-subscribers' );
199
  }
200
 
 
201
  include 'partials/subscription-successfull.php';
202
 
203
  } elseif ( 'viewstatus' === $option ) {
129
  public function es_email_subscribe_wp_loaded() {
130
  new ES_Cron();
131
  }
132
+
133
  public function es_email_subscribe_init() {
134
 
135
  global $wpdb;
138
  new ES_Handle_Subscription();
139
  new ES_Shortcode();
140
 
141
+ $option = ! empty( $_REQUEST['es'] ) ? sanitize_text_field($_REQUEST['es']) : '';
142
  $db_id = ! empty( $_REQUEST['db'] ) ? $_REQUEST['db'] : '';
143
+ $email = ! empty( $_REQUEST['email'] ) ? sanitize_email($_REQUEST['email']) : '';
144
+ $guid = ! empty( $_REQUEST['guid'] ) ? sanitize_text_field($_REQUEST['guid']) : '';
145
 
146
  $email = str_replace( ' ', '+', $email );
147
 
148
  if ( ! empty( $option ) ) {
149
  if ( ( 'optin' === $option || 'unsubscribe' === $option ) && ! empty( $db_id ) ) {
150
  //check if contact exist with id and email
151
+ $contacts = ES_DB_Contacts::is_contact_exists( $db_id, $email );
152
+
153
+ if ( ! empty( $contacts ) && count( $contacts ) > 0 ) {
154
  $ids = array( $db_id );
155
  $status = $subject = $content = '';
156
  $unsubscribed = 0;
157
  if ( $option === 'optin' ) {
158
  $status = 'subscribed';
159
  $message = get_option( 'ig_es_subscription_success_message' );
 
160
  } elseif ( $option === 'unsubscribe' ) {
161
  $status = 'unsubscribed';
162
  $unsubscribed = 1;
163
  $message = get_option( 'ig_es_unsubscribe_success_message' );
 
164
  }
165
 
166
+ // Update Global Subscription status
167
+ // We are doing global subscription/ unsubscription
168
  ES_DB_Contacts::edit_subscriber_status_global( $ids, $unsubscribed );
169
 
170
+ $is_status_update_required = ES_DB_Lists_Contacts::is_status_update_required( $ids, $status );
171
 
172
+ if ( $is_status_update_required ) {
 
 
 
 
 
 
 
 
173
 
174
+ // Update subscription status in lists_contacts table
175
+ ES_DB_Lists_Contacts::edit_subscriber_status( $ids, $status );
176
 
177
+ if ( 'optin' === $option ) {
178
+
179
+ $contact = ES_DB_Contacts::get_subsribers_email_name_map( array( $email ) );
180
+ $data = array(
181
+ 'name' => ! empty( $contact[ $email ] ) ? $contact[ $email ]['name'] : '',
182
+ 'first_name' => ! empty( $contact[ $email ] ) ? $contact[ $email ]['first_name'] : '',
183
+ 'last_name' => ! empty( $contact[ $email ] ) ? $contact[ $email ]['last_name'] : '',
184
+ 'email' => $email,
185
+ 'db_id' => $db_id,
186
+ 'guid' => $guid
187
+ );
188
 
189
+ $enable_welcome_email = get_option( 'ig_es_enable_welcome_email', 'no' );
 
190
 
191
+ if ( $enable_welcome_email === 'yes' ) {
192
+ $content = ES_Mailer::prepare_welcome_email( $data );
193
+ $subject = ES_Mailer::prepare_welcome_email_subject( $data );
194
+ ES_Mailer::send( $email, $subject, $content );
195
+ }
196
+
197
+ $lists = ES_DB_Lists::get_all_lists_name_by_contact( $db_id );
198
+ $list_name = implode( ", ", $lists );
199
+
200
+ $data['list_name'] = $list_name;
201
+ ES_Common::send_signup_notification_to_admins( $data );
202
+ }
203
+ } else {
204
+ if($status === 'subscribed') {
205
+ $message = __('You are already subscribed!', 'email-subscribers');
206
+ } else {
207
+ $message = __('You are already unsubscribed!', 'email-subscribers');
208
+ }
209
  }
210
 
211
  do_action( 'es_redirect_to_optin_page', $option );
213
  $message = __( 'Sorry, we couldn\'t find you. Please contact admin.', 'email-subscribers' );
214
  }
215
 
216
+ // We are using $message in following file
217
  include 'partials/subscription-successfull.php';
218
 
219
  } elseif ( 'viewstatus' === $option ) {
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.13
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses
11
 
@@ -278,10 +278,6 @@ Refer [here](https://www.icegram.com/documentation/es-css-help/).
278
 
279
  Refer [here](https://www.icegram.com/documentation/es-faq/).
280
 
281
- = 26. How to allow user to select the group when subscribing via subscribe form? =
282
-
283
- Use our free plugin [Email Subscribers - Group Selector](https://wordpress.org/plugins/email-subscribers-advanced-form/).
284
-
285
  == Screenshots ==
286
 
287
  1. Front Page - Subscription Form
@@ -304,6 +300,11 @@ Use our free plugin [Email Subscribers - Group Selector](https://wordpress.org/p
304
 
305
  == Changelog ==
306
 
 
 
 
 
 
307
  = 4.1.13 (20.08.2019) =
308
  * New: Added option to select "All Categories" in post notifications.
309
  * New: Send "Welcome Email" to contact which are being added from Audience dashboard
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.14
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses
11
 
278
 
279
  Refer [here](https://www.icegram.com/documentation/es-faq/).
280
 
 
 
 
 
281
  == Screenshots ==
282
 
283
  1. Front Page - Subscription Form
300
 
301
  == Changelog ==
302
 
303
+ = 4.1.14 (28.08.2019) =
304
+ * New: Import First Name & Last Name
305
+ * Update: Added "Send Welcome email" option to send out Welcome Email.
306
+ * Fix: Multiple Welcome & Admin email notification on clicking confirmation link multiple times
307
+
308
  = 4.1.13 (20.08.2019) =
309
  * New: Added option to select "All Categories" in post notifications.
310
  * New: Send "Welcome Email" to contact which are being added from Audience dashboard