Email Subscribers & Newsletters - Version 4.2.3

Version Description

Download this release

Release Info

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

Code changes from version 4.2.2 to 4.2.3

admin/class-email-subscribers-admin.php CHANGED
@@ -166,33 +166,51 @@ class Email_Subscribers_Admin {
166
  }
167
 
168
  public function email_subscribers_admin_menu() {
169
- // This adds the main menu page
170
- add_menu_page( __( 'Email Subscribers', 'email-subscribers' ), __( 'Email Subscribers', 'email-subscribers' ), 'edit_posts', 'es_dashboard', array( $this, 'es_dashboard_callback' ), 'dashicons-email', 30 );
171
 
172
- // Submenu
173
- add_submenu_page( 'es_dashboard', __( 'Dashboard', 'email-subscribers' ), __( 'Dashboard', 'email-subscribers' ), 'edit_posts', 'es_dashboard', array( $this, 'es_dashboard_callback' ) );
174
 
175
- // Add Campaigns Submenu
176
- $hook = add_submenu_page( 'es_dashboard', __( 'Campaigns', 'email-subscribers' ), __( 'Campaigns', 'email-subscribers' ), 'edit_posts', 'es_campaigns', array( $this, 'render_campaigns' ) );
177
- add_action( "load-$hook", array( 'ES_Campaigns_Table', 'screen_options' ) );
178
 
179
- // Add Forms Submenu
180
- $hook = add_submenu_page( 'es_dashboard', __( 'Forms', 'email-subscribers' ), __( 'Forms', 'email-subscribers' ), 'edit_posts', 'es_forms', array( $this, 'render_forms' ) );
181
- add_action( "load-$hook", array( 'ES_Forms_Table', 'screen_options' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
 
183
- // Add Contacts Submenu
184
- $hook = add_submenu_page( 'es_dashboard', __( 'Audience', 'email-subscribers' ), __( 'Audience', 'email-subscribers' ), 'edit_posts', 'es_subscribers', array( $this, 'render_contacts' ) );
185
- add_action( "load-$hook", array( 'ES_Contacts_Table', 'screen_options' ) );
 
186
 
187
- // Add Lists Submenu
188
- $hook = add_submenu_page( 'es_dashboard', __( 'Lists', 'email-subscribers' ), '<span id="ig-es-lists">' . __( 'Lists', 'email-subscribers' ) . '</span>', 'edit_posts', 'es_lists', array( $this, 'render_lists' ) );
189
- add_action( "load-$hook", array( 'ES_Lists_Table', 'screen_options' ) );
 
 
 
 
 
 
 
 
 
190
 
191
- add_submenu_page( 'es_dashboard', __( 'Post Notifications', 'email-subscribers' ), '<span id="ig-es-post-notifications">' . __( 'Post Notifications', 'email-subscribers' ) . '</span>', 'edit_posts', 'es_notifications', array( $this, 'load_post_notifications' ) );
192
- add_submenu_page( 'es_dashboard', __( 'Broadcast', 'email-subscribers' ), '<span id="ig-es-broadcast">' . __( 'Broadcast', 'email-subscribers' ) . '</span>', 'edit_posts', 'es_newsletters', array( $this, 'load_newsletters' ) );
193
- add_submenu_page( 'es_dashboard', __( 'Reports', 'email-subscribers' ), __( 'Reports', 'email-subscribers' ), 'edit_posts', 'es_reports', array( $this, 'load_reports' ) );
194
- add_submenu_page( 'es_dashboard', __( 'Settings', 'email-subscribers' ), __( 'Settings', 'email-subscribers' ), 'edit_posts', 'es_settings', array( $this, 'load_settings' ) );
195
- add_submenu_page( null, __( 'Template Preview', 'email-subscribers' ), __( 'Template Preview', 'email-subscribers' ), 'edit_posts', 'es_template_preview', array( $this, 'load_preview' ) );
196
  }
197
 
198
  public function plugins_loaded() {
@@ -489,7 +507,13 @@ class Email_Subscribers_Admin {
489
  $option_name = ig_es_get_request_data( 'option_name' );
490
 
491
  if ( $es_skip == '1' && ! empty( $option_name ) ) {
492
- update_option( 'ig_es_ob_skip_' . $option_name, 'yes' );
 
 
 
 
 
 
493
  $referer = wp_get_referer();
494
  wp_safe_redirect( $referer );
495
  exit();
166
  }
167
 
168
  public function email_subscribers_admin_menu() {
 
 
169
 
170
+ $accessible_sub_menus = ES_Common::ig_es_get_accessible_sub_menus();
 
171
 
172
+ if ( count( $accessible_sub_menus ) > 0 ) {
173
+ // This adds the main menu page
174
+ add_menu_page( __( 'Email Subscribers', 'email-subscribers' ), __( 'Email Subscribers', 'email-subscribers' ), 'edit_posts', 'es_dashboard', array( $this, 'es_dashboard_callback' ), 'dashicons-email', 30 );
175
 
176
+ // Submenu
177
+ add_submenu_page( 'es_dashboard', __( 'Dashboard', 'email-subscribers' ), __( 'Dashboard', 'email-subscribers' ), 'edit_posts', 'es_dashboard', array( $this, 'es_dashboard_callback' ) );
178
+ }
179
+
180
+ if ( in_array( 'campaigns', $accessible_sub_menus ) ) {
181
+ // Add Campaigns Submenu
182
+ $hook = add_submenu_page( 'es_dashboard', __( 'Campaigns', 'email-subscribers' ), __( 'Campaigns', 'email-subscribers' ), 'edit_posts', 'es_campaigns', array( $this, 'render_campaigns' ) );
183
+ add_action( "load-$hook", array( 'ES_Campaigns_Table', 'screen_options' ) );
184
+
185
+ add_submenu_page( 'es_dashboard', __( 'Post Notifications', 'email-subscribers' ), '<span id="ig-es-post-notifications">' . __( 'Post Notifications', 'email-subscribers' ) . '</span>', 'edit_posts', 'es_notifications', array( $this, 'load_post_notifications' ) );
186
+ add_submenu_page( 'es_dashboard', __( 'Broadcast', 'email-subscribers' ), '<span id="ig-es-broadcast">' . __( 'Broadcast', 'email-subscribers' ) . '</span>', 'edit_posts', 'es_newsletters', array( $this, 'load_newsletters' ) );
187
+ add_submenu_page( null, __( 'Template Preview', 'email-subscribers' ), __( 'Template Preview', 'email-subscribers' ), 'edit_posts', 'es_template_preview', array( $this, 'load_preview' ) );
188
+ }
189
+
190
+ if ( in_array( 'forms', $accessible_sub_menus ) ) {
191
+ // Add Forms Submenu
192
+ $hook = add_submenu_page( 'es_dashboard', __( 'Forms', 'email-subscribers' ), __( 'Forms', 'email-subscribers' ), 'edit_posts', 'es_forms', array( $this, 'render_forms' ) );
193
+ add_action( "load-$hook", array( 'ES_Forms_Table', 'screen_options' ) );
194
+ }
195
 
196
+ if ( in_array( 'audience', $accessible_sub_menus ) ) {
197
+ // Add Contacts Submenu
198
+ $hook = add_submenu_page( 'es_dashboard', __( 'Audience', 'email-subscribers' ), __( 'Audience', 'email-subscribers' ), 'edit_posts', 'es_subscribers', array( $this, 'render_contacts' ) );
199
+ add_action( "load-$hook", array( 'ES_Contacts_Table', 'screen_options' ) );
200
 
201
+ // Add Lists Submenu
202
+ $hook = add_submenu_page( 'es_dashboard', __( 'Lists', 'email-subscribers' ), '<span id="ig-es-lists">' . __( 'Lists', 'email-subscribers' ) . '</span>', 'edit_posts', 'es_lists', array( $this, 'render_lists' ) );
203
+ add_action( "load-$hook", array( 'ES_Lists_Table', 'screen_options' ) );
204
+ }
205
+
206
+ if ( in_array( 'reports', $accessible_sub_menus ) ) {
207
+ add_submenu_page( 'es_dashboard', __( 'Reports', 'email-subscribers' ), __( 'Reports', 'email-subscribers' ), 'edit_posts', 'es_reports', array( $this, 'load_reports' ) );
208
+ }
209
+
210
+ if ( in_array( 'settings', $accessible_sub_menus ) ) {
211
+ add_submenu_page( 'es_dashboard', __( 'Settings', 'email-subscribers' ), __( 'Settings', 'email-subscribers' ), 'manage_options', 'es_settings', array( $this, 'load_settings' ) );
212
+ }
213
 
 
 
 
 
 
214
  }
215
 
216
  public function plugins_loaded() {
507
  $option_name = ig_es_get_request_data( 'option_name' );
508
 
509
  if ( $es_skip == '1' && ! empty( $option_name ) ) {
510
+ /**
511
+ * If user logged in then only save option.
512
+ */
513
+ $can_access_settings = ES_Common::ig_es_can_access('settings');
514
+ if ( $can_access_settings ) {
515
+ update_option( 'ig_es_ob_skip_' . $option_name, 'yes' );
516
+ }
517
  $referer = wp_get_referer();
518
  wp_safe_redirect( $referer );
519
  exit();
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.2.2
7
  * Author: Icegram
8
  * Author URI: https://www.icegram.com/
9
  * Requires at least: 3.9
@@ -28,7 +28,7 @@ if ( ! defined( 'WPINC' ) ) {
28
  if ( ! defined( 'ES_PLUGIN_DIR' ) ) {
29
  define( 'ES_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
30
  }
31
- define( 'ES_PLUGIN_VERSION', '4.2.2' );
32
  define( 'ES_PLUGIN_BASE_NAME', plugin_basename( __FILE__ ) );
33
  define( 'IG_ES_FEEDBACK_VERSION', '1.0.10' );
34
 
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.2.3
7
  * Author: Icegram
8
  * Author URI: https://www.icegram.com/
9
  * Requires at least: 3.9
28
  if ( ! defined( 'ES_PLUGIN_DIR' ) ) {
29
  define( 'ES_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
30
  }
31
+ define( 'ES_PLUGIN_VERSION', '4.2.3' );
32
  define( 'ES_PLUGIN_BASE_NAME', plugin_basename( __FILE__ ) );
33
  define( 'IG_ES_FEEDBACK_VERSION', '1.0.10' );
34
 
includes/admin/class-es-actions.php CHANGED
@@ -195,12 +195,17 @@ if ( ! class_exists( 'ES_Actions' ) ) {
195
  * @since 4.2.0
196
  */
197
  public function open( $contact_id, $message_id, $campaign_id ) {
198
- return $this->add_action( array(
199
- 'contact_id' => $contact_id,
200
- 'message_id' => $message_id,
201
- 'campaign_id' => $campaign_id,
202
- 'type' => IG_MESSAGE_OPEN,
203
- ) );
 
 
 
 
 
204
  }
205
 
206
  /**
@@ -266,6 +271,28 @@ if ( ! class_exists( 'ES_Actions' ) ) {
266
  'type' => $hard ? IG_MESSAGE_HARD_BOUNCE : IG_MESSAGE_SOFT_BOUNCE,
267
  ) );
268
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  }
270
  }
271
 
195
  * @since 4.2.0
196
  */
197
  public function open( $contact_id, $message_id, $campaign_id ) {
198
+
199
+ // Track only if campaign sent.
200
+ if ( $this->is_campaign_sent( $contact_id, $message_id, $campaign_id ) ) {
201
+
202
+ return $this->add_action( array(
203
+ 'contact_id' => $contact_id,
204
+ 'message_id' => $message_id,
205
+ 'campaign_id' => $campaign_id,
206
+ 'type' => IG_MESSAGE_OPEN,
207
+ ) );
208
+ }
209
  }
210
 
211
  /**
271
  'type' => $hard ? IG_MESSAGE_HARD_BOUNCE : IG_MESSAGE_SOFT_BOUNCE,
272
  ) );
273
  }
274
+
275
+ /**
276
+ * Check whether campaign is sent to specific contact
277
+ *
278
+ * @param $contact_id
279
+ * @param $message_id
280
+ * @param $campaign_id
281
+ *
282
+ * @return string|null
283
+ *
284
+ * @since 4.2.3
285
+ */
286
+ public function is_campaign_sent( $contact_id, $message_id, $campaign_id ) {
287
+
288
+ global $wpdb;
289
+
290
+ $ig_actions_table = IG_ACTIONS_TABLE;
291
+
292
+ $sql = "SELECT count(*) FROM $ig_actions_table WHERE contact_id = %d AND message_id = %d AND campaign_id = %d AND type = %d";
293
+
294
+ return $wpdb->get_var( $wpdb->prepare( $sql, $contact_id, $message_id, $campaign_id, IG_MESSAGE_SENT ) );
295
+ }
296
  }
297
  }
298
 
includes/admin/class-es-admin-settings.php CHANGED
@@ -32,73 +32,81 @@ class ES_Admin_Settings {
32
  $submitted = ig_es_get_request_data( 'submitted' );
33
  $submit_action = ig_es_get_request_data( 'submit_action' );
34
 
35
- $nonce = ig_es_get_request_data( '_wpnonce' );
36
-
37
  if ( 'submitted' === $submitted && 'ig-es-save-admin-settings' === $submit_action ) {
38
- $options = ig_es_get_post_data('', '', false);
39
- $options = apply_filters( 'ig_es_before_save_settings', $options );
40
-
41
- $options['ig_es_disable_wp_cron'] = isset( $options['ig_es_disable_wp_cron'] ) ? $options['ig_es_disable_wp_cron'] : 'no';
42
- $options['ig_es_track_email_opens'] = isset( $options['ig_es_track_email_opens'] ) ? $options['ig_es_track_email_opens'] : 'no';
43
- $text_fields_to_sanitize = array(
44
- 'ig_es_from_name',
45
- 'ig_es_admin_emails',
46
- 'ig_es_email_type',
47
- 'ig_es_optin_type',
48
- 'ig_es_post_image_size',
49
- 'ig_es_track_email_opens',
50
- 'ig_es_enable_welcome_email',
51
- 'ig_es_welcome_email_subject',
52
- 'ig_es_confirmation_mail_subject',
53
- 'ig_es_notify_admin',
54
- 'ig_es_admin_new_contact_email_subject',
55
- 'ig_es_enable_cron_admin_email',
56
- 'ig_es_cron_admin_email_subject',
57
- 'ig_es_cronurl',
58
- 'ig_es_hourly_email_send_limit',
59
- 'ig_es_disable_wp_cron'
60
- );
61
-
62
- $texarea_fields_to_sanitize = array(
63
- 'ig_es_unsubscribe_link_content',
64
- 'ig_es_subscription_success_message',
65
- 'ig_es_subscription_error_messsage',
66
- 'ig_es_unsubscribe_success_message',
67
- 'ig_es_unsubscribe_error_message',
68
- 'ig_es_welcome_email_content',
69
- 'ig_es_confirmation_mail_content',
70
- 'ig_es_admin_new_contact_email_content',
71
- 'ig_es_cron_admin_email',
72
- 'ig_es_blocked_domains',
73
- 'ig_es_form_submission_success_message'
74
- );
75
-
76
- $email_fields_to_sanitize = array(
77
- 'ig_es_from_email'
78
- );
79
-
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
- }
92
 
93
- update_option( $key, wp_unslash( $value ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  }
95
- }
96
 
97
- do_action( 'ig_es_after_settings_save', $options );
 
 
 
 
 
98
 
99
- $message = __( 'Settings have been saved successfully!' );
100
- $status = 'success';
101
- ES_Common::show_message( $message, $status );
102
  }
103
 
104
 
@@ -141,17 +149,6 @@ class ES_Admin_Settings {
141
  </div>
142
 
143
  </div>
144
-
145
- <!--
146
- <div class="content save">
147
- <input type="hidden" name="submitted" value="submitted"/>
148
- <input type="hidden" name="submit_action" value="ig-es-save-admin-settings"/>
149
- <?php $nonce = wp_create_nonce( 'es-update-settings' ); ?>
150
-
151
- <input type="hidden" name="update-settings" id="ig-update-settings" value="<?php echo $nonce; ?>"/>
152
- <?php submit_button(); ?>
153
- </div>
154
- -->
155
  </form>
156
  </div>
157
  <?php
@@ -538,31 +535,31 @@ class ES_Admin_Settings {
538
  'ig_es_mailer_settings' => array(
539
  'type' => 'html',
540
  // 'html' => ES_Admin_Settings::mailers_html(),
541
- 'sub_fields' => array(
542
- 'mailer' => array(
543
- 'id' => 'ig_es_mailer_settings[mailer]',
544
- 'name' => __( 'Select Mailer', 'email-subscribers' ),
545
- 'type' => 'html',
546
- 'html' => ES_Admin_Settings::mailers_html(),
547
- 'desc' => '',
548
  ),
549
- 'ig_es_pepipost_api_key' => array(
550
- 'type' => 'password',
551
- 'options' => false,
552
- 'placeholder' => '',
553
- 'supplemental' => '',
554
- 'default' => '',
555
- 'id' => "ig_es_mailer_settings[pepipost][api_key]",
556
- 'name' => __( 'Pepipost API key', 'email-subscribers' ),
557
- 'desc' => '',
558
- 'class' => 'pepipost'
559
  ),
560
  'ig_es_pepipost_docblock' => array(
561
- 'type' => 'html',
562
- 'html' => ES_Admin_Settings::pepipost_doc_block(),
563
- 'id' => 'ig_es_pepipost_docblock',
564
  // 'class' => 'ig_es_docblock',
565
- 'name' => ''
566
  )
567
 
568
  ),
@@ -605,22 +602,22 @@ class ES_Admin_Settings {
605
  if ( 'ig_es_cronurl' === $arguments['id'] ) {
606
  $value = ES_Common::get_cron_url();
607
  } else {
608
- if(!empty($arguments['option_value'])){
609
- preg_match("(\[.*$)",$arguments['id'],$m);
610
- $n = explode('][', $m[0]);
611
- $n = str_replace('[', '', $n);
612
- $n = str_replace(']', '', $n);
613
- $count = count($n);
614
- $id = '';
615
- foreach ($n as $key => $val) {
616
- if( $id == ''){
617
- $id = !empty($arguments['option_value'][$val]) ? $arguments['option_value'][$val] : '';
618
- }else{
619
- $id = $id[$val];
620
  }
621
  }
622
  $value = $id;
623
- }else{
624
  $value = get_option( $arguments['id'] ); // Get the current value, if there is one
625
  }
626
  }
@@ -657,10 +654,10 @@ class ES_Admin_Settings {
657
  $uid, $id_key, $placeholder, $value, $class );
658
  break;
659
  case 'file':
660
- $field_html = '<input type="text" id="logo_url" name="' . $uid . '" value="' . $value . '" class="'.$class.'"/> <input id="upload_logo_button" type="button" class="button" value="Upload Logo" />';
661
  break;
662
  case 'checkbox' :
663
- $field_html = '<input id="' . $id_key . '" type="checkbox" name="' . $uid . '" value="yes" ' . checked( $value, 'yes', false ) . ' class="'.$class.'" />' . $placeholder . '</input>';
664
  break;
665
 
666
  case 'select':
@@ -725,7 +722,7 @@ class ES_Admin_Settings {
725
  $html .= "<tbody>";
726
  $button_html = '';
727
  foreach ( $fields as $key => $field ) {
728
- if(!empty($field['name'])){
729
  $html .= "<tr><th scope='row'>";
730
  $html .= $field['name'];
731
 
@@ -743,18 +740,18 @@ class ES_Admin_Settings {
743
  if ( ! empty( $field['sub_fields'] ) ) {
744
  $option_key = '';
745
  foreach ( $field['sub_fields'] as $key => $sub_field ) {
746
- if(strpos($sub_field['id'], '[') ){
747
- $parts = explode('[', $sub_field['id']);
748
- if($option_key !== $parts[0]){
749
  $option_value = get_option( $parts[0] );
750
- $option_key = $parts[0];
751
  }
752
- $sub_field['option_value'] = is_array($option_value) ? $option_value : '';
753
  }
754
- $class = (!empty($sub_field['class'])) ? $sub_field['class'] : "";
755
- $html .= ( $sub_field !== reset( $field['sub_fields'] ) ) ? '<br/>' : '';
756
- $html .= '<div class="es_sub_headline '.$class.'" ><strong>' . $sub_field['name'] . '</strong></div>';
757
- $html .= $this->field_callback( $sub_field, $key ) ;
758
  }
759
  } else {
760
  $html .= $this->field_callback( $field );
@@ -765,54 +762,56 @@ class ES_Admin_Settings {
765
 
766
  $button_html = empty( $button_html ) ? "<tr>" : $button_html;
767
 
768
- $html .= $button_html . "<td class='es-settings-submit-btn'>";
769
- $html .= '<input type="hidden" name="submitted" value="submitted"/>';
770
- $html .= '<input type="hidden" name="submit_action" value="ig-es-save-admin-settings"/>';
771
- $nonce = wp_create_nonce( 'es-update-settings' );
772
- $html .= '<input type="hidden" name="update-settings" id="ig-update-settings" value="' . $nonce . '"/>';
773
- $html .= '<input type="submit" name="submit" id="submit" class="button button-primary" value="' . __( 'Save Settings', 'email-subscribers' ) . '">';
774
- $html .= "</td></tr>";
775
- $html .= "</tbody>";
776
- $html .= "</table>";
 
 
777
  echo $html;
778
 
779
  }
780
 
781
- public static function mailers_html(){
782
- $html = '';
783
- $es_email_type = get_option( 'ig_es_email_type' );
784
- $selected_mailer_settings = get_option( 'ig_es_mailer_settings' );
785
- $selected_mailer = $selected_mailer_settings['mailer'];
786
- $default_mailer = ($es_email_type === 'php_html_mail' || $es_email_type === 'php_plaintext_mail' || $selected_mailer === 'phpmail') ? 'phpmail' : $selected_mailer;
787
- $pepipost_doc_block = '';
788
- $mailers = array(
789
- 'wpmail' => array( 'name'=> 'WP Mail', 'logo' => EMAIL_SUBSCRIBERS_URL . '/admin/images/wpmail.png'),
790
- 'phpmail' => array( 'name'=> 'PHP mail', 'logo' => EMAIL_SUBSCRIBERS_URL . '/admin/images/phpmail.png'),
791
- 'pepipost' => array( 'name'=> 'Pepipost', 'logo' => EMAIL_SUBSCRIBERS_URL . '/admin/images/pepipost.png', 'docblock' => $pepipost_doc_block ),
792
  );
793
- $mailers = apply_filters('ig_es_mailers', $mailers);
794
- $default_mailer = (array_key_exists($default_mailer, $mailers)) ? $default_mailer : 'wpmail';
795
- foreach ($mailers as $key => $mailer) {
796
- $class = ($key === 'pepipost') ? 'es_recommended' : '';
797
- $html .= '<label><div class="es-mailer-logo '.$class.'"><div class="es-logo-wrapper"><img src="' .$mailer['logo'].'" alt="Default (none)"></div>';
798
- $html .= '<input type="radio" class="es_mailer" name="ig_es_mailer_settings[mailer]" value="'.$key.'" '.checked( $default_mailer, $key, false ).'>'.$mailer['name'].'</input></div></label>';
799
  }
800
 
801
  return $html;
802
 
803
  }
804
 
805
- public static function pepipost_doc_block(){
806
  $html = '';
807
  ob_start();
808
  ?>
809
- <div class="es_sub_headline ig_es_docblock ig_es_pepipost_div_wrapper pepipost">
810
- <ul>
811
- <li><a class="" href="https://app.pepipost.com/index.php/signup/icegram?fpr=icegram" target="_blank"><?php _e('Signup for Pepipost', 'email-subscribers') ?></a></li>
812
- <li><?php _e('How to find', 'email-subscribers' ) ?> <a href="https://developers.pepipost.com/api/getstarted/overview?utm_source=icegram&utm_medium=es_inapp&utm_campaign=pepipost" target="_blank"> <?php _e('Pepipost API key', 'email-subscribers')?></a></li>
813
- <li><a href="https://www.icegram.com/email-subscribers-integrates-with-pepipost?utm_source=es_inapp&utm_medium=es_upsale&utm_campaign=upsale" target="_blank"><?php _e('Why to choose Pepipost') ?></a></li>
814
- </ul>
815
- </div>
816
 
817
  <?php
818
 
32
  $submitted = ig_es_get_request_data( 'submitted' );
33
  $submit_action = ig_es_get_request_data( 'submit_action' );
34
 
 
 
35
  if ( 'submitted' === $submitted && 'ig-es-save-admin-settings' === $submit_action ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
+ $nonce = ig_es_get_request_data( 'update-settings' );
38
+ if ( ! wp_verify_nonce( $nonce, 'update-settings' ) ) {
39
+ $message = __( 'You do not have permission to update settings', 'email-subscribers' );
40
+ ES_Common::show_message( $message, 'error' );
41
+ } else {
42
+
43
+ $options = ig_es_get_post_data( '', '', false );
44
+
45
+ $options = apply_filters( 'ig_es_before_save_settings', $options );
46
+
47
+ $options['ig_es_disable_wp_cron'] = isset( $options['ig_es_disable_wp_cron'] ) ? $options['ig_es_disable_wp_cron'] : 'no';
48
+ $options['ig_es_track_email_opens'] = isset( $options['ig_es_track_email_opens'] ) ? $options['ig_es_track_email_opens'] : 'no';
49
+ $text_fields_to_sanitize = array(
50
+ 'ig_es_from_name',
51
+ 'ig_es_admin_emails',
52
+ 'ig_es_email_type',
53
+ 'ig_es_optin_type',
54
+ 'ig_es_post_image_size',
55
+ 'ig_es_track_email_opens',
56
+ 'ig_es_enable_welcome_email',
57
+ 'ig_es_welcome_email_subject',
58
+ 'ig_es_confirmation_mail_subject',
59
+ 'ig_es_notify_admin',
60
+ 'ig_es_admin_new_contact_email_subject',
61
+ 'ig_es_enable_cron_admin_email',
62
+ 'ig_es_cron_admin_email_subject',
63
+ 'ig_es_cronurl',
64
+ 'ig_es_hourly_email_send_limit',
65
+ 'ig_es_disable_wp_cron'
66
+ );
67
+
68
+ $texarea_fields_to_sanitize = array(
69
+ 'ig_es_unsubscribe_link_content',
70
+ 'ig_es_subscription_success_message',
71
+ 'ig_es_subscription_error_messsage',
72
+ 'ig_es_unsubscribe_success_message',
73
+ 'ig_es_unsubscribe_error_message',
74
+ 'ig_es_welcome_email_content',
75
+ 'ig_es_confirmation_mail_content',
76
+ 'ig_es_admin_new_contact_email_content',
77
+ 'ig_es_cron_admin_email',
78
+ 'ig_es_blocked_domains',
79
+ 'ig_es_form_submission_success_message'
80
+ );
81
+
82
+ $email_fields_to_sanitize = array(
83
+ 'ig_es_from_email'
84
+ );
85
+
86
+ foreach ( $options as $key => $value ) {
87
+ if ( substr( $key, 0, 6 ) === 'ig_es_' ) {
88
+
89
+ $value = stripslashes_deep( $value );
90
+
91
+ if ( in_array( $key, $text_fields_to_sanitize ) ) {
92
+ $value = sanitize_text_field( $value );
93
+ } elseif ( in_array( $key, $texarea_fields_to_sanitize ) ) {
94
+ $value = wp_kses_post( $value );
95
+ } elseif ( in_array( $key, $email_fields_to_sanitize ) ) {
96
+ $value = sanitize_email( $value );
97
+ }
98
+
99
+ update_option( $key, wp_unslash( $value ) );
100
+ }
101
  }
 
102
 
103
+ do_action( 'ig_es_after_settings_save', $options );
104
+
105
+ $message = __( 'Settings have been saved successfully!' );
106
+ $status = 'success';
107
+ ES_Common::show_message( $message, $status );
108
+ }
109
 
 
 
 
110
  }
111
 
112
 
149
  </div>
150
 
151
  </div>
 
 
 
 
 
 
 
 
 
 
 
152
  </form>
153
  </div>
154
  <?php
535
  'ig_es_mailer_settings' => array(
536
  'type' => 'html',
537
  // 'html' => ES_Admin_Settings::mailers_html(),
538
+ 'sub_fields' => array(
539
+ 'mailer' => array(
540
+ 'id' => 'ig_es_mailer_settings[mailer]',
541
+ 'name' => __( 'Select Mailer', 'email-subscribers' ),
542
+ 'type' => 'html',
543
+ 'html' => ES_Admin_Settings::mailers_html(),
544
+ 'desc' => '',
545
  ),
546
+ 'ig_es_pepipost_api_key' => array(
547
+ 'type' => 'password',
548
+ 'options' => false,
549
+ 'placeholder' => '',
550
+ 'supplemental' => '',
551
+ 'default' => '',
552
+ 'id' => "ig_es_mailer_settings[pepipost][api_key]",
553
+ 'name' => __( 'Pepipost API key', 'email-subscribers' ),
554
+ 'desc' => '',
555
+ 'class' => 'pepipost'
556
  ),
557
  'ig_es_pepipost_docblock' => array(
558
+ 'type' => 'html',
559
+ 'html' => ES_Admin_Settings::pepipost_doc_block(),
560
+ 'id' => 'ig_es_pepipost_docblock',
561
  // 'class' => 'ig_es_docblock',
562
+ 'name' => ''
563
  )
564
 
565
  ),
602
  if ( 'ig_es_cronurl' === $arguments['id'] ) {
603
  $value = ES_Common::get_cron_url();
604
  } else {
605
+ if ( ! empty( $arguments['option_value'] ) ) {
606
+ preg_match( "(\[.*$)", $arguments['id'], $m );
607
+ $n = explode( '][', $m[0] );
608
+ $n = str_replace( '[', '', $n );
609
+ $n = str_replace( ']', '', $n );
610
+ $count = count( $n );
611
+ $id = '';
612
+ foreach ( $n as $key => $val ) {
613
+ if ( $id == '' ) {
614
+ $id = ! empty( $arguments['option_value'][ $val ] ) ? $arguments['option_value'][ $val ] : '';
615
+ } else {
616
+ $id = $id[ $val ];
617
  }
618
  }
619
  $value = $id;
620
+ } else {
621
  $value = get_option( $arguments['id'] ); // Get the current value, if there is one
622
  }
623
  }
654
  $uid, $id_key, $placeholder, $value, $class );
655
  break;
656
  case 'file':
657
+ $field_html = '<input type="text" id="logo_url" name="' . $uid . '" value="' . $value . '" class="' . $class . '"/> <input id="upload_logo_button" type="button" class="button" value="Upload Logo" />';
658
  break;
659
  case 'checkbox' :
660
+ $field_html = '<input id="' . $id_key . '" type="checkbox" name="' . $uid . '" value="yes" ' . checked( $value, 'yes', false ) . ' class="' . $class . '" />' . $placeholder . '</input>';
661
  break;
662
 
663
  case 'select':
722
  $html .= "<tbody>";
723
  $button_html = '';
724
  foreach ( $fields as $key => $field ) {
725
+ if ( ! empty( $field['name'] ) ) {
726
  $html .= "<tr><th scope='row'>";
727
  $html .= $field['name'];
728
 
740
  if ( ! empty( $field['sub_fields'] ) ) {
741
  $option_key = '';
742
  foreach ( $field['sub_fields'] as $key => $sub_field ) {
743
+ if ( strpos( $sub_field['id'], '[' ) ) {
744
+ $parts = explode( '[', $sub_field['id'] );
745
+ if ( $option_key !== $parts[0] ) {
746
  $option_value = get_option( $parts[0] );
747
+ $option_key = $parts[0];
748
  }
749
+ $sub_field['option_value'] = is_array( $option_value ) ? $option_value : '';
750
  }
751
+ $class = ( ! empty( $sub_field['class'] ) ) ? $sub_field['class'] : "";
752
+ $html .= ( $sub_field !== reset( $field['sub_fields'] ) ) ? '<br/>' : '';
753
+ $html .= '<div class="es_sub_headline ' . $class . '" ><strong>' . $sub_field['name'] . '</strong></div>';
754
+ $html .= $this->field_callback( $sub_field, $key );
755
  }
756
  } else {
757
  $html .= $this->field_callback( $field );
762
 
763
  $button_html = empty( $button_html ) ? "<tr>" : $button_html;
764
 
765
+ $nonce_field = wp_nonce_field( 'update-settings', 'update-settings', true, false );
766
+
767
+ $html .= $button_html . "<td class='es-settings-submit-btn'>";
768
+ $html .= '<input type="hidden" name="submitted" value="submitted"/>';
769
+ $html .= '<input type="hidden" name="submit_action" value="ig-es-save-admin-settings"/>';
770
+ //$html .= '<input type="hidden" name="update-settings" id="update-settings" value="' . $nonce . '"/>';
771
+ $html .= $nonce_field;
772
+ $html .= '<input type="submit" name="submit" id="submit" class="button button-primary" value="' . __( 'Save Settings', 'email-subscribers' ) . '">';
773
+ $html .= "</td></tr>";
774
+ $html .= "</tbody>";
775
+ $html .= "</table>";
776
  echo $html;
777
 
778
  }
779
 
780
+ public static function mailers_html() {
781
+ $html = '';
782
+ $es_email_type = get_option( 'ig_es_email_type' );
783
+ $selected_mailer_settings = get_option( 'ig_es_mailer_settings' );
784
+ $selected_mailer = $selected_mailer_settings['mailer'];
785
+ $default_mailer = ( $es_email_type === 'php_html_mail' || $es_email_type === 'php_plaintext_mail' || $selected_mailer === 'phpmail' ) ? 'phpmail' : $selected_mailer;
786
+ $pepipost_doc_block = '';
787
+ $mailers = array(
788
+ 'wpmail' => array( 'name' => 'WP Mail', 'logo' => EMAIL_SUBSCRIBERS_URL . '/admin/images/wpmail.png' ),
789
+ 'phpmail' => array( 'name' => 'PHP mail', 'logo' => EMAIL_SUBSCRIBERS_URL . '/admin/images/phpmail.png' ),
790
+ 'pepipost' => array( 'name' => 'Pepipost', 'logo' => EMAIL_SUBSCRIBERS_URL . '/admin/images/pepipost.png', 'docblock' => $pepipost_doc_block ),
791
  );
792
+ $mailers = apply_filters( 'ig_es_mailers', $mailers );
793
+ $default_mailer = ( array_key_exists( $default_mailer, $mailers ) ) ? $default_mailer : 'wpmail';
794
+ foreach ( $mailers as $key => $mailer ) {
795
+ $class = ( $key === 'pepipost' ) ? 'es_recommended' : '';
796
+ $html .= '<label><div class="es-mailer-logo ' . $class . '"><div class="es-logo-wrapper"><img src="' . $mailer['logo'] . '" alt="Default (none)"></div>';
797
+ $html .= '<input type="radio" class="es_mailer" name="ig_es_mailer_settings[mailer]" value="' . $key . '" ' . checked( $default_mailer, $key, false ) . '>' . $mailer['name'] . '</input></div></label>';
798
  }
799
 
800
  return $html;
801
 
802
  }
803
 
804
+ public static function pepipost_doc_block() {
805
  $html = '';
806
  ob_start();
807
  ?>
808
+ <div class="es_sub_headline ig_es_docblock ig_es_pepipost_div_wrapper pepipost">
809
+ <ul>
810
+ <li><a class="" href="https://app.pepipost.com/index.php/signup/icegram?fpr=icegram" target="_blank"><?php _e( 'Signup for Pepipost', 'email-subscribers' ) ?></a></li>
811
+ <li><?php _e( 'How to find', 'email-subscribers' ) ?> <a href="https://developers.pepipost.com/api/getstarted/overview?utm_source=icegram&utm_medium=es_inapp&utm_campaign=pepipost" target="_blank"> <?php _e( 'Pepipost API key', 'email-subscribers' ) ?></a></li>
812
+ <li><a href="https://www.icegram.com/email-subscribers-integrates-with-pepipost?utm_source=es_inapp&utm_medium=es_upsale&utm_campaign=upsale" target="_blank"><?php _e( 'Why to choose Pepipost' ) ?></a></li>
813
+ </ul>
814
+ </div>
815
 
816
  <?php
817
 
includes/admin/class-es-export-subscribers.php CHANGED
@@ -18,7 +18,9 @@ class Export_Subscribers {
18
  $report = ig_es_get_request_data( 'report' );
19
  $status = ig_es_get_request_data( 'status' );
20
 
21
- if ( $report && $status ) {
 
 
22
 
23
  $status = trim( $status );
24
 
@@ -62,7 +64,7 @@ class Export_Subscribers {
62
  }
63
 
64
  public function plugin_menu() {
65
- add_submenu_page( null, 'Export Contacts', __( 'Export Contacts', 'email-subscribers' ), get_option( 'es_roles_subscriber', true ), 'es_export_subscribers', array( $this, 'export_subscribers_page' ) );
66
  }
67
 
68
  public function prepare_header_footer_row() {
@@ -101,6 +103,7 @@ class Export_Subscribers {
101
  if ( $i % 2 === 0 ) {
102
  $class = 'alternate';
103
  }
 
104
  $url = "admin.php?page=download_report&report=users&status={$key}";
105
 
106
  ?>
18
  $report = ig_es_get_request_data( 'report' );
19
  $status = ig_es_get_request_data( 'status' );
20
 
21
+ $can_access = ES_Common::ig_es_can_access( 'audience' );
22
+
23
+ if ( $report && $status && $can_access ) {
24
 
25
  $status = trim( $status );
26
 
64
  }
65
 
66
  public function plugin_menu() {
67
+ add_submenu_page( null, 'Export Contacts', __( 'Export Contacts', 'email-subscribers' ), 'edit_posts', 'es_export_subscribers', array( $this, 'export_subscribers_page' ) );
68
  }
69
 
70
  public function prepare_header_footer_row() {
103
  if ( $i % 2 === 0 ) {
104
  $class = 'alternate';
105
  }
106
+
107
  $url = "admin.php?page=download_report&report=users&status={$key}";
108
 
109
  ?>
includes/admin/class-es-handle-subscription.php CHANGED
@@ -151,7 +151,6 @@ class ES_Handle_Subscription {
151
 
152
  if ( $contact_id ) {
153
 
154
- error_log( 'Firing ig_es_contact_subscribe' );
155
  do_action( 'ig_es_contact_subscribe', $contact_id, $this->list_ids );
156
 
157
  $this->db_id = $contact_id;
151
 
152
  if ( $contact_id ) {
153
 
 
154
  do_action( 'ig_es_contact_subscribe', $contact_id, $this->list_ids );
155
 
156
  $this->db_id = $contact_id;
includes/admin/class-es-tools.php CHANGED
@@ -18,16 +18,22 @@ class ES_Tools {
18
  // class instance
19
  static $instance;
20
 
21
- // class constructor
22
  public function __construct() {
23
- add_action( 'wp_ajax_es_send_test_email', array( $this, 'es_send_test_email_callback' ) );
 
 
 
 
 
24
  }
25
 
26
  public static function es_send_test_email_callback() {
27
- $email = sanitize_email(ig_es_get_request_data('es_test_email'));
 
28
 
29
  $email_response = '';
30
  $response = array();
 
31
  if ( ! empty( $email ) ) {
32
  $subject = 'Email Subscribers: ' . sprintf( esc_html__( 'Test email to %s', 'email-subscribers' ), $email );
33
  $content = self::get_email_message();
18
  // class instance
19
  static $instance;
20
 
 
21
  public function __construct() {
22
+
23
+ // Allow only to send test email to user who have Settings & Campaigns permission
24
+ $accessible_sub_menus = ES_Common::ig_es_get_accessible_sub_menus();
25
+ if ( in_array( 'settings', $accessible_sub_menus ) || in_array( 'campaigns', $accessible_sub_menus ) ) {
26
+ add_action( 'wp_ajax_es_send_test_email', array( $this, 'es_send_test_email_callback' ) );
27
+ }
28
  }
29
 
30
  public static function es_send_test_email_callback() {
31
+
32
+ $email = sanitize_email( ig_es_get_request_data( 'es_test_email' ) );
33
 
34
  $email_response = '';
35
  $response = array();
36
+
37
  if ( ! empty( $email ) ) {
38
  $subject = 'Email Subscribers: ' . sprintf( esc_html__( 'Test email to %s', 'email-subscribers' ), $email );
39
  $content = self::get_email_message();
includes/class-es-common.php CHANGED
@@ -172,7 +172,7 @@ Class ES_Common {
172
 
173
  $where = "(deleted_at IS NULL OR deleted_at = '0000-00-00 00:00:00')";
174
 
175
- $lists = ES()->forms_db->get_id_name_map($where);
176
 
177
  if ( ! is_null( $default_label ) ) {
178
  $default_option[0] = __( $default_label, 'email-subscribers' );
@@ -939,7 +939,7 @@ Class ES_Common {
939
  *
940
  */
941
  public static function render_feedback_widget( $params ) {
942
- global $ig_es_feedback;
943
 
944
  $feedback = $ig_es_feedback;
945
 
@@ -1164,4 +1164,76 @@ Class ES_Common {
1164
 
1165
  }
1166
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1167
  }
172
 
173
  $where = "(deleted_at IS NULL OR deleted_at = '0000-00-00 00:00:00')";
174
 
175
+ $lists = ES()->forms_db->get_id_name_map( $where );
176
 
177
  if ( ! is_null( $default_label ) ) {
178
  $default_option[0] = __( $default_label, 'email-subscribers' );
939
  *
940
  */
941
  public static function render_feedback_widget( $params ) {
942
+ global $ig_es_feedback;
943
 
944
  $feedback = $ig_es_feedback;
945
 
1164
 
1165
  }
1166
 
1167
+ /**
1168
+ * Check whether user has access to this page
1169
+ *
1170
+ * @param $page
1171
+ *
1172
+ * @return bool|mixed|void
1173
+ *
1174
+ * @since 4.2.3
1175
+ */
1176
+ public static function ig_es_can_access( $page ) {
1177
+
1178
+ $user = wp_get_current_user();
1179
+
1180
+ if ( ! $user->exists() ) {
1181
+ return false;
1182
+ }
1183
+
1184
+ $default_permission = 'manage_options';
1185
+
1186
+ $can_access = $user->has_cap( $default_permission );
1187
+
1188
+ // Is Admin? Have full access
1189
+ if($can_access) {
1190
+ return true;
1191
+ }
1192
+
1193
+ // We are using this filter in ES Premium to check permission
1194
+ return apply_filters( 'ig_es_can_access', $can_access, $page );
1195
+
1196
+ }
1197
+
1198
+ /**
1199
+ * Get accessible submenus
1200
+ *
1201
+ * @return array|mixed|void
1202
+ *
1203
+ * @since 4.2.3
1204
+ */
1205
+ public static function ig_es_get_accessible_sub_menus() {
1206
+
1207
+ $sub_menus = array();
1208
+
1209
+ $user = wp_get_current_user();
1210
+
1211
+ if ( ! $user->exists() ) {
1212
+ return $sub_menus;
1213
+ }
1214
+
1215
+ $default_permission = 'manage_options';
1216
+ $is_administrator = $user->has_cap( $default_permission );
1217
+
1218
+ // Is user administrator? User has access to all submenus
1219
+ if ( $is_administrator ) {
1220
+ $sub_menus = array(
1221
+ 'dashboard',
1222
+ 'audience',
1223
+ 'reports',
1224
+ 'forms',
1225
+ 'campaigns',
1226
+ 'sequences',
1227
+ 'settings'
1228
+ );
1229
+
1230
+ return $sub_menus;
1231
+ }
1232
+
1233
+ // We are using this in ES Premium
1234
+ $sub_menus = apply_filters( 'ig_es_accessible_sub_menus', $sub_menus );
1235
+
1236
+ return array_unique($sub_menus);
1237
+ }
1238
+
1239
  }
includes/class-es-mailer.php CHANGED
@@ -33,19 +33,21 @@ class ES_Mailer {
33
  $emails_name_map = ES_DB_Contacts::get_subscribers_email_name_map( $emails );
34
 
35
  foreach ( $mails as $mail ) {
36
- $email = $mail['email'];
37
- $id = $mail['contact_id'];
38
- $guid = $mail['mailing_queue_hash'];
39
- $email_name = ! empty( $emails_name_map[ $email ] ) ? $emails_name_map[ $email ]['name'] : '';
40
- $first_name = ! empty( $emails_name_map[ $email ] ) ? $emails_name_map[ $email ]['first_name'] : '';
41
- $last_name = ! empty( $emails_name_map[ $email ] ) ? $emails_name_map[ $email ]['last_name'] : '';
 
 
42
 
43
  $keywords = array(
44
  'name' => $email_name,
45
  'first_name' => $first_name,
46
  'last_name' => $last_name,
47
  'email' => $email,
48
- 'guid' => $guid,
49
  'dbid' => $id,
50
  'message_id' => $notification['id'],
51
  'campaign_id' => $notification['campaign_id']
@@ -57,11 +59,11 @@ class ES_Mailer {
57
 
58
  $send = self::send( $email, $subject, $body );
59
 
60
- if ( $send ) {
61
- ES_DB_Sending_Queue::update_sent_status( $mail['id'], 'Sent' );
62
- }
63
-
64
  ES_Common::update_total_email_sent_count();
 
 
 
65
  }
66
 
67
  }
@@ -386,7 +388,7 @@ class ES_Mailer {
386
 
387
  public static function send( $to_email, $subject, $email_template ) {
388
 
389
- $response = array('status' => 'ERROR');
390
  $subject = html_entity_decode( $subject, ENT_QUOTES, get_bloginfo( 'charset' ) );
391
  $get_email_type = get_option( 'ig_es_email_type', true );
392
  $site_title = get_bloginfo();
@@ -430,7 +432,7 @@ class ES_Mailer {
430
 
431
  } else {
432
  $result = mail( $to_email, $subject, $email_template, $headers );
433
- if($result) {
434
  $response['status'] = 'SUCCESS';
435
  }
436
  }
33
  $emails_name_map = ES_DB_Contacts::get_subscribers_email_name_map( $emails );
34
 
35
  foreach ( $mails as $mail ) {
36
+ $email = $mail['email'];
37
+ $id = $mail['contact_id'];
38
+ $guid = $mail['mailing_queue_hash'];
39
+ $campaign_id = $mail['campaign_id'];
40
+ $message_id = $mail['mailing_queue_id'];
41
+ $email_name = ! empty( $emails_name_map[ $email ] ) ? $emails_name_map[ $email ]['name'] : '';
42
+ $first_name = ! empty( $emails_name_map[ $email ] ) ? $emails_name_map[ $email ]['first_name'] : '';
43
+ $last_name = ! empty( $emails_name_map[ $email ] ) ? $emails_name_map[ $email ]['last_name'] : '';
44
 
45
  $keywords = array(
46
  'name' => $email_name,
47
  'first_name' => $first_name,
48
  'last_name' => $last_name,
49
  'email' => $email,
50
+ 'hash' => $guid,
51
  'dbid' => $id,
52
  'message_id' => $notification['id'],
53
  'campaign_id' => $notification['campaign_id']
59
 
60
  $send = self::send( $email, $subject, $body );
61
 
62
+ ES_DB_Sending_Queue::update_sent_status( $mail['id'], 'Sent' );
 
 
 
63
  ES_Common::update_total_email_sent_count();
64
+
65
+ // Track Message Sent
66
+ do_action( 'ig_es_message_sent', $id, $campaign_id, $message_id );
67
  }
68
 
69
  }
388
 
389
  public static function send( $to_email, $subject, $email_template ) {
390
 
391
+ $response = array( 'status' => 'ERROR' );
392
  $subject = html_entity_decode( $subject, ENT_QUOTES, get_bloginfo( 'charset' ) );
393
  $get_email_type = get_option( 'ig_es_email_type', true );
394
  $site_title = get_bloginfo();
432
 
433
  } else {
434
  $result = mail( $to_email, $subject, $email_template, $headers );
435
+ if ( $result ) {
436
  $response['status'] = 'SUCCESS';
437
  }
438
  }
public/class-email-subscribers-public.php CHANGED
@@ -143,11 +143,11 @@ class Email_Subscribers_Public {
143
  if ( ! empty( $hash ) ) {
144
  $data = ig_es_decode_request_data( $hash );
145
 
146
- $db_id = ! empty( $data['contact_id'] ) ? $data['contact_id'] : 0;
147
  $email = ! empty( $data['email'] ) ? $data['email'] : '';
148
  $guid = ! empty( $data['guid'] ) ? $data['guid'] : '';
149
- $message_id = ! empty( $data['message_id'] ) ? $data['message_id'] : 0;
150
- $campaign_id = ! empty( $data['campaign_id'] ) ? $data['campaign_id'] : 0;
151
  } else {
152
  $db_id = ig_es_get_request_data( 'db' );
153
  $email = ig_es_get_request_data( 'email' );
@@ -260,8 +260,10 @@ class Email_Subscribers_Public {
260
  if ( ! empty( $guid ) && ! empty( $email ) ) {
261
  ES_DB_Sending_Queue::update_viewed_status( $guid, $email );
262
 
263
- // Track Message Open
264
- do_action( 'ig_es_message_open', $db_id, $message_id, $campaign_id );
 
 
265
  }
266
  }
267
 
@@ -324,67 +326,67 @@ class Email_Subscribers_Public {
324
 
325
  ?>
326
 
327
- <style type="text/css">
328
- .ig_es_form_wrapper {
329
- width: 30%;
330
- margin: 0 auto;
331
- border: 2px #e8e3e3 solid;
332
- padding: 0.9em;
333
- border-radius: 5px;
334
- }
335
-
336
- .ig_es_form_heading {
337
- font-size: 1.3em;
338
- line-height: 1.5em;
339
- margin-bottom: 0.5em;
340
- }
341
-
342
- .ig_es_list_checkbox {
343
- margin-right: 0.5em;
344
- }
345
-
346
- .ig_es_submit {
347
- color: #FFFFFF !important;
348
- border-color: #03a025 !important;
349
- background: #03a025 !important;
350
- box-shadow: 0 1px 0 #03a025;
351
- font-weight: bold;
352
- height: 2.4em;
353
- line-height: 1em;
354
- cursor: pointer;
355
- border-width: 1px;
356
- border-style: solid;
357
- -webkit-appearance: none;
358
- border-radius: 3px;
359
- white-space: nowrap;
360
- box-sizing: border-box;
361
- font-size: 1em;
362
- padding: 0 2em;
363
- margin-top: 1em;
364
- }
365
-
366
- .confirmation-no : {
367
- border-color: #FF0000 !important;
368
- background: #FF0000 !important;
369
- box-shadow: 0 1px 0 #FF0000;
370
- }
371
-
372
- .ig_es_submit:hover {
373
- color: #FFF !important;
374
- background: #0AAB2E !important;
375
- border-color: #0AAB2E !important;
376
- }
377
-
378
- .ig_es_form_wrapper hr {
379
- display: block;
380
- height: 1px;
381
- border: 0;
382
- border-top: 1px solid #ccc;
383
- margin: 1em 0;
384
- padding: 0;
385
- }
386
-
387
- </style>
388
 
389
  <div class="ig_es_form_wrapper">
390
  <form action="<?php echo $action; ?>" method="post" id="">
143
  if ( ! empty( $hash ) ) {
144
  $data = ig_es_decode_request_data( $hash );
145
 
146
+ $db_id = ! empty( $data['contact_id'] ) ? (int) $data['contact_id'] : 0;
147
  $email = ! empty( $data['email'] ) ? $data['email'] : '';
148
  $guid = ! empty( $data['guid'] ) ? $data['guid'] : '';
149
+ $message_id = ! empty( $data['message_id'] ) ? (int) $data['message_id'] : 0;
150
+ $campaign_id = ! empty( $data['campaign_id'] ) ? (int) $data['campaign_id'] : 0;
151
  } else {
152
  $db_id = ig_es_get_request_data( 'db' );
153
  $email = ig_es_get_request_data( 'email' );
260
  if ( ! empty( $guid ) && ! empty( $email ) ) {
261
  ES_DB_Sending_Queue::update_viewed_status( $guid, $email );
262
 
263
+ if($campaign_id > 0 && $db_id > 0) {
264
+ do_action( 'ig_es_message_open', $db_id, $message_id, $campaign_id );
265
+ }
266
+
267
  }
268
  }
269
 
326
 
327
  ?>
328
 
329
+ <style type="text/css">
330
+ .ig_es_form_wrapper {
331
+ width: 30%;
332
+ margin: 0 auto;
333
+ border: 2px #e8e3e3 solid;
334
+ padding: 0.9em;
335
+ border-radius: 5px;
336
+ }
337
+
338
+ .ig_es_form_heading {
339
+ font-size: 1.3em;
340
+ line-height: 1.5em;
341
+ margin-bottom: 0.5em;
342
+ }
343
+
344
+ .ig_es_list_checkbox {
345
+ margin-right: 0.5em;
346
+ }
347
+
348
+ .ig_es_submit {
349
+ color: #FFFFFF !important;
350
+ border-color: #03a025 !important;
351
+ background: #03a025 !important;
352
+ box-shadow: 0 1px 0 #03a025;
353
+ font-weight: bold;
354
+ height: 2.4em;
355
+ line-height: 1em;
356
+ cursor: pointer;
357
+ border-width: 1px;
358
+ border-style: solid;
359
+ -webkit-appearance: none;
360
+ border-radius: 3px;
361
+ white-space: nowrap;
362
+ box-sizing: border-box;
363
+ font-size: 1em;
364
+ padding: 0 2em;
365
+ margin-top: 1em;
366
+ }
367
+
368
+ .confirmation-no : {
369
+ border-color: #FF0000 !important;
370
+ background: #FF0000 !important;
371
+ box-shadow: 0 1px 0 #FF0000;
372
+ }
373
+
374
+ .ig_es_submit:hover {
375
+ color: #FFF !important;
376
+ background: #0AAB2E !important;
377
+ border-color: #0AAB2E !important;
378
+ }
379
+
380
+ .ig_es_form_wrapper hr {
381
+ display: block;
382
+ height: 1px;
383
+ border: 0;
384
+ border-top: 1px solid #ccc;
385
+ margin: 1em 0;
386
+ padding: 0;
387
+ }
388
+
389
+ </style>
390
 
391
  <div class="ig_es_form_wrapper">
392
  <form action="<?php echo $action; ?>" method="post" id="">
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.3
8
- Stable tag: 4.2.2
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses
11
 
@@ -300,7 +300,14 @@ Refer [here](https://www.icegram.com/documentation/es-faq/).
300
 
301
  == Changelog ==
302
 
303
- = 4.2.2 (14.10.2019) =
 
 
 
 
 
 
 
304
  * New: Added configuration option for label & placeholder for subscription form
305
  * Update: Ask subscribers for confirmation before unsubscription
306
  * Fix: Unsubscription issue
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.3
8
+ Stable tag: 4.2.3
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses
11
 
300
 
301
  == Changelog ==
302
 
303
+ **4.2.3 (17.10.2019)**
304
+ * Update: Now, only administrator can access Email Subscribers menus.
305
+ * Fix: Email open tracking
306
+ * Fix: Vulnerability while exporting contacts
307
+ * Fix: Vulnerability while sending test email
308
+ * Fix: Check permission before saving settings
309
+
310
+ = 4.2.2 (15.10.2019) =
311
  * New: Added configuration option for label & placeholder for subscription form
312
  * Update: Ask subscribers for confirmation before unsubscription
313
  * Fix: Unsubscription issue