Version Description
Download this release
Release Info
Developer | Icegram |
Plugin | Email Subscribers & Newsletters |
Version | 4.2.4 |
Comparing to | |
See all releases |
Code changes from version 4.2.3 to 4.2.4
- admin/class-email-subscribers-admin.php +26 -6
- admin/css/email-subscribers-admin.css +93 -0
- admin/images/29-30.png +0 -0
- admin/images/31-1.png +0 -0
- admin/images/pre-halloween-2019.png +0 -0
- admin/js/email-subscribers-admin.js +78 -28
- admin/js/es-onboarding.js +36 -36
- admin/partials/dashboard.php +1 -1
- email-subscribers.php +2 -2
- ig-es-offer.php +13 -6
- includes/admin/class-es-actions.php +22 -27
- includes/admin/class-es-admin-settings.php +1 -1
- includes/admin/class-es-campaigns-table.php +1 -1
- includes/admin/class-es-contacts-table.php +7 -7
- includes/admin/class-es-form-widget.php +1 -0
- includes/admin/class-es-handle-post-notification.php +1 -1
- includes/admin/class-es-handle-subscription.php +2 -2
- includes/admin/class-es-import-subscribers.php +3 -3
- includes/admin/class-es-newsletters.php +301 -147
- includes/admin/class-es-post-notifications.php +19 -3
- includes/admin/class-es-queue.php +2 -2
- includes/class-email-subscribers.php +18 -7
- includes/class-es-common.php +28 -7
- includes/class-es-install.php +53 -17
- includes/class-es-mailer.php +95 -14
- includes/db/class-es-db-actions.php +56 -13
- includes/db/class-es-db-campaigns.php +1 -1
- includes/db/class-es-db-contacts.php +325 -171
- includes/db/class-es-db-links.php +37 -15
- includes/db/class-es-db-lists.php +3 -0
- includes/db/class-es-db-sending-queue.php +4 -3
- includes/db/class-es-db.php +59 -7
- includes/es-backward.php +2 -2
- includes/feedback.php +1 -1
- includes/upgrade/es-update-functions.php +50 -2
- public/class-email-subscribers-public.php +32 -12
- public/partials/class-es-shortcode.php +8 -9
- readme.txt +8 -1
admin/class-email-subscribers-admin.php
CHANGED
@@ -299,8 +299,8 @@ class Email_Subscribers_Admin {
|
|
299 |
* @since 4.2.1
|
300 |
*/
|
301 |
public function render_forms() {
|
302 |
-
$
|
303 |
-
$
|
304 |
}
|
305 |
|
306 |
/**
|
@@ -309,8 +309,8 @@ class Email_Subscribers_Admin {
|
|
309 |
* @since 4.2.1
|
310 |
*/
|
311 |
public function render_lists() {
|
312 |
-
$
|
313 |
-
$
|
314 |
}
|
315 |
|
316 |
public function load_post_notifications() {
|
@@ -439,7 +439,7 @@ class Email_Subscribers_Admin {
|
|
439 |
$star_rating_dismiss = get_option( 'ig_es_dismiss_star_notice', 'no' );
|
440 |
$star_rating_done = get_option( 'ig_es_star_notice_done', 'no' );
|
441 |
// Show if - more than 2 post notifications or Newsletters sent OR more than 10 subscribers
|
442 |
-
$total_contacts =
|
443 |
$total_email_sent = ES_DB_Mailing_Queue::get_notifications_count();
|
444 |
|
445 |
if ( ( $total_contacts >= 10 || $total_email_sent > 2 ) && 'yes' !== $star_rating_dismiss && 'yes' !== $star_rating_done ) {
|
@@ -471,7 +471,7 @@ class Email_Subscribers_Admin {
|
|
471 |
'hash' => ES_Common::generate_guid(),
|
472 |
'created_at' => ig_get_current_date_time()
|
473 |
);
|
474 |
-
$contact_id =
|
475 |
if ( $contact_id ) {
|
476 |
$data = array(
|
477 |
'list_id' => array( $list_id ),
|
@@ -534,6 +534,26 @@ class Email_Subscribers_Admin {
|
|
534 |
die( json_encode( array( 'total' => $total_count ) ) );
|
535 |
}
|
536 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
537 |
/**
|
538 |
* Hooked to 'set-screen-options' filter
|
539 |
*
|
299 |
* @since 4.2.1
|
300 |
*/
|
301 |
public function render_forms() {
|
302 |
+
$forms = new ES_Forms_Table();
|
303 |
+
$forms->render();
|
304 |
}
|
305 |
|
306 |
/**
|
309 |
* @since 4.2.1
|
310 |
*/
|
311 |
public function render_lists() {
|
312 |
+
$lists = new ES_Lists_Table();
|
313 |
+
$lists->render();
|
314 |
}
|
315 |
|
316 |
public function load_post_notifications() {
|
439 |
$star_rating_dismiss = get_option( 'ig_es_dismiss_star_notice', 'no' );
|
440 |
$star_rating_done = get_option( 'ig_es_star_notice_done', 'no' );
|
441 |
// Show if - more than 2 post notifications or Newsletters sent OR more than 10 subscribers
|
442 |
+
$total_contacts = ES()->contacts_db->count_active_contacts_by_list_id();
|
443 |
$total_email_sent = ES_DB_Mailing_Queue::get_notifications_count();
|
444 |
|
445 |
if ( ( $total_contacts >= 10 || $total_email_sent > 2 ) && 'yes' !== $star_rating_dismiss && 'yes' !== $star_rating_done ) {
|
471 |
'hash' => ES_Common::generate_guid(),
|
472 |
'created_at' => ig_get_current_date_time()
|
473 |
);
|
474 |
+
$contact_id = ES()->contacts_db->insert( $data );
|
475 |
if ( $contact_id ) {
|
476 |
$data = array(
|
477 |
'list_id' => array( $list_id ),
|
534 |
die( json_encode( array( 'total' => $total_count ) ) );
|
535 |
}
|
536 |
|
537 |
+
public function get_template_content(){
|
538 |
+
global $ig_es_tracker;
|
539 |
+
|
540 |
+
$template_id = (int) ig_es_get_request_data( 'template_id', 0 );
|
541 |
+
if ( $template_id == 0 ) {
|
542 |
+
return 0;
|
543 |
+
}
|
544 |
+
$post_temp_arr = get_post( $template_id );
|
545 |
+
$result['subject'] = ! empty( $post_temp_arr->post_title ) ? $post_temp_arr->post_title : '';
|
546 |
+
$result['body'] = ! empty( $post_temp_arr->post_content ) ? $post_temp_arr->post_content : '';
|
547 |
+
//get meta data of template
|
548 |
+
$active_plugins = $ig_es_tracker::get_active_plugins();
|
549 |
+
if ( in_array( 'email-subscribers-premium/email-subscribers-premium.php', $active_plugins ) ) {
|
550 |
+
$result['inline_css'] = get_post_meta( $template_id, 'es_custom_css', true );
|
551 |
+
$result['es_utm_campaign'] = get_post_meta( $template_id, 'es_utm_campaign', true );
|
552 |
+
}
|
553 |
+
|
554 |
+
die( json_encode( $result ) );
|
555 |
+
}
|
556 |
+
|
557 |
/**
|
558 |
* Hooked to 'set-screen-options' filter
|
559 |
*
|
admin/css/email-subscribers-admin.css
CHANGED
@@ -1260,3 +1260,96 @@ div.es .last {
|
|
1260 |
width: 40%;
|
1261 |
padding: 0.7em;
|
1262 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1260 |
width: 40%;
|
1261 |
padding: 0.7em;
|
1262 |
}
|
1263 |
+
|
1264 |
+
/* Email Subscribers new css : Start*/
|
1265 |
+
.es_settings_field{
|
1266 |
+
margin-bottom: 0.8em;
|
1267 |
+
}
|
1268 |
+
.es_settings_left_pan{
|
1269 |
+
width: 75%;
|
1270 |
+
display: inline-block;
|
1271 |
+
float: left;
|
1272 |
+
}
|
1273 |
+
.es_settings_field input[type="text"], .es_settings_field input[type="email"]{
|
1274 |
+
width: 100%;
|
1275 |
+
padding: 10px;
|
1276 |
+
font-size: 16px;
|
1277 |
+
height: auto;
|
1278 |
+
}
|
1279 |
+
.es_settings_field label{
|
1280 |
+
font-size: 0.9em;
|
1281 |
+
text-transform: uppercase;
|
1282 |
+
letter-spacing: .3px;
|
1283 |
+
line-height: 2.2;
|
1284 |
+
}
|
1285 |
+
.es_settings_right_pan{
|
1286 |
+
/*padding: 1.5em;*/
|
1287 |
+
/*background: #FFF;*/
|
1288 |
+
/*border-left: 1px solid #e6e6e6;*/
|
1289 |
+
/*border-top-left-radius: 5px;*/
|
1290 |
+
/*border-bottom-left-radius: 5px;*/
|
1291 |
+
width: 19%;
|
1292 |
+
display: inline-block;
|
1293 |
+
margin-left: 2em;
|
1294 |
+
/*float: right;*/
|
1295 |
+
}
|
1296 |
+
.es_settings_field select{
|
1297 |
+
height: 3em;
|
1298 |
+
margin-bottom: 7px;
|
1299 |
+
padding-right: 20px;
|
1300 |
+
background-color: #FFF !important;
|
1301 |
+
width: 100%;
|
1302 |
+
}
|
1303 |
+
.es_campaign_name_wrapper{
|
1304 |
+
margin-bottom: 1em;
|
1305 |
+
padding-bottom: 1em;
|
1306 |
+
border-bottom: 1px solid #afafaf;
|
1307 |
+
}
|
1308 |
+
.es_campaign_name_wrapper .es_newsletter_name{
|
1309 |
+
width: 80%;
|
1310 |
+
/* margin-right: 1em; */
|
1311 |
+
/* border: none !important; */
|
1312 |
+
/* background-color: transparent !important; */
|
1313 |
+
box-shadow: none !important;
|
1314 |
+
color: #656565 !important;
|
1315 |
+
font-size: 1.5em;
|
1316 |
+
/* width: 100%; */
|
1317 |
+
padding: 10px;
|
1318 |
+
font-size: 16px;
|
1319 |
+
height: auto;
|
1320 |
+
}
|
1321 |
+
.es_primary_btn{
|
1322 |
+
font-size: 1.2em;
|
1323 |
+
color: #FFFFFF;
|
1324 |
+
border-color: #03a025 !important;
|
1325 |
+
background: #03a025;
|
1326 |
+
box-shadow: 0 1px 0 #03a025;
|
1327 |
+
font-weight: bold;
|
1328 |
+
height: 2.6em;
|
1329 |
+
padding: 9px 18px;
|
1330 |
+
/*font-size: 13px;*/
|
1331 |
+
border-radius: 3px;
|
1332 |
+
text-align: center;
|
1333 |
+
border: solid 1px #dce1e5;
|
1334 |
+
cursor: pointer;
|
1335 |
+
/* line-height: 0.6em; */
|
1336 |
+
|
1337 |
+
}
|
1338 |
+
.es_primary_btn:hover{
|
1339 |
+
color: #03a025;
|
1340 |
+
background: #FFF;
|
1341 |
+
}
|
1342 |
+
.es_secondary_btn{
|
1343 |
+
padding: 9px 18px;
|
1344 |
+
font-size: 13px;
|
1345 |
+
border-radius: 3px;
|
1346 |
+
text-align: center;
|
1347 |
+
border: solid 1px #dce1e5;
|
1348 |
+
cursor: pointer;
|
1349 |
+
margin-top: 1em;
|
1350 |
+
}
|
1351 |
+
.es_secondary_btn:hover{
|
1352 |
+
color: #000;
|
1353 |
+
background: #FFF;
|
1354 |
+
}
|
1355 |
+
/* Email Subscribers new css : End*/
|
admin/images/29-30.png
ADDED
Binary file
|
admin/images/31-1.png
ADDED
Binary file
|
admin/images/pre-halloween-2019.png
DELETED
Binary file
|
admin/js/email-subscribers-admin.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
(function
|
2 |
|
3 |
$(document).ready(
|
4 |
-
function
|
5 |
-
$(document).on('change', '.es_visible', function
|
6 |
if ($('.es_visible:checked').length >= 1) {
|
7 |
$('.es_required').prop('disabled', false);
|
8 |
$('.es_name_label').removeAttr('disabled');
|
@@ -19,7 +19,7 @@
|
|
19 |
$('div#es-settings-tabs div#menu-tab-listing ul').height(defaultHeight);
|
20 |
|
21 |
// Set Tab Height
|
22 |
-
$('.ui-tabs-anchor').click(function
|
23 |
var tab = $(this).attr('href');
|
24 |
$('#email_tabs_form').attr('action', tab);
|
25 |
var tabHight = $('div#es-settings-tabs div#menu-tab-content div' + tab).height() + 30;
|
@@ -40,7 +40,7 @@
|
|
40 |
//jQuery(".es-audience-view .bulkactions #bulk-action-selector-bottom").after(statusselect);
|
41 |
// jQuery(".es-audience-view .bulkactions #bulk-action-selector-bottom").after(groupselect);
|
42 |
|
43 |
-
jQuery("#bulk-action-selector-top").change(function
|
44 |
if (jQuery('option:selected', this).attr('value') == 'bulk_list_update' || jQuery('option:selected', this).attr('value') == 'bulk_list_add') {
|
45 |
jQuery('.groupsselect').eq(1).show();
|
46 |
jQuery('.statusesselect').eq(1).hide();
|
@@ -55,13 +55,13 @@
|
|
55 |
|
56 |
jQuery('.es-audience-view .tablenav.bottom #bulk-action-selector-bottom').hide();
|
57 |
jQuery('.es-audience-view .tablenav.bottom #doaction2').hide();
|
58 |
-
jQuery(document).on('change', "#base_template_id", function
|
59 |
var img = jQuery('option:selected', this).data('img')
|
60 |
jQuery('.es-templ-img').html(img);
|
61 |
});
|
62 |
|
63 |
//send test emails
|
64 |
-
$(document).on('click', '#es-send-test', function
|
65 |
e.preventDefault();
|
66 |
var test_email = $('#es-test-email').val();
|
67 |
var params = {};
|
@@ -74,7 +74,7 @@
|
|
74 |
url: ajaxurl,
|
75 |
data: params,
|
76 |
dataType: 'json',
|
77 |
-
success: function
|
78 |
if (response && typeof response.status !== 'undefined' && response.status == "SUCCESS") {
|
79 |
$('#es-send-test').parent().find('.helper').html('<span style="color:green">' + response.message + '</span>');
|
80 |
} else {
|
@@ -84,7 +84,7 @@
|
|
84 |
$('#es-send-test').next('#spinner-image').hide();
|
85 |
},
|
86 |
|
87 |
-
error: function
|
88 |
$('#es-send-test').next('#spinner-image').hide();
|
89 |
}
|
90 |
});
|
@@ -95,14 +95,17 @@
|
|
95 |
});
|
96 |
|
97 |
//klawoo form submit
|
98 |
-
jQuery("form[name=klawoo_subscribe]").submit(function
|
99 |
e.preventDefault();
|
100 |
var form = e.target;
|
101 |
jQuery(form).find('#klawoo_response').html('');
|
102 |
jQuery(form).find('#klawoo_response').show();
|
103 |
|
104 |
params = jQuery(form).serializeArray();
|
105 |
-
params.push({
|
|
|
|
|
|
|
106 |
|
107 |
jQuery.ajax({
|
108 |
method: 'POST',
|
@@ -110,7 +113,7 @@
|
|
110 |
url: ajaxurl,
|
111 |
async: false,
|
112 |
data: params,
|
113 |
-
success: function
|
114 |
if (response != '') {
|
115 |
var parser = new DOMParser()
|
116 |
var el = parser.parseFromString(response, "text/xml");
|
@@ -123,7 +126,7 @@
|
|
123 |
jQuery('.es-emm-optin #name').val('');
|
124 |
jQuery('.es-emm-optin #email').val('');
|
125 |
jQuery('.es-emm-optin #es-gdpr-agree').attr('checked', false);
|
126 |
-
setTimeout(function
|
127 |
jQuery(form).find('#klawoo_response').hide('slow');
|
128 |
}, 2000);
|
129 |
}
|
@@ -140,7 +143,7 @@
|
|
140 |
|
141 |
// Select List ID for Export
|
142 |
var _href = $('#ig_es_export_link_select_list').attr("href");
|
143 |
-
$('#ig_es_export_list_dropdown').change(function
|
144 |
var selected_list_id = $(this).val();
|
145 |
|
146 |
$('#ig_es_export_link_select_list').attr("href", _href + '&list_id=' + selected_list_id);
|
@@ -156,7 +159,7 @@
|
|
156 |
url: ajaxurl,
|
157 |
async: false,
|
158 |
data: params,
|
159 |
-
success: function
|
160 |
if (response != '') {
|
161 |
response = JSON.parse(response);
|
162 |
$('#ig_es_export_select_list .ig_es_total_contacts').text(response.total);
|
@@ -169,7 +172,7 @@
|
|
169 |
// Broadcast Setttings
|
170 |
// Get count by list
|
171 |
$('#ig_es_campaign_submit_button').attr("disabled", true);
|
172 |
-
$('#ig_es_broadcast_list_ids').change(function(){
|
173 |
var selected_list_id = $(this).val();
|
174 |
|
175 |
// Update total count in lists
|
@@ -184,13 +187,13 @@
|
|
184 |
url: ajaxurl,
|
185 |
async: false,
|
186 |
data: params,
|
187 |
-
success: function
|
188 |
if (response !== '') {
|
189 |
response = JSON.parse(response);
|
190 |
-
if(response.hasOwnProperty('total')) {
|
191 |
var total = response.total;
|
192 |
$('#ig_es_total_contacts').text(response.total);
|
193 |
-
if(total == 0
|
194 |
$('#ig_es_campaign_submit_button').attr("disabled", true);
|
195 |
} else {
|
196 |
$('#ig_es_campaign_submit_button').attr("disabled", false);
|
@@ -201,29 +204,76 @@
|
|
201 |
});
|
202 |
});
|
203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
//post notification category select
|
205 |
-
jQuery(document).on('change', '.es-note-category-parent', function(){
|
206 |
var val = jQuery('.es-note-category-parent:checked').val();
|
207 |
-
if('{a}All{a}' === val){
|
208 |
jQuery('input[name="es_note_cat[]"]').not('.es_custom_post_type').closest('tr').hide();
|
209 |
-
}else{
|
210 |
jQuery('input[name="es_note_cat[]"]').not('.es_custom_post_type').closest('tr').show();
|
211 |
}
|
212 |
|
213 |
});
|
|
|
214 |
jQuery('.es-note-category-parent').trigger('change');
|
215 |
|
216 |
|
217 |
//es mailer settings
|
218 |
-
jQuery(
|
219 |
-
var val =
|
220 |
jQuery('[name*="ig_es_mailer_settings"], .es_sub_headline').not('.es_mailer').hide();
|
221 |
-
jQuery(document).find('.'+val).show();
|
222 |
});
|
223 |
jQuery('.es_mailer').trigger('change');
|
224 |
-
});
|
225 |
-
|
226 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
|
228 |
|
229 |
|
@@ -231,4 +281,4 @@
|
|
231 |
|
232 |
function checkDelete() {
|
233 |
return confirm('Are you sure?');
|
234 |
-
}
|
1 |
+
(function($) {
|
2 |
|
3 |
$(document).ready(
|
4 |
+
function() {
|
5 |
+
$(document).on('change', '.es_visible', function() {
|
6 |
if ($('.es_visible:checked').length >= 1) {
|
7 |
$('.es_required').prop('disabled', false);
|
8 |
$('.es_name_label').removeAttr('disabled');
|
19 |
$('div#es-settings-tabs div#menu-tab-listing ul').height(defaultHeight);
|
20 |
|
21 |
// Set Tab Height
|
22 |
+
$('.ui-tabs-anchor').click(function() {
|
23 |
var tab = $(this).attr('href');
|
24 |
$('#email_tabs_form').attr('action', tab);
|
25 |
var tabHight = $('div#es-settings-tabs div#menu-tab-content div' + tab).height() + 30;
|
40 |
//jQuery(".es-audience-view .bulkactions #bulk-action-selector-bottom").after(statusselect);
|
41 |
// jQuery(".es-audience-view .bulkactions #bulk-action-selector-bottom").after(groupselect);
|
42 |
|
43 |
+
jQuery("#bulk-action-selector-top").change(function() {
|
44 |
if (jQuery('option:selected', this).attr('value') == 'bulk_list_update' || jQuery('option:selected', this).attr('value') == 'bulk_list_add') {
|
45 |
jQuery('.groupsselect').eq(1).show();
|
46 |
jQuery('.statusesselect').eq(1).hide();
|
55 |
|
56 |
jQuery('.es-audience-view .tablenav.bottom #bulk-action-selector-bottom').hide();
|
57 |
jQuery('.es-audience-view .tablenav.bottom #doaction2').hide();
|
58 |
+
jQuery(document).on('change', "#base_template_id", function() {
|
59 |
var img = jQuery('option:selected', this).data('img')
|
60 |
jQuery('.es-templ-img').html(img);
|
61 |
});
|
62 |
|
63 |
//send test emails
|
64 |
+
$(document).on('click', '#es-send-test', function(e) {
|
65 |
e.preventDefault();
|
66 |
var test_email = $('#es-test-email').val();
|
67 |
var params = {};
|
74 |
url: ajaxurl,
|
75 |
data: params,
|
76 |
dataType: 'json',
|
77 |
+
success: function(response) {
|
78 |
if (response && typeof response.status !== 'undefined' && response.status == "SUCCESS") {
|
79 |
$('#es-send-test').parent().find('.helper').html('<span style="color:green">' + response.message + '</span>');
|
80 |
} else {
|
84 |
$('#es-send-test').next('#spinner-image').hide();
|
85 |
},
|
86 |
|
87 |
+
error: function(err) {
|
88 |
$('#es-send-test').next('#spinner-image').hide();
|
89 |
}
|
90 |
});
|
95 |
});
|
96 |
|
97 |
//klawoo form submit
|
98 |
+
jQuery("form[name=klawoo_subscribe]").submit(function(e) {
|
99 |
e.preventDefault();
|
100 |
var form = e.target;
|
101 |
jQuery(form).find('#klawoo_response').html('');
|
102 |
jQuery(form).find('#klawoo_response').show();
|
103 |
|
104 |
params = jQuery(form).serializeArray();
|
105 |
+
params.push({
|
106 |
+
name: 'action',
|
107 |
+
value: 'es_klawoo_subscribe'
|
108 |
+
});
|
109 |
|
110 |
jQuery.ajax({
|
111 |
method: 'POST',
|
113 |
url: ajaxurl,
|
114 |
async: false,
|
115 |
data: params,
|
116 |
+
success: function(response) {
|
117 |
if (response != '') {
|
118 |
var parser = new DOMParser()
|
119 |
var el = parser.parseFromString(response, "text/xml");
|
126 |
jQuery('.es-emm-optin #name').val('');
|
127 |
jQuery('.es-emm-optin #email').val('');
|
128 |
jQuery('.es-emm-optin #es-gdpr-agree').attr('checked', false);
|
129 |
+
setTimeout(function() {
|
130 |
jQuery(form).find('#klawoo_response').hide('slow');
|
131 |
}, 2000);
|
132 |
}
|
143 |
|
144 |
// Select List ID for Export
|
145 |
var _href = $('#ig_es_export_link_select_list').attr("href");
|
146 |
+
$('#ig_es_export_list_dropdown').change(function() {
|
147 |
var selected_list_id = $(this).val();
|
148 |
|
149 |
$('#ig_es_export_link_select_list').attr("href", _href + '&list_id=' + selected_list_id);
|
159 |
url: ajaxurl,
|
160 |
async: false,
|
161 |
data: params,
|
162 |
+
success: function(response) {
|
163 |
if (response != '') {
|
164 |
response = JSON.parse(response);
|
165 |
$('#ig_es_export_select_list .ig_es_total_contacts').text(response.total);
|
172 |
// Broadcast Setttings
|
173 |
// Get count by list
|
174 |
$('#ig_es_campaign_submit_button').attr("disabled", true);
|
175 |
+
$('#ig_es_broadcast_list_ids').change(function() {
|
176 |
var selected_list_id = $(this).val();
|
177 |
|
178 |
// Update total count in lists
|
187 |
url: ajaxurl,
|
188 |
async: false,
|
189 |
data: params,
|
190 |
+
success: function(response) {
|
191 |
if (response !== '') {
|
192 |
response = JSON.parse(response);
|
193 |
+
if (response.hasOwnProperty('total')) {
|
194 |
var total = response.total;
|
195 |
$('#ig_es_total_contacts').text(response.total);
|
196 |
+
if (total == 0) {
|
197 |
$('#ig_es_campaign_submit_button').attr("disabled", true);
|
198 |
} else {
|
199 |
$('#ig_es_campaign_submit_button').attr("disabled", false);
|
204 |
});
|
205 |
});
|
206 |
|
207 |
+
jQuery(document).on('change', '#base_template_id', function() {
|
208 |
+
var template_id = $(this).val();
|
209 |
+
// Update total count in lists
|
210 |
+
var params = {
|
211 |
+
action: 'get_template_content',
|
212 |
+
template_id: template_id,
|
213 |
+
};
|
214 |
+
|
215 |
+
$.ajax({
|
216 |
+
method: 'POST',
|
217 |
+
url: ajaxurl,
|
218 |
+
async: false,
|
219 |
+
data: params,
|
220 |
+
success: function(response) {
|
221 |
+
if (response !== '') {
|
222 |
+
response = JSON.parse(response);
|
223 |
+
if (response.hasOwnProperty('subject')) {
|
224 |
+
// jQuery('#ig_es_broadcast_subject').val(response.subject);
|
225 |
+
jQuery('.wp-editor-boradcast').val(response.body);
|
226 |
+
tinyMCE.activeEditor.setContent(response.body);
|
227 |
+
if (response.inline_css && jQuery('#inline_css').length) {
|
228 |
+
jQuery('#inline_css').val(response.inline_css);
|
229 |
+
}
|
230 |
+
if (response.es_utm_campaign && jQuery('#es_utm_campaign').length) {
|
231 |
+
jQuery('#es_utm_campaign').val(response.es_utm_campaign);
|
232 |
+
}
|
233 |
+
}
|
234 |
+
}
|
235 |
+
}
|
236 |
+
});
|
237 |
+
});
|
238 |
+
|
239 |
//post notification category select
|
240 |
+
jQuery(document).on('change', '.es-note-category-parent', function() {
|
241 |
var val = jQuery('.es-note-category-parent:checked').val();
|
242 |
+
if ('{a}All{a}' === val) {
|
243 |
jQuery('input[name="es_note_cat[]"]').not('.es_custom_post_type').closest('tr').hide();
|
244 |
+
} else {
|
245 |
jQuery('input[name="es_note_cat[]"]').not('.es_custom_post_type').closest('tr').show();
|
246 |
}
|
247 |
|
248 |
});
|
249 |
+
|
250 |
jQuery('.es-note-category-parent').trigger('change');
|
251 |
|
252 |
|
253 |
//es mailer settings
|
254 |
+
jQuery(document).on('change', '.es_mailer', function(e) {
|
255 |
+
var val = jQuery('.es_mailer:checked').val();
|
256 |
jQuery('[name*="ig_es_mailer_settings"], .es_sub_headline').not('.es_mailer').hide();
|
257 |
+
jQuery(document).find('.' + val).show();
|
258 |
});
|
259 |
jQuery('.es_mailer').trigger('change');
|
|
|
|
|
260 |
|
261 |
+
//preview broadcast
|
262 |
+
// ig_es_preview_broadcast
|
263 |
+
jQuery(document).on('click', '#ig_es_preview_broadcast', function(e) {
|
264 |
+
if (jQuery('.wp-editor-boradcast').val() !== '') {
|
265 |
+
jQuery('.es-form').find('form').attr('target', '_blank');
|
266 |
+
jQuery('.es-form').find('form').find('#es_broadcast_preview').val('preview');
|
267 |
+
jQuery(this).unbind('submit').submit();
|
268 |
+
}
|
269 |
+
});
|
270 |
+
jQuery(document).on('click', '#ig_es_campaign_submit_button', function(e) {
|
271 |
+
if (jQuery('.wp-editor-boradcast').val() !== '') {
|
272 |
+
jQuery('.es-form').find('form').attr('target', '');
|
273 |
+
jQuery('.es-form').find('form').find('#es_broadcast_preview').val('');
|
274 |
+
}
|
275 |
+
});
|
276 |
+
});
|
277 |
|
278 |
|
279 |
|
281 |
|
282 |
function checkDelete() {
|
283 |
return confirm('Are you sure?');
|
284 |
+
}
|
admin/js/es-onboarding.js
CHANGED
@@ -8,54 +8,54 @@ jQuery(document).ready(function() {
|
|
8 |
}
|
9 |
|
10 |
jQuery(document).on('click', '.es-send-email', function() {
|
11 |
-
|
12 |
jQuery('.es-send-email-screen .es-loader').show();
|
13 |
var emails = [];
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
jQuery('#button-send').hide();
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
},
|
39 |
-
error: function(data, status, xhr) {}
|
40 |
-
};
|
41 |
-
|
42 |
-
jQuery.ajax(params);
|
43 |
-
}else{
|
44 |
jQuery(".es_email").addClass('error')
|
45 |
jQuery("#es-send-email-form")[0].reportValidity();
|
46 |
-
|
47 |
|
48 |
});
|
49 |
-
|
50 |
jQuery(document).on('click', '.es-receive-success-btn', function() {
|
51 |
-
|
52 |
-
|
53 |
|
54 |
});
|
55 |
|
56 |
jQuery(document).on('click', '.es-receive-error-btn', function() {
|
57 |
-
|
58 |
-
|
59 |
});
|
60 |
|
61 |
});
|
8 |
}
|
9 |
|
10 |
jQuery(document).on('click', '.es-send-email', function() {
|
11 |
+
if (jQuery("#es-send-email-form")[0].checkValidity()) {
|
12 |
jQuery('.es-send-email-screen .es-loader').show();
|
13 |
var emails = [];
|
14 |
+
jQuery(".es_email").each(function() {
|
15 |
+
if ((jQuery.trim(jQuery(this).val()).length > 0)) {
|
16 |
+
emails.push(jQuery(this).val());
|
17 |
+
}
|
18 |
+
});
|
19 |
+
var params = {
|
20 |
+
type: 'POST',
|
21 |
+
url: ajaxurl,
|
22 |
+
data: {
|
23 |
+
action: 'send_test_email',
|
24 |
+
emails: emails
|
25 |
+
},
|
26 |
+
dataType: 'json',
|
27 |
+
success: function(data, status, xhr) {
|
28 |
+
jQuery('.es-send-email-screen .es-loader').find('img').hide();
|
29 |
+
jQuery('.active').fadeOut('fast').removeClass('active');
|
30 |
+
jQuery('#button-send').hide();
|
31 |
+
if (data.status == 'SUCCESS') {
|
32 |
+
jQuery('.sp.es-success').addClass('active').fadeIn('slow');
|
33 |
+
} else if (data.status == 'ERROR') {
|
34 |
+
jQuery('.sp.es-error').find('.es-email-sending-error').html('<i class="dashicons dashicons-es dashicons-no-alt" style="color: #e66060"></i>' + data.message);
|
35 |
+
jQuery('.sp.es-error').addClass('active').fadeIn('slow');
|
36 |
jQuery('#button-send').hide();
|
37 |
+
}
|
38 |
+
},
|
39 |
+
error: function(data, status, xhr) {}
|
40 |
+
};
|
41 |
+
|
42 |
+
jQuery.ajax(params);
|
43 |
+
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
jQuery(".es_email").addClass('error')
|
45 |
jQuery("#es-send-email-form")[0].reportValidity();
|
46 |
+
}
|
47 |
|
48 |
});
|
49 |
+
|
50 |
jQuery(document).on('click', '.es-receive-success-btn', function() {
|
51 |
+
jQuery('.active').fadeOut('fast').removeClass('active');
|
52 |
+
jQuery('.sp.es-receive-success').fadeIn('slow').addClass('active');
|
53 |
|
54 |
});
|
55 |
|
56 |
jQuery(document).on('click', '.es-receive-error-btn', function() {
|
57 |
+
jQuery('.active').fadeOut('fast').removeClass('active');
|
58 |
+
jQuery('.sp.es-receive-error').fadeIn('slow').addClass('active');
|
59 |
});
|
60 |
|
61 |
});
|
admin/partials/dashboard.php
CHANGED
@@ -77,7 +77,7 @@ $current_user_email = $current_user->user_email;
|
|
77 |
</div>
|
78 |
<div class="es-right">
|
79 |
<div class="es-quick-stats" >
|
80 |
-
<?php $sub_count =
|
81 |
$total_forms = ES()->forms_db->count_forms();
|
82 |
$total_lists = ES()->lists_db->count_lists();
|
83 |
$total_campaigns = ES()->campaigns_db->get_total_campaigns();
|
77 |
</div>
|
78 |
<div class="es-right">
|
79 |
<div class="es-quick-stats" >
|
80 |
+
<?php $sub_count = ES()->contacts_db->count_active_contacts_by_list_id();
|
81 |
$total_forms = ES()->forms_db->count_forms();
|
82 |
$total_lists = ES()->lists_db->count_lists();
|
83 |
$total_campaigns = ES()->campaigns_db->get_total_campaigns();
|
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.
|
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.
|
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.4
|
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.4' );
|
32 |
define( 'ES_PLUGIN_BASE_NAME', plugin_basename( __FILE__ ) );
|
33 |
define( 'IG_ES_FEEDBACK_VERSION', '1.0.10' );
|
34 |
|
ig-es-offer.php
CHANGED
@@ -1,6 +1,3 @@
|
|
1 |
-
<?php
|
2 |
-
if( get_option('ig_es_offer_pre_halloween_done_2019') == 'yes' ) return;
|
3 |
-
?>
|
4 |
<style type="text/css">
|
5 |
.ig_es_offer{
|
6 |
width: 70%;
|
@@ -12,6 +9,16 @@
|
|
12 |
width: 100%;
|
13 |
}
|
14 |
</style>
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<style type="text/css">
|
2 |
.ig_es_offer{
|
3 |
width: 70%;
|
9 |
width: 100%;
|
10 |
}
|
11 |
</style>
|
12 |
+
<?php
|
13 |
+
if( (get_option('ig_es_offer_halloween_done_2019') !== 'yes') && ($ig_current_date >= strtotime("2019-10-23")) && ($ig_current_date <= strtotime("2019-10-30")) ) { ?>
|
14 |
+
<div class="ig_es_offer">
|
15 |
+
<a target="_blank" href="?es_dismiss_admin_notice=1&option_name=offer_halloween_done_2019"><img src="<?php echo EMAIL_SUBSCRIBERS_URL ?>/admin/images/29-30.png" /></a>
|
16 |
+
</div>
|
17 |
+
|
18 |
+
<?php }
|
19 |
+
if( (get_option('ig_es_offer_last_day_halloween_done_2019') !== 'yes') && ($ig_current_date >= strtotime("2019-10-31")) && ($ig_current_date <= strtotime("2019-11-1")) ) { ?>
|
20 |
+
<div class="ig_es_offer">
|
21 |
+
<a target="_blank" href="?es_dismiss_admin_notice=1&option_name=offer_last_day_halloween_done_2019"><img src="<?php echo EMAIL_SUBSCRIBERS_URL ?>/admin/images/31-1.png" /></a>
|
22 |
+
</div>
|
23 |
+
|
24 |
+
<?php } ?>
|
includes/admin/class-es-actions.php
CHANGED
@@ -53,7 +53,7 @@ if ( ! class_exists( 'ES_Actions' ) ) {
|
|
53 |
add_action( 'ig_es_contact_subscribe', array( &$this, 'subscribe' ), 10, 2 );
|
54 |
add_action( 'ig_es_message_sent', array( &$this, 'sent' ), 10, 3 );
|
55 |
add_action( 'ig_es_message_open', array( &$this, 'open' ), 10, 3 );
|
56 |
-
add_action( 'ig_es_message_click', array( &$this, 'click' ), 10,
|
57 |
add_action( 'ig_es_contact_unsubscribe', array( &$this, 'unsubscribe' ), 10, 4 );
|
58 |
//add_action( 'ig_es_message_bounce', array( &$this, 'bounce' ), 10, 3 );
|
59 |
//add_action( 'ig_es_subscriber_error', array( &$this, 'error' ), 10, 3 );
|
@@ -94,52 +94,41 @@ if ( ! class_exists( 'ES_Actions' ) ) {
|
|
94 |
*/
|
95 |
private function add( $args, $explicit = true ) {
|
96 |
|
97 |
-
global $wpdb;
|
98 |
-
|
99 |
$args = wp_parse_args( $args, array(
|
100 |
'created_at' => ig_es_get_current_gmt_timestamp(),
|
101 |
'updated_at' => ig_es_get_current_gmt_timestamp(),
|
102 |
'count' => 1,
|
103 |
) );
|
104 |
|
105 |
-
|
106 |
-
$sql .= " VALUES ('" . implode( "','", array_values( $args ) ) . "') ON DUPLICATE KEY UPDATE";
|
107 |
-
|
108 |
-
$sql .= ( $explicit ) ? " created_at = created_at, count = count+1, updated_at = '" . ig_es_get_current_gmt_timestamp() . "'" : ' count = values(count)';
|
109 |
-
|
110 |
-
$result = $wpdb->query( $sql );
|
111 |
-
|
112 |
-
if ( false !== $result ) {
|
113 |
-
return true;
|
114 |
-
}
|
115 |
|
116 |
-
return false;
|
117 |
}
|
118 |
|
119 |
/**
|
120 |
-
*
|
121 |
*
|
122 |
* @param $args
|
123 |
* @param bool $explicit
|
124 |
*
|
125 |
-
* @
|
126 |
-
*
|
127 |
-
* @since 4.2.0
|
128 |
*/
|
129 |
-
private function
|
|
|
130 |
return $this->add( $args, $explicit );
|
131 |
}
|
132 |
|
133 |
/**
|
134 |
-
* Add
|
135 |
*
|
136 |
* @param $args
|
137 |
* @param bool $explicit
|
138 |
*
|
|
|
|
|
139 |
* @since 4.2.0
|
140 |
*/
|
141 |
-
|
142 |
-
|
143 |
}
|
144 |
|
145 |
/**
|
@@ -194,7 +183,7 @@ if ( ! class_exists( 'ES_Actions' ) ) {
|
|
194 |
*
|
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 ) ) {
|
@@ -204,7 +193,7 @@ if ( ! class_exists( 'ES_Actions' ) ) {
|
|
204 |
'message_id' => $message_id,
|
205 |
'campaign_id' => $campaign_id,
|
206 |
'type' => IG_MESSAGE_OPEN,
|
207 |
-
) );
|
208 |
}
|
209 |
}
|
210 |
|
@@ -220,13 +209,19 @@ if ( ! class_exists( 'ES_Actions' ) ) {
|
|
220 |
*
|
221 |
* @since 4.2.0
|
222 |
*/
|
223 |
-
public function click( $contact_id, $campaign_id, $
|
224 |
-
|
|
|
|
|
|
|
|
|
|
|
225 |
'contact_id' => $contact_id,
|
226 |
'campaign_id' => $campaign_id,
|
|
|
227 |
'link_id' => $link_id,
|
228 |
'type' => IG_LINK_CLICK,
|
229 |
-
) );
|
230 |
}
|
231 |
|
232 |
/**
|
53 |
add_action( 'ig_es_contact_subscribe', array( &$this, 'subscribe' ), 10, 2 );
|
54 |
add_action( 'ig_es_message_sent', array( &$this, 'sent' ), 10, 3 );
|
55 |
add_action( 'ig_es_message_open', array( &$this, 'open' ), 10, 3 );
|
56 |
+
add_action( 'ig_es_message_click', array( &$this, 'click' ), 10, 5 );
|
57 |
add_action( 'ig_es_contact_unsubscribe', array( &$this, 'unsubscribe' ), 10, 4 );
|
58 |
//add_action( 'ig_es_message_bounce', array( &$this, 'bounce' ), 10, 3 );
|
59 |
//add_action( 'ig_es_subscriber_error', array( &$this, 'error' ), 10, 3 );
|
94 |
*/
|
95 |
private function add( $args, $explicit = true ) {
|
96 |
|
|
|
|
|
97 |
$args = wp_parse_args( $args, array(
|
98 |
'created_at' => ig_es_get_current_gmt_timestamp(),
|
99 |
'updated_at' => ig_es_get_current_gmt_timestamp(),
|
100 |
'count' => 1,
|
101 |
) );
|
102 |
|
103 |
+
return $this->db->add( $args, $explicit );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
|
|
105 |
}
|
106 |
|
107 |
/**
|
108 |
+
* Track Contact Action
|
109 |
*
|
110 |
* @param $args
|
111 |
* @param bool $explicit
|
112 |
*
|
113 |
+
* @since 4.2.4
|
|
|
|
|
114 |
*/
|
115 |
+
private function add_contact_action( $args, $explicit = true ) {
|
116 |
+
|
117 |
return $this->add( $args, $explicit );
|
118 |
}
|
119 |
|
120 |
/**
|
121 |
+
* Add action
|
122 |
*
|
123 |
* @param $args
|
124 |
* @param bool $explicit
|
125 |
*
|
126 |
+
* @return bool
|
127 |
+
*
|
128 |
* @since 4.2.0
|
129 |
*/
|
130 |
+
private function add_action( $args, $explicit = true ) {
|
131 |
+
return $this->add( $args, $explicit );
|
132 |
}
|
133 |
|
134 |
/**
|
183 |
*
|
184 |
* @since 4.2.0
|
185 |
*/
|
186 |
+
public function open( $contact_id, $message_id, $campaign_id, $explicit = true ) {
|
187 |
|
188 |
// Track only if campaign sent.
|
189 |
if ( $this->is_campaign_sent( $contact_id, $message_id, $campaign_id ) ) {
|
193 |
'message_id' => $message_id,
|
194 |
'campaign_id' => $campaign_id,
|
195 |
'type' => IG_MESSAGE_OPEN,
|
196 |
+
), $explicit );
|
197 |
}
|
198 |
}
|
199 |
|
209 |
*
|
210 |
* @since 4.2.0
|
211 |
*/
|
212 |
+
public function click( $link_id, $contact_id, $message_id, $campaign_id, $explicit = true ) {
|
213 |
+
|
214 |
+
// When someone click on link which means they have opened that email
|
215 |
+
// Track Email Open
|
216 |
+
$this->open( $contact_id, $message_id, $campaign_id, false );
|
217 |
+
|
218 |
+
return $this->add_contact_action( array(
|
219 |
'contact_id' => $contact_id,
|
220 |
'campaign_id' => $campaign_id,
|
221 |
+
'message_id' => $message_id,
|
222 |
'link_id' => $link_id,
|
223 |
'type' => IG_LINK_CLICK,
|
224 |
+
), $explicit );
|
225 |
}
|
226 |
|
227 |
/**
|
includes/admin/class-es-admin-settings.php
CHANGED
@@ -96,7 +96,7 @@ class ES_Admin_Settings {
|
|
96 |
$value = sanitize_email( $value );
|
97 |
}
|
98 |
|
99 |
-
update_option( $key, wp_unslash( $value ) );
|
100 |
}
|
101 |
}
|
102 |
|
96 |
$value = sanitize_email( $value );
|
97 |
}
|
98 |
|
99 |
+
update_option( $key, wp_unslash( $value ), false);
|
100 |
}
|
101 |
}
|
102 |
|
includes/admin/class-es-campaigns-table.php
CHANGED
@@ -261,7 +261,7 @@ class ES_Campaigns_Table extends WP_List_Table {
|
|
261 |
$title = ! empty( $item['name'] ) ? $item['name'] : '';
|
262 |
}
|
263 |
|
264 |
-
$slug = ( in_array( $item['type'], array( 'post_notification', '
|
265 |
|
266 |
$actions ['edit'] = sprintf( __( '<a href="?page=%s&action=%s&list=%s&_wpnonce=%s">Edit</a>', 'email-subscribers' ), $slug, 'edit', absint( $item['id'] ), $nonce );
|
267 |
$actions['delete'] = sprintf( __( '<a href="?page=%s&action=%s&list=%s&_wpnonce=%s" onclick="return checkDelete()">Delete</a>', 'email-subscribers' ), esc_attr( 'es_campaigns' ), 'delete', absint( $item['id'] ), $nonce );
|
261 |
$title = ! empty( $item['name'] ) ? $item['name'] : '';
|
262 |
}
|
263 |
|
264 |
+
$slug = ( in_array( $item['type'], array( 'post_notification', 'post_digest' ) ) ) ? esc_attr( 'es_notifications' ) : 'es_' . $item['type'];
|
265 |
|
266 |
$actions ['edit'] = sprintf( __( '<a href="?page=%s&action=%s&list=%s&_wpnonce=%s">Edit</a>', 'email-subscribers' ), $slug, 'edit', absint( $item['id'] ), $nonce );
|
267 |
$actions['delete'] = sprintf( __( '<a href="?page=%s&action=%s&list=%s&_wpnonce=%s" onclick="return checkDelete()">Delete</a>', 'email-subscribers' ), esc_attr( 'es_campaigns' ), 'delete', absint( $item['id'] ), $nonce );
|
includes/admin/class-es-contacts-table.php
CHANGED
@@ -256,14 +256,14 @@ class ES_Contacts_Table extends WP_List_Table {
|
|
256 |
if ( $id ) {
|
257 |
$this->update_contact( $id, $contact );
|
258 |
} else {
|
259 |
-
$id =
|
260 |
if ( ! $id ) {
|
261 |
$contact['source'] = 'admin';
|
262 |
$contact['status'] = 'verified';
|
263 |
$contact['hash'] = ES_Common::generate_guid();
|
264 |
$contact['created_at'] = ig_get_current_date_time();
|
265 |
|
266 |
-
$id =
|
267 |
|
268 |
} else {
|
269 |
$message = __( 'Contact already exist.', 'email-subscribers' );
|
@@ -895,7 +895,7 @@ class ES_Contacts_Table extends WP_List_Table {
|
|
895 |
die( 'You do not have a permission to delete contact(s)' );
|
896 |
} else {
|
897 |
$subscriber_id = absint( ig_es_get_request_data( 'subscriber' ) );
|
898 |
-
$deleted =
|
899 |
if ( $deleted ) {
|
900 |
$message = __( 'Contact(s) have been deleted successfully!', 'email-subscribers' );
|
901 |
ES_Common::show_message( $message, 'success' );
|
@@ -914,7 +914,7 @@ class ES_Contacts_Table extends WP_List_Table {
|
|
914 |
die( 'You do not have a permission to resend email confirmation' );
|
915 |
} else {
|
916 |
$id = absint( ig_es_get_request_data( 'subscriber' ) );
|
917 |
-
$subscriber =
|
918 |
$template_data = array(
|
919 |
'email' => $subscriber['email'],
|
920 |
'db_id' => $subscriber['id'],
|
@@ -956,7 +956,7 @@ class ES_Contacts_Table extends WP_List_Table {
|
|
956 |
// If the delete bulk action is triggered
|
957 |
if ( ( 'bulk_delete' === $action ) || ( 'bulk_delete' === $action2 ) ) {
|
958 |
|
959 |
-
$deleted =
|
960 |
|
961 |
if ( $deleted ) {
|
962 |
$message = __( 'Contact(s) have been deleted successfully!', 'email-subscribers' );
|
@@ -997,7 +997,7 @@ class ES_Contacts_Table extends WP_List_Table {
|
|
997 |
return;
|
998 |
}
|
999 |
|
1000 |
-
$edited =
|
1001 |
|
1002 |
if ( $edited ) {
|
1003 |
$message = __( 'Contact(s) have been moved to list successfully!', 'email-subscribers' );
|
@@ -1018,7 +1018,7 @@ class ES_Contacts_Table extends WP_List_Table {
|
|
1018 |
return;
|
1019 |
}
|
1020 |
|
1021 |
-
$edited =
|
1022 |
|
1023 |
if ( $edited ) {
|
1024 |
$message = __( 'Contact(s) have been added to list successfully!', 'email-subscribers' );
|
256 |
if ( $id ) {
|
257 |
$this->update_contact( $id, $contact );
|
258 |
} else {
|
259 |
+
$id = ES()->contacts_db->get_contact_id_by_email( $email );
|
260 |
if ( ! $id ) {
|
261 |
$contact['source'] = 'admin';
|
262 |
$contact['status'] = 'verified';
|
263 |
$contact['hash'] = ES_Common::generate_guid();
|
264 |
$contact['created_at'] = ig_get_current_date_time();
|
265 |
|
266 |
+
$id = ES()->contacts_db->insert( $contact );
|
267 |
|
268 |
} else {
|
269 |
$message = __( 'Contact already exist.', 'email-subscribers' );
|
895 |
die( 'You do not have a permission to delete contact(s)' );
|
896 |
} else {
|
897 |
$subscriber_id = absint( ig_es_get_request_data( 'subscriber' ) );
|
898 |
+
$deleted = ES()->contacts_db->delete_contacts_by_ids( array( $subscriber_id ) );
|
899 |
if ( $deleted ) {
|
900 |
$message = __( 'Contact(s) have been deleted successfully!', 'email-subscribers' );
|
901 |
ES_Common::show_message( $message, 'success' );
|
914 |
die( 'You do not have a permission to resend email confirmation' );
|
915 |
} else {
|
916 |
$id = absint( ig_es_get_request_data( 'subscriber' ) );
|
917 |
+
$subscriber = ES()->contacts_db->get_by_id( $id );
|
918 |
$template_data = array(
|
919 |
'email' => $subscriber['email'],
|
920 |
'db_id' => $subscriber['id'],
|
956 |
// If the delete bulk action is triggered
|
957 |
if ( ( 'bulk_delete' === $action ) || ( 'bulk_delete' === $action2 ) ) {
|
958 |
|
959 |
+
$deleted = ES()->contacts_db->delete_contacts_by_ids( $subscriber_ids );
|
960 |
|
961 |
if ( $deleted ) {
|
962 |
$message = __( 'Contact(s) have been deleted successfully!', 'email-subscribers' );
|
997 |
return;
|
998 |
}
|
999 |
|
1000 |
+
$edited = ES()->contacts_db->update_contacts_list( $subscriber_ids, $list_id );
|
1001 |
|
1002 |
if ( $edited ) {
|
1003 |
$message = __( 'Contact(s) have been moved to list successfully!', 'email-subscribers' );
|
1018 |
return;
|
1019 |
}
|
1020 |
|
1021 |
+
$edited = ES()->contacts_db->add_contacts_to_list( $subscriber_ids, $list_id );
|
1022 |
|
1023 |
if ( $edited ) {
|
1024 |
$message = __( 'Contact(s) have been added to list successfully!', 'email-subscribers' );
|
includes/admin/class-es-form-widget.php
CHANGED
@@ -45,6 +45,7 @@ class ES_Form_Widget extends WP_Widget {
|
|
45 |
$data['email_label'] = ( ! empty( $form_data['email_label'] ) ) ? $form_data['email_label'] : '';
|
46 |
$data['email_place_holder'] = ( ! empty( $form_data['email_place_holder'] ) ) ? $form_data['email_place_holder'] : '';
|
47 |
$data['button_label'] = ( ! empty( $form_data['button_label'] ) ) ? $form_data['button_label'] : '';
|
|
|
48 |
|
49 |
ES_Shortcode::render_form( $data );
|
50 |
|
45 |
$data['email_label'] = ( ! empty( $form_data['email_label'] ) ) ? $form_data['email_label'] : '';
|
46 |
$data['email_place_holder'] = ( ! empty( $form_data['email_place_holder'] ) ) ? $form_data['email_place_holder'] : '';
|
47 |
$data['button_label'] = ( ! empty( $form_data['button_label'] ) ) ? $form_data['button_label'] : '';
|
48 |
+
$data['form_version'] = ( ! empty( $form_data['form_version'] ) ) ? $form_data['form_version'] : '';
|
49 |
|
50 |
ES_Shortcode::render_form( $data );
|
51 |
|
includes/admin/class-es-handle-post-notification.php
CHANGED
@@ -83,7 +83,7 @@ class ES_Handle_Post_Notification {
|
|
83 |
$template = get_post( $template_id ); // to confirm if template exists in ES->Templates
|
84 |
if ( is_object( $template ) ) {
|
85 |
$list_id = $notification['list_ids'];
|
86 |
-
$subscribers =
|
87 |
|
88 |
//schedule
|
89 |
if ( count( $subscribers ) > 0 ) {
|
83 |
$template = get_post( $template_id ); // to confirm if template exists in ES->Templates
|
84 |
if ( is_object( $template ) ) {
|
85 |
$list_id = $notification['list_ids'];
|
86 |
+
$subscribers = ES()->contacts_db->get_active_contacts_by_list_id( $list_id );
|
87 |
|
88 |
//schedule
|
89 |
if ( count( $subscribers ) > 0 ) {
|
includes/admin/class-es-handle-subscription.php
CHANGED
@@ -103,7 +103,7 @@ class ES_Handle_Subscription {
|
|
103 |
* - If not, create contact and then save list
|
104 |
*/
|
105 |
|
106 |
-
$contact_id =
|
107 |
if ( ! $contact_id ) {
|
108 |
$data = array();
|
109 |
$data['first_name'] = $this->first_name;
|
@@ -124,7 +124,7 @@ class ES_Handle_Subscription {
|
|
124 |
exit;
|
125 |
}
|
126 |
|
127 |
-
$contact_id =
|
128 |
|
129 |
//do_action( 'ig_es_contact_added', $data);
|
130 |
|
103 |
* - If not, create contact and then save list
|
104 |
*/
|
105 |
|
106 |
+
$contact_id = ES()->contacts_db->get_contact_id_by_email( $this->email );
|
107 |
if ( ! $contact_id ) {
|
108 |
$data = array();
|
109 |
$data['first_name'] = $this->first_name;
|
124 |
exit;
|
125 |
}
|
126 |
|
127 |
+
$contact_id = ES()->contacts_db->insert( $data );
|
128 |
|
129 |
//do_action( 'ig_es_contact_added', $data);
|
130 |
|
includes/admin/class-es-import-subscribers.php
CHANGED
@@ -62,7 +62,7 @@ class ES_Import_Subscribers {
|
|
62 |
// Get Headers
|
63 |
$headers = array_map( 'trim', fgetcsv( $handle ) );
|
64 |
|
65 |
-
$existing_contacts_email_id_map =
|
66 |
|
67 |
$existing_contacts = array();
|
68 |
if ( count( $existing_contacts_email_id_map ) > 0 ) {
|
@@ -129,9 +129,9 @@ class ES_Import_Subscribers {
|
|
129 |
|
130 |
if ( count( $emails ) > 0 ) {
|
131 |
|
132 |
-
|
133 |
|
134 |
-
$contact_ids =
|
135 |
if ( count( $contact_ids ) > 0 ) {
|
136 |
ES_DB_Lists_Contacts::delete_contacts_from_list( $list_id, $contact_ids );
|
137 |
ES_DB_Lists_Contacts::do_import_contacts_into_list( $list_id, $contact_ids, $status, 1, $current_date_time );
|
62 |
// Get Headers
|
63 |
$headers = array_map( 'trim', fgetcsv( $handle ) );
|
64 |
|
65 |
+
$existing_contacts_email_id_map = ES()->contacts_db->get_email_id_map();
|
66 |
|
67 |
$existing_contacts = array();
|
68 |
if ( count( $existing_contacts_email_id_map ) > 0 ) {
|
129 |
|
130 |
if ( count( $emails ) > 0 ) {
|
131 |
|
132 |
+
ES()->contacts_db->do_batch_insert( $contacts_data );
|
133 |
|
134 |
+
$contact_ids = ES()->contacts_db->get_contact_ids_by_emails( $emails );
|
135 |
if ( count( $contact_ids ) > 0 ) {
|
136 |
ES_DB_Lists_Contacts::delete_contacts_from_list( $list_id, $contact_ids );
|
137 |
ES_DB_Lists_Contacts::do_import_contacts_into_list( $list_id, $contact_ids, $status, 1, $current_date_time );
|
includes/admin/class-es-newsletters.php
CHANGED
@@ -22,7 +22,7 @@ class ES_Newsletters {
|
|
22 |
// class constructor
|
23 |
public function __construct() {
|
24 |
//add_filter( 'set-screen-option', array( __CLASS__, 'set_screen' ), 10, 3 );
|
25 |
-
add_action( 'admin_init', array( $this, 'setup_sections' ) );
|
26 |
add_filter( 'ig_es_refresh_newsletter_content', array( $this, 'refresh_newsletter_content' ), 10, 2 );
|
27 |
}
|
28 |
|
@@ -32,45 +32,76 @@ class ES_Newsletters {
|
|
32 |
|
33 |
public function es_newsletters_settings_callback() {
|
34 |
|
35 |
-
$this->email_subscribers_settings_fields();
|
36 |
-
|
37 |
$submitted = ig_es_get_request_data( 'submitted' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
$template_id = ig_es_get_request_data( 'ig_es_broadcast_base_template_id' );
|
44 |
-
if ( empty( $template_id ) ) {
|
45 |
-
$message = __( 'Please select template.', 'email-subscribers' );
|
46 |
-
ES_Common::show_message( $message, 'error' );
|
47 |
-
} elseif ( empty( $list_id ) ) {
|
48 |
-
$message = __( 'Please select list.', 'email-subscribers' );
|
49 |
-
ES_Common::show_message( $message, 'error' );
|
50 |
-
} else {
|
51 |
|
52 |
-
|
53 |
-
'base_template_id' => $template_id,
|
54 |
-
'list_ids' => $list_id,
|
55 |
-
'status' => 1
|
56 |
-
);
|
57 |
|
58 |
-
|
|
|
|
|
59 |
|
60 |
-
|
61 |
-
$message = __( sprintf( 'A new broadcast has been created successfully! Contacts from selected list will be notified within an hour. Want to notify now? <a href="%s" target="_blank">Click here</a>', $reports_url ), 'email-subscribers' );
|
62 |
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
-
do_action( 'ig_es_broadcast_created' );
|
66 |
}
|
67 |
|
68 |
}
|
69 |
-
|
70 |
-
$this->prepare_newsletter_settings_form();
|
71 |
}
|
72 |
|
73 |
public function prepare_newsletter_settings_form() {
|
|
|
|
|
|
|
|
|
74 |
|
75 |
?>
|
76 |
|
@@ -79,14 +110,56 @@ class ES_Newsletters {
|
|
79 |
<a href="admin.php?page=es_campaigns" class="page-title-action"><?php _e( 'Campaigns', 'email-subscribers' ) ?></a>
|
80 |
<a href="edit.php?post_type=es_template" class="page-title-action es-imp-button"><?php _e( 'Manage Templates', 'email-subscribers' ) ?></a>
|
81 |
</h2>
|
82 |
-
<div class="es-form" style="width:
|
83 |
<form method="post" action="#">
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
</form>
|
91 |
</div>
|
92 |
<div clas="es-preview" style="float: right;width: 19%;">
|
@@ -96,12 +169,13 @@ class ES_Newsletters {
|
|
96 |
|
97 |
<?php
|
98 |
|
99 |
-
}
|
100 |
|
101 |
-
public function setup_sections() {
|
102 |
-
add_settings_section( 'newsletters_settings', '', array( $this, 'email_subscribers_settings_callback' ), 'newsletters_settings' );
|
103 |
}
|
104 |
|
|
|
|
|
|
|
|
|
105 |
public function email_subscribers_settings_callback( $arguments ) {
|
106 |
|
107 |
?>
|
@@ -112,134 +186,134 @@ class ES_Newsletters {
|
|
112 |
|
113 |
}
|
114 |
|
115 |
-
public function email_subscribers_settings_fields() {
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
}
|
161 |
-
|
162 |
-
public function field_callback( $arguments ) {
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
}
|
206 |
|
207 |
public static function es_send_email_callback( $data ) {
|
208 |
|
209 |
-
|
210 |
-
|
211 |
|
212 |
-
$title = get_the_title( $
|
213 |
|
214 |
$data['type'] = 'newsletter';
|
215 |
-
$data['name'] = $
|
216 |
-
$data['subject'] = $title;
|
217 |
$data['slug'] = sanitize_title( sanitize_text_field( $data['name'] ) );
|
218 |
-
$data['list_ids'] = $list_id;
|
219 |
-
$data['base_template_id'] = $template_id;
|
220 |
|
221 |
$data = apply_filters( 'ig_es_broadcast_data', $data );
|
222 |
|
223 |
-
if ( ! empty( $
|
224 |
-
|
225 |
-
$post_temp_arr = get_post( $template_id );
|
226 |
|
|
|
227 |
$campaign_id = ES()->campaigns_db->save_campaign( $data );
|
228 |
|
229 |
if ( is_object( $post_temp_arr ) ) {
|
230 |
|
231 |
-
$post_subject = ! empty( $post_temp_arr->post_title ) ? $post_temp_arr->post_title : '';
|
232 |
-
$post_template_content = ! empty( $post_temp_arr->post_content ) ? $post_temp_arr->post_content : '';
|
233 |
-
$
|
|
|
|
|
234 |
|
235 |
-
$subscribers = ES_DB_Contacts::get_active_subscribers_by_list_id( $list_id );
|
236 |
if ( ! empty( $subscribers ) && count( $subscribers ) > 0 ) {
|
237 |
$guid = ES_Common::generate_guid( 6 );
|
238 |
$data = array(
|
239 |
'hash' => $guid,
|
240 |
'campaign_id' => $campaign_id,
|
241 |
-
'subject' => $
|
242 |
-
'body' => $
|
243 |
'count' => count( $subscribers ),
|
244 |
'status' => 'In Queue',
|
245 |
'start_at' => ! empty( $data['start_at'] ) ? $data['start_at'] : '',
|
@@ -268,10 +342,9 @@ class ES_Newsletters {
|
|
268 |
public static function refresh_newsletter_content( $content, $args) {
|
269 |
$campaign_id = $args['campaign_id'];
|
270 |
$template_id = ES()->campaigns_db->get_template_id_by_campaign( $campaign_id );
|
271 |
-
$
|
272 |
-
$content['
|
273 |
-
$content['body'] =
|
274 |
-
$content['body'] = ES_Common::es_process_template_body( $content['body'], $template_id );
|
275 |
return $content;
|
276 |
}
|
277 |
|
@@ -283,4 +356,85 @@ class ES_Newsletters {
|
|
283 |
return self::$instance;
|
284 |
}
|
285 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
}
|
22 |
// class constructor
|
23 |
public function __construct() {
|
24 |
//add_filter( 'set-screen-option', array( __CLASS__, 'set_screen' ), 10, 3 );
|
25 |
+
// add_action( 'admin_init', array( $this, 'setup_sections' ) );
|
26 |
add_filter( 'ig_es_refresh_newsletter_content', array( $this, 'refresh_newsletter_content' ), 10, 2 );
|
27 |
}
|
28 |
|
32 |
|
33 |
public function es_newsletters_settings_callback() {
|
34 |
|
35 |
+
// $this->email_subscribers_settings_fields();
|
36 |
+
|
37 |
$submitted = ig_es_get_request_data( 'submitted' );
|
38 |
+
$preview = ig_es_get_request_data( 'es_broadcast_preview' );
|
39 |
+
$broadcast_data = ig_es_get_request_data( 'broadcast_data', array(), false );
|
40 |
+
if( 'preview' !== $preview ){
|
41 |
+
if ( 'submitted' === $submitted ) {
|
42 |
+
|
43 |
+
// $email_sent_type = __('Active', 'email-subscribers');
|
44 |
+
$list_id = !empty($broadcast_data['list_ids']) ? $broadcast_data['list_ids'] : '' ;
|
45 |
+
$template_id = !empty($broadcast_data['template_id']) ? $broadcast_data['template_id'] : '' ;
|
46 |
+
$subject = !empty($broadcast_data['subject']) ? $broadcast_data['subject'] : '' ;
|
47 |
+
// $template_id = ig_es_get_request_data( 'ig_es_broadcast_base_template_id' );
|
48 |
+
if ( empty( $template_id ) ) {
|
49 |
+
$message = __( 'Please select template.', 'email-subscribers' );
|
50 |
+
ES_Common::show_message( $message, 'error' );
|
51 |
+
} elseif ( empty( $list_id ) ) {
|
52 |
+
$message = __( 'Please select list.', 'email-subscribers' );
|
53 |
+
ES_Common::show_message( $message, 'error' );
|
54 |
+
} elseif ( empty( $subject ) ) {
|
55 |
+
$message = __( 'Please add the subject', 'email-subscribers' );
|
56 |
+
ES_Common::show_message( $message, 'error' );
|
57 |
+
}else {
|
58 |
|
59 |
+
$data = array(
|
60 |
+
'base_template_id' => $template_id,
|
61 |
+
'list_ids' => $list_id,
|
62 |
+
'status' => 1
|
63 |
+
);
|
64 |
+
$broadcast_data['base_template_id'] = $template_id;
|
65 |
+
$broadcast_data['list_ids'] = $list_id;
|
66 |
+
// $meta = !empty($broadcast_data['meta']) ? $broadcast_data['meta'] : array();
|
67 |
+
// $meta['pre_header'] = $broadcast_data['pre_header'];
|
68 |
+
// $broadcast_data['meta'] = maybe_serialize($meta);
|
69 |
+
self::es_send_email_callback( $broadcast_data );
|
70 |
|
71 |
+
$reports_url = admin_url( 'admin.php?page=es_reports' );
|
72 |
+
$message = __( sprintf( 'A new broadcast has been created successfully! Contacts from selected list will be notified within an hour. Want to notify now? <a href="%s" target="_blank">Click here</a>', $reports_url ), 'email-subscribers' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
+
ES_Common::show_message( $message, 'success' );
|
|
|
|
|
|
|
|
|
75 |
|
76 |
+
do_action( 'ig_es_broadcast_created' );
|
77 |
+
$broadcast_data = array();
|
78 |
+
}
|
79 |
|
80 |
+
}
|
|
|
81 |
|
82 |
+
$this->prepare_newsletter_settings_form();
|
83 |
+
}else if('preview' === $preview ){
|
84 |
+
// $broadcast_data = ig_es_get_request_data( 'broadcast_data', array(), false );
|
85 |
+
if ( empty( $broadcast_data['body'] ) ) {
|
86 |
+
$message = __( 'Please add message content', 'email-subscribers' );
|
87 |
+
ES_Common::show_message( $message, 'error' );
|
88 |
+
$this->prepare_newsletter_settings_form();
|
89 |
+
} else{
|
90 |
+
//content validation
|
91 |
+
$template_data['content'] = !empty($broadcast_data['body']) ? $broadcast_data['body'] : '';
|
92 |
+
$template_data['template_id'] = !empty($broadcast_data['template_id']) ? $broadcast_data['template_id'] : '';
|
93 |
+
$this->es_broadcast_preview_callback( $template_data );
|
94 |
|
|
|
95 |
}
|
96 |
|
97 |
}
|
|
|
|
|
98 |
}
|
99 |
|
100 |
public function prepare_newsletter_settings_form() {
|
101 |
+
$newsletter_data = array();
|
102 |
+
$templates = ES_Common::prepare_templates_dropdown_options( 'newsletter' );
|
103 |
+
$lists = ES_Common::prepare_list_dropdown_options();
|
104 |
+
$from_email = ES_Common::get_ig_option( 'from_email' );
|
105 |
|
106 |
?>
|
107 |
|
110 |
<a href="admin.php?page=es_campaigns" class="page-title-action"><?php _e( 'Campaigns', 'email-subscribers' ) ?></a>
|
111 |
<a href="edit.php?post_type=es_template" class="page-title-action es-imp-button"><?php _e( 'Manage Templates', 'email-subscribers' ) ?></a>
|
112 |
</h2>
|
113 |
+
<div class="es-form" style="width: 100%;">
|
114 |
<form method="post" action="#">
|
115 |
+
<div class="es_newsletters_settings_wrapper">
|
116 |
+
<div class="es_campaign_name_wrapper ">
|
117 |
+
<input placeholder="Add Broadcast name" type="text" class="es_newsletter_name" name="broadcast_data[name]" value="">
|
118 |
+
<input id="ig_es_campaign_submit_button" class="es_primary_btn" type="submit" name="submit" value="Send Broadcast">
|
119 |
+
<input type="hidden" name="submitted" value="submitted">
|
120 |
+
</div>
|
121 |
+
<div class="es_settings_left_pan">
|
122 |
+
<div class="es_settings_field">
|
123 |
+
<label><?php _e('From Email', 'email-subscribers')?><br/><input type="email" name="broadcast_data[from_email]" value="<?php echo $from_email; ?>"/></label>
|
124 |
+
</div>
|
125 |
+
<div class="es_settings_field">
|
126 |
+
<label><?php _e('Design template', 'email-subscribers')?><br/><select name="broadcast_data[template_id]" id="base_template_id"><?php echo $templates ?></select></label>
|
127 |
+
</div>
|
128 |
+
<div class="es_settings_field"><label><?php _e('Subject', 'email-subscribers')?><br/><input type="text" id="ig_es_broadcast_subject" name="broadcast_data[subject]" placeholder="<?php _e('New Broadcast', 'email-subscribers')?>"/></label></div>
|
129 |
+
<!-- <div class="es_settings_field"><label><?php _e('Pre Header', 'email-subscribers')?><br/><input type="text" name="broadcast_data[pre_header]"/></label></div> -->
|
130 |
+
<div class="es_settings_field">
|
131 |
+
<label><?php _e('Body', 'email-subscribers'); ?></label>
|
132 |
+
<?php
|
133 |
+
$body = !empty($broadcast_data['body']) ? $broadcast_data['body'] : '';
|
134 |
+
$editor_args = array(
|
135 |
+
'textarea_name' => 'broadcast_data[body]',
|
136 |
+
'textarea_rows' => 40,
|
137 |
+
'editor_class' => 'wp-editor-content',
|
138 |
+
'media_buttons' => true,
|
139 |
+
'tinymce' => true,
|
140 |
+
'quicktags'=> true,
|
141 |
+
'wpautop' => false,
|
142 |
+
'editor_class' => 'wp-editor-boradcast'
|
143 |
+
);
|
144 |
+
wp_editor( $body, 'edit-es-boradcast-body', $editor_args ); ?>
|
145 |
+
</div>
|
146 |
+
<?php do_action( 'ig_es_after_broadcast_left_pan_settings'); ?>
|
147 |
+
</div>
|
148 |
+
<div class="es_settings_right_pan">
|
149 |
+
<div class="es_settings_field">
|
150 |
+
<label><?php _e('Recipients', 'email-subscribers')?><br/><select name="broadcast_data[list_ids]" id="ig_es_broadcast_list_ids"><?php echo $lists ?></select></label>
|
151 |
+
</div>
|
152 |
+
<hr>
|
153 |
+
<div class="es_settings_field">
|
154 |
+
<label>
|
155 |
+
<input class="es_secondary_btn" type="submit" id="ig_es_preview_broadcast" value="<?php _e('Preview this email in browser', 'email-subscribers')?>">
|
156 |
+
<input type="hidden" name="es_broadcast_preview" id="es_broadcast_preview">
|
157 |
+
</label>
|
158 |
+
</div>
|
159 |
+
<?php do_action( 'ig_es_after_broadcast_right_pan_settings'); ?>
|
160 |
+
</div>
|
161 |
+
|
162 |
+
</div>
|
163 |
</form>
|
164 |
</div>
|
165 |
<div clas="es-preview" style="float: right;width: 19%;">
|
169 |
|
170 |
<?php
|
171 |
|
|
|
172 |
|
|
|
|
|
173 |
}
|
174 |
|
175 |
+
// public function setup_sections() {
|
176 |
+
// add_settings_section( 'newsletters_settings', '', array( $this, 'email_subscribers_settings_callback' ), 'newsletters_settings' );
|
177 |
+
// }
|
178 |
+
|
179 |
public function email_subscribers_settings_callback( $arguments ) {
|
180 |
|
181 |
?>
|
186 |
|
187 |
}
|
188 |
|
189 |
+
// public function email_subscribers_settings_fields() {
|
190 |
+
|
191 |
+
// $templates = ES_Common::prepare_templates_dropdown_options( 'newsletter' );
|
192 |
+
// // $sent_types = ES_Common::prepare_notification_send_type_dropdown_options();
|
193 |
+
// $groups = ES_Common::prepare_list_dropdown_options();
|
194 |
+
|
195 |
+
// $fields = array(
|
196 |
+
// array(
|
197 |
+
// 'uid' => 'ig_es_broadcast_base_template_id',
|
198 |
+
// 'label' => __( 'Select Template', 'email-subscribers' ),
|
199 |
+
// 'section' => 'newsletters_settings',
|
200 |
+
// 'type' => 'select',
|
201 |
+
// 'options' => $templates,
|
202 |
+
// 'placeholder' => '',
|
203 |
+
// 'helper' => '',
|
204 |
+
// 'supplemental' => __( 'Content of the selected template will be broadcasted.', 'email-subscribers' ),
|
205 |
+
// 'default' => ''
|
206 |
+
// ),
|
207 |
+
|
208 |
+
// array(
|
209 |
+
// 'uid' => 'ig_es_broadcast_list_ids',
|
210 |
+
// 'label' => __( 'Select List', 'email-subscribers' ),
|
211 |
+
// 'section' => 'newsletters_settings',
|
212 |
+
// 'type' => 'select',
|
213 |
+
// 'options' => $groups,
|
214 |
+
// 'placeholder' => '',
|
215 |
+
// 'helper' => '',
|
216 |
+
// 'supplemental' => __( 'Contacts from the selected list will be notified.', 'email-subscribers' ),
|
217 |
+
// 'default' => ''
|
218 |
+
// ),
|
219 |
+
|
220 |
+
// array(
|
221 |
+
// 'uid' => 'ig_es_total_contacts',
|
222 |
+
// 'label' => __( 'Total Contacts', 'email-subscribers' ),
|
223 |
+
// 'section' => 'newsletters_settings',
|
224 |
+
// 'type' => 'label',
|
225 |
+
// 'default' => 0
|
226 |
+
// ),
|
227 |
+
// );
|
228 |
+
// $fields = apply_filters( 'email_newsletter_settings_fields', $fields );
|
229 |
+
// foreach ( $fields as $field ) {
|
230 |
+
// add_settings_field( $field['uid'], $field['label'], array( $this, 'field_callback' ), $field['section'], $field['section'], $field );
|
231 |
+
// register_setting( 'es_newsletters_settings', $field['uid'] );
|
232 |
+
// }
|
233 |
+
|
234 |
+
// }
|
235 |
+
|
236 |
+
// public function field_callback( $arguments ) {
|
237 |
+
// $value = get_option( $arguments['uid'] ); // Get the current value, if there is one
|
238 |
+
// if ( ! $value && isset( $arguments['default'] ) ) { // If no value exists
|
239 |
+
// $value = $arguments['default']; // Set to our default
|
240 |
+
// }
|
241 |
+
|
242 |
+
// // Check which type of field we want
|
243 |
+
// switch ( $arguments['type'] ) {
|
244 |
+
|
245 |
+
// case 'label': // If it is a text field
|
246 |
+
// printf( '<p id="%1$s">%2$s</p>', $arguments['uid'], $value );
|
247 |
+
// break;
|
248 |
+
|
249 |
+
// case 'textarea':
|
250 |
+
// printf( '<textarea name="%1$s" id="%1$s" placeholder="%2$s" rows="5" cols="50">%3$s</textarea>', $arguments['uid'], $arguments['placeholder'], $value );
|
251 |
+
// break;
|
252 |
+
// case 'file':
|
253 |
+
// echo '<input type="text" id="logo_url" name="' . $arguments['uid'] . '" value="' . $value . '" />
|
254 |
+
// <input id="upload_logo_button" type="button" class="button" value="Upload Logo" />';
|
255 |
+
// break;
|
256 |
+
// case 'select':
|
257 |
+
// if ( ! empty ( $arguments['options'] ) ) {
|
258 |
+
// printf( '<select name="%1$s" id="%1$s">%2$s</select>', $arguments['uid'], $arguments['options'] );
|
259 |
+
// }
|
260 |
+
// break;
|
261 |
+
|
262 |
+
// case 'text':
|
263 |
+
// case 'email':
|
264 |
+
// default:
|
265 |
+
// printf( '<input name="%1$s" id="%1$s" type="%2$s" placeholder="%3$s" value="%4$s" />', $arguments['uid'], $arguments['type'], $arguments['placeholder'], $value );
|
266 |
+
|
267 |
+
// }
|
268 |
+
|
269 |
+
// // If there is help text
|
270 |
+
// if ( isset( $arguments['helper'] ) ) {
|
271 |
+
// printf( '<span class="helper"> %s</span>', $arguments['helper'] ); // Show it
|
272 |
+
// }
|
273 |
+
|
274 |
+
// // If there is supplemental text
|
275 |
+
// if ( isset( $arguments['supplemental'] ) ) {
|
276 |
+
// printf( '<p class="description">%s</p>', $arguments['supplemental'] ); // Show it
|
277 |
+
// }
|
278 |
+
|
279 |
+
// }
|
280 |
|
281 |
public static function es_send_email_callback( $data ) {
|
282 |
|
283 |
+
//$template_id = ! empty( $data['base_template_id'] ) ? $data['base_template_id'] : '';
|
284 |
+
$list_id = ! empty( $data['list_ids'] ) ? $data['list_ids'] : '';
|
285 |
|
286 |
+
$title = get_the_title( $data['base_template_id'] );
|
287 |
|
288 |
$data['type'] = 'newsletter';
|
289 |
+
$data['name'] = !empty( $data['name'] ) ? $data['name'] : $data['subject'] ;
|
290 |
+
// $data['subject'] = $title;
|
291 |
$data['slug'] = sanitize_title( sanitize_text_field( $data['name'] ) );
|
292 |
+
// $data['list_ids'] = $list_id;
|
293 |
+
// $data['base_template_id'] = $template_id;
|
294 |
|
295 |
$data = apply_filters( 'ig_es_broadcast_data', $data );
|
296 |
|
297 |
+
if ( ! empty( $data['base_template_id'] ) ) {
|
|
|
|
|
298 |
|
299 |
+
$post_temp_arr = get_post( $data['base_template_id'] );
|
300 |
$campaign_id = ES()->campaigns_db->save_campaign( $data );
|
301 |
|
302 |
if ( is_object( $post_temp_arr ) ) {
|
303 |
|
304 |
+
// $post_subject = ! empty( $post_temp_arr->post_title ) ? $post_temp_arr->post_title : '';
|
305 |
+
// $post_template_content = ! empty( $post_temp_arr->post_content ) ? $post_temp_arr->post_content : '';
|
306 |
+
$data['body'] = ES_Common::es_process_template_body( $data['body'], $data['base_template_id'], $campaign_id );
|
307 |
+
|
308 |
+
$subscribers = ES()->contacts_db->get_active_contacts_by_list_id( $list_id );
|
309 |
|
|
|
310 |
if ( ! empty( $subscribers ) && count( $subscribers ) > 0 ) {
|
311 |
$guid = ES_Common::generate_guid( 6 );
|
312 |
$data = array(
|
313 |
'hash' => $guid,
|
314 |
'campaign_id' => $campaign_id,
|
315 |
+
'subject' => $data['subject'],
|
316 |
+
'body' => $data['body'],
|
317 |
'count' => count( $subscribers ),
|
318 |
'status' => 'In Queue',
|
319 |
'start_at' => ! empty( $data['start_at'] ) ? $data['start_at'] : '',
|
342 |
public static function refresh_newsletter_content( $content, $args) {
|
343 |
$campaign_id = $args['campaign_id'];
|
344 |
$template_id = ES()->campaigns_db->get_template_id_by_campaign( $campaign_id );
|
345 |
+
$content['subject'] = ES()->campaigns_db->get_column( 'subject', $campaign_id );
|
346 |
+
$content['body'] = ES()->campaigns_db->get_column( 'body', $campaign_id );
|
347 |
+
$content['body'] = ES_Common::es_process_template_body( $content['body'], $template_id, $campaign_id );
|
|
|
348 |
return $content;
|
349 |
}
|
350 |
|
356 |
return self::$instance;
|
357 |
}
|
358 |
|
359 |
+
public function es_broadcast_preview_callback( $template_data ) {
|
360 |
+
|
361 |
+
$template_id = $template_data['template_id'];
|
362 |
+
|
363 |
+
// $template = get_post( $template_id, ARRAY_A );
|
364 |
+
|
365 |
+
if ( !empty($template_data['content'] )) {
|
366 |
+
$current_user = wp_get_current_user();
|
367 |
+
$username = $current_user->user_login;
|
368 |
+
$useremail = $current_user->user_email;
|
369 |
+
|
370 |
+
$es_template_body = $template_data['content'] ;
|
371 |
+
|
372 |
+
// $es_template_type = get_post_meta( $template_id, 'es_template_type', true );
|
373 |
+
|
374 |
+
|
375 |
+
// if ( 'post_notification' === $es_template_type ) {
|
376 |
+
// $args = array( 'numberposts' => '1', 'order' => 'DESC', 'post_status' => 'publish' );
|
377 |
+
// $recent_posts = wp_get_recent_posts( $args );
|
378 |
+
|
379 |
+
// if ( count( $recent_posts ) > 0 ) {
|
380 |
+
// $recent_post = array_shift( $recent_posts );
|
381 |
+
|
382 |
+
// $post_id = $recent_post['ID'];
|
383 |
+
// $es_template_body = ES_Handle_Post_Notification::prepare_body( $es_template_body, $post_id, $template_id );
|
384 |
+
// }
|
385 |
+
// } else {
|
386 |
+
// $es_template_body = ES_Common::es_process_template_body( $es_template_body, $template_id );
|
387 |
+
// }
|
388 |
+
|
389 |
+
$es_template_body = ES_Common::es_process_template_body( $es_template_body , $template_id );
|
390 |
+
$es_template_body = str_replace( '{{NAME}}', $username, $es_template_body );
|
391 |
+
$es_template_body = str_replace( '{{EMAIL}}', $useremail, $es_template_body );
|
392 |
+
|
393 |
+
if ( has_post_thumbnail( $template_id ) ) {
|
394 |
+
$image_array = wp_get_attachment_image_src( get_post_thumbnail_id( $template_id ), 'full' );
|
395 |
+
$image = '<img src="' . $image_array[0] . '" class="img-responsive" alt="Image for Post ' . $template_id . '" />';
|
396 |
+
} else {
|
397 |
+
$image = '';
|
398 |
+
}
|
399 |
+
|
400 |
+
$html = '';
|
401 |
+
$html .= '<style type="text/css">
|
402 |
+
.es-sidebar {
|
403 |
+
width: 23%;
|
404 |
+
background-color: rgb(230, 230, 230);
|
405 |
+
padding:15px;
|
406 |
+
border-right: 1px solid #bdbdbd;
|
407 |
+
}
|
408 |
+
.es-preview {
|
409 |
+
float: left;
|
410 |
+
padding:15px;
|
411 |
+
width: 70%;
|
412 |
+
background-color:#FFF;
|
413 |
+
font-size:16px;
|
414 |
+
}
|
415 |
+
</style>
|
416 |
+
<div class="wrap">
|
417 |
+
<div class="tool-box">
|
418 |
+
<div class="es-main" style="display:flex;">
|
419 |
+
<div class="es-sidebar">
|
420 |
+
<h2 style="margin-bottom:1em;">
|
421 |
+
Template Preview <a class="add-new-h2" target="_blank" href="' . admin_url() . 'admin.php?page=es-general-information">Help</a>
|
422 |
+
</h2>
|
423 |
+
<p>
|
424 |
+
This is how your email may look.<br><br>Note: Different email services (like gmail, yahoo etc) display email content differently. So there could be a slight variation on how your customer will view the email content. </p>
|
425 |
+
</div>
|
426 |
+
<div class="es-preview">' . $es_template_body . '</div>
|
427 |
+
<div style="clear:both;"></div>
|
428 |
+
</div>
|
429 |
+
<div style="clear:both;"></div>
|
430 |
+
</div>
|
431 |
+
</div>';
|
432 |
+
echo apply_filters( 'the_content', $html );
|
433 |
+
} else {
|
434 |
+
echo 'Please publish it or save it as a draft';
|
435 |
+
}
|
436 |
+
|
437 |
+
}
|
438 |
+
|
439 |
+
|
440 |
}
|
includes/admin/class-es-post-notifications.php
CHANGED
@@ -39,7 +39,7 @@ class ES_Post_Notifications_Table {
|
|
39 |
$template_id = ig_es_get_request_data( 'template_id' );
|
40 |
$cat = ig_es_get_request_data( 'es_note_cat' );
|
41 |
$es_note_cat_parent = ig_es_get_request_data( 'es_note_cat_parent' );
|
42 |
-
$cat = !empty($es_note_cat_parent) ? array($es_note_cat_parent) : $cat;
|
43 |
|
44 |
if ( empty( $list_id ) ) {
|
45 |
$message = __( 'Please select list.', 'email-subscribers' );
|
@@ -78,7 +78,8 @@ class ES_Post_Notifications_Table {
|
|
78 |
return;
|
79 |
}
|
80 |
$this->save_list( $data );
|
81 |
-
$
|
|
|
82 |
ES_Common::show_message( $message, 'success' );
|
83 |
}
|
84 |
|
@@ -195,10 +196,25 @@ class ES_Post_Notifications_Table {
|
|
195 |
$data['name'] = $title;
|
196 |
|
197 |
$data = apply_filters( 'ig_es_post_notification_data', $data );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
$this->save_list( $data, $id );
|
199 |
|
200 |
$data['categories'] = ES_Common::convert_categories_string_to_array( $data['categories'], true );
|
201 |
-
$
|
|
|
202 |
ES_Common::show_message( $message, 'success' );
|
203 |
} else {
|
204 |
|
39 |
$template_id = ig_es_get_request_data( 'template_id' );
|
40 |
$cat = ig_es_get_request_data( 'es_note_cat' );
|
41 |
$es_note_cat_parent = ig_es_get_request_data( 'es_note_cat_parent' );
|
42 |
+
$cat = (!empty($es_note_cat_parent) && $es_note_cat_parent == '{a}All{a}') ? array($es_note_cat_parent) : $cat;
|
43 |
|
44 |
if ( empty( $list_id ) ) {
|
45 |
$message = __( 'Please select list.', 'email-subscribers' );
|
78 |
return;
|
79 |
}
|
80 |
$this->save_list( $data );
|
81 |
+
$type = ucwords(str_replace('_', ' ', $data['type']));
|
82 |
+
$message = __( "$type has been added successfully!", 'email-subscribers' );
|
83 |
ES_Common::show_message( $message, 'success' );
|
84 |
}
|
85 |
|
196 |
$data['name'] = $title;
|
197 |
|
198 |
$data = apply_filters( 'ig_es_post_notification_data', $data );
|
199 |
+
//check tempalte id
|
200 |
+
if ( empty( $data['base_template_id'] ) ) {
|
201 |
+
$message = __( 'Please select template.', 'email-subscribers' );
|
202 |
+
ES_Common::show_message( $message, 'error' );
|
203 |
+
$this->prepare_post_notification_form( $id, $data );
|
204 |
+
return;
|
205 |
+
}
|
206 |
+
//check categories
|
207 |
+
if ( empty( $categories ) ) {
|
208 |
+
$message = __( 'Please select Categories.', 'email-subscribers' );
|
209 |
+
ES_Common::show_message( $message, 'error' );
|
210 |
+
$this->prepare_post_notification_form( $id, $data );
|
211 |
+
return;
|
212 |
+
}
|
213 |
$this->save_list( $data, $id );
|
214 |
|
215 |
$data['categories'] = ES_Common::convert_categories_string_to_array( $data['categories'], true );
|
216 |
+
$type = ucwords(str_replace('_', ' ', $data['type']));
|
217 |
+
$message = __( "$type has been updated successfully!", 'email-subscribers' );
|
218 |
ES_Common::show_message( $message, 'success' );
|
219 |
} else {
|
220 |
|
includes/admin/class-es-queue.php
CHANGED
@@ -127,7 +127,7 @@ if ( ! class_exists( 'ES_Queue' ) ) {
|
|
127 |
$list_id = $campaign['list_ids'];
|
128 |
|
129 |
// Do we have active subscribers?
|
130 |
-
$contacts =
|
131 |
$total_contacts = count( $contacts );
|
132 |
|
133 |
if ( $total_contacts > 0 ) {
|
@@ -525,7 +525,7 @@ if ( ! class_exists( 'ES_Queue' ) ) {
|
|
525 |
// We need unique ids
|
526 |
$contact_ids = array_unique( $contact_ids );
|
527 |
|
528 |
-
$contacts =
|
529 |
|
530 |
foreach ( $campaigns_notifications as $campaign_id => $notifications ) {
|
531 |
|
127 |
$list_id = $campaign['list_ids'];
|
128 |
|
129 |
// Do we have active subscribers?
|
130 |
+
$contacts = ES()->contacts_db->get_active_contacts_by_list_id( $list_id );
|
131 |
$total_contacts = count( $contacts );
|
132 |
|
133 |
if ( $total_contacts > 0 ) {
|
525 |
// We need unique ids
|
526 |
$contact_ids = array_unique( $contact_ids );
|
527 |
|
528 |
+
$contacts = ES()->contacts_db->get_details_by_ids( $contact_ids );
|
529 |
|
530 |
foreach ( $campaigns_notifications as $campaign_id => $notifications ) {
|
531 |
|
includes/class-email-subscribers.php
CHANGED
@@ -165,6 +165,13 @@ class Email_Subscribers {
|
|
165 |
*/
|
166 |
public $blocked_emails_db;
|
167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
/**
|
169 |
*
|
170 |
* @since 4.2.1
|
@@ -264,7 +271,7 @@ class Email_Subscribers {
|
|
264 |
$es_pro_plugin_meta_data = get_plugin_data( WP_PLUGIN_DIR . '/email-subscribers-premium/email-subscribers-premium.php' );
|
265 |
$es_pro_plugin_version = $es_pro_plugin_meta_data['Version'];
|
266 |
|
267 |
-
if ( is_admin() && ! empty( $es_pro_plugin_version ) && version_compare( $es_pro_plugin_version, '4.2.
|
268 |
$upgrade_url = admin_url( 'plugins.php?plugin_status=upgrade' );
|
269 |
ob_start();
|
270 |
?>
|
@@ -351,15 +358,15 @@ class Email_Subscribers {
|
|
351 |
'email-subscribers' ) . '</a></p></div>';
|
352 |
}
|
353 |
|
354 |
-
//
|
355 |
$timezone_format = _x('Y-m-d', 'timezone date format');
|
356 |
$ig_current_date = strtotime(date_i18n($timezone_format));
|
357 |
-
$ig_es_offer_start = strtotime("2019-10-
|
358 |
-
$ig_es_offer_end = strtotime("2019-
|
359 |
if(($ig_current_date >= $ig_es_offer_start) && ($ig_current_date <= $ig_es_offer_end)) {
|
360 |
include_once( EMAIL_SUBSCRIBERS_DIR.'/ig-es-offer.php');
|
361 |
}
|
362 |
-
//
|
363 |
|
364 |
|
365 |
}
|
@@ -388,8 +395,9 @@ class Email_Subscribers {
|
|
388 |
if ( $option_name === 'redirect_upsale_notice' ) {
|
389 |
header( "Location: https://www.icegram.com/email-subscribers-starter-plan-pricing/?utm_source=es&utm_medium=es_upsale_banner&utm_campaign=es_upsale" );
|
390 |
exit();
|
391 |
-
} if($option_name === 'offer_pre_halloween_done_2019'){
|
392 |
-
|
|
|
393 |
exit();
|
394 |
}else {
|
395 |
$referer = wp_get_referer();
|
@@ -629,6 +637,7 @@ class Email_Subscribers {
|
|
629 |
require_once ES_PLUGIN_DIR . 'includes/db/class-es-db-queue.php';
|
630 |
require_once ES_PLUGIN_DIR . 'includes/db/class-es-db-mailing-queue.php';
|
631 |
require_once ES_PLUGIN_DIR . 'includes/db/class-es-db-lists.php';
|
|
|
632 |
require_once ES_PLUGIN_DIR . 'includes/db/class-es-db-contacts.php';
|
633 |
require_once ES_PLUGIN_DIR . 'includes/db/class-es-db-lists-contacts.php';
|
634 |
require_once ES_PLUGIN_DIR . 'includes/db/class-es-db-sending-queue.php';
|
@@ -741,6 +750,7 @@ class Email_Subscribers {
|
|
741 |
$this->loader->add_filter( 'set-screen-option', $plugin_admin, 'save_screen_options', 20, 3 );
|
742 |
|
743 |
$this->loader->add_action( 'wp_ajax_count_contacts_by_list', $plugin_admin, 'count_contacts_by_list' );
|
|
|
744 |
|
745 |
//$this->loader->add_filter( 'ig_es_blocked_domains', $plugin_admin, 'blocked_domains', 10, 1 );
|
746 |
//$this->loader->add_filter( 'ig_es_whitelist_ips', $plugin_admin, 'whitelist_ips', 10, 1 );
|
@@ -881,6 +891,7 @@ class Email_Subscribers {
|
|
881 |
self::$instance->forms_db = new ES_DB_Forms();
|
882 |
self::$instance->contacts_db = new ES_DB_Contacts();
|
883 |
self::$instance->blocked_emails_db = new ES_DB_Blocked_Emails();
|
|
|
884 |
self::$instance->queue = new ES_Queue();
|
885 |
self::$instance->actions = new ES_Actions();
|
886 |
|
165 |
*/
|
166 |
public $blocked_emails_db;
|
167 |
|
168 |
+
/**
|
169 |
+
* @since 4.2.4
|
170 |
+
*
|
171 |
+
* @var object|ES_DB_Links
|
172 |
+
*/
|
173 |
+
public $links_db;
|
174 |
+
|
175 |
/**
|
176 |
*
|
177 |
* @since 4.2.1
|
271 |
$es_pro_plugin_meta_data = get_plugin_data( WP_PLUGIN_DIR . '/email-subscribers-premium/email-subscribers-premium.php' );
|
272 |
$es_pro_plugin_version = $es_pro_plugin_meta_data['Version'];
|
273 |
|
274 |
+
if ( is_admin() && ! empty( $es_pro_plugin_version ) && version_compare( $es_pro_plugin_version, '4.2.4', '<' ) ) {
|
275 |
$upgrade_url = admin_url( 'plugins.php?plugin_status=upgrade' );
|
276 |
ob_start();
|
277 |
?>
|
358 |
'email-subscribers' ) . '</a></p></div>';
|
359 |
}
|
360 |
|
361 |
+
//halloween 2019 :start
|
362 |
$timezone_format = _x('Y-m-d', 'timezone date format');
|
363 |
$ig_current_date = strtotime(date_i18n($timezone_format));
|
364 |
+
$ig_es_offer_start = strtotime("2019-10-29");
|
365 |
+
$ig_es_offer_end = strtotime("2019-11-1");
|
366 |
if(($ig_current_date >= $ig_es_offer_start) && ($ig_current_date <= $ig_es_offer_end)) {
|
367 |
include_once( EMAIL_SUBSCRIBERS_DIR.'/ig-es-offer.php');
|
368 |
}
|
369 |
+
//halloween 2019 :end
|
370 |
|
371 |
|
372 |
}
|
395 |
if ( $option_name === 'redirect_upsale_notice' ) {
|
396 |
header( "Location: https://www.icegram.com/email-subscribers-starter-plan-pricing/?utm_source=es&utm_medium=es_upsale_banner&utm_campaign=es_upsale" );
|
397 |
exit();
|
398 |
+
} if($option_name === 'offer_pre_halloween_done_2019' || $option_name === 'offer_halloween_done_2019' || $option_name === 'offer_last_day_halloween_done_2019'){
|
399 |
+
$url = "https://www.icegram.com/?utm_source=in_app&utm_medium=es_banner&utm_campaign=".$option_name;
|
400 |
+
header("Location: {$url}");
|
401 |
exit();
|
402 |
}else {
|
403 |
$referer = wp_get_referer();
|
637 |
require_once ES_PLUGIN_DIR . 'includes/db/class-es-db-queue.php';
|
638 |
require_once ES_PLUGIN_DIR . 'includes/db/class-es-db-mailing-queue.php';
|
639 |
require_once ES_PLUGIN_DIR . 'includes/db/class-es-db-lists.php';
|
640 |
+
require_once ES_PLUGIN_DIR . 'includes/db/class-es-db-links.php';
|
641 |
require_once ES_PLUGIN_DIR . 'includes/db/class-es-db-contacts.php';
|
642 |
require_once ES_PLUGIN_DIR . 'includes/db/class-es-db-lists-contacts.php';
|
643 |
require_once ES_PLUGIN_DIR . 'includes/db/class-es-db-sending-queue.php';
|
750 |
$this->loader->add_filter( 'set-screen-option', $plugin_admin, 'save_screen_options', 20, 3 );
|
751 |
|
752 |
$this->loader->add_action( 'wp_ajax_count_contacts_by_list', $plugin_admin, 'count_contacts_by_list' );
|
753 |
+
$this->loader->add_action( 'wp_ajax_get_template_content', $plugin_admin, 'get_template_content' );
|
754 |
|
755 |
//$this->loader->add_filter( 'ig_es_blocked_domains', $plugin_admin, 'blocked_domains', 10, 1 );
|
756 |
//$this->loader->add_filter( 'ig_es_whitelist_ips', $plugin_admin, 'whitelist_ips', 10, 1 );
|
891 |
self::$instance->forms_db = new ES_DB_Forms();
|
892 |
self::$instance->contacts_db = new ES_DB_Contacts();
|
893 |
self::$instance->blocked_emails_db = new ES_DB_Blocked_Emails();
|
894 |
+
self::$instance->links_db = new ES_DB_Links();
|
895 |
self::$instance->queue = new ES_Queue();
|
896 |
self::$instance->actions = new ES_Actions();
|
897 |
|
includes/class-es-common.php
CHANGED
@@ -56,7 +56,7 @@ Class ES_Common {
|
|
56 |
return $convert_template;
|
57 |
}
|
58 |
|
59 |
-
public static function es_process_template_body( $content, $tmpl_id = 0 ) {
|
60 |
$content = convert_chars( convert_smilies( wptexturize( $content ) ) );
|
61 |
if ( isset( $GLOBALS['wp_embed'] ) ) {
|
62 |
$content = $GLOBALS['wp_embed']->autoembed( $content );
|
@@ -66,10 +66,11 @@ Class ES_Common {
|
|
66 |
$content = do_shortcode( shortcode_unautop( $content ) );
|
67 |
$data['content'] = $content;
|
68 |
$data['tmpl_id'] = $tmpl_id;
|
|
|
69 |
$data = apply_filters( 'es_after_process_template_body', $data );
|
70 |
$content = $data['content'];
|
71 |
//total contacts
|
72 |
-
$total_contacts =
|
73 |
$content = str_replace( "{{TOTAL-CONTACTS}}", $total_contacts, $content );
|
74 |
//blog title
|
75 |
$blog_name = get_option( 'blogname' );
|
@@ -1024,7 +1025,7 @@ Class ES_Common {
|
|
1024 |
|
1025 |
public static function get_ig_es_meta_info() {
|
1026 |
|
1027 |
-
$total_contacts =
|
1028 |
$total_lists = ES()->lists_db->count_lists();
|
1029 |
$total_newsletters = ES()->campaigns_db->get_total_newsletters();
|
1030 |
$total_post_notifications = ES()->campaigns_db->get_total_post_notifications;
|
@@ -1186,9 +1187,9 @@ Class ES_Common {
|
|
1186 |
$can_access = $user->has_cap( $default_permission );
|
1187 |
|
1188 |
// Is Admin? Have full access
|
1189 |
-
if($can_access) {
|
1190 |
-
|
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 );
|
@@ -1233,7 +1234,27 @@ Class ES_Common {
|
|
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 |
}
|
56 |
return $convert_template;
|
57 |
}
|
58 |
|
59 |
+
public static function es_process_template_body( $content, $tmpl_id = 0, $campaign_id = 0 ) {
|
60 |
$content = convert_chars( convert_smilies( wptexturize( $content ) ) );
|
61 |
if ( isset( $GLOBALS['wp_embed'] ) ) {
|
62 |
$content = $GLOBALS['wp_embed']->autoembed( $content );
|
66 |
$content = do_shortcode( shortcode_unautop( $content ) );
|
67 |
$data['content'] = $content;
|
68 |
$data['tmpl_id'] = $tmpl_id;
|
69 |
+
$data['campaign_id'] = $campaign_id;
|
70 |
$data = apply_filters( 'es_after_process_template_body', $data );
|
71 |
$content = $data['content'];
|
72 |
//total contacts
|
73 |
+
$total_contacts = ES()->contacts_db->count_active_contacts_by_list_id();
|
74 |
$content = str_replace( "{{TOTAL-CONTACTS}}", $total_contacts, $content );
|
75 |
//blog title
|
76 |
$blog_name = get_option( 'blogname' );
|
1025 |
|
1026 |
public static function get_ig_es_meta_info() {
|
1027 |
|
1028 |
+
$total_contacts = ES()->contacts_db->count();
|
1029 |
$total_lists = ES()->lists_db->count_lists();
|
1030 |
$total_newsletters = ES()->campaigns_db->get_total_newsletters();
|
1031 |
$total_post_notifications = ES()->campaigns_db->get_total_post_notifications;
|
1187 |
$can_access = $user->has_cap( $default_permission );
|
1188 |
|
1189 |
// Is Admin? Have full access
|
1190 |
+
if ( $can_access ) {
|
1191 |
+
return true;
|
1192 |
+
}
|
1193 |
|
1194 |
// We are using this filter in ES Premium to check permission
|
1195 |
return apply_filters( 'ig_es_can_access', $can_access, $page );
|
1234 |
// We are using this in ES Premium
|
1235 |
$sub_menus = apply_filters( 'ig_es_accessible_sub_menus', $sub_menus );
|
1236 |
|
1237 |
+
return array_unique( $sub_menus );
|
1238 |
+
}
|
1239 |
+
|
1240 |
+
/**
|
1241 |
+
* Generate Hash
|
1242 |
+
*
|
1243 |
+
* @param $length
|
1244 |
+
*
|
1245 |
+
* @return false|string
|
1246 |
+
*
|
1247 |
+
* @since 4.2.4
|
1248 |
+
*/
|
1249 |
+
public static function generate_hash( $length ) {
|
1250 |
+
|
1251 |
+
$length = ( $length ) ? $length : 12;
|
1252 |
+
$auth_key = '';
|
1253 |
+
if ( defined( 'AUTH_KEY' ) ) {
|
1254 |
+
$auth_key = AUTH_KEY;
|
1255 |
+
}
|
1256 |
+
|
1257 |
+
return substr( md5( $auth_key . wp_rand( $length, 64 ) ), 0, $length );
|
1258 |
}
|
1259 |
|
1260 |
}
|
includes/class-es-install.php
CHANGED
@@ -141,6 +141,12 @@ class ES_Install {
|
|
141 |
'ig_es_update_421_drop_tables',
|
142 |
'ig_es_update_421_create_tables',
|
143 |
'ig_es_update_421_db_version'
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
)
|
145 |
|
146 |
);
|
@@ -843,20 +849,7 @@ class ES_Install {
|
|
843 |
KEY `contact_id` (contact_id),
|
844 |
KEY `meta_ley` (meta_key)
|
845 |
) $collate;
|
846 |
-
|
847 |
-
CREATE TABLE `{$wpdb->prefix}ig_links` (
|
848 |
-
`id` int(10) NOT NULL AUTO_INCREMENT,
|
849 |
-
`message_id` int(10) unsigned NOT NULL,
|
850 |
-
`campaign_id` int(10) unsigned NOT NULL,
|
851 |
-
`link` varchar(2083) NOT NULL,
|
852 |
-
`hash` varchar(20) NOT NULL,
|
853 |
-
`created_at` datetime DEFAULT NULL,
|
854 |
-
PRIMARY KEY (id),
|
855 |
-
KEY `campaign_id` (campaign_id),
|
856 |
-
KEY `message_id` (message_id),
|
857 |
-
KEY `link` (link(100))
|
858 |
-
) $collate;
|
859 |
-
";
|
860 |
|
861 |
return $tables;
|
862 |
}
|
@@ -933,11 +926,54 @@ class ES_Install {
|
|
933 |
return $tables;
|
934 |
}
|
935 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
936 |
private static function get_schema() {
|
937 |
|
938 |
$tables = self::get_ig_es_400_schema();
|
939 |
$tables .= self::get_ig_es_420_schema();
|
940 |
$tables .= self::get_ig_es_421_schema();
|
|
|
941 |
|
942 |
return $tables;
|
943 |
}
|
@@ -971,7 +1007,7 @@ class ES_Install {
|
|
971 |
'created_at' => ig_get_current_date_time()
|
972 |
);
|
973 |
|
974 |
-
$contact_id =
|
975 |
|
976 |
if ( $contact_id ) {
|
977 |
$data = array(
|
@@ -1066,7 +1102,7 @@ class ES_Install {
|
|
1066 |
|
1067 |
$campaign_id = ES()->campaigns_db->save_campaign( $data );
|
1068 |
|
1069 |
-
$subscribers =
|
1070 |
if ( ! empty( $subscribers ) && count( $subscribers ) > 0 ) {
|
1071 |
$guid = ES_Common::generate_guid( 6 );
|
1072 |
$now = ig_get_current_date_time();
|
@@ -1179,7 +1215,7 @@ class ES_Install {
|
|
1179 |
|
1180 |
$campaign_id = ES()->campaigns_db->save_campaign( $data );
|
1181 |
|
1182 |
-
$subscribers =
|
1183 |
if ( ! empty( $subscribers ) && count( $subscribers ) > 0 ) {
|
1184 |
|
1185 |
$args = array( 'posts_per_page' => 1 );
|
141 |
'ig_es_update_421_drop_tables',
|
142 |
'ig_es_update_421_create_tables',
|
143 |
'ig_es_update_421_db_version'
|
144 |
+
),
|
145 |
+
|
146 |
+
'4.2.4' => array(
|
147 |
+
'ig_es_update_424_drop_tables',
|
148 |
+
'ig_es_update_424_create_tables',
|
149 |
+
'ig_es_update_424_db_version'
|
150 |
)
|
151 |
|
152 |
);
|
849 |
KEY `contact_id` (contact_id),
|
850 |
KEY `meta_ley` (meta_key)
|
851 |
) $collate;
|
852 |
+
";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
853 |
|
854 |
return $tables;
|
855 |
}
|
926 |
return $tables;
|
927 |
}
|
928 |
|
929 |
+
/**
|
930 |
+
* Create Links Table
|
931 |
+
*
|
932 |
+
* @return string
|
933 |
+
*
|
934 |
+
* @sinc 4.2.4
|
935 |
+
*/
|
936 |
+
public static function get_ig_es_424_schema() {
|
937 |
+
|
938 |
+
global $wpdb;
|
939 |
+
|
940 |
+
$collate = '';
|
941 |
+
|
942 |
+
if ( $wpdb->has_cap( 'collation' ) ) {
|
943 |
+
$collate = $wpdb->get_charset_collate();
|
944 |
+
}
|
945 |
+
|
946 |
+
$tables = "CREATE TABLE `{$wpdb->prefix}ig_links` (
|
947 |
+
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
948 |
+
`message_id` int(10) unsigned NOT NULL,
|
949 |
+
`campaign_id` int(10) unsigned NOT NULL,
|
950 |
+
`link` varchar(2083) NOT NULL,
|
951 |
+
`hash` varchar(20) NOT NULL,
|
952 |
+
`i` tinyint(1) unsigned NOT NULL,
|
953 |
+
`created_at` datetime DEFAULT NULL,
|
954 |
+
PRIMARY KEY (id),
|
955 |
+
KEY `campaign_id` (campaign_id),
|
956 |
+
KEY `message_id` (message_id),
|
957 |
+
KEY `link` (link(100))
|
958 |
+
) $collate;
|
959 |
+
";
|
960 |
+
|
961 |
+
return $tables;
|
962 |
+
}
|
963 |
+
|
964 |
+
/**
|
965 |
+
* Collect multiple version table schema
|
966 |
+
*
|
967 |
+
* @return string
|
968 |
+
*
|
969 |
+
* @since 4.2.0
|
970 |
+
*/
|
971 |
private static function get_schema() {
|
972 |
|
973 |
$tables = self::get_ig_es_400_schema();
|
974 |
$tables .= self::get_ig_es_420_schema();
|
975 |
$tables .= self::get_ig_es_421_schema();
|
976 |
+
$tables .= self::get_ig_es_424_schema();
|
977 |
|
978 |
return $tables;
|
979 |
}
|
1007 |
'created_at' => ig_get_current_date_time()
|
1008 |
);
|
1009 |
|
1010 |
+
$contact_id = ES()->contacts_db->insert( $data );
|
1011 |
|
1012 |
if ( $contact_id ) {
|
1013 |
$data = array(
|
1102 |
|
1103 |
$campaign_id = ES()->campaigns_db->save_campaign( $data );
|
1104 |
|
1105 |
+
$subscribers = ES()->contacts_db->get_active_contacts_by_list_id( $list_id );
|
1106 |
if ( ! empty( $subscribers ) && count( $subscribers ) > 0 ) {
|
1107 |
$guid = ES_Common::generate_guid( 6 );
|
1108 |
$now = ig_get_current_date_time();
|
1215 |
|
1216 |
$campaign_id = ES()->campaigns_db->save_campaign( $data );
|
1217 |
|
1218 |
+
$subscribers = ES()->contacts_db->get_active_contacts_by_list_id( $list_id );
|
1219 |
if ( ! empty( $subscribers ) && count( $subscribers ) > 0 ) {
|
1220 |
|
1221 |
$args = array( 'posts_per_page' => 1 );
|
includes/class-es-mailer.php
CHANGED
@@ -30,7 +30,7 @@ class ES_Mailer {
|
|
30 |
|
31 |
$emails = array_map( "temp_fun", $mails );
|
32 |
|
33 |
-
$emails_name_map =
|
34 |
|
35 |
foreach ( $mails as $mail ) {
|
36 |
$email = $mail['email'];
|
@@ -53,9 +53,9 @@ class ES_Mailer {
|
|
53 |
'campaign_id' => $notification['campaign_id']
|
54 |
);
|
55 |
|
|
|
56 |
// Preparing email body
|
57 |
$body = self::prepare_email_template( $content, $keywords );
|
58 |
-
//add links
|
59 |
|
60 |
$send = self::send( $email, $subject, $body );
|
61 |
|
@@ -124,7 +124,7 @@ class ES_Mailer {
|
|
124 |
public static function prepare_welcome_email( $data ) {
|
125 |
|
126 |
$blog_name = get_option( 'blogname' );
|
127 |
-
$total_contacts =
|
128 |
$content = stripslashes( get_option( 'ig_es_welcome_email_content', '' ) );
|
129 |
|
130 |
$name = isset( $data['name'] ) ? $data['name'] : '';
|
@@ -133,7 +133,7 @@ class ES_Mailer {
|
|
133 |
$email = isset( $data['email'] ) ? $data['email'] : '';
|
134 |
$list_name = isset( $data['list_name'] ) ? $data['list_name'] : '';
|
135 |
$db_id = isset( $data['db_id'] ) ? $data['db_id'] : '';
|
136 |
-
$guid =
|
137 |
// $guid = isset( $data['guid'] ) ? $data['guid'] : '';
|
138 |
$guid = ! empty( $guid ) ? $guid : '';
|
139 |
|
@@ -166,12 +166,12 @@ class ES_Mailer {
|
|
166 |
public static function prepare_double_optin_email( $data ) {
|
167 |
|
168 |
$blog_name = get_option( 'blogname' );
|
169 |
-
$total_contacts =
|
170 |
$content = stripslashes( get_option( 'ig_es_confirmation_mail_content', '' ) );
|
171 |
|
172 |
|
173 |
$db_id = isset( $data['db_id'] ) ? $data['db_id'] : '';
|
174 |
-
$guid =
|
175 |
// $guid = isset( $data['guid'] ) ? $data['guid'] : '';
|
176 |
$guid = ! empty( $guid ) ? $guid : '';
|
177 |
$email = isset( $data['email'] ) ? $data['email'] : '';
|
@@ -212,7 +212,7 @@ class ES_Mailer {
|
|
212 |
$hash = isset( $keywords['hash'] ) ? $keywords['hash'] : '';
|
213 |
|
214 |
if ( empty( $hash ) ) {
|
215 |
-
$hash =
|
216 |
}
|
217 |
|
218 |
$template_content = str_replace( "{{NAME}}", $name, $template_content );
|
@@ -227,23 +227,35 @@ class ES_Mailer {
|
|
227 |
$template_content = wpautop( $template_content );
|
228 |
|
229 |
$template_content = do_shortcode( shortcode_unautop( $template_content ) );
|
|
|
|
|
|
|
|
|
|
|
230 |
$data['content'] = $template_content;
|
231 |
$data['tmpl_id'] = $template_id;
|
232 |
$data = apply_filters( 'es_after_process_template_body', $data );
|
233 |
$template_content = $data['content'];
|
234 |
|
235 |
-
|
236 |
$link_data = array(
|
237 |
-
'
|
238 |
-
'
|
239 |
-
'campaign_id' => ! empty( $keywords['campaign_id'] ) ? $keywords['campaign_id'] : 0,
|
240 |
'contact_id' => $contact_id,
|
241 |
'email' => $email,
|
242 |
'guid' => $hash
|
243 |
);
|
244 |
|
245 |
-
$
|
246 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
|
248 |
$is_track_email_opens = get_option( 'ig_es_track_email_opens', 'yes' );
|
249 |
|
@@ -276,7 +288,7 @@ class ES_Mailer {
|
|
276 |
*/
|
277 |
public static function prepare_link( $data = array() ) {
|
278 |
/**
|
279 |
-
* We are getting different data like action, message_id, campaign_id contact_id, guid, email etc in $data
|
280 |
*/
|
281 |
$action = ! empty( $data['action'] ) ? $data['action'] : '';
|
282 |
|
@@ -464,4 +476,73 @@ class ES_Mailer {
|
|
464 |
}
|
465 |
|
466 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
467 |
}
|
30 |
|
31 |
$emails = array_map( "temp_fun", $mails );
|
32 |
|
33 |
+
$emails_name_map = ES()->contacts_db->get_contacts_email_name_map( $emails );
|
34 |
|
35 |
foreach ( $mails as $mail ) {
|
36 |
$email = $mail['email'];
|
53 |
'campaign_id' => $notification['campaign_id']
|
54 |
);
|
55 |
|
56 |
+
|
57 |
// Preparing email body
|
58 |
$body = self::prepare_email_template( $content, $keywords );
|
|
|
59 |
|
60 |
$send = self::send( $email, $subject, $body );
|
61 |
|
124 |
public static function prepare_welcome_email( $data ) {
|
125 |
|
126 |
$blog_name = get_option( 'blogname' );
|
127 |
+
$total_contacts = ES()->contacts_db->count_active_contacts_by_list_id();
|
128 |
$content = stripslashes( get_option( 'ig_es_welcome_email_content', '' ) );
|
129 |
|
130 |
$name = isset( $data['name'] ) ? $data['name'] : '';
|
133 |
$email = isset( $data['email'] ) ? $data['email'] : '';
|
134 |
$list_name = isset( $data['list_name'] ) ? $data['list_name'] : '';
|
135 |
$db_id = isset( $data['db_id'] ) ? $data['db_id'] : '';
|
136 |
+
$guid = ES()->contacts_db->get_contact_hash_by_id( $db_id );
|
137 |
// $guid = isset( $data['guid'] ) ? $data['guid'] : '';
|
138 |
$guid = ! empty( $guid ) ? $guid : '';
|
139 |
|
166 |
public static function prepare_double_optin_email( $data ) {
|
167 |
|
168 |
$blog_name = get_option( 'blogname' );
|
169 |
+
$total_contacts = ES()->contacts_db->count_active_contacts_by_list_id();
|
170 |
$content = stripslashes( get_option( 'ig_es_confirmation_mail_content', '' ) );
|
171 |
|
172 |
|
173 |
$db_id = isset( $data['db_id'] ) ? $data['db_id'] : '';
|
174 |
+
$guid = ES()->contacts_db->get_contact_hash_by_id( $db_id );
|
175 |
// $guid = isset( $data['guid'] ) ? $data['guid'] : '';
|
176 |
$guid = ! empty( $guid ) ? $guid : '';
|
177 |
$email = isset( $data['email'] ) ? $data['email'] : '';
|
212 |
$hash = isset( $keywords['hash'] ) ? $keywords['hash'] : '';
|
213 |
|
214 |
if ( empty( $hash ) ) {
|
215 |
+
$hash = ES()->contacts_db->get_contact_hash_by_id( $contact_id );
|
216 |
}
|
217 |
|
218 |
$template_content = str_replace( "{{NAME}}", $name, $template_content );
|
227 |
$template_content = wpautop( $template_content );
|
228 |
|
229 |
$template_content = do_shortcode( shortcode_unautop( $template_content ) );
|
230 |
+
|
231 |
+
$campaign_id = ! empty( $keywords['campaign_id'] ) ? $keywords['campaign_id'] : 0;
|
232 |
+
$message_id = ! empty( $keywords['message_id'] ) ? $keywords['message_id'] : 0;
|
233 |
+
|
234 |
+
|
235 |
$data['content'] = $template_content;
|
236 |
$data['tmpl_id'] = $template_id;
|
237 |
$data = apply_filters( 'es_after_process_template_body', $data );
|
238 |
$template_content = $data['content'];
|
239 |
|
|
|
240 |
$link_data = array(
|
241 |
+
'message_id' => $message_id,
|
242 |
+
'campaign_id' => $campaign_id,
|
|
|
243 |
'contact_id' => $contact_id,
|
244 |
'email' => $email,
|
245 |
'guid' => $hash
|
246 |
);
|
247 |
|
248 |
+
$is_track_clicks = false;
|
249 |
+
$is_track_clicks = apply_filters( 'ig_es_track_clicks', $is_track_clicks, $contact_id, $campaign_id );
|
250 |
+
if ( $is_track_clicks ) {
|
251 |
+
$link_data['action'] = 'click';
|
252 |
+
$template_content = self::replace_links( $template_content, $link_data );
|
253 |
+
}
|
254 |
+
|
255 |
+
|
256 |
+
$link_data['action'] = 'unsubscribe';
|
257 |
+
$unsubscribe_link = self::prepare_link( $link_data );
|
258 |
+
$unsubtext = self::get_unsubscribe_text( $unsubscribe_link );
|
259 |
|
260 |
$is_track_email_opens = get_option( 'ig_es_track_email_opens', 'yes' );
|
261 |
|
288 |
*/
|
289 |
public static function prepare_link( $data = array() ) {
|
290 |
/**
|
291 |
+
* We are getting different data like action, message_id, campaign_id, contact_id, guid, email etc in $data
|
292 |
*/
|
293 |
$action = ! empty( $data['action'] ) ? $data['action'] : '';
|
294 |
|
476 |
}
|
477 |
|
478 |
}
|
479 |
+
|
480 |
+
/**
|
481 |
+
* Replace links with tracking link
|
482 |
+
*
|
483 |
+
* @param $content
|
484 |
+
* @param $data
|
485 |
+
*
|
486 |
+
* @return string|string[]|null
|
487 |
+
*
|
488 |
+
* @since 4.2.4
|
489 |
+
*/
|
490 |
+
public static function replace_links( $content, $data ) {
|
491 |
+
|
492 |
+
// get all links from the basecontent
|
493 |
+
preg_match_all( '# href=(\'|")?(https?[^\'"]+)(\'|")?#', $content, $links );
|
494 |
+
$links = $links[2];
|
495 |
+
|
496 |
+
if ( empty( $links ) ) {
|
497 |
+
return $content;
|
498 |
+
}
|
499 |
+
|
500 |
+
$inserted_links = array();
|
501 |
+
|
502 |
+
$campaign_id = ! empty( $data['campaign_id'] ) ? $data['campaign_id'] : 0;
|
503 |
+
$message_id = ! empty( $data['message_id'] ) ? $data['message_id'] : 0;
|
504 |
+
|
505 |
+
foreach ( $links as $link ) {
|
506 |
+
|
507 |
+
if ( ! isset( $inserted_links[ $link ] ) ) {
|
508 |
+
$index = 0;
|
509 |
+
} else {
|
510 |
+
$index = $inserted_links[ $link ] + 1;
|
511 |
+
}
|
512 |
+
|
513 |
+
$inserted_links[ $link ] = $index;
|
514 |
+
$result = ES()->links_db->get_link_by_campaign_id( $link, $campaign_id, $message_id, $index );
|
515 |
+
|
516 |
+
if ( is_array( $result ) && count( $result ) > 0 ) {
|
517 |
+
$hash = $result[0]['hash'];
|
518 |
+
} else {
|
519 |
+
|
520 |
+
$hash = ES_Common::generate_hash( 12 );
|
521 |
+
|
522 |
+
$link_data = array(
|
523 |
+
'link' => $link,
|
524 |
+
'message_id' => $message_id,
|
525 |
+
'campaign_id' => $campaign_id,
|
526 |
+
'hash' => $hash,
|
527 |
+
'i' => $index
|
528 |
+
);
|
529 |
+
|
530 |
+
$insert = ES()->links_db->insert( $link_data );
|
531 |
+
}
|
532 |
+
|
533 |
+
$data['link_hash'] = $hash;
|
534 |
+
|
535 |
+
$new_link = self::prepare_link( $data );
|
536 |
+
|
537 |
+
$link = ' href="' . $link . '"';
|
538 |
+
$new_link = ' href="' . $new_link . '"';
|
539 |
+
|
540 |
+
if ( ( $pos = strpos( $content, $link ) ) !== false ) {
|
541 |
+
$content = preg_replace( '/' . preg_quote( $link, '/' ) . '/', $new_link, $content, 1 );
|
542 |
+
}
|
543 |
+
}
|
544 |
+
|
545 |
+
return $content;
|
546 |
+
}
|
547 |
+
|
548 |
}
|
includes/db/class-es-db-actions.php
CHANGED
@@ -34,8 +34,6 @@ class ES_DB_Actions extends ES_DB {
|
|
34 |
|
35 |
$this->table_name = $wpdb->prefix . 'ig_actions';
|
36 |
|
37 |
-
$this->primary_key = 'id';
|
38 |
-
|
39 |
$this->version = '1.0';
|
40 |
|
41 |
}
|
@@ -49,12 +47,15 @@ class ES_DB_Actions extends ES_DB {
|
|
49 |
*/
|
50 |
public function get_columns() {
|
51 |
return array(
|
52 |
-
'
|
53 |
-
'
|
54 |
-
'
|
55 |
-
'
|
56 |
-
'
|
57 |
-
'
|
|
|
|
|
|
|
58 |
);
|
59 |
}
|
60 |
|
@@ -65,11 +66,53 @@ class ES_DB_Actions extends ES_DB {
|
|
65 |
*/
|
66 |
public function get_column_defaults() {
|
67 |
return array(
|
68 |
-
'
|
69 |
-
'
|
70 |
-
'
|
71 |
-
'
|
72 |
-
'
|
|
|
|
|
|
|
|
|
73 |
);
|
74 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
}
|
34 |
|
35 |
$this->table_name = $wpdb->prefix . 'ig_actions';
|
36 |
|
|
|
|
|
37 |
$this->version = '1.0';
|
38 |
|
39 |
}
|
47 |
*/
|
48 |
public function get_columns() {
|
49 |
return array(
|
50 |
+
'contact_id' => '%d',
|
51 |
+
'message_id' => '%d',
|
52 |
+
'campaign_id' => '%d',
|
53 |
+
'type' => '%d',
|
54 |
+
'count' => '%d',
|
55 |
+
'link_id' => '%d',
|
56 |
+
'list_id' => '%d',
|
57 |
+
'created_at' => '%d',
|
58 |
+
'updated_at' => '%d'
|
59 |
);
|
60 |
}
|
61 |
|
66 |
*/
|
67 |
public function get_column_defaults() {
|
68 |
return array(
|
69 |
+
'contact_id' => null,
|
70 |
+
'message_id' => null,
|
71 |
+
'campaign_id' => null,
|
72 |
+
'type' => 0,
|
73 |
+
'count' => 0,
|
74 |
+
'link_id' => 0,
|
75 |
+
'list_id' => 0,
|
76 |
+
'created_at' => ig_es_get_current_gmt_timestamp(),
|
77 |
+
'updated_at' => ig_es_get_current_gmt_timestamp()
|
78 |
);
|
79 |
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Track action
|
83 |
+
*
|
84 |
+
* @param $args
|
85 |
+
* @param bool $explicit
|
86 |
+
*
|
87 |
+
* @return bool
|
88 |
+
*
|
89 |
+
* @since 4.2.4
|
90 |
+
*/
|
91 |
+
public function add( $args, $explicit = true ) {
|
92 |
+
|
93 |
+
global $wpdb;
|
94 |
+
|
95 |
+
$ig_actions_table = IG_ACTIONS_TABLE;
|
96 |
+
|
97 |
+
$args_keys = array_keys( $args );
|
98 |
+
$args_keys_str = $this->array_to_str( $args_keys );
|
99 |
+
|
100 |
+
$sql = "INSERT INTO $ig_actions_table ($args_keys_str)";
|
101 |
+
|
102 |
+
$args_values = array_values( $args );
|
103 |
+
|
104 |
+
$args_values_str = $this->array_to_str( $args_values, "', '" );
|
105 |
+
|
106 |
+
$sql .= " VALUES ('{$args_values_str}') ON DUPLICATE KEY UPDATE";
|
107 |
+
|
108 |
+
$sql .= ( $explicit ) ? $wpdb->prepare( " created_at = created_at, count = count+1, updated_at = %d", ig_es_get_current_gmt_timestamp() ) : ' count = values(count)';
|
109 |
+
|
110 |
+
$result = $wpdb->query( $sql );
|
111 |
+
|
112 |
+
if ( false !== $result ) {
|
113 |
+
return true;
|
114 |
+
}
|
115 |
+
|
116 |
+
return false;
|
117 |
+
}
|
118 |
}
|
includes/db/class-es-db-campaigns.php
CHANGED
@@ -179,7 +179,7 @@ class ES_DB_Campaigns extends ES_DB {
|
|
179 |
* @modify 4.2.1
|
180 |
*/
|
181 |
public function get_campaign_type_by_id( $id ) {
|
182 |
-
return $this->
|
183 |
}
|
184 |
|
185 |
/**
|
179 |
* @modify 4.2.1
|
180 |
*/
|
181 |
public function get_campaign_type_by_id( $id ) {
|
182 |
+
return $this->get_column( 'type', $id );
|
183 |
}
|
184 |
|
185 |
/**
|
includes/db/class-es-db-contacts.php
CHANGED
@@ -1,17 +1,55 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
// Exit if accessed directly
|
4 |
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
exit;
|
6 |
}
|
7 |
|
8 |
-
class ES_DB_Contacts {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
|
|
|
|
|
|
|
|
|
|
10 |
public function __construct() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
}
|
13 |
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
return array(
|
16 |
'id' => '%d',
|
17 |
'wp_user_id' => '%d',
|
@@ -38,9 +76,9 @@ class ES_DB_Contacts {
|
|
38 |
/**
|
39 |
* Get default column values
|
40 |
*
|
41 |
-
* @since
|
42 |
*/
|
43 |
-
public
|
44 |
return array(
|
45 |
'wp_user_id' => 0,
|
46 |
'first_name' => '',
|
@@ -63,17 +101,29 @@ class ES_DB_Contacts {
|
|
63 |
);
|
64 |
}
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
74 |
}
|
75 |
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
global $wpdb;
|
79 |
|
@@ -85,12 +135,15 @@ class ES_DB_Contacts {
|
|
85 |
|
86 |
$emails = array_map( "temp", $emails );
|
87 |
|
88 |
-
$
|
89 |
-
|
|
|
|
|
90 |
|
91 |
if ( count( $subscribers ) > 0 ) {
|
92 |
foreach ( $subscribers as $subscriber ) {
|
93 |
-
$name
|
|
|
94 |
$subscriber_email_name_map[ $subscriber['email'] ] = array(
|
95 |
'name' => $name,
|
96 |
'first_name' => $subscriber['first_name'],
|
@@ -104,58 +157,76 @@ class ES_DB_Contacts {
|
|
104 |
|
105 |
}
|
106 |
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
if ( ! empty( $id ) ) {
|
111 |
-
|
112 |
-
$ig_contacts_table = IG_CONTACTS_TABLE;
|
113 |
-
$query = "SELECT hash FROM {$ig_contacts_table} WHERE id = %d";
|
114 |
-
$sql = $wpdb->prepare( $query, $id );
|
115 |
-
$contact_hash = $wpdb->get_col( $sql );
|
116 |
-
|
117 |
-
if ( ! empty( $contact_hash ) ) {
|
118 |
-
return $contact_hash[0];
|
119 |
-
}
|
120 |
}
|
121 |
|
122 |
return '';
|
|
|
123 |
}
|
124 |
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
global $wpdb;
|
127 |
|
128 |
-
|
129 |
-
$sql = $wpdb->prepare( $query, $id, $email );
|
130 |
-
$contact_count = $wpdb->get_results( $sql, ARRAY_A );
|
131 |
|
132 |
-
|
133 |
-
|
134 |
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
if ( ! empty( $email ) ) {
|
139 |
-
$sql .= "AND `email` LIKE '%{$email}%'";
|
140 |
}
|
141 |
|
142 |
-
|
143 |
-
|
144 |
-
return $subscriber;
|
145 |
-
|
146 |
}
|
147 |
|
148 |
/**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
*/
|
150 |
-
public
|
|
|
|
|
|
|
|
|
151 |
|
152 |
global $wpdb;
|
153 |
|
154 |
-
$
|
155 |
-
$sql = $wpdb->prepare( $query, $list_id );
|
156 |
-
$subscribers = $wpdb->get_results( $sql, ARRAY_A );
|
157 |
|
158 |
-
|
|
|
|
|
159 |
|
160 |
}
|
161 |
|
@@ -167,29 +238,40 @@ class ES_DB_Contacts {
|
|
167 |
* @return array|object|null
|
168 |
*
|
169 |
* @since 4.2.1
|
|
|
|
|
170 |
*/
|
171 |
-
public
|
172 |
-
|
173 |
-
global $wpdb;
|
174 |
-
|
175 |
-
$contacts_table = IG_CONTACTS_TABLE;
|
176 |
|
177 |
-
|
|
|
|
|
178 |
|
179 |
-
$
|
180 |
-
$subscribers = $wpdb->get_results( $query, ARRAY_A );
|
181 |
|
182 |
-
|
183 |
|
|
|
184 |
}
|
185 |
|
186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
global $wpdb;
|
189 |
|
190 |
-
$
|
191 |
|
192 |
-
|
|
|
|
|
193 |
$query .= ' AND list_id = %d';
|
194 |
$query = $wpdb->prepare( $query, $list_id );
|
195 |
}
|
@@ -200,47 +282,56 @@ class ES_DB_Contacts {
|
|
200 |
|
201 |
}
|
202 |
|
203 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
global $wpdb;
|
205 |
|
206 |
-
$
|
207 |
-
$active_subscribers = $wpdb->get_var( $query );
|
208 |
|
209 |
-
|
210 |
-
}
|
211 |
|
212 |
-
|
213 |
-
|
214 |
|
215 |
-
$
|
216 |
-
$insert = $wpdb->insert( IG_CONTACTS_TABLE, $data );
|
217 |
|
218 |
-
|
219 |
-
return $wpdb->insert_id;
|
220 |
-
}
|
221 |
|
222 |
-
return
|
223 |
}
|
224 |
|
225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
global $wpdb;
|
227 |
-
$ids = implode( ',', array_map( 'absint', $ids ) );
|
228 |
-
$query = "DELETE FROM " . IG_CONTACTS_TABLE . " WHERE id IN ($ids)";
|
229 |
-
$wpdb->query( $query );
|
230 |
-
$query_2 = "DELETE FROM " . IG_LISTS_CONTACTS_TABLE . " WHERE contact_id IN ($ids)";
|
231 |
|
232 |
-
|
233 |
-
}
|
234 |
|
235 |
-
|
236 |
-
|
|
|
237 |
|
238 |
-
$ids_str = implode( ',', array_map( 'absint', $ids ) );
|
239 |
//delete all list contact entry
|
240 |
-
$
|
241 |
-
$wpdb->query( $
|
242 |
|
243 |
-
$values = array();
|
244 |
$optin_type_option = get_option( 'ig_es_optin_type', true );
|
245 |
$optin_type = 1;
|
246 |
if ( in_array( $optin_type_option, array( 'double_opt_in', 'double_optin' ) ) ) {
|
@@ -252,8 +343,9 @@ class ES_DB_Contacts {
|
|
252 |
array_push( $values, $list_id, $contact_id, 'subscribed', $optin_type, $subscribed_at, $subscribed_ip );
|
253 |
$place_holders[] = "( %d, %d, %s, %s, %s, %s )"; /* In my case, i know they will always be integers */
|
254 |
}
|
255 |
-
|
256 |
-
$query
|
|
|
257 |
$sql = $wpdb->prepare( "$query ", $values );
|
258 |
if ( $wpdb->query( $sql ) ) {
|
259 |
return true;
|
@@ -262,16 +354,30 @@ class ES_DB_Contacts {
|
|
262 |
}
|
263 |
}
|
264 |
|
265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
global $wpdb;
|
267 |
|
268 |
-
$
|
|
|
|
|
|
|
|
|
269 |
|
270 |
-
$delete_list_contact = "DELETE FROM
|
271 |
$del_query = $wpdb->prepare( $delete_list_contact, array( $list_id ) );
|
272 |
$wpdb->query( $del_query );
|
273 |
|
274 |
-
$values = array();
|
275 |
$optin_type_option = get_option( 'ig_es_optin_type', true );
|
276 |
$optin_type = 1;
|
277 |
if ( in_array( $optin_type_option, array( 'double_opt_in', 'double_optin' ) ) ) {
|
@@ -284,7 +390,7 @@ class ES_DB_Contacts {
|
|
284 |
$place_holders[] = "( %d, %d, %s, %s, %s, %s )"; /* In my case, i know they will always be integers */
|
285 |
}
|
286 |
$query = "INSERT INTO " . IG_LISTS_CONTACTS_TABLE . " (`list_id`, `contact_id`, `status`, `optin_type`, `subscribed_at`, `subscribed_ip` ) VALUES ";
|
287 |
-
$query .=
|
288 |
$sql = $wpdb->prepare( "$query ", $values );
|
289 |
if ( $wpdb->query( $sql ) ) {
|
290 |
return true;
|
@@ -293,49 +399,60 @@ class ES_DB_Contacts {
|
|
293 |
}
|
294 |
}
|
295 |
|
296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
297 |
global $wpdb;
|
298 |
|
299 |
-
$
|
300 |
-
|
|
|
|
|
|
|
301 |
|
302 |
-
$sql = "UPDATE
|
303 |
$query = $wpdb->prepare( $sql, array( $unsubscribed ) );
|
304 |
|
305 |
return $wpdb->query( $query );
|
306 |
|
307 |
}
|
308 |
|
309 |
-
|
310 |
/**
|
311 |
-
*
|
|
|
|
|
|
|
312 |
*
|
313 |
-
* @return
|
314 |
*/
|
315 |
-
public
|
316 |
global $wpdb;
|
317 |
|
318 |
-
$
|
319 |
|
320 |
-
|
321 |
-
}
|
322 |
-
|
323 |
-
public static function is_subscriber_exist_in_list( $email, $list_id ) {
|
324 |
-
global $wpdb;
|
325 |
-
|
326 |
-
$query = "SELECT id as contact_id FROM " . IG_CONTACTS_TABLE . " WHERE email = %s";
|
327 |
-
$sql = $wpdb->prepare( $query, $email );
|
328 |
-
$contact_id = $wpdb->get_var( $sql );
|
329 |
-
$data = array();
|
330 |
if ( ! empty( $contact_id ) ) {
|
|
|
331 |
|
332 |
if ( ! is_array( $list_id ) ) {
|
333 |
$list_id = array( $list_id );
|
334 |
}
|
335 |
|
336 |
-
$
|
337 |
-
|
338 |
-
$
|
|
|
|
|
|
|
|
|
339 |
$list_contact_count = $wpdb->get_var( $list_sql );
|
340 |
if ( ! empty( $list_contact_count ) ) {
|
341 |
$data['list_id'] = true;
|
@@ -347,10 +464,19 @@ class ES_DB_Contacts {
|
|
347 |
return $data;
|
348 |
}
|
349 |
|
350 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
351 |
global $wpdb;
|
352 |
|
353 |
-
$
|
|
|
|
|
354 |
$contacts = $wpdb->get_results( $query, ARRAY_A );
|
355 |
$details = array();
|
356 |
if ( count( $contacts ) > 0 ) {
|
@@ -372,10 +498,12 @@ class ES_DB_Contacts {
|
|
372 |
* @return array
|
373 |
*
|
374 |
* @since 4.2.1
|
|
|
|
|
375 |
*/
|
376 |
-
public
|
377 |
|
378 |
-
$contacts =
|
379 |
|
380 |
$results = array();
|
381 |
if ( ! empty( $contacts ) && count( $contacts ) > 0 ) {
|
@@ -388,14 +516,25 @@ class ES_DB_Contacts {
|
|
388 |
return $results;
|
389 |
}
|
390 |
|
391 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
global $wpdb;
|
393 |
|
394 |
-
$
|
|
|
|
|
395 |
|
396 |
if ( count( $emails ) > 0 ) {
|
397 |
-
$emails_str =
|
398 |
-
$query .= " WHERE email IN (
|
399 |
}
|
400 |
|
401 |
$ids = $wpdb->get_col( $query );
|
@@ -403,17 +542,29 @@ class ES_DB_Contacts {
|
|
403 |
return $ids;
|
404 |
}
|
405 |
|
406 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
global $wpdb;
|
408 |
|
409 |
-
$
|
|
|
|
|
410 |
|
411 |
if ( count( $emails ) > 0 ) {
|
412 |
-
$emails_str =
|
413 |
-
$query .= " WHERE email IN (
|
414 |
}
|
415 |
$results = $wpdb->get_results( $query, ARRAY_A );
|
416 |
-
|
|
|
417 |
if ( count( $results ) > 0 ) {
|
418 |
foreach ( $results as $result ) {
|
419 |
$map[ $result['email'] ] = $result['id'];
|
@@ -424,19 +575,26 @@ class ES_DB_Contacts {
|
|
424 |
|
425 |
}
|
426 |
|
427 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
428 |
|
429 |
// Prepare a batch of 50 contacts.
|
430 |
$batches = array_chunk( $contacts, 50 );
|
431 |
|
432 |
-
$columns =
|
433 |
unset( $columns['id'] );
|
434 |
$fields = array_keys( $columns );
|
435 |
foreach ( $batches as $batch ) {
|
436 |
$values = $place_holders = array();
|
437 |
foreach ( $batch as $key => $contact ) {
|
438 |
|
439 |
-
$contact = wp_parse_args( $contact,
|
440 |
|
441 |
$formats = array();
|
442 |
foreach ( $columns as $column => $format ) {
|
@@ -451,62 +609,53 @@ class ES_DB_Contacts {
|
|
451 |
}
|
452 |
}
|
453 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
$contacts_table = IG_CONTACTS_TABLE;
|
459 |
-
$query = "INSERT INTO {$contacts_table} (`wp_user_id`, `first_name`, `last_name`, `email`, `source`, `form_id`, `status`, `unsubscribed`, `hash`, `created_at`, `updated_at` ) VALUES ";
|
460 |
-
$query .= implode( ', ', $place_holders );
|
461 |
-
$sql = $wpdb->prepare( "$query ", $values );
|
462 |
-
|
463 |
-
if ( $wpdb->query( $sql ) ) {
|
464 |
-
return true;
|
465 |
-
} else {
|
466 |
-
return false;
|
467 |
}
|
468 |
|
|
|
469 |
}
|
470 |
|
471 |
-
|
|
|
|
|
|
|
|
|
|
|
472 |
global $wpdb;
|
473 |
|
474 |
-
$
|
475 |
-
$contact = $wpdb->get_var( $wpdb->prepare( $query, $email ) );
|
476 |
-
|
477 |
-
if ( $contact ) {
|
478 |
-
return $contact;
|
479 |
-
}
|
480 |
-
|
481 |
-
return null;
|
482 |
-
|
483 |
-
}
|
484 |
-
|
485 |
-
public static function migrate_subscribers_from_older_version() {
|
486 |
-
global $wpdb;
|
487 |
//Get Total count of subscribers
|
488 |
-
$query = "SELECT count(*) as total FROM "
|
489 |
$total = $wpdb->get_var( $query );
|
490 |
|
491 |
// If we have subscribers?
|
492 |
if ( $total > 0 ) {
|
493 |
|
494 |
-
// Get all existing
|
495 |
-
$
|
496 |
-
$emails = $wpdb->get_col( $query );
|
497 |
if ( ! is_array( $emails ) ) {
|
498 |
$emails = array();
|
499 |
}
|
500 |
|
501 |
// Import subscribers into batch of 100
|
502 |
$batch_size = IG_DEFAULT_BATCH_SIZE;
|
503 |
-
$
|
504 |
$lists_contacts = array();
|
505 |
//$exclude_status = array( 'Unsubscribed', 'Unconfirmed' );
|
506 |
$j = 0;
|
507 |
-
for ( $i = 0; $i < $
|
508 |
$batch_start = $i * $batch_size;
|
509 |
-
$query = "SELECT * FROM
|
510 |
$results = $wpdb->get_results( $query, ARRAY_A );
|
511 |
if ( count( $results ) > 0 ) {
|
512 |
$contacts = array();
|
@@ -552,7 +701,7 @@ class ES_DB_Contacts {
|
|
552 |
//}
|
553 |
}
|
554 |
|
555 |
-
|
556 |
}
|
557 |
|
558 |
}
|
@@ -580,22 +729,27 @@ class ES_DB_Contacts {
|
|
580 |
*
|
581 |
* @since 4.2.0
|
582 |
*/
|
583 |
-
public
|
584 |
global $wpdb;
|
585 |
|
586 |
-
$ids =
|
587 |
-
$
|
|
|
|
|
|
|
588 |
|
589 |
$current_date = ig_get_current_date_time();
|
590 |
|
|
|
|
|
591 |
if ( 'subscribed' === $status ) {
|
592 |
-
$sql = "UPDATE
|
593 |
$query = $wpdb->prepare( $sql, array( $status, $current_date ) );
|
594 |
} elseif ( 'unsubscribed' === $status ) {
|
595 |
-
$sql = "UPDATE
|
596 |
$query = $wpdb->prepare( $sql, array( $status, $current_date ) );
|
597 |
} elseif ( 'unconfirmed' === $status ) {
|
598 |
-
$sql = "UPDATE
|
599 |
$query = $wpdb->prepare( $sql, array( $status, IG_DOUBLE_OPTIN ) );
|
600 |
}
|
601 |
|
1 |
<?php
|
|
|
2 |
// Exit if accessed directly
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
exit;
|
5 |
}
|
6 |
|
7 |
+
class ES_DB_Contacts extends ES_DB {
|
8 |
+
/**
|
9 |
+
* @since 4.2.4
|
10 |
+
* @var $table_name
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
public $table_name;
|
14 |
+
/**
|
15 |
+
* @since 4.2.4
|
16 |
+
* @var $version
|
17 |
+
*
|
18 |
+
*/
|
19 |
+
public $version;
|
20 |
+
/**
|
21 |
+
* @since 4.2.4
|
22 |
+
* @var $primary_key
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
public $primary_key;
|
26 |
|
27 |
+
/**
|
28 |
+
* ES_DB_Contacts constructor.
|
29 |
+
*
|
30 |
+
* @since 4.2.4
|
31 |
+
*/
|
32 |
public function __construct() {
|
33 |
+
global $wpdb;
|
34 |
+
|
35 |
+
parent::__construct();
|
36 |
+
|
37 |
+
$this->table_name = $wpdb->prefix . 'ig_contacts';
|
38 |
+
|
39 |
+
$this->primary_key = 'id';
|
40 |
+
|
41 |
+
$this->version = '1.0';
|
42 |
|
43 |
}
|
44 |
|
45 |
+
/**
|
46 |
+
* Get columns
|
47 |
+
*
|
48 |
+
* @return array
|
49 |
+
*
|
50 |
+
* @since 4.0.0
|
51 |
+
*/
|
52 |
+
public function get_columns() {
|
53 |
return array(
|
54 |
'id' => '%d',
|
55 |
'wp_user_id' => '%d',
|
76 |
/**
|
77 |
* Get default column values
|
78 |
*
|
79 |
+
* @since 4.0.0
|
80 |
*/
|
81 |
+
public function get_column_defaults() {
|
82 |
return array(
|
83 |
'wp_user_id' => 0,
|
84 |
'first_name' => '',
|
101 |
);
|
102 |
}
|
103 |
|
104 |
+
/**
|
105 |
+
* Get by id
|
106 |
+
*
|
107 |
+
* @param $id
|
108 |
+
*
|
109 |
+
* @return array|object|void|null
|
110 |
+
*
|
111 |
+
* @since 4.0.0
|
112 |
+
*/
|
113 |
+
public function get_by_id( $id ) {
|
114 |
+
return $this->get( $id );
|
115 |
}
|
116 |
|
117 |
+
/**
|
118 |
+
* Get contact email name map
|
119 |
+
*
|
120 |
+
* @param array $emails
|
121 |
+
*
|
122 |
+
* @return array
|
123 |
+
*
|
124 |
+
* @since 4.2.2
|
125 |
+
*/
|
126 |
+
public function get_contacts_email_name_map( $emails = array() ) {
|
127 |
|
128 |
global $wpdb;
|
129 |
|
135 |
|
136 |
$emails = array_map( "temp", $emails );
|
137 |
|
138 |
+
$ig_contacts_table = IG_CONTACTS_TABLE;
|
139 |
+
|
140 |
+
$emails_str = $this->array_to_str( $emails );
|
141 |
+
$subscribers = $wpdb->get_results( "SELECT email, first_name, last_name FROM $ig_contacts_table WHERE email IN ( " . $emails_str . ")", ARRAY_A );
|
142 |
|
143 |
if ( count( $subscribers ) > 0 ) {
|
144 |
foreach ( $subscribers as $subscriber ) {
|
145 |
+
$name = ES_Common::prepare_name_from_first_name_last_name( $subscriber['first_name'], $subscriber['last_name'] );
|
146 |
+
|
147 |
$subscriber_email_name_map[ $subscriber['email'] ] = array(
|
148 |
'name' => $name,
|
149 |
'first_name' => $subscriber['first_name'],
|
157 |
|
158 |
}
|
159 |
|
160 |
+
/**
|
161 |
+
* Get contact hash by contact id
|
162 |
+
*
|
163 |
+
* @param $id
|
164 |
+
*
|
165 |
+
* @return array|string|null
|
166 |
+
*
|
167 |
+
* @since 4.0.0
|
168 |
+
*/
|
169 |
+
public function get_contact_hash_by_id( $id ) {
|
170 |
|
171 |
if ( ! empty( $id ) ) {
|
172 |
+
return $this->get_column( 'hash', $id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
}
|
174 |
|
175 |
return '';
|
176 |
+
|
177 |
}
|
178 |
|
179 |
+
/**
|
180 |
+
* Is contacts exists based on id & email?
|
181 |
+
*
|
182 |
+
* @param string $id
|
183 |
+
* @param string $email
|
184 |
+
*
|
185 |
+
* @return bool
|
186 |
+
*
|
187 |
+
* @since 4.0.0
|
188 |
+
*
|
189 |
+
* @modify 4.2.4
|
190 |
+
*/
|
191 |
+
public function is_contact_exists( $id = '', $email = '' ) {
|
192 |
global $wpdb;
|
193 |
|
194 |
+
if ( ! empty( $id ) && ! empty( $email ) ) {
|
|
|
|
|
195 |
|
196 |
+
$where = $wpdb->prepare( 'id = %d AND email = %s', $id, $email );
|
197 |
+
$count = $this->count( $where );
|
198 |
|
199 |
+
if ( $count ) {
|
200 |
+
return true;
|
201 |
+
}
|
|
|
|
|
202 |
}
|
203 |
|
204 |
+
return false;
|
|
|
|
|
|
|
205 |
}
|
206 |
|
207 |
/**
|
208 |
+
* Get active contacts by list_id
|
209 |
+
*
|
210 |
+
* @param $list_id
|
211 |
+
*
|
212 |
+
* @return array|object|null
|
213 |
+
*
|
214 |
+
* @since 4.2.4
|
215 |
+
*
|
216 |
*/
|
217 |
+
public function get_active_contacts_by_list_id( $list_id ) {
|
218 |
+
|
219 |
+
if ( empty( $list_id ) ) {
|
220 |
+
return array();
|
221 |
+
}
|
222 |
|
223 |
global $wpdb;
|
224 |
|
225 |
+
$ig_lists_contacts_table = IG_LISTS_CONTACTS_TABLE;
|
|
|
|
|
226 |
|
227 |
+
$where = $wpdb->prepare( "id IN (SELECT contact_id FROM $ig_lists_contacts_table WHERE list_id = %d AND status IN ('subscribed', 'confirmed'))", $list_id );
|
228 |
+
|
229 |
+
return $this->get_by_conditions( $where );
|
230 |
|
231 |
}
|
232 |
|
238 |
* @return array|object|null
|
239 |
*
|
240 |
* @since 4.2.1
|
241 |
+
*
|
242 |
+
* @modify 4.2.4
|
243 |
*/
|
244 |
+
public function get_contacts_by_ids( $ids ) {
|
|
|
|
|
|
|
|
|
245 |
|
246 |
+
if ( ! is_array( $ids ) && ! count( $ids ) > 0 ) {
|
247 |
+
return array();
|
248 |
+
}
|
249 |
|
250 |
+
$ids_str = $this->array_to_str( $ids );
|
|
|
251 |
|
252 |
+
$where = "id IN ($ids_str)";
|
253 |
|
254 |
+
return $this->get_by_conditions( $where );
|
255 |
}
|
256 |
|
257 |
+
/**
|
258 |
+
* Count Active Contacts by list id
|
259 |
+
*
|
260 |
+
* @param string $list_id
|
261 |
+
*
|
262 |
+
* @return string|null
|
263 |
+
*
|
264 |
+
* @since 4.2.4
|
265 |
+
*/
|
266 |
+
public function count_active_contacts_by_list_id( $list_id = '' ) {
|
267 |
|
268 |
global $wpdb;
|
269 |
|
270 |
+
$ig_lists_contacts_table = IG_LISTS_CONTACTS_TABLE;
|
271 |
|
272 |
+
$query = $wpdb->prepare( "SELECT count(distinct(contact_id)) as total_subscribers FROM $ig_lists_contacts_table WHERE status = %s", 'subscribed' );
|
273 |
+
|
274 |
+
if ( ! empty( $list_id ) ) {
|
275 |
$query .= ' AND list_id = %d';
|
276 |
$query = $wpdb->prepare( $query, $list_id );
|
277 |
}
|
282 |
|
283 |
}
|
284 |
|
285 |
+
/**
|
286 |
+
* Delete Contacts by ids
|
287 |
+
*
|
288 |
+
* @param $ids
|
289 |
+
*
|
290 |
+
* @return bool|int
|
291 |
+
*
|
292 |
+
* @since 4.2.4
|
293 |
+
*/
|
294 |
+
public function delete_contacts_by_ids( $ids ) {
|
295 |
global $wpdb;
|
296 |
|
297 |
+
$ids = array_map( 'absint', $ids );
|
|
|
298 |
|
299 |
+
$ids = $this->array_to_str( $ids );
|
|
|
300 |
|
301 |
+
$where = "id IN ($ids)";
|
302 |
+
$this->delete_by_condition( $where );
|
303 |
|
304 |
+
$ig_lists_contacts_table = IG_LISTS_CONTACTS_TABLE;
|
|
|
305 |
|
306 |
+
$query = "DELETE FROM $ig_lists_contacts_table WHERE contact_id IN ($ids)";
|
|
|
|
|
307 |
|
308 |
+
return $wpdb->query( $query );
|
309 |
}
|
310 |
|
311 |
+
/**
|
312 |
+
* Update Contact Lists
|
313 |
+
*
|
314 |
+
* @param $ids
|
315 |
+
* @param $list_id
|
316 |
+
*
|
317 |
+
* @return bool
|
318 |
+
*
|
319 |
+
* @since 4.0.0
|
320 |
+
*/
|
321 |
+
public function update_contacts_list( $ids, $list_id ) {
|
322 |
global $wpdb;
|
|
|
|
|
|
|
|
|
323 |
|
324 |
+
$ids = array_map( 'absint', $ids );
|
|
|
325 |
|
326 |
+
$ids_str = $this->array_to_str( $ids );
|
327 |
+
|
328 |
+
$ig_lists_contacts_table = IG_LISTS_CONTACTS_TABLE;
|
329 |
|
|
|
330 |
//delete all list contact entry
|
331 |
+
$query = "DELETE FROM $ig_lists_contacts_table WHERE contact_id IN ($ids_str) ";
|
332 |
+
$wpdb->query( $query );
|
333 |
|
334 |
+
$values = $place_holders = array();
|
335 |
$optin_type_option = get_option( 'ig_es_optin_type', true );
|
336 |
$optin_type = 1;
|
337 |
if ( in_array( $optin_type_option, array( 'double_opt_in', 'double_optin' ) ) ) {
|
343 |
array_push( $values, $list_id, $contact_id, 'subscribed', $optin_type, $subscribed_at, $subscribed_ip );
|
344 |
$place_holders[] = "( %d, %d, %s, %s, %s, %s )"; /* In my case, i know they will always be integers */
|
345 |
}
|
346 |
+
|
347 |
+
$query = "INSERT INTO $ig_lists_contacts_table (`list_id`, `contact_id`, `status`, `optin_type`, `subscribed_at`, `subscribed_ip` ) VALUES ";
|
348 |
+
$query .= $this->array_to_str($place_holders);
|
349 |
$sql = $wpdb->prepare( "$query ", $values );
|
350 |
if ( $wpdb->query( $sql ) ) {
|
351 |
return true;
|
354 |
}
|
355 |
}
|
356 |
|
357 |
+
/**
|
358 |
+
* Add contacts to list
|
359 |
+
*
|
360 |
+
* @param $ids
|
361 |
+
* @param $list_id
|
362 |
+
*
|
363 |
+
* @return bool
|
364 |
+
*
|
365 |
+
* @since 4.0.0
|
366 |
+
*/
|
367 |
+
public function add_contacts_to_list( $ids, $list_id ) {
|
368 |
global $wpdb;
|
369 |
|
370 |
+
$ids = array_map( 'absint', $ids );
|
371 |
+
|
372 |
+
$ids_str = $this->array_to_str( $ids );
|
373 |
+
|
374 |
+
$ig_lists_contacts_table = IG_LISTS_CONTACTS_TABLE;
|
375 |
|
376 |
+
$delete_list_contact = "DELETE FROM $ig_lists_contacts_table WHERE contact_id IN ($ids_str) AND list_id = %s";
|
377 |
$del_query = $wpdb->prepare( $delete_list_contact, array( $list_id ) );
|
378 |
$wpdb->query( $del_query );
|
379 |
|
380 |
+
$values = $place_holders = array();
|
381 |
$optin_type_option = get_option( 'ig_es_optin_type', true );
|
382 |
$optin_type = 1;
|
383 |
if ( in_array( $optin_type_option, array( 'double_opt_in', 'double_optin' ) ) ) {
|
390 |
$place_holders[] = "( %d, %d, %s, %s, %s, %s )"; /* In my case, i know they will always be integers */
|
391 |
}
|
392 |
$query = "INSERT INTO " . IG_LISTS_CONTACTS_TABLE . " (`list_id`, `contact_id`, `status`, `optin_type`, `subscribed_at`, `subscribed_ip` ) VALUES ";
|
393 |
+
$query .= $this->array_to_str( $place_holders );
|
394 |
$sql = $wpdb->prepare( "$query ", $values );
|
395 |
if ( $wpdb->query( $sql ) ) {
|
396 |
return true;
|
399 |
}
|
400 |
}
|
401 |
|
402 |
+
/**
|
403 |
+
* Edit global status of contact
|
404 |
+
*
|
405 |
+
* @param $ids
|
406 |
+
* @param $unsubscribed
|
407 |
+
*
|
408 |
+
* @return bool|int
|
409 |
+
*
|
410 |
+
* @since 4.2.4
|
411 |
+
*/
|
412 |
+
public function edit_contact_global_status( $ids, $unsubscribed ) {
|
413 |
global $wpdb;
|
414 |
|
415 |
+
$ig_contacts_table = IG_CONTACTS_TABLE;
|
416 |
+
|
417 |
+
$ids = array_map( 'absint', $ids );
|
418 |
+
|
419 |
+
$ids = $this->array_to_str( $ids );
|
420 |
|
421 |
+
$sql = "UPDATE $ig_contacts_table SET unsubscribed = %d WHERE id IN ($ids)";
|
422 |
$query = $wpdb->prepare( $sql, array( $unsubscribed ) );
|
423 |
|
424 |
return $wpdb->query( $query );
|
425 |
|
426 |
}
|
427 |
|
|
|
428 |
/**
|
429 |
+
* Is Contact exists in list?
|
430 |
+
*
|
431 |
+
* @param $email
|
432 |
+
* @param $list_id
|
433 |
*
|
434 |
+
* @return array
|
435 |
*/
|
436 |
+
public function is_contact_exist_in_list( $email, $list_id ) {
|
437 |
global $wpdb;
|
438 |
|
439 |
+
$contact_id = $this->get_column_by( 'id', 'email', $email );
|
440 |
|
441 |
+
$data = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
442 |
if ( ! empty( $contact_id ) ) {
|
443 |
+
$data['contact_id'] = $contact_id;
|
444 |
|
445 |
if ( ! is_array( $list_id ) ) {
|
446 |
$list_id = array( $list_id );
|
447 |
}
|
448 |
|
449 |
+
$ig_lists_contacts_table = IG_LISTS_CONTACTS_TABLE;
|
450 |
+
|
451 |
+
$list_ids_str = $this->array_to_str( $list_id );
|
452 |
+
|
453 |
+
$list_query = "SELECT count(*) as count FROM $ig_lists_contacts_table WHERE list_id IN ($list_ids_str) AND contact_id = %s";
|
454 |
+
$list_sql = $wpdb->prepare( $list_query, $contact_id );
|
455 |
+
|
456 |
$list_contact_count = $wpdb->get_var( $list_sql );
|
457 |
if ( ! empty( $list_contact_count ) ) {
|
458 |
$data['list_id'] = true;
|
464 |
return $data;
|
465 |
}
|
466 |
|
467 |
+
/**
|
468 |
+
* Get Email Details Map
|
469 |
+
*
|
470 |
+
* @return array
|
471 |
+
*
|
472 |
+
* @since 4.0.0
|
473 |
+
*/
|
474 |
+
public function get_email_details_map() {
|
475 |
global $wpdb;
|
476 |
|
477 |
+
$ig_contacts_table = IG_CONTACTS_TABLE;
|
478 |
+
|
479 |
+
$query = "SELECT id, email, hash FROM $ig_contacts_table";
|
480 |
$contacts = $wpdb->get_results( $query, ARRAY_A );
|
481 |
$details = array();
|
482 |
if ( count( $contacts ) > 0 ) {
|
498 |
* @return array
|
499 |
*
|
500 |
* @since 4.2.1
|
501 |
+
*
|
502 |
+
* @modify 4.2.4
|
503 |
*/
|
504 |
+
public function get_details_by_ids( $contact_ids = array() ) {
|
505 |
|
506 |
+
$contacts = $this->get_contacts_by_ids( $contact_ids );
|
507 |
|
508 |
$results = array();
|
509 |
if ( ! empty( $contacts ) && count( $contacts ) > 0 ) {
|
516 |
return $results;
|
517 |
}
|
518 |
|
519 |
+
/**
|
520 |
+
* Get contact ids by emails
|
521 |
+
*
|
522 |
+
* @param array $emails
|
523 |
+
*
|
524 |
+
* @return array
|
525 |
+
*
|
526 |
+
* @sinc 4.0.0
|
527 |
+
*/
|
528 |
+
public function get_contact_ids_by_emails( $emails = array() ) {
|
529 |
global $wpdb;
|
530 |
|
531 |
+
$ig_contacts_table = IG_CONTACTS_TABLE;
|
532 |
+
|
533 |
+
$query = "SELECT id FROM $ig_contacts_table";
|
534 |
|
535 |
if ( count( $emails ) > 0 ) {
|
536 |
+
$emails_str = $this->array_to_str( $emails );
|
537 |
+
$query .= " WHERE email IN ($emails_str)";
|
538 |
}
|
539 |
|
540 |
$ids = $wpdb->get_col( $query );
|
542 |
return $ids;
|
543 |
}
|
544 |
|
545 |
+
/**
|
546 |
+
* Get contacts Email => id map
|
547 |
+
*
|
548 |
+
* @param array $emails
|
549 |
+
*
|
550 |
+
* @return array
|
551 |
+
*
|
552 |
+
* @since 4.0.0
|
553 |
+
*/
|
554 |
+
public function get_email_id_map( $emails = array() ) {
|
555 |
global $wpdb;
|
556 |
|
557 |
+
$ig_contacts_table = IG_CONTACTS_TABLE;
|
558 |
+
|
559 |
+
$query = "SELECT id, email FROM $ig_contacts_table";
|
560 |
|
561 |
if ( count( $emails ) > 0 ) {
|
562 |
+
$emails_str = $this->array_to_str( $emails );
|
563 |
+
$query .= " WHERE email IN ($emails_str)";
|
564 |
}
|
565 |
$results = $wpdb->get_results( $query, ARRAY_A );
|
566 |
+
|
567 |
+
$map = array();
|
568 |
if ( count( $results ) > 0 ) {
|
569 |
foreach ( $results as $result ) {
|
570 |
$map[ $result['email'] ] = $result['id'];
|
575 |
|
576 |
}
|
577 |
|
578 |
+
/**
|
579 |
+
* Batch Insert Contacts
|
580 |
+
*
|
581 |
+
* @param $contacts
|
582 |
+
*
|
583 |
+
* @since 4.0.0
|
584 |
+
*/
|
585 |
+
public function do_batch_insert( $contacts ) {
|
586 |
|
587 |
// Prepare a batch of 50 contacts.
|
588 |
$batches = array_chunk( $contacts, 50 );
|
589 |
|
590 |
+
$columns = $this->get_columns();
|
591 |
unset( $columns['id'] );
|
592 |
$fields = array_keys( $columns );
|
593 |
foreach ( $batches as $batch ) {
|
594 |
$values = $place_holders = array();
|
595 |
foreach ( $batch as $key => $contact ) {
|
596 |
|
597 |
+
$contact = wp_parse_args( $contact, $this->get_column_defaults() );
|
598 |
|
599 |
$formats = array();
|
600 |
foreach ( $columns as $column => $format ) {
|
609 |
}
|
610 |
}
|
611 |
|
612 |
+
/**
|
613 |
+
* Get contact id by email
|
614 |
+
*
|
615 |
+
* @param $email
|
616 |
+
*
|
617 |
+
* @return string|null
|
618 |
+
*/
|
619 |
+
public function get_contact_id_by_email( $email ) {
|
620 |
|
621 |
+
if ( empty( $email ) ) {
|
622 |
+
return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
623 |
}
|
624 |
|
625 |
+
return $this->get_column_by( 'id', 'email', $email );
|
626 |
}
|
627 |
|
628 |
+
/**
|
629 |
+
* Migrate all subscribers from 3.5.x to contacts table
|
630 |
+
*
|
631 |
+
* @since 4.0.0
|
632 |
+
*/
|
633 |
+
public function migrate_subscribers_from_older_version() {
|
634 |
global $wpdb;
|
635 |
|
636 |
+
$es_email_list_table = ES_EMAILLIST_TABLE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
637 |
//Get Total count of subscribers
|
638 |
+
$query = "SELECT count(*) as total FROM $es_email_list_table";
|
639 |
$total = $wpdb->get_var( $query );
|
640 |
|
641 |
// If we have subscribers?
|
642 |
if ( $total > 0 ) {
|
643 |
|
644 |
+
// Get all existing Contacts
|
645 |
+
$emails = $this->get_column( 'email' );
|
|
|
646 |
if ( ! is_array( $emails ) ) {
|
647 |
$emails = array();
|
648 |
}
|
649 |
|
650 |
// Import subscribers into batch of 100
|
651 |
$batch_size = IG_DEFAULT_BATCH_SIZE;
|
652 |
+
$total_batches = ( $total > IG_DEFAULT_BATCH_SIZE ) ? ceil( $total / $batch_size ) : 1;
|
653 |
$lists_contacts = array();
|
654 |
//$exclude_status = array( 'Unsubscribed', 'Unconfirmed' );
|
655 |
$j = 0;
|
656 |
+
for ( $i = 0; $i < $total_batches; $i ++ ) {
|
657 |
$batch_start = $i * $batch_size;
|
658 |
+
$query = "SELECT * FROM $es_email_list_table LIMIT {$batch_start}, {$batch_size} ";
|
659 |
$results = $wpdb->get_results( $query, ARRAY_A );
|
660 |
if ( count( $results ) > 0 ) {
|
661 |
$contacts = array();
|
701 |
//}
|
702 |
}
|
703 |
|
704 |
+
$this->do_batch_insert( $contacts );
|
705 |
}
|
706 |
|
707 |
}
|
729 |
*
|
730 |
* @since 4.2.0
|
731 |
*/
|
732 |
+
public function edit_list_contact_status( $contact_ids, $list_ids, $status ) {
|
733 |
global $wpdb;
|
734 |
|
735 |
+
$ids = array_map( 'absint', $contact_ids );
|
736 |
+
$ids = $this->array_to_str($ids);
|
737 |
+
|
738 |
+
$list_ids = array_map( 'absint', $list_ids );
|
739 |
+
$list_ids = $this->array_to_str($list_ids);
|
740 |
|
741 |
$current_date = ig_get_current_date_time();
|
742 |
|
743 |
+
$ig_contacts_table = IG_LISTS_CONTACTS_TABLE;
|
744 |
+
|
745 |
if ( 'subscribed' === $status ) {
|
746 |
+
$sql = "UPDATE $ig_contacts_table SET status = %s, subscribed_at = %s WHERE contact_id IN ($ids) AND list_id IN ($list_ids)";
|
747 |
$query = $wpdb->prepare( $sql, array( $status, $current_date ) );
|
748 |
} elseif ( 'unsubscribed' === $status ) {
|
749 |
+
$sql = "UPDATE $ig_contacts_table SET status = %s, unsubscribed_at = %s WHERE contact_id IN ($ids) AND list_id IN ($list_ids)";
|
750 |
$query = $wpdb->prepare( $sql, array( $status, $current_date ) );
|
751 |
} elseif ( 'unconfirmed' === $status ) {
|
752 |
+
$sql = "UPDATE $ig_contacts_table SET status = %s, optin_type = %d, subscribed_at = NULL, unsubscribed_at = NULL WHERE contact_id IN ($ids) AND list_id IN ($list_ids)";
|
753 |
$query = $wpdb->prepare( $sql, array( $status, IG_DOUBLE_OPTIN ) );
|
754 |
}
|
755 |
|
includes/db/class-es-db-links.php
CHANGED
@@ -4,19 +4,19 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
4 |
exit;
|
5 |
}
|
6 |
|
7 |
-
if ( class_exists( 'ES_DB_Links' ) ) {
|
8 |
/**
|
9 |
* Store Campaigns links
|
10 |
*
|
11 |
* Class ES_DB_Links
|
12 |
*
|
13 |
-
* @since 4.2.
|
14 |
*/
|
15 |
class ES_DB_Links extends ES_DB {
|
16 |
/**
|
17 |
* Table Name
|
18 |
*
|
19 |
-
* @since 4.2.
|
20 |
* @var string
|
21 |
*
|
22 |
*/
|
@@ -24,7 +24,7 @@ if ( class_exists( 'ES_DB_Links' ) ) {
|
|
24 |
/**
|
25 |
* Table Version
|
26 |
*
|
27 |
-
* @since 4.2.
|
28 |
* @var string
|
29 |
*
|
30 |
*/
|
@@ -32,7 +32,7 @@ if ( class_exists( 'ES_DB_Links' ) ) {
|
|
32 |
/**
|
33 |
* Primary key
|
34 |
*
|
35 |
-
* @since 4.2.
|
36 |
* @var string
|
37 |
*
|
38 |
*/
|
@@ -43,7 +43,7 @@ if ( class_exists( 'ES_DB_Links' ) ) {
|
|
43 |
*
|
44 |
* ES_DB_Links constructor.
|
45 |
*
|
46 |
-
* @since 4.2.
|
47 |
*/
|
48 |
public function __construct() {
|
49 |
global $wpdb;
|
@@ -60,7 +60,7 @@ if ( class_exists( 'ES_DB_Links' ) ) {
|
|
60 |
/**
|
61 |
* Get columns and formats
|
62 |
*
|
63 |
-
* @since 4.2.
|
64 |
*/
|
65 |
public function get_columns() {
|
66 |
return array(
|
@@ -69,6 +69,7 @@ if ( class_exists( 'ES_DB_Links' ) ) {
|
|
69 |
'campaign_id' => '%d',
|
70 |
'link' => '%s',
|
71 |
'hash' => '%s',
|
|
|
72 |
'created_at' => '%s',
|
73 |
);
|
74 |
}
|
@@ -76,15 +77,16 @@ if ( class_exists( 'ES_DB_Links' ) ) {
|
|
76 |
/**
|
77 |
* Get default column values
|
78 |
*
|
79 |
-
* @since 4.2.
|
80 |
*/
|
81 |
public function get_column_defaults() {
|
82 |
|
83 |
return array(
|
84 |
'message_id' => 0,
|
85 |
'campaign_id' => 0,
|
86 |
-
'link' =>
|
87 |
-
'hash' =>
|
|
|
88 |
'created_at' => ig_get_current_date_time(),
|
89 |
);
|
90 |
}
|
@@ -94,14 +96,14 @@ if ( class_exists( 'ES_DB_Links' ) ) {
|
|
94 |
*
|
95 |
* @param null $hash
|
96 |
*
|
97 |
-
* @return
|
98 |
*
|
99 |
-
* @since 4.2.
|
100 |
*/
|
101 |
public function get_by_hash( $hash = null ) {
|
102 |
|
103 |
-
if (
|
104 |
-
return
|
105 |
}
|
106 |
|
107 |
return $this->get_by( 'hash', $hash );
|
@@ -114,7 +116,7 @@ if ( class_exists( 'ES_DB_Links' ) ) {
|
|
114 |
*
|
115 |
* @return array|object|void|null
|
116 |
*
|
117 |
-
* @since 4.2.
|
118 |
*/
|
119 |
public function get_by_id( $id = 0 ) {
|
120 |
|
@@ -125,5 +127,25 @@ if ( class_exists( 'ES_DB_Links' ) ) {
|
|
125 |
return $this->get_by( 'id', $id );
|
126 |
}
|
127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
}
|
129 |
}
|
4 |
exit;
|
5 |
}
|
6 |
|
7 |
+
if ( ! class_exists( 'ES_DB_Links' ) ) {
|
8 |
/**
|
9 |
* Store Campaigns links
|
10 |
*
|
11 |
* Class ES_DB_Links
|
12 |
*
|
13 |
+
* @since 4.2.4
|
14 |
*/
|
15 |
class ES_DB_Links extends ES_DB {
|
16 |
/**
|
17 |
* Table Name
|
18 |
*
|
19 |
+
* @since 4.2.4
|
20 |
* @var string
|
21 |
*
|
22 |
*/
|
24 |
/**
|
25 |
* Table Version
|
26 |
*
|
27 |
+
* @since 4.2.4
|
28 |
* @var string
|
29 |
*
|
30 |
*/
|
32 |
/**
|
33 |
* Primary key
|
34 |
*
|
35 |
+
* @since 4.2.4
|
36 |
* @var string
|
37 |
*
|
38 |
*/
|
43 |
*
|
44 |
* ES_DB_Links constructor.
|
45 |
*
|
46 |
+
* @since 4.2.4
|
47 |
*/
|
48 |
public function __construct() {
|
49 |
global $wpdb;
|
60 |
/**
|
61 |
* Get columns and formats
|
62 |
*
|
63 |
+
* @since 4.2.4
|
64 |
*/
|
65 |
public function get_columns() {
|
66 |
return array(
|
69 |
'campaign_id' => '%d',
|
70 |
'link' => '%s',
|
71 |
'hash' => '%s',
|
72 |
+
'i' => '%d',
|
73 |
'created_at' => '%s',
|
74 |
);
|
75 |
}
|
77 |
/**
|
78 |
* Get default column values
|
79 |
*
|
80 |
+
* @since 4.2.4
|
81 |
*/
|
82 |
public function get_column_defaults() {
|
83 |
|
84 |
return array(
|
85 |
'message_id' => 0,
|
86 |
'campaign_id' => 0,
|
87 |
+
'link' => '',
|
88 |
+
'hash' => '',
|
89 |
+
'i' => '',
|
90 |
'created_at' => ig_get_current_date_time(),
|
91 |
);
|
92 |
}
|
96 |
*
|
97 |
* @param null $hash
|
98 |
*
|
99 |
+
* @return array|object|void|null
|
100 |
*
|
101 |
+
* @since 4.2.4
|
102 |
*/
|
103 |
public function get_by_hash( $hash = null ) {
|
104 |
|
105 |
+
if ( empty( $hash ) ) {
|
106 |
+
return array();
|
107 |
}
|
108 |
|
109 |
return $this->get_by( 'hash', $hash );
|
116 |
*
|
117 |
* @return array|object|void|null
|
118 |
*
|
119 |
+
* @since 4.2.4
|
120 |
*/
|
121 |
public function get_by_id( $id = 0 ) {
|
122 |
|
127 |
return $this->get_by( 'id', $id );
|
128 |
}
|
129 |
|
130 |
+
/**
|
131 |
+
* Check whether link exists in campaign
|
132 |
+
*
|
133 |
+
* @param $link
|
134 |
+
* @param int $campaign_id
|
135 |
+
* @param int $message_id
|
136 |
+
* @param int $index
|
137 |
+
*
|
138 |
+
* @return string|null
|
139 |
+
*
|
140 |
+
* @since 4.2.4
|
141 |
+
*/
|
142 |
+
public function get_link_by_campaign_id( $link, $campaign_id = 0, $message_id = 0, $index = 0 ) {
|
143 |
+
global $wpdb;
|
144 |
+
|
145 |
+
$where = $wpdb->prepare( " link = %s AND campaign_id = %d AND message_id = %d AND i = %d", $link, $campaign_id, $message_id, $index );
|
146 |
+
|
147 |
+
return $this->get_by_conditions( $where );
|
148 |
+
}
|
149 |
+
|
150 |
}
|
151 |
}
|
includes/db/class-es-db-lists.php
CHANGED
@@ -32,12 +32,15 @@ class ES_DB_Lists extends ES_DB {
|
|
32 |
public function __construct() {
|
33 |
global $wpdb;
|
34 |
|
|
|
|
|
35 |
$this->table_name = $wpdb->prefix . 'ig_lists';
|
36 |
|
37 |
$this->primary_key = 'id';
|
38 |
|
39 |
$this->version = '1.0';
|
40 |
|
|
|
41 |
}
|
42 |
|
43 |
/**
|
32 |
public function __construct() {
|
33 |
global $wpdb;
|
34 |
|
35 |
+
parent::__construct();
|
36 |
+
|
37 |
$this->table_name = $wpdb->prefix . 'ig_lists';
|
38 |
|
39 |
$this->primary_key = 'id';
|
40 |
|
41 |
$this->version = '1.0';
|
42 |
|
43 |
+
|
44 |
}
|
45 |
|
46 |
/**
|
includes/db/class-es-db-sending-queue.php
CHANGED
@@ -212,7 +212,8 @@ class ES_DB_Sending_Queue {
|
|
212 |
global $wpdb;
|
213 |
|
214 |
$delivery_reports_table = IG_SENDING_QUEUE_TABLE;
|
215 |
-
|
|
|
216 |
$query .= implode( ', ', $place_holders );
|
217 |
$sql = $wpdb->prepare( "$query ", $values );
|
218 |
|
@@ -239,7 +240,7 @@ class ES_DB_Sending_Queue {
|
|
239 |
global $wpdb;
|
240 |
|
241 |
$mailing_queue_details = ES_DB_Mailing_Queue::get_id_details_map();
|
242 |
-
$email_details =
|
243 |
|
244 |
$query = "SELECT count(*) as total FROM " . EMAIL_SUBSCRIBERS_STATS_TABLE;
|
245 |
|
@@ -326,7 +327,7 @@ class ES_DB_Sending_Queue {
|
|
326 |
global $wpdb;
|
327 |
|
328 |
$mailing_queue_details = ES_DB_Mailing_Queue::get_id_details_map();
|
329 |
-
$email_details =
|
330 |
|
331 |
$query = "SELECT count(*) as total FROM " . EMAIL_SUBSCRIBERS_STATS_TABLE;
|
332 |
|
212 |
global $wpdb;
|
213 |
|
214 |
$delivery_reports_table = IG_SENDING_QUEUE_TABLE;
|
215 |
+
|
216 |
+
$query = "INSERT INTO $delivery_reports_table (`mailing_queue_id`, `mailing_queue_hash`, `campaign_id`, `contact_id`, `contact_hash`, `email`, `status`, `links`, `opened`, `sent_at`, `opened_at`) VALUES ";
|
217 |
$query .= implode( ', ', $place_holders );
|
218 |
$sql = $wpdb->prepare( "$query ", $values );
|
219 |
|
240 |
global $wpdb;
|
241 |
|
242 |
$mailing_queue_details = ES_DB_Mailing_Queue::get_id_details_map();
|
243 |
+
$email_details = ES()->contacts_db->get_email_details_map();
|
244 |
|
245 |
$query = "SELECT count(*) as total FROM " . EMAIL_SUBSCRIBERS_STATS_TABLE;
|
246 |
|
327 |
global $wpdb;
|
328 |
|
329 |
$mailing_queue_details = ES_DB_Mailing_Queue::get_id_details_map();
|
330 |
+
$email_details = ES()->contacts_db->get_email_details_map();
|
331 |
|
332 |
$query = "SELECT count(*) as total FROM " . EMAIL_SUBSCRIBERS_STATS_TABLE;
|
333 |
|
includes/db/class-es-db.php
CHANGED
@@ -104,7 +104,7 @@ abstract class ES_DB {
|
|
104 |
$query = "SELECT * FROM $this->table_name";
|
105 |
|
106 |
if ( ! empty( $where ) ) {
|
107 |
-
$query .= " WHERE
|
108 |
}
|
109 |
|
110 |
return $wpdb->get_results( $query, $output );
|
@@ -256,7 +256,32 @@ abstract class ES_DB {
|
|
256 |
return false;
|
257 |
}
|
258 |
|
259 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
return false;
|
261 |
}
|
262 |
|
@@ -303,7 +328,7 @@ abstract class ES_DB {
|
|
303 |
$query = "SELECT count(*) FROM $this->table_name";
|
304 |
|
305 |
if ( ! empty( $where ) ) {
|
306 |
-
$query .= " WHERE
|
307 |
}
|
308 |
|
309 |
return $wpdb->get_var( $query );
|
@@ -366,7 +391,7 @@ abstract class ES_DB {
|
|
366 |
|
367 |
$place_holders[] = "( " . implode( ', ', $formats ) . " )";
|
368 |
$fields_str = "`" . implode( "`, `", $fields ) . "`";
|
369 |
-
$query = "INSERT INTO $this->table_name
|
370 |
$query .= implode( ', ', $place_holders );
|
371 |
$sql = $wpdb->prepare( $query, $final_values );
|
372 |
|
@@ -375,12 +400,22 @@ abstract class ES_DB {
|
|
375 |
}
|
376 |
}
|
377 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
public static function do_insert( $table_name, $fields, $place_holders, $values ) {
|
379 |
global $wpdb;
|
380 |
|
381 |
$fields_str = "`" . implode( "`, `", $fields ) . "`";
|
382 |
|
383 |
-
$query = "INSERT INTO
|
384 |
$query .= implode( ', ', $place_holders );
|
385 |
$sql = $wpdb->prepare( $query, $values );
|
386 |
|
@@ -400,12 +435,12 @@ abstract class ES_DB {
|
|
400 |
*
|
401 |
* @since 4.2.2
|
402 |
*/
|
403 |
-
public function get_id_name_map($where = '') {
|
404 |
global $wpdb;
|
405 |
|
406 |
$query = "SELECT $this->primary_key, name FROM $this->table_name";
|
407 |
|
408 |
-
if(!empty($where)) {
|
409 |
$query .= " WHERE $where";
|
410 |
}
|
411 |
|
@@ -445,4 +480,21 @@ abstract class ES_DB {
|
|
445 |
|
446 |
}
|
447 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
448 |
}
|
104 |
$query = "SELECT * FROM $this->table_name";
|
105 |
|
106 |
if ( ! empty( $where ) ) {
|
107 |
+
$query .= " WHERE $where";
|
108 |
}
|
109 |
|
110 |
return $wpdb->get_results( $query, $output );
|
256 |
return false;
|
257 |
}
|
258 |
|
259 |
+
$where = $wpdb->prepare( "$this->primary_key = %d", $row_id );
|
260 |
+
|
261 |
+
if ( false === $this->delete_by_condition( $where ) ) {
|
262 |
+
return false;
|
263 |
+
}
|
264 |
+
|
265 |
+
return true;
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Delete records based on $where
|
270 |
+
*
|
271 |
+
* @param string $where
|
272 |
+
*
|
273 |
+
* @return bool
|
274 |
+
*
|
275 |
+
* @since 4.2.4
|
276 |
+
*/
|
277 |
+
public function delete_by_condition( $where = '' ) {
|
278 |
+
global $wpdb;
|
279 |
+
|
280 |
+
if ( empty( $where ) ) {
|
281 |
+
return false;
|
282 |
+
}
|
283 |
+
|
284 |
+
if ( false === $wpdb->query( "DELETE FROM $this->table_name WHERE $where" ) ) {
|
285 |
return false;
|
286 |
}
|
287 |
|
328 |
$query = "SELECT count(*) FROM $this->table_name";
|
329 |
|
330 |
if ( ! empty( $where ) ) {
|
331 |
+
$query .= " WHERE $where";
|
332 |
}
|
333 |
|
334 |
return $wpdb->get_var( $query );
|
391 |
|
392 |
$place_holders[] = "( " . implode( ', ', $formats ) . " )";
|
393 |
$fields_str = "`" . implode( "`, `", $fields ) . "`";
|
394 |
+
$query = "INSERT INTO $this->table_name({$fields_str}) VALUES ";
|
395 |
$query .= implode( ', ', $place_holders );
|
396 |
$sql = $wpdb->prepare( $query, $final_values );
|
397 |
|
400 |
}
|
401 |
}
|
402 |
|
403 |
+
/**
|
404 |
+
* @param $table_name
|
405 |
+
* @param $fields
|
406 |
+
* @param $place_holders
|
407 |
+
* @param $values
|
408 |
+
*
|
409 |
+
* @return bool
|
410 |
+
*
|
411 |
+
*
|
412 |
+
*/
|
413 |
public static function do_insert( $table_name, $fields, $place_holders, $values ) {
|
414 |
global $wpdb;
|
415 |
|
416 |
$fields_str = "`" . implode( "`, `", $fields ) . "`";
|
417 |
|
418 |
+
$query = "INSERT INTO $table_name ({$fields_str}) VALUES ";
|
419 |
$query .= implode( ', ', $place_holders );
|
420 |
$sql = $wpdb->prepare( $query, $values );
|
421 |
|
435 |
*
|
436 |
* @since 4.2.2
|
437 |
*/
|
438 |
+
public function get_id_name_map( $where = '' ) {
|
439 |
global $wpdb;
|
440 |
|
441 |
$query = "SELECT $this->primary_key, name FROM $this->table_name";
|
442 |
|
443 |
+
if ( ! empty( $where ) ) {
|
444 |
$query .= " WHERE $where";
|
445 |
}
|
446 |
|
480 |
|
481 |
}
|
482 |
|
483 |
+
/**
|
484 |
+
* Convert array into str for IN query
|
485 |
+
*
|
486 |
+
* @param $array
|
487 |
+
*
|
488 |
+
* @return string
|
489 |
+
*
|
490 |
+
* @since 4.2.4
|
491 |
+
*/
|
492 |
+
public function array_to_str( $array, $glue = ', ' ) {
|
493 |
+
if ( is_array( $array ) && count( $array ) > 0 ) {
|
494 |
+
return implode( $glue, $array );
|
495 |
+
}
|
496 |
+
|
497 |
+
return '';
|
498 |
+
}
|
499 |
+
|
500 |
}
|
includes/es-backward.php
CHANGED
@@ -46,9 +46,9 @@ class es_cls_dbquery {
|
|
46 |
'hash' => $guid,
|
47 |
'created_at' => ig_get_current_date_time(),
|
48 |
);
|
49 |
-
$contact_id =
|
50 |
if ( ! $contact_id ) {
|
51 |
-
$contact_id =
|
52 |
}
|
53 |
|
54 |
if ( $contact_id ) {
|
46 |
'hash' => $guid,
|
47 |
'created_at' => ig_get_current_date_time(),
|
48 |
);
|
49 |
+
$contact_id = ES()->contacts_db->get_contact_id_by_email( $email );
|
50 |
if ( ! $contact_id ) {
|
51 |
+
$contact_id = ES()->contacts_db->insert( $sub_data );
|
52 |
}
|
53 |
|
54 |
if ( $contact_id ) {
|
includes/feedback.php
CHANGED
@@ -117,7 +117,7 @@ function ig_es_render_fb_widget() {
|
|
117 |
return;
|
118 |
}
|
119 |
|
120 |
-
$total_contacts =
|
121 |
|
122 |
// Got 25 contacts?
|
123 |
// It's time to Join Email Subscribers Secret Club on Facebook
|
117 |
return;
|
118 |
}
|
119 |
|
120 |
+
$total_contacts = ES()->contacts_db->count();
|
121 |
|
122 |
// Got 25 contacts?
|
123 |
// It's time to Join Email Subscribers Secret Club on Facebook
|
includes/upgrade/es-update-functions.php
CHANGED
@@ -480,7 +480,7 @@ function ig_es_update_400_migrate_lists() {
|
|
480 |
|
481 |
// Import contacts from es_emaillist table to ig_contacts and ig_lists_contacts table
|
482 |
function ig_es_update_400_migrate_subscribers() {
|
483 |
-
|
484 |
}
|
485 |
|
486 |
function ig_es_update_400_migrate_post_notifications() {
|
@@ -927,4 +927,52 @@ function ig_es_update_421_db_version() {
|
|
927 |
ES_Install::update_db_version( '4.2.1' );
|
928 |
}
|
929 |
|
930 |
-
/* --------------------- ES 4.2.1(End)--------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
480 |
|
481 |
// Import contacts from es_emaillist table to ig_contacts and ig_lists_contacts table
|
482 |
function ig_es_update_400_migrate_subscribers() {
|
483 |
+
ES()->contacts_db->migrate_subscribers_from_older_version();
|
484 |
}
|
485 |
|
486 |
function ig_es_update_400_migrate_post_notifications() {
|
927 |
ES_Install::update_db_version( '4.2.1' );
|
928 |
}
|
929 |
|
930 |
+
/* --------------------- ES 4.2.1(End)--------------------------- */
|
931 |
+
|
932 |
+
/**
|
933 |
+
* Drop ig_links table
|
934 |
+
*
|
935 |
+
* @since 4.2.4
|
936 |
+
*/
|
937 |
+
function ig_es_update_424_drop_tables() {
|
938 |
+
global $wpdb;
|
939 |
+
|
940 |
+
/**
|
941 |
+
* Note: Still we are not using ig_links table.
|
942 |
+
* So, it's ok to drop ig_links table now as we want to modify structure
|
943 |
+
* Which we are going to create in 'ig_es_update_424_create_table' function.
|
944 |
+
*/
|
945 |
+
$tables_to_drop = array(
|
946 |
+
$wpdb->prefix . 'ig_links'
|
947 |
+
);
|
948 |
+
|
949 |
+
foreach ( $tables_to_drop as $table ) {
|
950 |
+
$query = "DROP TABLE IF EXISTS {$table}";
|
951 |
+
$wpdb->query( $query );
|
952 |
+
}
|
953 |
+
}
|
954 |
+
|
955 |
+
/**
|
956 |
+
* Create ig_links table
|
957 |
+
*
|
958 |
+
* @since 4.2.4
|
959 |
+
*/
|
960 |
+
function ig_es_update_424_create_tables() {
|
961 |
+
global $wpdb;
|
962 |
+
|
963 |
+
$wpdb->hide_errors();
|
964 |
+
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
965 |
+
dbDelta( ES_Install::get_ig_es_424_schema() );
|
966 |
+
}
|
967 |
+
|
968 |
+
/**
|
969 |
+
* Update DB Update history
|
970 |
+
*
|
971 |
+
* @since 4.2.4
|
972 |
+
*/
|
973 |
+
function ig_es_update_424_db_version() {
|
974 |
+
ES_Install::update_db_version( '4.2.4' );
|
975 |
+
}
|
976 |
+
|
977 |
+
|
978 |
+
/* --------------------- ES 4.2.4(End)--------------------------- */
|
public/class-email-subscribers-public.php
CHANGED
@@ -161,9 +161,9 @@ class Email_Subscribers_Public {
|
|
161 |
if ( ! empty( $option ) ) {
|
162 |
if ( ( 'optin' === $option || 'unsubscribe' === $option ) && ! empty( $db_id ) ) {
|
163 |
//check if contact exist with id and email
|
164 |
-
$
|
165 |
|
166 |
-
if (
|
167 |
$ids = array( $db_id );
|
168 |
$status = $subject = $content = '';
|
169 |
$unsubscribed = 0;
|
@@ -172,10 +172,10 @@ class Email_Subscribers_Public {
|
|
172 |
if ( $is_status_update_required ) {
|
173 |
if ( $option === 'optin' ) {
|
174 |
$message = get_option( 'ig_es_subscription_success_message' );
|
175 |
-
|
176 |
ES_DB_Lists_Contacts::edit_subscriber_status( $ids, $status );
|
177 |
//send welcome email
|
178 |
-
$contact =
|
179 |
$data = array(
|
180 |
'name' => ! empty( $contact[ $email ] ) ? $contact[ $email ]['name'] : '',
|
181 |
'first_name' => ! empty( $contact[ $email ] ) ? $contact[ $email ]['first_name'] : '',
|
@@ -205,7 +205,6 @@ class Email_Subscribers_Public {
|
|
205 |
$unsubscribe_lists = ig_es_get_post_data( 'unsubscribe_lists', array() );
|
206 |
$list_selected = ig_es_get_request_data( 'list_selected' );
|
207 |
|
208 |
-
|
209 |
$message = get_option( 'ig_es_unsubscribe_success_message' );
|
210 |
|
211 |
$active_plugins = $ig_es_tracker::get_active_plugins();
|
@@ -228,12 +227,12 @@ class Email_Subscribers_Public {
|
|
228 |
}
|
229 |
|
230 |
//update list status
|
231 |
-
|
232 |
//check if all list have same status
|
233 |
$list_ids = ES_DB_Lists_Contacts::get_list_ids_by_contact( $db_id, 'subscribed' );
|
234 |
if ( count( $list_ids ) == 0 ) {
|
235 |
//update global
|
236 |
-
|
237 |
|
238 |
}
|
239 |
|
@@ -260,11 +259,32 @@ class Email_Subscribers_Public {
|
|
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 |
-
|
265 |
-
|
266 |
|
267 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
}
|
269 |
|
270 |
}
|
@@ -284,9 +304,9 @@ class Email_Subscribers_Public {
|
|
284 |
|
285 |
$contact_data = wp_parse_args( $contact_data, $default_data );
|
286 |
|
287 |
-
$contact =
|
288 |
if ( empty( $contact['contact_id'] ) ) {
|
289 |
-
$contact_id =
|
290 |
} else {
|
291 |
$contact_id = $contact['contact_id'];
|
292 |
}
|
161 |
if ( ! empty( $option ) ) {
|
162 |
if ( ( 'optin' === $option || 'unsubscribe' === $option ) && ! empty( $db_id ) ) {
|
163 |
//check if contact exist with id and email
|
164 |
+
$is_contact_exists = ES()->contacts_db->is_contact_exists( $db_id, $email );
|
165 |
|
166 |
+
if ( $is_contact_exists ) {
|
167 |
$ids = array( $db_id );
|
168 |
$status = $subject = $content = '';
|
169 |
$unsubscribed = 0;
|
172 |
if ( $is_status_update_required ) {
|
173 |
if ( $option === 'optin' ) {
|
174 |
$message = get_option( 'ig_es_subscription_success_message' );
|
175 |
+
ES()->contacts_db->edit_contact_global_status( $ids, $unsubscribed );
|
176 |
ES_DB_Lists_Contacts::edit_subscriber_status( $ids, $status );
|
177 |
//send welcome email
|
178 |
+
$contact = ES()->contacts_db->get_contacts_email_name_map( array( $email ) );
|
179 |
$data = array(
|
180 |
'name' => ! empty( $contact[ $email ] ) ? $contact[ $email ]['name'] : '',
|
181 |
'first_name' => ! empty( $contact[ $email ] ) ? $contact[ $email ]['first_name'] : '',
|
205 |
$unsubscribe_lists = ig_es_get_post_data( 'unsubscribe_lists', array() );
|
206 |
$list_selected = ig_es_get_request_data( 'list_selected' );
|
207 |
|
|
|
208 |
$message = get_option( 'ig_es_unsubscribe_success_message' );
|
209 |
|
210 |
$active_plugins = $ig_es_tracker::get_active_plugins();
|
227 |
}
|
228 |
|
229 |
//update list status
|
230 |
+
ES()->contacts_db->edit_list_contact_status( array( $db_id ), $unsubscribe_lists, 'unsubscribed' );
|
231 |
//check if all list have same status
|
232 |
$list_ids = ES_DB_Lists_Contacts::get_list_ids_by_contact( $db_id, 'subscribed' );
|
233 |
if ( count( $list_ids ) == 0 ) {
|
234 |
//update global
|
235 |
+
ES()->contacts_db->edit_contact_global_status( array( $db_id ), 1 );
|
236 |
|
237 |
}
|
238 |
|
259 |
if ( ! empty( $guid ) && ! empty( $email ) ) {
|
260 |
ES_DB_Sending_Queue::update_viewed_status( $guid, $email );
|
261 |
|
262 |
+
if ( $campaign_id > 0 && $db_id > 0 ) {
|
263 |
+
do_action( 'ig_es_message_open', $db_id, $message_id, $campaign_id );
|
264 |
+
}
|
265 |
|
266 |
}
|
267 |
+
} elseif ( 'click' === $option ) {
|
268 |
+
|
269 |
+
if ( ! empty( $data['link_hash'] ) ) {
|
270 |
+
$hash = $data['link_hash'];
|
271 |
+
$link = ES()->links_db->get_by_hash( $hash );
|
272 |
+
|
273 |
+
if ( ! empty( $link ) ) {
|
274 |
+
$campaign_id = ! empty( $data['campaign_id'] ) ? $data['campaign_id'] : 0;
|
275 |
+
$message_id = ! empty( $data['message_id'] ) ? $data['message_id'] : 0;
|
276 |
+
$contact_id = ! empty( $data['contact_id'] ) ? $data['contact_id'] : 0;
|
277 |
+
$link_id = ! empty( $link['id'] ) ? $link['id'] : 0;
|
278 |
+
|
279 |
+
// Track Link Click
|
280 |
+
do_action( 'ig_es_message_click', $link_id, $contact_id, $message_id, $campaign_id );
|
281 |
+
|
282 |
+
// Now, redirect to target
|
283 |
+
wp_redirect( $link['link'] );
|
284 |
+
exit;
|
285 |
+
}
|
286 |
+
}
|
287 |
+
|
288 |
}
|
289 |
|
290 |
}
|
304 |
|
305 |
$contact_data = wp_parse_args( $contact_data, $default_data );
|
306 |
|
307 |
+
$contact = ES()->contacts_db->is_contact_exist_in_list( $email, $list_id );
|
308 |
if ( empty( $contact['contact_id'] ) ) {
|
309 |
+
$contact_id = ES()->contacts_db->insert( $contact_data );
|
310 |
} else {
|
311 |
$contact_id = $contact['contact_id'];
|
312 |
}
|
public/partials/class-es-shortcode.php
CHANGED
@@ -138,13 +138,13 @@ class ES_Shortcode {
|
|
138 |
|
139 |
/**
|
140 |
* We did not have $email_label, $name_label in
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
*/
|
149 |
if ( $form_version == '0.1' ) {
|
150 |
$email_label = __( 'Email', 'email-subscribers' );
|
@@ -152,7 +152,7 @@ class ES_Shortcode {
|
|
152 |
}
|
153 |
|
154 |
//replace total contact
|
155 |
-
$total_contacts =
|
156 |
$desc = str_replace( "{{TOTAL-CONTACTS}}", $total_contacts, $desc );
|
157 |
|
158 |
$current_page = get_the_ID();
|
@@ -163,7 +163,6 @@ class ES_Shortcode {
|
|
163 |
$nonce = wp_create_nonce( 'es-subscribe' );
|
164 |
|
165 |
|
166 |
-
|
167 |
// Name
|
168 |
$name_html = $required = '';
|
169 |
if ( ! empty( $show_name ) && 'no' !== $show_name ) {
|
138 |
|
139 |
/**
|
140 |
* We did not have $email_label, $name_label in
|
141 |
+
* ES < 4.2.2
|
142 |
+
*
|
143 |
+
* Since ES 4.2.2, we are adding form_version in form settings.
|
144 |
+
*
|
145 |
+
* If we don't find Form Version in settings, we are setting as 0.1
|
146 |
+
*
|
147 |
+
* So, if form_version is 0.1 then set default label
|
148 |
*/
|
149 |
if ( $form_version == '0.1' ) {
|
150 |
$email_label = __( 'Email', 'email-subscribers' );
|
152 |
}
|
153 |
|
154 |
//replace total contact
|
155 |
+
$total_contacts = ES()->contacts_db->count_active_contacts_by_list_id();
|
156 |
$desc = str_replace( "{{TOTAL-CONTACTS}}", $total_contacts, $desc );
|
157 |
|
158 |
$current_page = get_the_ID();
|
163 |
$nonce = wp_create_nonce( 'es-subscribe' );
|
164 |
|
165 |
|
|
|
166 |
// Name
|
167 |
$name_html = $required = '';
|
168 |
if ( ! empty( $show_name ) && 'no' !== $show_name ) {
|
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.
|
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.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
|
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.4
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses
|
11 |
|
300 |
|
301 |
== Changelog ==
|
302 |
|
303 |
+
**4.2.4 (23.10.2019)**
|
304 |
+
|
305 |
+
* Update: Improve Create Broadcast UI
|
306 |
+
* Fix: Unable to remove label for Email field in Subscription Form
|
307 |
+
* Fix: Validate Post Notification data
|
308 |
+
|
309 |
**4.2.3 (17.10.2019)**
|
310 |
+
|
311 |
* Update: Now, only administrator can access Email Subscribers menus.
|
312 |
* Fix: Email open tracking
|
313 |
* Fix: Vulnerability while exporting contacts
|