Email Subscribers & Newsletters - Version 3.5.15

Version Description

(25.10.2018) = * Fix: Extra field shown for forms on RTL sites

Download this release

Release Info

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

Code changes from version 3.5.14 to 3.5.15

changelog.txt CHANGED
@@ -4,6 +4,10 @@ Author : Icegram
4
  Author URI : https://www.icegram.com/
5
  License : GPLv3
6
 
 
 
 
 
7
  ***********************************************************Version 3.5.14***********************************************************
8
 
9
  * Fix: Improve prevention of spam signups
4
  Author URI : https://www.icegram.com/
5
  License : GPLv3
6
 
7
+ ***********************************************************Version 3.5.15***********************************************************
8
+
9
+ * Fix: Extra field shown for forms on RTL sites
10
+
11
  ***********************************************************Version 3.5.14***********************************************************
12
 
13
  * Fix: Improve prevention of spam signups
classes/es-offer.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if( get_option('es_offer_halloween_done_2018_email_subscribers') == 'no' ) return;
3
+ ?>
4
+ <style type="text/css">
5
+ .es_offer{
6
+ width: 70%;
7
+ height: auto;
8
+ margin: 1em auto;
9
+ text-align: center;
10
+ background-color: #f18322;
11
+ font-size: 1.2em;
12
+ letter-spacing: 3px;
13
+ line-height: 1em;
14
+ padding: 1.2em;
15
+ background-image: url('<?php echo ES_URL ?>/images/happy-hallowen.png');
16
+ background-repeat: no-repeat;
17
+ background-size: 40%;
18
+ background-position: left;
19
+ }
20
+ .es_offer_heading{
21
+ color: #FFF;
22
+ padding: 1em 0;
23
+ line-height: 1em;
24
+ margin-left: 9em;
25
+ }
26
+ .es_main_heading {
27
+ font-size: 5em;
28
+ color: #b70f0f;
29
+ font-weight: 600;
30
+ line-height: 1em;
31
+ position: relative;
32
+ }
33
+
34
+ .es_text{
35
+ font-size: 0.9em;
36
+ }
37
+ .es_left_text{
38
+ padding: 0.5em 0em;
39
+ color: #000;
40
+ }
41
+ .es_right_text{
42
+ color: #FFFFFF;
43
+ font-weight: 600;
44
+ max-width: 50%;
45
+ padding: 10px 56px;
46
+ width: auto;
47
+ margin: 0.3em 0em;
48
+ display: inline-block;
49
+ text-decoration: none;
50
+ background: #b70f0f;
51
+ font-size: 2em;
52
+ line-height: 1.2em;
53
+ }
54
+ .es_right_text:hover, .es_right_text:active{
55
+ color: inherit;
56
+ }
57
+ .es_offer_content{
58
+ margin-left: 35%;
59
+ }
60
+ </style>
61
+ <div class="es_offer">
62
+ <div style="float:right;"><img src="<?php echo ES_URL ?>/images/icegram-logo-16bit-gray-30.png" /></div>
63
+ <div class="es_offer_content">
64
+ <div class="es_offer_heading">&mdash; Halloween Sale &mdash;</div>
65
+ <div class="es_main_heading">Upto 50% OFF</div>
66
+ <div class="es_text">
67
+ <div class="es_left_text" style="font-size:1.1em;">Offer applicable on</div>
68
+ <div class="es_left_text" style="font-size:1.1em;"> <span style="color:#FFF;font-weight:bold">Icegram, Rainmaker & Email Subscribers</span></div>
69
+ <a href="?dismiss_admin_notice=1&option_name=es_offer_halloween_done_2018" target="_blank" class="es_right_text">Claim This Offer</a>
70
+ <div class="es_left_text">Offer ends on 2nd November, 2018 - so hurry.. </div>
71
+ </div>
72
+ </div>
73
+ </div>
classes/es-register.php CHANGED
@@ -810,18 +810,31 @@ class es_cls_registerhook {
810
  $es_rating_text = $es_rating_text[$key];
811
  echo '<div class="notice notice-warning" style="background-color: #FFF;"><p style="letter-spacing: 0.6px;">' . $es_rating_text . ' <a style="float:right" class="es-admin-btn es-admin-btn-secondary" href="?dismiss_admin_notice=1&option_name=es_star_review">' . __( 'No, I don\'t like it', 'email-subscribers' ) . '</a></p></div>';
812
  }
 
 
 
 
 
 
 
 
 
 
813
  }
814
 
815
  // Function to dismiss any admin notice
816
  public static function dismiss_admin_notice() {
817
-
818
  if ( isset( $_GET['dismiss_admin_notice'] ) && $_GET['dismiss_admin_notice'] == '1' && isset( $_GET['option_name'] ) ) {
819
  $option_name = sanitize_text_field( $_GET['option_name'] );
820
  update_option( $option_name . '_email_subscribers', 'no' );
821
-
822
- $referer = wp_get_referer();
823
- wp_safe_redirect( $referer );
824
- exit();
 
 
 
 
825
 
826
  }
827
 
@@ -1156,8 +1169,10 @@ class es_cls_registerhook {
1156
  </div>
1157
  <?php if ( $es_name != "YES" ) { ?>
1158
  <input type="hidden" id="es_txt_name" name="es_txt_name" value="">
1159
- <?php } ?>
1160
- <div style="position:absolute; left: -5000px"><input type="text" name="es_required_field" class="es_required_field" tabindex="-1" autocomplete="es_test"/></div>
 
 
1161
  <input type="hidden" id="es_txt_group" name="es_txt_group" value="<?php echo $es_group; ?>">
1162
  <?php $nonce = wp_create_nonce( 'es-subscribe' ); ?>
1163
  <input type="hidden" name="es-subscribe" id="es-subscribe" value="<?php echo $nonce; ?>"/>
810
  $es_rating_text = $es_rating_text[$key];
811
  echo '<div class="notice notice-warning" style="background-color: #FFF;"><p style="letter-spacing: 0.6px;">' . $es_rating_text . ' <a style="float:right" class="es-admin-btn es-admin-btn-secondary" href="?dismiss_admin_notice=1&option_name=es_star_review">' . __( 'No, I don\'t like it', 'email-subscribers' ) . '</a></p></div>';
812
  }
813
+
814
+ //halloween 2018 :start
815
+ $timezone_format = _x('Y-m-d', 'timezone date format');
816
+ $ig_current_date = strtotime(date_i18n($timezone_format));
817
+ $ig_offer_start = strtotime("2018-10-30");
818
+ $ig_offer_end = strtotime("2018-11-2");
819
+ if(($ig_current_date >= $ig_offer_start) && ($ig_current_date <= $ig_offer_end)) {
820
+ include_once('es-offer.php');
821
+ }
822
+ //halloween 2018 :end
823
  }
824
 
825
  // Function to dismiss any admin notice
826
  public static function dismiss_admin_notice() {
 
827
  if ( isset( $_GET['dismiss_admin_notice'] ) && $_GET['dismiss_admin_notice'] == '1' && isset( $_GET['option_name'] ) ) {
828
  $option_name = sanitize_text_field( $_GET['option_name'] );
829
  update_option( $option_name . '_email_subscribers', 'no' );
830
+ if($option_name === 'es_offer_halloween_done_2018'){
831
+ header("Location: https://www.icegram.com/latest-valid-coupons-discounts-offers-deals/?utm_source=in_app&utm_medium=es_banner&utm_campaign=halloween_2018");
832
+ exit();
833
+ }else{
834
+ $referer = wp_get_referer();
835
+ wp_safe_redirect( $referer );
836
+ exit();
837
+ }
838
 
839
  }
840
 
1169
  </div>
1170
  <?php if ( $es_name != "YES" ) { ?>
1171
  <input type="hidden" id="es_txt_name" name="es_txt_name" value="">
1172
+ <?php }
1173
+ $es_req_style = (!is_rtl()) ? 'position:absolute; left: -5000px' : 'position:absolute; right: -5000px' ;
1174
+ ?>
1175
+ <div style="<?php echo $es_req_style ?>"><input type="text" name="es_required_field" class="es_required_field" tabindex="-1" autocomplete="off"/></div>
1176
  <input type="hidden" id="es_txt_group" name="es_txt_group" value="<?php echo $es_group; ?>">
1177
  <?php $nonce = wp_create_nonce( 'es-subscribe' ); ?>
1178
  <input type="hidden" name="es-subscribe" id="es-subscribe" value="<?php echo $nonce; ?>"/>
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: 3.5.14
7
  * Author: Icegram
8
  * Author URI: https://www.icegram.com/
9
  * Requires at least: 3.9
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: 3.5.15
7
  * Author: Icegram
8
  * Author URI: https://www.icegram.com/
9
  * Requires at least: 3.9
images/andrea-avatar-300x300.jpg DELETED
Binary file
images/happy-hallowen.png ADDED
Binary file
images/signature.png DELETED
Binary file
job/es-subscribe.php CHANGED
@@ -4,106 +4,118 @@
4
  if ( ! defined( 'ABSPATH' ) ) {
5
  exit;
6
  }
 
 
7
 
8
- class es_cls_job_subscribe {
9
-
10
- public function __construct() {
11
- if ( defined( 'DOING_AJAX' ) && true === DOING_AJAX ) {
12
- add_action( 'wp_ajax_es_add_subscriber', array( $this, 'es_add_subscriber' ) );
13
- add_action( 'wp_ajax_nopriv_es_add_subscriber', array( $this, 'es_add_subscriber' ) );
14
  }
15
- }
16
-
17
- public function es_add_subscriber() {
18
- $es_response = array();
19
- //honey-pot validation
20
- if(!empty($_POST['es_required_field'])){
21
- $es_response['error'] = 'unexpected-error';
22
- echo json_encode($es_response);
23
- die();
24
  }
25
- //block address list
26
- $es_disposable_list = array('\.ru');
27
- if(preg_match('/('.implode('|', $es_disposable_list).')$/i', trim($_POST['esfpx_es_txt_email']))){
28
- $es_response['error'] = 'unexpected-error';
29
  echo json_encode($es_response);
30
  die();
31
  }
32
 
33
- if ( ( isset( $_POST['es'] ) ) && ( 'subscribe' === $_POST['es'] ) && ( isset( $_POST['action'] ) ) && ( 'es_add_subscriber' === $_POST['action'] ) && !empty( $_POST['esfpx_es-subscribe'] ) ) {
34
-
35
- foreach ($_POST as $key => $value) {
36
- $new_key = str_replace('_pg', '', $key);
37
- $_POST[$new_key] = $value;
 
 
38
  }
39
-
40
- $es_subscriber_name = isset( $_POST['esfpx_es_txt_name'] ) ? trim($_POST['esfpx_es_txt_name']) : '';
41
- $es_subscriber_email = isset( $_POST['esfpx_es_txt_email'] ) ? trim($_POST['esfpx_es_txt_email']) : '';
42
- $es_subscriber_group = isset( $_POST['esfpx_es_txt_group'] ) ? trim($_POST['esfpx_es_txt_group']) : '';
43
- $es_nonce = $_POST['esfpx_es-subscribe'];
44
-
45
- $subscriber_form = array(
46
- 'es_email_name' => '',
47
- 'es_email_mail' => '',
48
- 'es_email_group' => '',
49
- 'es_email_status' => '',
50
- 'es_nonce' => ''
51
- );
52
-
53
- if( $es_subscriber_group == '' ) {
54
- $es_subscriber_group = 'Public';
55
  }
56
 
57
- if ( $es_subscriber_email != '' ) {
58
- if ( !filter_var( $es_subscriber_email, FILTER_VALIDATE_EMAIL ) ) {
59
- $es_response['error'] = 'invalid-email';
60
- } else {
61
- $action = '';
62
- global $wpdb;
63
 
64
- $subscriber_form['es_email_name'] = $es_subscriber_name;
65
- $subscriber_form['es_email_mail'] = $es_subscriber_email;
66
- $subscriber_form['es_email_group'] = $es_subscriber_group;
67
- $subscriber_form['es_nonce'] = $es_nonce;
68
 
69
- $es_optintype = get_option( 'ig_es_optintype' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
- if( $es_optintype == "Double Opt In" ) {
72
- $subscriber_form['es_email_status'] = "Unconfirmed";
 
73
  } else {
74
- $subscriber_form['es_email_status'] = "Single Opt In";
75
- }
 
 
 
 
 
 
 
76
 
77
- $action = es_cls_dbquery::es_view_subscriber_widget($subscriber_form);
78
- if( $action == "sus" ) {
79
- $subscribers = es_cls_dbquery::es_view_subscriber_one($es_subscriber_email,$es_subscriber_group);
80
  if( $es_optintype == "Double Opt In" ) {
81
- es_cls_sendmail::es_sendmail("optin", $template = 0, $subscribers, "optin", 0);
82
- $es_response['success'] = 'subscribed-pending-doubleoptin';
83
  } else {
84
- $es_c_usermailoption = get_option( 'ig_es_welcomeemail' );
85
- if ( $es_c_usermailoption == "YES" ) {
86
- es_cls_sendmail::es_sendmail("welcome", $template = 0, $subscribers, "welcome", 0);
87
- }
88
- $es_response['success'] = 'subscribed-successfully';
89
- }
90
- } elseif( $action == "ext" ) {
91
- $es_response['success'] = 'already-exist';
92
- } elseif( $action == "invalid" ) {
93
- $es_response['error'] = 'invalid-email';
 
 
 
 
 
 
 
 
 
 
 
94
  }
 
 
95
  }
96
  } else {
97
- $es_response['error'] = 'no-email-address';
98
- }
99
- } else {
100
- $es_response['error'] = 'unexpected-error';
101
- }
102
-
103
-
104
- echo json_encode($es_response);
105
- die();
106
  }
107
- }
108
-
109
- new es_cls_job_subscribe();
4
  if ( ! defined( 'ABSPATH' ) ) {
5
  exit;
6
  }
7
+ if ( !class_exists( 'es_cls_job_subscribe' ) ) {
8
+ class es_cls_job_subscribe {
9
 
10
+ public function __construct( $isActionsNeeded ) {
11
+ if ( defined( 'DOING_AJAX' ) && (true === DOING_AJAX) && (true === $isActionsNeeded) ) {
12
+ add_action( 'wp_ajax_es_add_subscriber', array( $this, 'es_add_subscriber' ), 10 );
13
+ add_action( 'wp_ajax_nopriv_es_add_subscriber', array( $this, 'es_add_subscriber' ), 10 );
14
+ }
 
15
  }
16
+ public static function getInstance( $isActionsNeeded = true){
17
+ static $es_cls_job_subscribe_obj = null;
18
+ if (null === $es_cls_job_subscribe_obj) {
19
+ $es_cls_job_subscribe_obj = new es_cls_job_subscribe($isActionsNeeded);
20
+ }
21
+ return $es_cls_job_subscribe_obj;
 
 
 
22
  }
23
+
24
+
25
+ public function es_add_subscriber( ) {
26
+ $es_response = $this->es_add_subscribers_db();
27
  echo json_encode($es_response);
28
  die();
29
  }
30
 
31
+ public function es_add_subscribers_db(){
32
+ $es_response = array();
33
+ //honey-pot validation
34
+ if(!empty($_POST['es_required_field'])){
35
+ $es_response['error'] = 'unexpected-error';
36
+ return $es_response;
37
+
38
  }
39
+ //block address list
40
+ $es_disposable_list = array('\.ru');
41
+ if(preg_match('/('.implode('|', $es_disposable_list).')$/i', trim($_POST['esfpx_es_txt_email']))){
42
+ $es_response['error'] = 'unexpected-error';
43
+ $echoAble=json_encode($es_response);
44
+ return $es_response;
 
 
 
 
 
 
 
 
 
 
45
  }
46
 
47
+ if ( ( isset( $_POST['es'] ) ) && ( 'subscribe' === $_POST['es'] ) && !empty( $_POST['esfpx_es-subscribe'] ) ) {
 
 
 
 
 
48
 
49
+ foreach ($_POST as $key => $value) {
50
+ $new_key = str_replace('_pg', '', $key);
51
+ $_POST[$new_key] = $value;
52
+ }
53
 
54
+ $es_subscriber_name = isset( $_POST['esfpx_es_txt_name'] ) ? trim($_POST['esfpx_es_txt_name']) : '';
55
+ $es_subscriber_email = isset( $_POST['esfpx_es_txt_email'] ) ? trim($_POST['esfpx_es_txt_email']) : '';
56
+ $es_subscriber_group = isset( $_POST['esfpx_es_txt_group'] ) ? trim($_POST['esfpx_es_txt_group']) : '';
57
+ $es_nonce = $_POST['esfpx_es-subscribe'];
58
+
59
+ $subscriber_form = array(
60
+ 'es_email_name' => '',
61
+ 'es_email_mail' => '',
62
+ 'es_email_group' => '',
63
+ 'es_email_status' => '',
64
+ 'es_nonce' => ''
65
+ );
66
+
67
+ if( $es_subscriber_group == '' ) {
68
+ $es_subscriber_group = 'Public';
69
+ }
70
 
71
+ if ( $es_subscriber_email != '' ) {
72
+ if ( !filter_var( $es_subscriber_email, FILTER_VALIDATE_EMAIL ) ) {
73
+ $es_response['error'] = 'invalid-email';
74
  } else {
75
+ $action = '';
76
+ global $wpdb;
77
+
78
+ $subscriber_form['es_email_name'] = $es_subscriber_name;
79
+ $subscriber_form['es_email_mail'] = $es_subscriber_email;
80
+ $subscriber_form['es_email_group'] = $es_subscriber_group;
81
+ $subscriber_form['es_nonce'] = $es_nonce;
82
+
83
+ $es_optintype = get_option( 'ig_es_optintype' );
84
 
 
 
 
85
  if( $es_optintype == "Double Opt In" ) {
86
+ $subscriber_form['es_email_status'] = "Unconfirmed";
 
87
  } else {
88
+ $subscriber_form['es_email_status'] = "Single Opt In";
89
+ }
90
+ //validate lead
91
+ $action = es_cls_dbquery::es_view_subscriber_widget($subscriber_form);
92
+ if( $action == "sus" ) {
93
+ $subscribers = es_cls_dbquery::es_view_subscriber_one($es_subscriber_email,$es_subscriber_group);
94
+ if( $es_optintype == "Double Opt In" ) {
95
+ es_cls_sendmail::es_sendmail("optin", $template = 0, $subscribers, "optin", 0);
96
+ $es_response['success'] = 'subscribed-pending-doubleoptin';
97
+ } else {
98
+ $es_c_usermailoption = get_option( 'ig_es_welcomeemail' );
99
+ if ( $es_c_usermailoption == "YES" ) {
100
+ es_cls_sendmail::es_sendmail("welcome", $template = 0, $subscribers, "welcome", 0);
101
+ }
102
+ $es_response['success'] = 'subscribed-successfully';
103
+ }
104
+ } elseif( $action == "ext" ) {
105
+ $es_response['success'] = 'already-exist';
106
+ } elseif( $action == "invalid" ) {
107
+ $es_response['error'] = 'invalid-email';
108
+ }
109
  }
110
+ } else {
111
+ $es_response['error'] = 'no-email-address';
112
  }
113
  } else {
114
+ $es_response['error'] = 'unexpected-error-1';
115
+ }
116
+
117
+ return $es_response;
118
+ }
 
 
 
 
119
  }
120
+ $es_cls_job_subscribe_obj = es_cls_job_subscribe::getInstance(true);
121
+ }
 
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
6
  Requires at least: 3.9
7
  Tested up to: 4.9.8
8
- Stable tag: 3.5.14
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses
11
 
@@ -342,6 +342,9 @@ Use our free plugin [Email Subscribers - Group Selector](https://wordpress.org/p
342
 
343
  == Changelog ==
344
 
 
 
 
345
  = 3.5.14 (15.10.2018) =
346
 
347
  * Fix: Improve prevention of spam signups
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
6
  Requires at least: 3.9
7
  Tested up to: 4.9.8
8
+ Stable tag: 3.5.15
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses
11
 
342
 
343
  == Changelog ==
344
 
345
+ = 3.5.15 (25.10.2018) =
346
+ * Fix: Extra field shown for forms on RTL sites
347
+
348
  = 3.5.14 (15.10.2018) =
349
 
350
  * Fix: Improve prevention of spam signups
subscribers/view-subscriber-show.php CHANGED
@@ -324,6 +324,9 @@ if (isset($_POST['frm_es_display']) && $_POST['frm_es_display'] == 'yes') {
324
  <option value="Unconfirmed"><?php echo __( 'Unconfirmed', 'email-subscribers' ); ?></option>
325
  <option value="Unsubscribed"><?php echo __( 'Unsubscribed', 'email-subscribers' ); ?></option>
326
  <option value="Single Opt In"><?php echo __( 'Single Opt In', 'email-subscribers' ); ?></option>
 
 
 
327
  </select>
328
  <input type="submit" value="<?php echo __( 'Apply', 'email-subscribers' ); ?>" class="button action" id="doaction" name="doaction">
329
  </span>
324
  <option value="Unconfirmed"><?php echo __( 'Unconfirmed', 'email-subscribers' ); ?></option>
325
  <option value="Unsubscribed"><?php echo __( 'Unsubscribed', 'email-subscribers' ); ?></option>
326
  <option value="Single Opt In"><?php echo __( 'Single Opt In', 'email-subscribers' ); ?></option>
327
+ <?php
328
+ do_action('es_after_dropdown_status');
329
+ ?>
330
  </select>
331
  <input type="submit" value="<?php echo __( 'Apply', 'email-subscribers' ); ?>" class="button action" id="doaction" name="doaction">
332
  </span>
widget/es-widget-page.js CHANGED
@@ -45,39 +45,7 @@ ES.prototype = {
45
  data: formData,
46
  dataType: 'json',
47
  success: function(response) {
48
- if( response && typeof response.error !== 'undefined' && response.error === "" ) {
49
- es_msg_text = es_widget_page_notices.es_try_later;
50
- console.log(response, 'response.error');
51
- } else if ( response && response.error === 'unexpected-error' ) {
52
- es_msg_text = es_widget_page_notices.es_error;
53
- } else if ( response && response.error === 'invalid-email' ) {
54
- es_msg_text = es_widget_page_notices.es_invalid_email;
55
- } else if ( response && response.success === 'already-exist' ) {
56
- es_msg_text = es_widget_page_notices.es_email_exists;
57
- } else if ( response && response.error === 'no-email-address' ) {
58
- es_msg_text = es_widget_page_notices.es_email_notice;
59
- } else if( response.success && response.success === 'subscribed-pending-doubleoptin' ) {
60
- es_msg_text = es_widget_page_notices.es_success_notice;
61
- jQuery(form)[0].reset();
62
- jQuery(form).addClass('es_form_success');
63
- } else if( response && response.success === 'subscribed-successfully' ) {
64
- es_msg_text = es_widget_page_notices.es_success_message;
65
- jQuery(form)[0].reset();
66
- jQuery(form).addClass('es_form_success');
67
- }
68
- var esSuccessEvent = {
69
- detail: {
70
- es_response : "error",
71
- msg: ''
72
- },
73
- bubbles: true,
74
- cancelable: true
75
- } ;
76
-
77
- esSuccessEvent.detail.es_response = 'success';
78
- esSuccessEvent.detail.msg = es_msg_text;
79
- jQuery(form).find('.es_msg span').text(es_msg_text).show();
80
- jQuery(form).trigger('es_response', [ esSuccessEvent ]);
81
  },
82
  error: function(err) {
83
  console.log(err, 'error');
@@ -86,6 +54,41 @@ ES.prototype = {
86
  }
87
  },
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  prepareFormData: function (e, form, formData){
90
  jQuery.each((jQuery(form).serializeArray() || {}), function(i, field){
91
  formData['esfpx_'+ field.name] = field.value;
45
  data: formData,
46
  dataType: 'json',
47
  success: function(response) {
48
+ window.es.handleResponse(response, form);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  },
50
  error: function(err) {
51
  console.log(err, 'error');
54
  }
55
  },
56
 
57
+ handleResponse : function(response, form){
58
+ if( response && typeof response.error !== 'undefined' && response.error === "" ) {
59
+ es_msg_text = es_widget_page_notices.es_try_later;
60
+ } else if ( response && response.error === 'unexpected-error' ) {
61
+ es_msg_text = es_widget_page_notices.es_error;
62
+ } else if ( response && response.error === 'invalid-email' ) {
63
+ es_msg_text = es_widget_page_notices.es_invalid_email;
64
+ } else if ( response && response.success === 'already-exist' ) {
65
+ es_msg_text = es_widget_page_notices.es_email_exists;
66
+ } else if ( response && response.error === 'no-email-address' ) {
67
+ es_msg_text = es_widget_page_notices.es_email_notice;
68
+ } else if( response.success && response.success === 'subscribed-pending-doubleoptin' ) {
69
+ es_msg_text = es_widget_page_notices.es_success_notice;
70
+ jQuery(form)[0].reset();
71
+ jQuery(form).addClass('es_form_success');
72
+ } else if( response && response.success === 'subscribed-successfully' ) {
73
+ es_msg_text = es_widget_page_notices.es_success_message;
74
+ jQuery(form)[0].reset();
75
+ jQuery(form).addClass('es_form_success');
76
+ }
77
+ var esSuccessEvent = {
78
+ detail: {
79
+ es_response : "error",
80
+ msg: ''
81
+ },
82
+ bubbles: true,
83
+ cancelable: true
84
+ } ;
85
+
86
+ esSuccessEvent.detail.es_response = 'success';
87
+ esSuccessEvent.detail.msg = es_msg_text;
88
+ jQuery(form).find('.es_msg span').text(es_msg_text).show();
89
+ jQuery(form).trigger('es_response', [ esSuccessEvent ]);
90
+ },
91
+
92
  prepareFormData: function (e, form, formData){
93
  jQuery.each((jQuery(form).serializeArray() || {}), function(i, field){
94
  formData['esfpx_'+ field.name] = field.value;