Version Description
(2014.07.14) =
Download this release
Release Info
Developer | AndyGCook |
Plugin | HubSpot – Free Marketing Plugin for WordPress |
Version | 1.3.0 |
Comparing to | |
See all releases |
Code changes from version 1.2.0 to 1.3.0
- admin/inc/class-leadin-contact.php +6 -5
- admin/inc/class-leadin-list-table.php +23 -25
- admin/inc/class-leadin-viewers.php +4 -4
- admin/inc/class-stats-dashboard.php +8 -8
- admin/leadin-admin.php +1 -1
- inc/class-emailer.php +6 -3
- inc/leadin-ajax-functions.php +28 -26
- inc/leadin-functions.php +13 -12
- leadin.php +12 -5
- power-ups/contacts/admin/contacts-admin.php +8 -7
- readme.txt +7 -3
admin/inc/class-leadin-contact.php
CHANGED
@@ -27,7 +27,8 @@ class LI_Contact {
|
|
27 |
function set_hashkey_by_id ( $lead_id )
|
28 |
{
|
29 |
global $wpdb;
|
30 |
-
|
|
|
31 |
$this->hashkey = $wpdb->get_var($q);
|
32 |
|
33 |
return $this->hashkey;
|
@@ -53,8 +54,8 @@ class LI_Contact {
|
|
53 |
lead_status
|
54 |
FROM
|
55 |
li_leads
|
56 |
-
WHERE hashkey LIKE %s", '%b %D %l:%i%p', $this->hashkey);
|
57 |
-
|
58 |
$lead = $wpdb->get_row($q);
|
59 |
|
60 |
// Get all page views for the contact
|
@@ -69,7 +70,7 @@ class LI_Contact {
|
|
69 |
li_pageviews
|
70 |
WHERE
|
71 |
pageview_deleted = 0 AND
|
72 |
-
lead_hashkey LIKE %s ORDER BY event_date DESC", '%b %D', '%b %D %l:%i%p', $this->hashkey);
|
73 |
|
74 |
$pageviews = $wpdb->get_results($q, ARRAY_A);
|
75 |
|
@@ -86,7 +87,7 @@ class LI_Contact {
|
|
86 |
li_submissions
|
87 |
WHERE
|
88 |
form_deleted = 0 AND
|
89 |
-
lead_hashkey =
|
90 |
|
91 |
$submissions = $wpdb->get_results($q, ARRAY_A);
|
92 |
|
27 |
function set_hashkey_by_id ( $lead_id )
|
28 |
{
|
29 |
global $wpdb;
|
30 |
+
|
31 |
+
$q = $wpdb->prepare("SELECT hashkey FROM li_leads WHERE lead_id = %d " . $wpdb->multisite_query, $lead_id);
|
32 |
$this->hashkey = $wpdb->get_var($q);
|
33 |
|
34 |
return $this->hashkey;
|
54 |
lead_status
|
55 |
FROM
|
56 |
li_leads
|
57 |
+
WHERE hashkey LIKE %s " . $wpdb->multisite_query, '%b %D %l:%i%p', $this->hashkey);
|
58 |
+
|
59 |
$lead = $wpdb->get_row($q);
|
60 |
|
61 |
// Get all page views for the contact
|
70 |
li_pageviews
|
71 |
WHERE
|
72 |
pageview_deleted = 0 AND
|
73 |
+
lead_hashkey LIKE %s " . $wpdb->multisite_query . " ORDER BY event_date DESC", '%b %D', '%b %D %l:%i%p', $this->hashkey);
|
74 |
|
75 |
$pageviews = $wpdb->get_results($q, ARRAY_A);
|
76 |
|
87 |
li_submissions
|
88 |
WHERE
|
89 |
form_deleted = 0 AND
|
90 |
+
lead_hashkey = %s " . $wpdb->multisite_query . " ORDER BY event_date DESC", '%b %D %l:%i%p', $this->hashkey);
|
91 |
|
92 |
$submissions = $wpdb->get_results($q, ARRAY_A);
|
93 |
|
admin/inc/class-leadin-list-table.php
CHANGED
@@ -188,6 +188,7 @@ class LI_List_Table extends WP_List_Table {
|
|
188 |
function process_bulk_action ()
|
189 |
{
|
190 |
global $wpdb;
|
|
|
191 |
$ids_for_action = '';
|
192 |
$hashes_for_action = '';
|
193 |
|
@@ -201,7 +202,7 @@ class LI_List_Table extends WP_List_Table {
|
|
201 |
$ids_for_action .= ',';
|
202 |
}
|
203 |
|
204 |
-
$q = $wpdb->prepare("SELECT hashkey FROM li_leads WHERE lead_id IN ( " . $ids_for_action . " )", "");
|
205 |
$hashes = $wpdb->get_results($q);
|
206 |
|
207 |
if ( count($hashes) )
|
@@ -217,20 +218,20 @@ class LI_List_Table extends WP_List_Table {
|
|
217 |
//Detect when a bulk action is being triggered...
|
218 |
if( 'delete' === $this->current_action() )
|
219 |
{
|
220 |
-
$q = $wpdb->prepare("UPDATE li_pageviews SET pageview_deleted = 1 WHERE lead_hashkey IN (" . $hashes_for_action . ")", "");
|
221 |
$delete_pageviews = $wpdb->query($q);
|
222 |
|
223 |
-
$q = $wpdb->prepare("UPDATE li_submissions SET form_deleted = 1 WHERE lead_hashkey IN (" . $hashes_for_action . ")", "");
|
224 |
$delete_submissions = $wpdb->query($q);
|
225 |
|
226 |
-
$q = $wpdb->prepare("UPDATE li_leads SET lead_deleted = 1 WHERE lead_id IN (" . $ids_for_action . ")", "");
|
227 |
$delete_leads = $wpdb->query($q);
|
228 |
}
|
229 |
else if ( strstr($this->current_action(), 'change_status_to_') )
|
230 |
{
|
231 |
$new_status = str_replace('change_status_to_', '', $this->current_action());
|
232 |
|
233 |
-
$q = $wpdb->prepare("UPDATE li_leads SET lead_status = %s WHERE lead_id IN (" . $ids_for_action . ")", $new_status);
|
234 |
$wpdb->query($q);
|
235 |
}
|
236 |
}
|
@@ -275,7 +276,7 @@ class LI_List_Table extends WP_List_Table {
|
|
275 |
// filter for visiting a specific page
|
276 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'visited' )
|
277 |
{
|
278 |
-
$q = $wpdb->prepare("SELECT lead_hashkey FROM li_pageviews WHERE pageview_title LIKE '%%%s%%' GROUP BY lead_hashkey", htmlspecialchars(urldecode($_GET['filter_content'])));
|
279 |
$filtered_contacts = $wpdb->get_results($q);
|
280 |
|
281 |
if ( count($filtered_contacts) )
|
@@ -291,7 +292,7 @@ class LI_List_Table extends WP_List_Table {
|
|
291 |
// filter for a form submitted on a specific page
|
292 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'submitted' )
|
293 |
{
|
294 |
-
$q = $wpdb->prepare("SELECT lead_hashkey FROM li_submissions WHERE form_page_title LIKE '%%%s%%' GROUP BY lead_hashkey", htmlspecialchars(urldecode($_GET['filter_content'])));
|
295 |
$filtered_contacts = $wpdb->get_results($q);
|
296 |
|
297 |
if ( count($filtered_contacts) )
|
@@ -313,8 +314,8 @@ class LI_List_Table extends WP_List_Table {
|
|
313 |
COUNT(DISTINCT s.form_id) AS lead_form_submissions,
|
314 |
COUNT(DISTINCT p.pageview_id) AS lead_pageviews,
|
315 |
LOWER(DATE_FORMAT(MAX(p.pageview_date), %s)) AS last_visit,
|
316 |
-
( SELECT COUNT(DISTINCT pageview_id) FROM li_pageviews WHERE lead_hashkey = l.hashkey AND pageview_session_start = 1 AND pageview_deleted = 0 ) AS visits,
|
317 |
-
( SELECT MAX(pageview_source) AS pageview_source FROM li_pageviews WHERE lead_hashkey = l.hashkey AND pageview_session_start = 1 AND pageview_deleted = 0 ) AS pageview_source
|
318 |
FROM
|
319 |
li_leads l
|
320 |
LEFT JOIN li_submissions s ON l.hashkey = s.lead_hashkey
|
@@ -323,6 +324,7 @@ class LI_List_Table extends WP_List_Table {
|
|
323 |
|
324 |
$q .= $mysql_contact_type_filter;
|
325 |
$q .= ( $mysql_search_filter ? $mysql_search_filter : "" );
|
|
|
326 |
$q .= " GROUP BY l.lead_email";
|
327 |
|
328 |
$leads = $wpdb->get_results($q);
|
@@ -396,15 +398,15 @@ class LI_List_Table extends WP_List_Table {
|
|
396 |
$q = "
|
397 |
SELECT
|
398 |
COUNT(DISTINCT lead_email) AS total_contacts,
|
399 |
-
( SELECT COUNT(DISTINCT lead_email) FROM li_leads WHERE lead_status = 'lead' AND lead_email != '' AND lead_deleted = 0 ) AS total_leads,
|
400 |
-
( SELECT COUNT(DISTINCT lead_email) FROM li_leads WHERE lead_status = 'comment' AND lead_email != '' AND lead_deleted = 0 ) AS total_comments,
|
401 |
-
( SELECT COUNT(DISTINCT lead_email) FROM li_leads WHERE lead_status = 'subscribe' AND lead_email != '' AND lead_deleted = 0 ) AS total_subscribes,
|
402 |
-
( SELECT COUNT(DISTINCT lead_email) FROM li_leads WHERE lead_status = 'contacted' AND lead_email != '' AND lead_deleted = 0 ) AS total_contacted,
|
403 |
-
( SELECT COUNT(DISTINCT lead_email) FROM li_leads WHERE lead_status = 'customer' AND lead_email != '' AND lead_deleted = 0 ) AS total_customers
|
404 |
FROM
|
405 |
li_leads
|
406 |
WHERE
|
407 |
-
lead_email != '' AND lead_deleted = 0";
|
408 |
|
409 |
$totals = $wpdb->get_row($q);
|
410 |
return $totals;
|
@@ -497,32 +499,32 @@ class LI_List_Table extends WP_List_Table {
|
|
497 |
{
|
498 |
case 'comment' :
|
499 |
$this->view_label = 'Commenters';
|
500 |
-
$this->view_count = $this->totals->total_comments;
|
501 |
break;
|
502 |
|
503 |
case 'subscribe' :
|
504 |
$this->view_label = 'Subscribers';
|
505 |
-
$this->view_count = $this->totals->total_subscribes;
|
506 |
break;
|
507 |
|
508 |
case 'lead' :
|
509 |
$this->view_label = 'Leads';
|
510 |
-
$this->view_count = $this->totals->total_leads;
|
511 |
break;
|
512 |
|
513 |
case 'contacted' :
|
514 |
$this->view_label = 'Contacted';
|
515 |
-
$this->view_count = $this->totals->total_contacted;
|
516 |
break;
|
517 |
|
518 |
case 'customer' :
|
519 |
$this->view_label = 'Customers';
|
520 |
-
$this->view_count = $this->totals->total_customers;
|
521 |
break;
|
522 |
|
523 |
default:
|
524 |
$this->view_label = 'Contacts';
|
525 |
-
$this->view_count = $this->totals->total_contacts;
|
526 |
break;
|
527 |
}
|
528 |
|
@@ -544,8 +546,6 @@ class LI_List_Table extends WP_List_Table {
|
|
544 |
*/
|
545 |
function filters ()
|
546 |
{
|
547 |
-
global $wpdb;
|
548 |
-
|
549 |
$filters = $this->get_filters();
|
550 |
|
551 |
?>
|
@@ -580,8 +580,6 @@ class LI_List_Table extends WP_List_Table {
|
|
580 |
*/
|
581 |
function prepare_items ()
|
582 |
{
|
583 |
-
global $wpdb;
|
584 |
-
|
585 |
$per_page = 10;
|
586 |
|
587 |
$columns = $this->get_columns();
|
188 |
function process_bulk_action ()
|
189 |
{
|
190 |
global $wpdb;
|
191 |
+
|
192 |
$ids_for_action = '';
|
193 |
$hashes_for_action = '';
|
194 |
|
202 |
$ids_for_action .= ',';
|
203 |
}
|
204 |
|
205 |
+
$q = $wpdb->prepare("SELECT hashkey FROM li_leads WHERE lead_id IN ( " . $ids_for_action . " ) " . $wpdb->multisite_query, "");
|
206 |
$hashes = $wpdb->get_results($q);
|
207 |
|
208 |
if ( count($hashes) )
|
218 |
//Detect when a bulk action is being triggered...
|
219 |
if( 'delete' === $this->current_action() )
|
220 |
{
|
221 |
+
$q = $wpdb->prepare("UPDATE li_pageviews SET pageview_deleted = 1 WHERE lead_hashkey IN (" . $hashes_for_action . ") " . $wpdb->multisite_query, "");
|
222 |
$delete_pageviews = $wpdb->query($q);
|
223 |
|
224 |
+
$q = $wpdb->prepare("UPDATE li_submissions SET form_deleted = 1 WHERE lead_hashkey IN (" . $hashes_for_action . ") " . $wpdb->multisite_query, "");
|
225 |
$delete_submissions = $wpdb->query($q);
|
226 |
|
227 |
+
$q = $wpdb->prepare("UPDATE li_leads SET lead_deleted = 1 WHERE lead_id IN (" . $ids_for_action . ") " . $wpdb->multisite_query, "");
|
228 |
$delete_leads = $wpdb->query($q);
|
229 |
}
|
230 |
else if ( strstr($this->current_action(), 'change_status_to_') )
|
231 |
{
|
232 |
$new_status = str_replace('change_status_to_', '', $this->current_action());
|
233 |
|
234 |
+
$q = $wpdb->prepare("UPDATE li_leads SET lead_status = %s WHERE lead_id IN (" . $ids_for_action . ")" . $wpdb->multisite_query, $new_status);
|
235 |
$wpdb->query($q);
|
236 |
}
|
237 |
}
|
276 |
// filter for visiting a specific page
|
277 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'visited' )
|
278 |
{
|
279 |
+
$q = $wpdb->prepare("SELECT lead_hashkey FROM li_pageviews WHERE pageview_title LIKE '%%%s%%' " . $wpdb->multisite_query . " GROUP BY lead_hashkey", htmlspecialchars(urldecode($_GET['filter_content'])));
|
280 |
$filtered_contacts = $wpdb->get_results($q);
|
281 |
|
282 |
if ( count($filtered_contacts) )
|
292 |
// filter for a form submitted on a specific page
|
293 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'submitted' )
|
294 |
{
|
295 |
+
$q = $wpdb->prepare("SELECT lead_hashkey FROM li_submissions WHERE form_page_title LIKE '%%%s%%' " . $wpdb->multisite_query . " GROUP BY lead_hashkey", htmlspecialchars(urldecode($_GET['filter_content'])));
|
296 |
$filtered_contacts = $wpdb->get_results($q);
|
297 |
|
298 |
if ( count($filtered_contacts) )
|
314 |
COUNT(DISTINCT s.form_id) AS lead_form_submissions,
|
315 |
COUNT(DISTINCT p.pageview_id) AS lead_pageviews,
|
316 |
LOWER(DATE_FORMAT(MAX(p.pageview_date), %s)) AS last_visit,
|
317 |
+
( SELECT COUNT(DISTINCT pageview_id) FROM li_pageviews WHERE lead_hashkey = l.hashkey AND pageview_session_start = 1 AND pageview_deleted = 0 " . $wpdb->multisite_query . " ) AS visits,
|
318 |
+
( SELECT MAX(pageview_source) AS pageview_source FROM li_pageviews WHERE lead_hashkey = l.hashkey AND pageview_session_start = 1 AND pageview_deleted = 0 " . $wpdb->multisite_query . " ) AS pageview_source
|
319 |
FROM
|
320 |
li_leads l
|
321 |
LEFT JOIN li_submissions s ON l.hashkey = s.lead_hashkey
|
324 |
|
325 |
$q .= $mysql_contact_type_filter;
|
326 |
$q .= ( $mysql_search_filter ? $mysql_search_filter : "" );
|
327 |
+
$q .= $wpdb->prepare(" AND l.blog_id = %d ", $wpdb->blogid);
|
328 |
$q .= " GROUP BY l.lead_email";
|
329 |
|
330 |
$leads = $wpdb->get_results($q);
|
398 |
$q = "
|
399 |
SELECT
|
400 |
COUNT(DISTINCT lead_email) AS total_contacts,
|
401 |
+
( SELECT COUNT(DISTINCT lead_email) FROM li_leads WHERE lead_status = 'lead' AND lead_email != '' AND lead_deleted = 0 " . $wpdb->multisite_query . " ) AS total_leads,
|
402 |
+
( SELECT COUNT(DISTINCT lead_email) FROM li_leads WHERE lead_status = 'comment' AND lead_email != '' AND lead_deleted = 0 " . $wpdb->multisite_query . " ) AS total_comments,
|
403 |
+
( SELECT COUNT(DISTINCT lead_email) FROM li_leads WHERE lead_status = 'subscribe' AND lead_email != '' AND lead_deleted = 0 " . $wpdb->multisite_query . " ) AS total_subscribes,
|
404 |
+
( SELECT COUNT(DISTINCT lead_email) FROM li_leads WHERE lead_status = 'contacted' AND lead_email != '' AND lead_deleted = 0 " . $wpdb->multisite_query . " ) AS total_contacted,
|
405 |
+
( SELECT COUNT(DISTINCT lead_email) FROM li_leads WHERE lead_status = 'customer' AND lead_email != '' AND lead_deleted = 0 " . $wpdb->multisite_query . " ) AS total_customers
|
406 |
FROM
|
407 |
li_leads
|
408 |
WHERE
|
409 |
+
lead_email != '' AND lead_deleted = 0 " . $wpdb->multisite_query;
|
410 |
|
411 |
$totals = $wpdb->get_row($q);
|
412 |
return $totals;
|
499 |
{
|
500 |
case 'comment' :
|
501 |
$this->view_label = 'Commenters';
|
502 |
+
$this->view_count = number_format($this->totals->total_comments);
|
503 |
break;
|
504 |
|
505 |
case 'subscribe' :
|
506 |
$this->view_label = 'Subscribers';
|
507 |
+
$this->view_count = number_format($this->totals->total_subscribes);
|
508 |
break;
|
509 |
|
510 |
case 'lead' :
|
511 |
$this->view_label = 'Leads';
|
512 |
+
$this->view_count = number_format($this->totals->total_leads);
|
513 |
break;
|
514 |
|
515 |
case 'contacted' :
|
516 |
$this->view_label = 'Contacted';
|
517 |
+
$this->view_count = number_format($this->totals->total_contacted);
|
518 |
break;
|
519 |
|
520 |
case 'customer' :
|
521 |
$this->view_label = 'Customers';
|
522 |
+
$this->view_count = number_format($this->totals->total_customers);
|
523 |
break;
|
524 |
|
525 |
default:
|
526 |
$this->view_label = 'Contacts';
|
527 |
+
$this->view_count = number_format($this->totals->total_contacts);
|
528 |
break;
|
529 |
}
|
530 |
|
546 |
*/
|
547 |
function filters ()
|
548 |
{
|
|
|
|
|
549 |
$filters = $this->get_filters();
|
550 |
|
551 |
?>
|
580 |
*/
|
581 |
function prepare_items ()
|
582 |
{
|
|
|
|
|
583 |
$per_page = 10;
|
584 |
|
585 |
$columns = $this->get_columns();
|
admin/inc/class-leadin-viewers.php
CHANGED
@@ -35,8 +35,8 @@ class LI_Viewers {
|
|
35 |
li_pageviews.pageview_url = %s AND
|
36 |
li_pageviews.lead_hashkey = li_leads.hashkey AND
|
37 |
li_leads.lead_deleted = 0 AND
|
38 |
-
li_leads.lead_email != ''
|
39 |
-
GROUP BY
|
40 |
li_leads.lead_id
|
41 |
ORDER BY
|
42 |
pageview_date DESC", $pageview_url);
|
@@ -61,8 +61,8 @@ class LI_Viewers {
|
|
61 |
li_submissions.form_page_url = %s AND
|
62 |
li_submissions.lead_hashkey = li_leads.hashkey AND
|
63 |
li_leads.lead_deleted = 0 AND
|
64 |
-
li_submissions.form_deleted = 0
|
65 |
-
GROUP BY
|
66 |
li_leads.lead_id
|
67 |
ORDER BY
|
68 |
form_date DESC", $pageview_url);
|
35 |
li_pageviews.pageview_url = %s AND
|
36 |
li_pageviews.lead_hashkey = li_leads.hashkey AND
|
37 |
li_leads.lead_deleted = 0 AND
|
38 |
+
li_leads.lead_email != '' " . $wpdb->prepare(" AND blog_id = %d ", $wpdb->blogid) .
|
39 |
+
"GROUP BY
|
40 |
li_leads.lead_id
|
41 |
ORDER BY
|
42 |
pageview_date DESC", $pageview_url);
|
61 |
li_submissions.form_page_url = %s AND
|
62 |
li_submissions.lead_hashkey = li_leads.hashkey AND
|
63 |
li_leads.lead_deleted = 0 AND
|
64 |
+
li_submissions.form_deleted = 0 " . $wpdb->prepare(" AND blog_id = %d ", $wpdb->blogid) .
|
65 |
+
"GROUP BY
|
66 |
li_leads.lead_id
|
67 |
ORDER BY
|
68 |
form_date DESC", $pageview_url);
|
admin/inc/class-stats-dashboard.php
CHANGED
@@ -65,10 +65,10 @@ class LI_StatsDashboard {
|
|
65 |
function get_data_last_30_days_graph ()
|
66 |
{
|
67 |
global $wpdb;
|
68 |
-
$q = "SELECT DATE(lead_date) as lead_date, COUNT(DISTINCT hashkey) contacts FROM li_leads WHERE lead_email != '' GROUP BY DATE(lead_date)";
|
69 |
$contacts = $wpdb->get_results($q);
|
70 |
|
71 |
-
for ( $i = count($contacts); $i >= 0; $i-- )
|
72 |
{
|
73 |
$this->total_contacts += ( $contacts[$i]->contacts ? $contacts[$i]->contacts : 0);
|
74 |
$this->best_day_ever = ( $contacts[$i]->contacts && $contacts[$i]->contacts > $this->best_day_ever ? $contacts[$i]->contacts : $this->best_day_ever);
|
@@ -120,14 +120,14 @@ class LI_StatsDashboard {
|
|
120 |
DISTINCT lead_hashkey lh,
|
121 |
lead_id,
|
122 |
lead_email,
|
123 |
-
( SELECT COUNT(*) FROM li_pageviews WHERE lead_hashkey = lh ) as pageviews,
|
124 |
-
( SELECT MAX(pageview_source) AS pageview_source FROM li_pageviews WHERE lead_hashkey = lh AND pageview_session_start = 1 AND pageview_deleted = 0 ) AS lead_source
|
125 |
FROM
|
126 |
li_leads, li_pageviews
|
127 |
WHERE
|
128 |
pageview_date >= CURRENT_DATE() AND
|
129 |
li_leads.hashkey = li_pageviews.lead_hashkey AND
|
130 |
-
pageview_deleted = 0 AND lead_email != '' AND lead_deleted = 0";
|
131 |
|
132 |
return $wpdb->get_results($q);
|
133 |
}
|
@@ -147,7 +147,7 @@ class LI_StatsDashboard {
|
|
147 |
WHERE
|
148 |
lead_date >= CURRENT_DATE() AND
|
149 |
li_leads.hashkey = li_pageviews.lead_hashkey AND
|
150 |
-
pageview_deleted = 0 AND lead_email != '' AND lead_deleted = 0";
|
151 |
|
152 |
return $wpdb->get_results($q);
|
153 |
}
|
@@ -157,11 +157,11 @@ class LI_StatsDashboard {
|
|
157 |
global $wpdb;
|
158 |
|
159 |
$q = "SELECT hashkey lh,
|
160 |
-
( SELECT MAX(pageview_source) AS pageview_source FROM li_pageviews WHERE lead_hashkey = lh AND pageview_session_start = 1 AND pageview_deleted = 0 ) AS lead_source
|
161 |
FROM
|
162 |
li_leads
|
163 |
WHERE
|
164 |
-
lead_date BETWEEN CURDATE() - INTERVAL 30 DAY AND CURDATE() AND lead_email != ''";
|
165 |
|
166 |
$contacts = $wpdb->get_results($q);
|
167 |
|
65 |
function get_data_last_30_days_graph ()
|
66 |
{
|
67 |
global $wpdb;
|
68 |
+
$q = "SELECT DATE(lead_date) as lead_date, COUNT(DISTINCT hashkey) contacts FROM li_leads WHERE lead_email != '' " . $wpdb->multisite_query . " GROUP BY DATE(lead_date)";
|
69 |
$contacts = $wpdb->get_results($q);
|
70 |
|
71 |
+
for ( $i = count($contacts)-1; $i >= 0; $i-- )
|
72 |
{
|
73 |
$this->total_contacts += ( $contacts[$i]->contacts ? $contacts[$i]->contacts : 0);
|
74 |
$this->best_day_ever = ( $contacts[$i]->contacts && $contacts[$i]->contacts > $this->best_day_ever ? $contacts[$i]->contacts : $this->best_day_ever);
|
120 |
DISTINCT lead_hashkey lh,
|
121 |
lead_id,
|
122 |
lead_email,
|
123 |
+
( SELECT COUNT(*) FROM li_pageviews WHERE lead_hashkey = lh " . $wpdb->multisite_query . " ) as pageviews,
|
124 |
+
( SELECT MAX(pageview_source) AS pageview_source FROM li_pageviews WHERE lead_hashkey = lh AND pageview_session_start = 1 AND pageview_deleted = 0 " . $wpdb->multisite_query . " ) AS lead_source
|
125 |
FROM
|
126 |
li_leads, li_pageviews
|
127 |
WHERE
|
128 |
pageview_date >= CURRENT_DATE() AND
|
129 |
li_leads.hashkey = li_pageviews.lead_hashkey AND
|
130 |
+
pageview_deleted = 0 AND lead_email != '' AND lead_deleted = 0 " . $wpdb->prepare(" AND li_leads.blog_id = %d ", $wpdb->blogid);
|
131 |
|
132 |
return $wpdb->get_results($q);
|
133 |
}
|
147 |
WHERE
|
148 |
lead_date >= CURRENT_DATE() AND
|
149 |
li_leads.hashkey = li_pageviews.lead_hashkey AND
|
150 |
+
pageview_deleted = 0 AND lead_email != '' AND lead_deleted = 0 " . $wpdb->prepare(" AND li_leads.blog_id = %d ", $wpdb->blogid);
|
151 |
|
152 |
return $wpdb->get_results($q);
|
153 |
}
|
157 |
global $wpdb;
|
158 |
|
159 |
$q = "SELECT hashkey lh,
|
160 |
+
( SELECT MAX(pageview_source) AS pageview_source FROM li_pageviews WHERE lead_hashkey = lh AND pageview_session_start = 1 AND pageview_deleted = 0 " . $wpdb->multisite_query . " ) AS lead_source
|
161 |
FROM
|
162 |
li_leads
|
163 |
WHERE
|
164 |
+
lead_date BETWEEN CURDATE() - INTERVAL 30 DAY AND CURDATE() AND lead_email != '' " . $wpdb->multisite_query;
|
165 |
|
166 |
$contacts = $wpdb->get_results($q);
|
167 |
|
admin/leadin-admin.php
CHANGED
@@ -917,7 +917,7 @@ class WPLeadInAdmin {
|
|
917 |
text: ''
|
918 |
},
|
919 |
xAxis: {
|
920 |
-
categories: [ <?php echo $x_axis_labels; ?> ],
|
921 |
tickInterval: 2,
|
922 |
tickmarkPlacement: 'on',
|
923 |
labels: {
|
917 |
text: ''
|
918 |
},
|
919 |
xAxis: {
|
920 |
+
categories: [ <?php echo $this->stats_dashboard->x_axis_labels; ?> ],
|
921 |
tickInterval: 2,
|
922 |
tickmarkPlacement: 'on',
|
923 |
labels: {
|
inc/class-emailer.php
CHANGED
@@ -169,10 +169,13 @@ class LI_Emailer {
|
|
169 |
function build_form_fields ( $form_fields ) {
|
170 |
$built_form_fields = "";
|
171 |
|
172 |
-
|
173 |
{
|
174 |
-
$
|
175 |
-
|
|
|
|
|
|
|
176 |
}
|
177 |
|
178 |
return $built_form_fields;
|
169 |
function build_form_fields ( $form_fields ) {
|
170 |
$built_form_fields = "";
|
171 |
|
172 |
+
if ( count($form_fields) )
|
173 |
{
|
174 |
+
foreach ( $form_fields as $field )
|
175 |
+
{
|
176 |
+
$format = '<p class="lead-timeline__submission-field" style="margin: 0;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 19px;font-size: 14px;margin-bottom: 10px;"><label class="lead-timeline__submission-label" style="text-transform: uppercase;font-size: 12px;color: #999;letter-spacing: 0.05em;">%s</label><br/>%s </p>';
|
177 |
+
$built_form_fields .= sprintf($format, $field->label, $field->value);
|
178 |
+
}
|
179 |
}
|
180 |
|
181 |
return $built_form_fields;
|
inc/leadin-ajax-functions.php
CHANGED
@@ -18,17 +18,17 @@ function leadin_check_merged_contact ()
|
|
18 |
$stale_hash = $_POST['li_id'];
|
19 |
|
20 |
// Check if hashkey is in a merged contact
|
21 |
-
$q = $wpdb->prepare("SELECT hashkey, merged_hashkeys FROM li_leads WHERE merged_hashkeys LIKE '%%%s%%'", like_escape($stale_hash));
|
22 |
$row = $wpdb->get_row($q);
|
23 |
|
24 |
if ( isset($row->hashkey) && $stale_hash )
|
25 |
{
|
26 |
// One final update to set all the previous pageviews to the new hashkey
|
27 |
-
$q = $wpdb->prepare("UPDATE li_pageviews SET lead_hashkey = %s WHERE lead_hashkey = %s", $row->hashkey, $stale_hash);
|
28 |
$wpdb->query($q);
|
29 |
|
30 |
// One final update to set all the previous submissions to the new hashkey
|
31 |
-
$q = $wpdb->prepare("UPDATE li_submissions SET lead_hashkey = %s WHERE lead_hashkey = %s", $row->hashkey, $stale_hash);
|
32 |
$wpdb->query($q);
|
33 |
|
34 |
// Remove the passed hash from the merged hashkeys for the row
|
@@ -37,7 +37,7 @@ function leadin_check_merged_contact ()
|
|
37 |
// Delete the stale hash from the merged hashkeys array
|
38 |
$merged_hashkeys = leadin_array_delete($merged_hashkeys, "'" . $stale_hash . "'");
|
39 |
|
40 |
-
$q = $wpdb->prepare("UPDATE li_leads SET merged_hashkeys = %s WHERE hashkey = %s", rtrim(implode(',', $merged_hashkeys), ','), $row->hashkey);
|
41 |
$wpdb->query($q);
|
42 |
|
43 |
echo json_encode($row->hashkey);
|
@@ -71,14 +71,15 @@ function leadin_log_pageview ()
|
|
71 |
$result = $wpdb->insert(
|
72 |
'li_pageviews',
|
73 |
array(
|
74 |
-
'lead_hashkey'
|
75 |
-
'pageview_title'
|
76 |
-
'pageview_url'
|
77 |
-
'pageview_source'
|
78 |
-
'pageview_session_start'
|
|
|
79 |
),
|
80 |
array(
|
81 |
-
'%s', '%s', '%s', '%s'
|
82 |
)
|
83 |
);
|
84 |
|
@@ -104,12 +105,13 @@ function leadin_insert_lead ()
|
|
104 |
$result = $wpdb->insert(
|
105 |
'li_leads',
|
106 |
array(
|
107 |
-
'hashkey'
|
108 |
-
'lead_ip'
|
109 |
-
'lead_source'
|
|
|
110 |
),
|
111 |
array(
|
112 |
-
'%s', '%s', '%s'
|
113 |
)
|
114 |
);
|
115 |
|
@@ -144,7 +146,7 @@ function leadin_insert_form_submission ()
|
|
144 |
$li_admin_email = ( isset($options['li_email']) ) ? $options['li_email'] : '';
|
145 |
|
146 |
// Check to see if the form_hashkey exists, and if it does, don't run the insert or send the email
|
147 |
-
$q = $wpdb->prepare("SELECT form_hashkey FROM li_submissions WHERE form_hashkey = %s AND form_deleted = 0", $submission_hash);
|
148 |
$submission_hash_exists = $wpdb->get_var($q);
|
149 |
|
150 |
if ( $submission_hash_exists )
|
@@ -158,11 +160,11 @@ function leadin_insert_form_submission ()
|
|
158 |
if ( !(current_user_can('administrator') && $submission_type == 'comment') && !(strstr($li_admin_email, $email) && $submission_type == 'comment') )
|
159 |
{
|
160 |
// Get the contact row tied to hashkey
|
161 |
-
$q = $wpdb->prepare("SELECT * FROM li_leads WHERE hashkey = %s AND lead_deleted = 0", $hashkey);
|
162 |
$contact = $wpdb->get_row($q);
|
163 |
|
164 |
// Check for existing contacts based on whether the email is present in the contacts table
|
165 |
-
$q = $wpdb->prepare("SELECT lead_email, hashkey, merged_hashkeys, lead_status FROM li_leads WHERE lead_email = %s AND hashkey != %s AND lead_deleted = 0", $email, $hashkey);
|
166 |
$existing_contacts = $wpdb->get_results($q);
|
167 |
|
168 |
// Set the default contact life cycle status to lead
|
@@ -205,19 +207,19 @@ function leadin_insert_form_submission ()
|
|
205 |
$existing_contact_hashkeys = rtrim($existing_contact_hashkeys, ',');
|
206 |
|
207 |
// Update all the previous pageviews to the new hashkey
|
208 |
-
$q = $wpdb->prepare("UPDATE li_pageviews SET lead_hashkey = %s WHERE lead_hashkey IN ( $existing_contact_hashkeys )", $hashkey);
|
209 |
$wpdb->query($q);
|
210 |
|
211 |
// Update all the previous submissions to the new hashkey
|
212 |
-
$q = $wpdb->prepare("UPDATE li_submissions SET lead_hashkey = %s WHERE lead_hashkey IN ( $existing_contact_hashkeys )", $hashkey);
|
213 |
$wpdb->query($q);
|
214 |
|
215 |
// "Delete" all the old leads from the leads table
|
216 |
-
$wpdb->query("UPDATE li_leads SET lead_deleted = 1 WHERE hashkey IN ( $existing_contact_hashkeys )");
|
217 |
}
|
218 |
|
219 |
// Prevent duplicate form submission entries by deleting existing submissions if it didn't finish the process before the web page refreshed
|
220 |
-
$q = $wpdb->prepare("UPDATE li_submissions SET form_deleted = 1 WHERE form_hashkey = %s", $submission_hash);
|
221 |
$wpdb->query($q);
|
222 |
|
223 |
// Insert the form fields and hash into the submissions table
|
@@ -231,10 +233,11 @@ function leadin_insert_form_submission ()
|
|
231 |
'form_fields' => $form_json,
|
232 |
'form_type' => $submission_type,
|
233 |
'form_selector_id' => $form_selector_id,
|
234 |
-
'form_selector_classes' => $form_selector_classes
|
|
|
235 |
),
|
236 |
array(
|
237 |
-
'%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'
|
238 |
)
|
239 |
);
|
240 |
|
@@ -260,7 +263,7 @@ function leadin_insert_form_submission ()
|
|
260 |
$contact_status = $contact->lead_status;
|
261 |
|
262 |
// Update the contact with the new email, status and merged hashkeys
|
263 |
-
$q = $wpdb->prepare("UPDATE li_leads SET lead_email = %s, lead_status = %s, merged_hashkeys = %s WHERE hashkey = %s", $email, $contact_status, $existing_contact_hashkeys, $hashkey);
|
264 |
$rows_updated = $wpdb->query($q);
|
265 |
|
266 |
// Hit ESP APIs if power-up activated
|
@@ -317,7 +320,7 @@ function leadin_check_visitor_status ()
|
|
317 |
|
318 |
$hash = $_POST['li_id'];
|
319 |
|
320 |
-
$q = $wpdb->prepare("SELECT lead_status FROM li_leads WHERE hashkey = %s AND lead_deleted = 0", $hash);
|
321 |
$lead_status = $wpdb->get_var($q);
|
322 |
|
323 |
if ( isset($lead_status) )
|
@@ -371,5 +374,4 @@ function leadin_get_posts_and_pages ( )
|
|
371 |
add_action('wp_ajax_leadin_get_posts_and_pages', 'leadin_get_posts_and_pages'); // Call when user logged in
|
372 |
add_action('wp_ajax_nopriv_leadin_get_posts_and_pages', 'leadin_get_posts_and_pages'); // Call when user is not logged in
|
373 |
|
374 |
-
|
375 |
?>
|
18 |
$stale_hash = $_POST['li_id'];
|
19 |
|
20 |
// Check if hashkey is in a merged contact
|
21 |
+
$q = $wpdb->prepare("SELECT hashkey, merged_hashkeys FROM li_leads WHERE merged_hashkeys LIKE '%%%s%%' " . $wpdb->multisite_query, like_escape($stale_hash));
|
22 |
$row = $wpdb->get_row($q);
|
23 |
|
24 |
if ( isset($row->hashkey) && $stale_hash )
|
25 |
{
|
26 |
// One final update to set all the previous pageviews to the new hashkey
|
27 |
+
$q = $wpdb->prepare("UPDATE li_pageviews SET lead_hashkey = %s WHERE lead_hashkey = %s " . $wpdb->multisite_query, $row->hashkey, $stale_hash);
|
28 |
$wpdb->query($q);
|
29 |
|
30 |
// One final update to set all the previous submissions to the new hashkey
|
31 |
+
$q = $wpdb->prepare("UPDATE li_submissions SET lead_hashkey = %s WHERE lead_hashkey = %s " . $wpdb->multisite_query, $row->hashkey, $stale_hash);
|
32 |
$wpdb->query($q);
|
33 |
|
34 |
// Remove the passed hash from the merged hashkeys for the row
|
37 |
// Delete the stale hash from the merged hashkeys array
|
38 |
$merged_hashkeys = leadin_array_delete($merged_hashkeys, "'" . $stale_hash . "'");
|
39 |
|
40 |
+
$q = $wpdb->prepare("UPDATE li_leads SET merged_hashkeys = %s WHERE hashkey = %s " . $wpdb->multisite_query, rtrim(implode(',', $merged_hashkeys), ','), $row->hashkey);
|
41 |
$wpdb->query($q);
|
42 |
|
43 |
echo json_encode($row->hashkey);
|
71 |
$result = $wpdb->insert(
|
72 |
'li_pageviews',
|
73 |
array(
|
74 |
+
'lead_hashkey' => $hash,
|
75 |
+
'pageview_title' => $title,
|
76 |
+
'pageview_url' => $url,
|
77 |
+
'pageview_source' => $source,
|
78 |
+
'pageview_session_start' => ( !$last_visit ? 1 : 0 ),
|
79 |
+
'blog_id' => $wpdb->blogid
|
80 |
),
|
81 |
array(
|
82 |
+
'%s', '%s', '%s', '%s', '%s', '%s'
|
83 |
)
|
84 |
);
|
85 |
|
105 |
$result = $wpdb->insert(
|
106 |
'li_leads',
|
107 |
array(
|
108 |
+
'hashkey' => $hashkey,
|
109 |
+
'lead_ip' => $ipaddress,
|
110 |
+
'lead_source' => $source,
|
111 |
+
'blog_id' => $wpdb->blogid
|
112 |
),
|
113 |
array(
|
114 |
+
'%s', '%s', '%s', '%s'
|
115 |
)
|
116 |
);
|
117 |
|
146 |
$li_admin_email = ( isset($options['li_email']) ) ? $options['li_email'] : '';
|
147 |
|
148 |
// Check to see if the form_hashkey exists, and if it does, don't run the insert or send the email
|
149 |
+
$q = $wpdb->prepare("SELECT form_hashkey FROM li_submissions WHERE form_hashkey = %s AND form_deleted = 0 " . $wpdb->multisite_query, $submission_hash);
|
150 |
$submission_hash_exists = $wpdb->get_var($q);
|
151 |
|
152 |
if ( $submission_hash_exists )
|
160 |
if ( !(current_user_can('administrator') && $submission_type == 'comment') && !(strstr($li_admin_email, $email) && $submission_type == 'comment') )
|
161 |
{
|
162 |
// Get the contact row tied to hashkey
|
163 |
+
$q = $wpdb->prepare("SELECT * FROM li_leads WHERE hashkey = %s AND lead_deleted = 0 " . $wpdb->multisite_query, $hashkey);
|
164 |
$contact = $wpdb->get_row($q);
|
165 |
|
166 |
// Check for existing contacts based on whether the email is present in the contacts table
|
167 |
+
$q = $wpdb->prepare("SELECT lead_email, hashkey, merged_hashkeys, lead_status FROM li_leads WHERE lead_email = %s AND hashkey != %s AND lead_deleted = 0 " . $wpdb->multisite_query, $email, $hashkey);
|
168 |
$existing_contacts = $wpdb->get_results($q);
|
169 |
|
170 |
// Set the default contact life cycle status to lead
|
207 |
$existing_contact_hashkeys = rtrim($existing_contact_hashkeys, ',');
|
208 |
|
209 |
// Update all the previous pageviews to the new hashkey
|
210 |
+
$q = $wpdb->prepare("UPDATE li_pageviews SET lead_hashkey = %s WHERE lead_hashkey IN ( $existing_contact_hashkeys ) " . $wpdb->multisite_query, $hashkey);
|
211 |
$wpdb->query($q);
|
212 |
|
213 |
// Update all the previous submissions to the new hashkey
|
214 |
+
$q = $wpdb->prepare("UPDATE li_submissions SET lead_hashkey = %s WHERE lead_hashkey IN ( $existing_contact_hashkeys ) " . $wpdb->multisite_query, $hashkey);
|
215 |
$wpdb->query($q);
|
216 |
|
217 |
// "Delete" all the old leads from the leads table
|
218 |
+
$wpdb->query("UPDATE li_leads SET lead_deleted = 1 WHERE hashkey IN ( $existing_contact_hashkeys ) " . $wpdb->multisite_query);
|
219 |
}
|
220 |
|
221 |
// Prevent duplicate form submission entries by deleting existing submissions if it didn't finish the process before the web page refreshed
|
222 |
+
$q = $wpdb->prepare("UPDATE li_submissions SET form_deleted = 1 WHERE form_hashkey = %s " . $wpdb->multisite_query, $submission_hash);
|
223 |
$wpdb->query($q);
|
224 |
|
225 |
// Insert the form fields and hash into the submissions table
|
233 |
'form_fields' => $form_json,
|
234 |
'form_type' => $submission_type,
|
235 |
'form_selector_id' => $form_selector_id,
|
236 |
+
'form_selector_classes' => $form_selector_classes,
|
237 |
+
'blog_id' => $wpdb->blogid
|
238 |
),
|
239 |
array(
|
240 |
+
'%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'
|
241 |
)
|
242 |
);
|
243 |
|
263 |
$contact_status = $contact->lead_status;
|
264 |
|
265 |
// Update the contact with the new email, status and merged hashkeys
|
266 |
+
$q = $wpdb->prepare("UPDATE li_leads SET lead_email = %s, lead_status = %s, merged_hashkeys = %s WHERE hashkey = %s " . $wpdb->multisite_query, $email, $contact_status, $existing_contact_hashkeys, $hashkey);
|
267 |
$rows_updated = $wpdb->query($q);
|
268 |
|
269 |
// Hit ESP APIs if power-up activated
|
320 |
|
321 |
$hash = $_POST['li_id'];
|
322 |
|
323 |
+
$q = $wpdb->prepare("SELECT lead_status FROM li_leads WHERE hashkey = %s AND lead_deleted = 0 " . $wpdb->multisite_query, $hash);
|
324 |
$lead_status = $wpdb->get_var($q);
|
325 |
|
326 |
if ( isset($lead_status) )
|
374 |
add_action('wp_ajax_leadin_get_posts_and_pages', 'leadin_get_posts_and_pages'); // Call when user logged in
|
375 |
add_action('wp_ajax_nopriv_leadin_get_posts_and_pages', 'leadin_get_posts_and_pages'); // Call when user is not logged in
|
376 |
|
|
|
377 |
?>
|
inc/leadin-functions.php
CHANGED
@@ -281,7 +281,7 @@ function leadin_recover_contact_data ()
|
|
281 |
{
|
282 |
global $wpdb;
|
283 |
|
284 |
-
$q = $wpdb->prepare("SELECT * FROM li_submissions AS s LEFT JOIN li_leads AS l ON s.lead_hashkey = l.hashkey WHERE l.hashkey IS NULL AND s.form_fields LIKE '%%%s%%' AND s.form_fields LIKE '%%%s%%' AND form_deleted = 0", '@', '.');
|
285 |
$submissions = $wpdb->get_results($q);
|
286 |
|
287 |
if ( count($submissions) )
|
@@ -297,23 +297,24 @@ function leadin_recover_contact_data ()
|
|
297 |
if ( strstr($object['value'], '@') && strstr($object['value'], '@') && strlen($object['value']) <= 254 )
|
298 |
{
|
299 |
// check to see if the contact exists and if it does, skip the data recovery
|
300 |
-
$q = $wpdb->prepare("SELECT lead_email FROM li_leads WHERE lead_email = %s AND lead_deleted = 0", $object['value']);
|
301 |
$exists = $wpdb->get_var($q);
|
302 |
|
303 |
if ( $exists )
|
304 |
continue;
|
305 |
|
306 |
// get the original data
|
307 |
-
$q = $wpdb->prepare("SELECT pageview_date, pageview_source FROM li_pageviews WHERE lead_hashkey = %s AND pageview_deleted = 0 ORDER BY pageview_date ASC LIMIT 1", $submission->lead_hashkey);
|
308 |
$first_pageview = $wpdb->get_row($q);
|
309 |
|
310 |
// recreate the contact
|
311 |
-
$q = $wpdb->prepare("INSERT INTO li_leads ( lead_date, hashkey, lead_source, lead_email, lead_status ) VALUES ( %s, %s, %s, %s, %s )",
|
312 |
( $first_pageview->pageview_date ? $first_pageview->pageview_date : $submission->form_date),
|
313 |
$submission->lead_hashkey,
|
314 |
( $first_pageview->pageview_source ? $first_pageview->pageview_source : ''),
|
315 |
$object['value'],
|
316 |
-
$submission->form_type
|
|
|
317 |
);
|
318 |
|
319 |
$wpdb->query($q);
|
@@ -334,7 +335,7 @@ function leadin_delete_flag_fix ()
|
|
334 |
{
|
335 |
global $wpdb;
|
336 |
|
337 |
-
$q = $wpdb->prepare("SELECT lead_email, COUNT(hashkey) c FROM li_leads WHERE lead_email != '' AND lead_deleted = 0 GROUP BY lead_email HAVING c > 1", '');
|
338 |
$duplicates = $wpdb->get_results($q);
|
339 |
|
340 |
if ( count($duplicates) )
|
@@ -343,7 +344,7 @@ function leadin_delete_flag_fix ()
|
|
343 |
{
|
344 |
$existing_contact_status = 'lead';
|
345 |
|
346 |
-
$q = $wpdb->prepare("SELECT lead_email, hashkey, merged_hashkeys, lead_status FROM li_leads WHERE lead_email = %s AND lead_deleted = 0 ORDER BY lead_date DESC", $duplicate->lead_email);
|
347 |
$existing_contacts = $wpdb->get_results($q);
|
348 |
|
349 |
$newest = $existing_contacts[0];
|
@@ -388,19 +389,19 @@ function leadin_delete_flag_fix ()
|
|
388 |
if ( $existing_contact_hashkey_string )
|
389 |
{
|
390 |
// Set the merged hashkeys with the fixed merged hashkey values
|
391 |
-
$q = $wpdb->prepare("UPDATE li_leads SET merged_hashkeys = %s, lead_status = %s WHERE hashkey = %s", $existing_contact_hashkey_string, $existing_contact_status, $newest->hashkey);
|
392 |
$wpdb->query($q);
|
393 |
|
394 |
// "Delete" all the old contacts
|
395 |
-
$q = $wpdb->prepare("UPDATE li_leads SET merged_hashkeys = '', lead_deleted = 1 WHERE hashkey IN ( $existing_contact_hashkey_string )", '');
|
396 |
$wpdb->query($q);
|
397 |
|
398 |
// Set all the pageviews and submissions to the new hashkey just in case
|
399 |
-
$q = $wpdb->prepare("UPDATE li_pageviews SET lead_hashkey = %s WHERE lead_hashkey IN ( $existing_contact_hashkey_string )", $newest->hashkey);
|
400 |
$wpdb->query($q);
|
401 |
|
402 |
// Update all the previous submissions to the new hashkey just in case
|
403 |
-
$q = $wpdb->prepare("UPDATE li_submissions SET lead_hashkey = %s WHERE lead_hashkey IN ( $existing_contact_hashkey_string )", $newest->hashkey);
|
404 |
$wpdb->query($q);
|
405 |
}
|
406 |
}
|
@@ -509,7 +510,7 @@ function leadin_get_contact_types ( $date )
|
|
509 |
$q = $wpdb->prepare("SELECT `COLUMN_TYPE` FROM `information_schema`.`COLUMNS`
|
510 |
WHERE `TABLE_SCHEMA` = %s
|
511 |
AND `TABLE_NAME` = 'li_leads'
|
512 |
-
AND `COLUMN_NAME` = 'lead_status'
|
513 |
|
514 |
$row = $wpdb->get_row($q);
|
515 |
$set = $row->COLUMN_TYPE;
|
281 |
{
|
282 |
global $wpdb;
|
283 |
|
284 |
+
$q = $wpdb->prepare("SELECT * FROM li_submissions AS s LEFT JOIN li_leads AS l ON s.lead_hashkey = l.hashkey WHERE l.hashkey IS NULL AND s.form_fields LIKE '%%%s%%' AND s.form_fields LIKE '%%%s%%' AND form_deleted = 0 " . $wpdb->multisite_query, '@', '.');
|
285 |
$submissions = $wpdb->get_results($q);
|
286 |
|
287 |
if ( count($submissions) )
|
297 |
if ( strstr($object['value'], '@') && strstr($object['value'], '@') && strlen($object['value']) <= 254 )
|
298 |
{
|
299 |
// check to see if the contact exists and if it does, skip the data recovery
|
300 |
+
$q = $wpdb->prepare("SELECT lead_email FROM li_leads WHERE lead_email = %s AND lead_deleted = 0 " . $wpdb->multisite_query, $object['value']);
|
301 |
$exists = $wpdb->get_var($q);
|
302 |
|
303 |
if ( $exists )
|
304 |
continue;
|
305 |
|
306 |
// get the original data
|
307 |
+
$q = $wpdb->prepare("SELECT pageview_date, pageview_source FROM li_pageviews WHERE lead_hashkey = %s AND pageview_deleted = 0 " . $wpdb->multisite_query . " ORDER BY pageview_date ASC LIMIT 1", $submission->lead_hashkey);
|
308 |
$first_pageview = $wpdb->get_row($q);
|
309 |
|
310 |
// recreate the contact
|
311 |
+
$q = $wpdb->prepare("INSERT INTO li_leads ( lead_date, hashkey, lead_source, lead_email, lead_status, blog_id ) VALUES ( %s, %s, %s, %s, %s, %d )",
|
312 |
( $first_pageview->pageview_date ? $first_pageview->pageview_date : $submission->form_date),
|
313 |
$submission->lead_hashkey,
|
314 |
( $first_pageview->pageview_source ? $first_pageview->pageview_source : ''),
|
315 |
$object['value'],
|
316 |
+
$submission->form_type,
|
317 |
+
$wpdb->blogid
|
318 |
);
|
319 |
|
320 |
$wpdb->query($q);
|
335 |
{
|
336 |
global $wpdb;
|
337 |
|
338 |
+
$q = $wpdb->prepare("SELECT lead_email, COUNT(hashkey) c FROM li_leads WHERE lead_email != '' AND lead_deleted = 0 " . $wpdb->multisite_query . " GROUP BY lead_email HAVING c > 1", '');
|
339 |
$duplicates = $wpdb->get_results($q);
|
340 |
|
341 |
if ( count($duplicates) )
|
344 |
{
|
345 |
$existing_contact_status = 'lead';
|
346 |
|
347 |
+
$q = $wpdb->prepare("SELECT lead_email, hashkey, merged_hashkeys, lead_status FROM li_leads WHERE lead_email = %s AND lead_deleted = 0 " . $wpdb->multisite_query . " ORDER BY lead_date DESC", $duplicate->lead_email);
|
348 |
$existing_contacts = $wpdb->get_results($q);
|
349 |
|
350 |
$newest = $existing_contacts[0];
|
389 |
if ( $existing_contact_hashkey_string )
|
390 |
{
|
391 |
// Set the merged hashkeys with the fixed merged hashkey values
|
392 |
+
$q = $wpdb->prepare("UPDATE li_leads SET merged_hashkeys = %s, lead_status = %s WHERE hashkey = %s " . $wpdb->multisite_query, $existing_contact_hashkey_string, $existing_contact_status, $newest->hashkey);
|
393 |
$wpdb->query($q);
|
394 |
|
395 |
// "Delete" all the old contacts
|
396 |
+
$q = $wpdb->prepare("UPDATE li_leads SET merged_hashkeys = '', lead_deleted = 1 WHERE hashkey IN ( $existing_contact_hashkey_string ) " . $wpdb->multisite_query, '');
|
397 |
$wpdb->query($q);
|
398 |
|
399 |
// Set all the pageviews and submissions to the new hashkey just in case
|
400 |
+
$q = $wpdb->prepare("UPDATE li_pageviews SET lead_hashkey = %s WHERE lead_hashkey IN ( $existing_contact_hashkey_string ) " . $wpdb->multisite_query, $newest->hashkey);
|
401 |
$wpdb->query($q);
|
402 |
|
403 |
// Update all the previous submissions to the new hashkey just in case
|
404 |
+
$q = $wpdb->prepare("UPDATE li_submissions SET lead_hashkey = %s WHERE lead_hashkey IN ( $existing_contact_hashkey_string ) " . $wpdb->multisite_query, $newest->hashkey);
|
405 |
$wpdb->query($q);
|
406 |
}
|
407 |
}
|
510 |
$q = $wpdb->prepare("SELECT `COLUMN_TYPE` FROM `information_schema`.`COLUMNS`
|
511 |
WHERE `TABLE_SCHEMA` = %s
|
512 |
AND `TABLE_NAME` = 'li_leads'
|
513 |
+
AND `COLUMN_NAME` = 'lead_status' " . $wpdb->multisite_query, DB_NAME);
|
514 |
|
515 |
$row = $wpdb->get_row($q);
|
516 |
$set = $row->COLUMN_TYPE;
|
leadin.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: LeadIn
|
4 |
Plugin URI: http://leadin.com
|
5 |
Description: LeadIn is an easy-to-use marketing automation and lead tracking plugin for WordPress that helps you better understand your web site visitors.
|
6 |
-
Version: 1.
|
7 |
Author: Andy Cook, Nelson Joyce
|
8 |
Author URI: http://leadin.com
|
9 |
License: GPL2
|
@@ -23,10 +23,10 @@ if ( !defined('LEADIN_PLUGIN_SLUG') )
|
|
23 |
define('LEADIN_PLUGIN_SLUG', basename(dirname(__FILE__)));
|
24 |
|
25 |
if ( !defined('LEADIN_DB_VERSION') )
|
26 |
-
define('LEADIN_DB_VERSION', '1.
|
27 |
|
28 |
if ( !defined('LEADIN_PLUGIN_VERSION') )
|
29 |
-
define('LEADIN_PLUGIN_VERSION', '1.
|
30 |
|
31 |
if ( !defined('MIXPANEL_PROJECT_TOKEN') )
|
32 |
define('MIXPANEL_PROJECT_TOKEN', 'a9615503ec58a6bce2c646a58390eac1');
|
@@ -83,6 +83,9 @@ class WPLeadIn {
|
|
83 |
|
84 |
if ( isset($this->options['beta_tester']) && $this->options['beta_tester'] )
|
85 |
$li_wp_updater = new WPLeadInUpdater();
|
|
|
|
|
|
|
86 |
}
|
87 |
|
88 |
/**
|
@@ -154,6 +157,7 @@ class WPLeadIn {
|
|
154 |
`lead_status` set('contact','lead','comment','subscribe','contacted','customer') NOT NULL DEFAULT 'contact',
|
155 |
`merged_hashkeys` text,
|
156 |
`lead_deleted` int(1) NOT NULL DEFAULT '0',
|
|
|
157 |
PRIMARY KEY (`lead_id`),
|
158 |
KEY `hashkey` (`hashkey`)
|
159 |
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
|
@@ -167,6 +171,7 @@ class WPLeadIn {
|
|
167 |
`pageview_source` text NOT NULL,
|
168 |
`pageview_session_start` int(1) NOT NULL,
|
169 |
`pageview_deleted` int(1) NOT NULL DEFAULT '0',
|
|
|
170 |
PRIMARY KEY (`pageview_id`),
|
171 |
KEY `lead_hashkey` (`lead_hashkey`)
|
172 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
|
@@ -183,9 +188,10 @@ class WPLeadIn {
|
|
183 |
`form_selector_classes` mediumtext NOT NULL,
|
184 |
`form_hashkey` varchar(16) NOT NULL,
|
185 |
`form_deleted` int(1) NOT NULL DEFAULT '0',
|
|
|
186 |
PRIMARY KEY (`form_id`),
|
187 |
KEY `lead_hashkey` (`lead_hashkey`)
|
188 |
-
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1
|
189 |
|
190 |
dbDelta($sql);
|
191 |
|
@@ -256,7 +262,7 @@ class WPLeadIn {
|
|
256 |
$this->leadin_db_install();
|
257 |
|
258 |
// 1.1.0 upgrade - After the DB installation converts the set structure from contact to lead, update all the blank form_type = leads
|
259 |
-
$q = $wpdb->prepare("UPDATE li_submissions SET form_type = 'contact' WHERE form_type = 'lead' OR form_type = ''", "");
|
260 |
$wpdb->query($q);
|
261 |
}
|
262 |
}
|
@@ -536,6 +542,7 @@ class WPLeadIn {
|
|
536 |
|
537 |
global $leadin_wp;
|
538 |
global $li_wp_admin;
|
|
|
539 |
$leadin_wp = new WPLeadIn();
|
540 |
|
541 |
?>
|
3 |
Plugin Name: LeadIn
|
4 |
Plugin URI: http://leadin.com
|
5 |
Description: LeadIn is an easy-to-use marketing automation and lead tracking plugin for WordPress that helps you better understand your web site visitors.
|
6 |
+
Version: 1.3.0
|
7 |
Author: Andy Cook, Nelson Joyce
|
8 |
Author URI: http://leadin.com
|
9 |
License: GPL2
|
23 |
define('LEADIN_PLUGIN_SLUG', basename(dirname(__FILE__)));
|
24 |
|
25 |
if ( !defined('LEADIN_DB_VERSION') )
|
26 |
+
define('LEADIN_DB_VERSION', '1.3.0');
|
27 |
|
28 |
if ( !defined('LEADIN_PLUGIN_VERSION') )
|
29 |
+
define('LEADIN_PLUGIN_VERSION', '1.3.0');
|
30 |
|
31 |
if ( !defined('MIXPANEL_PROJECT_TOKEN') )
|
32 |
define('MIXPANEL_PROJECT_TOKEN', 'a9615503ec58a6bce2c646a58390eac1');
|
83 |
|
84 |
if ( isset($this->options['beta_tester']) && $this->options['beta_tester'] )
|
85 |
$li_wp_updater = new WPLeadInUpdater();
|
86 |
+
|
87 |
+
global $wpdb;
|
88 |
+
$wpdb->multisite_query = ( is_multisite() ? $wpdb->prepare(" AND blog_id = %d ", $wpdb->blogid) : "" );
|
89 |
}
|
90 |
|
91 |
/**
|
157 |
`lead_status` set('contact','lead','comment','subscribe','contacted','customer') NOT NULL DEFAULT 'contact',
|
158 |
`merged_hashkeys` text,
|
159 |
`lead_deleted` int(1) NOT NULL DEFAULT '0',
|
160 |
+
`blog_id` int(11) unsigned NOT NULL,
|
161 |
PRIMARY KEY (`lead_id`),
|
162 |
KEY `hashkey` (`hashkey`)
|
163 |
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
|
171 |
`pageview_source` text NOT NULL,
|
172 |
`pageview_session_start` int(1) NOT NULL,
|
173 |
`pageview_deleted` int(1) NOT NULL DEFAULT '0',
|
174 |
+
`blog_id` int(11) unsigned NOT NULL,
|
175 |
PRIMARY KEY (`pageview_id`),
|
176 |
KEY `lead_hashkey` (`lead_hashkey`)
|
177 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
|
188 |
`form_selector_classes` mediumtext NOT NULL,
|
189 |
`form_hashkey` varchar(16) NOT NULL,
|
190 |
`form_deleted` int(1) NOT NULL DEFAULT '0',
|
191 |
+
`blog_id` int(11) unsigned NOT NULL,
|
192 |
PRIMARY KEY (`form_id`),
|
193 |
KEY `lead_hashkey` (`lead_hashkey`)
|
194 |
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;";
|
195 |
|
196 |
dbDelta($sql);
|
197 |
|
262 |
$this->leadin_db_install();
|
263 |
|
264 |
// 1.1.0 upgrade - After the DB installation converts the set structure from contact to lead, update all the blank form_type = leads
|
265 |
+
$q = $wpdb->prepare("UPDATE li_submissions SET form_type = 'contact' WHERE form_type = 'lead' OR form_type = ''" . $wpdb->multisite_query, "");
|
266 |
$wpdb->query($q);
|
267 |
}
|
268 |
}
|
542 |
|
543 |
global $leadin_wp;
|
544 |
global $li_wp_admin;
|
545 |
+
global $multisite_query;
|
546 |
$leadin_wp = new WPLeadIn();
|
547 |
|
548 |
?>
|
power-ups/contacts/admin/contacts-admin.php
CHANGED
@@ -338,16 +338,16 @@ class WPLeadInContactsAdmin extends WPLeadInAdmin {
|
|
338 |
{
|
339 |
global $wpdb;
|
340 |
|
341 |
-
$q = $wpdb->prepare("SELECT hashkey FROM li_leads WHERE lead_id = %d", $lead_id);
|
342 |
$lead_hash = $wpdb->get_var($q);
|
343 |
|
344 |
-
$q = $wpdb->prepare("UPDATE li_pageviews SET pageview_deleted = 1 WHERE lead_hashkey = %s AND pageview_deleted = 0", $lead_hash);
|
345 |
$delete_pageviews = $wpdb->query($q);
|
346 |
|
347 |
-
$q = $wpdb->prepare("UPDATE li_submissions SET form_deleted = 1 WHERE lead_hashkey = %s AND form_deleted = 0", $lead_hash);
|
348 |
$delete_submissions = $wpdb->query($q);
|
349 |
|
350 |
-
$q = $wpdb->prepare("UPDATE li_leads SET lead_deleted = 1 WHERE lead_id = %d AND lead_deleted = 0", $lead_id);
|
351 |
$delete_lead = $wpdb->query($q);
|
352 |
|
353 |
return $delete_lead;
|
@@ -364,7 +364,7 @@ class WPLeadInContactsAdmin extends WPLeadInAdmin {
|
|
364 |
{
|
365 |
global $wpdb;
|
366 |
|
367 |
-
$q = $wpdb->prepare("UPDATE li_leads SET lead_status = %s WHERE lead_id = %d", $contact_status, $lead_id);
|
368 |
$result = $wpdb->query($q);
|
369 |
|
370 |
return $result;
|
@@ -461,7 +461,7 @@ if ( isset($_POST['export-all']) || isset($_POST['export-selected']) )
|
|
461 |
// filter for visiting a specific page
|
462 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'visited' )
|
463 |
{
|
464 |
-
$q = $wpdb->prepare("SELECT lead_hashkey FROM li_pageviews WHERE pageview_title LIKE '%%%s%%' GROUP BY lead_hashkey", htmlspecialchars(urldecode($_GET['filter_content'])));
|
465 |
$filtered_contacts = $wpdb->get_results($q);
|
466 |
|
467 |
if ( count($filtered_contacts) )
|
@@ -477,7 +477,7 @@ if ( isset($_POST['export-all']) || isset($_POST['export-selected']) )
|
|
477 |
// filter for a form submitted on a specific page
|
478 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'submitted' )
|
479 |
{
|
480 |
-
$q = $wpdb->prepare("SELECT lead_hashkey FROM li_submissions WHERE form_page_title LIKE '%%%s%%' GROUP BY lead_hashkey", htmlspecialchars(urldecode($_GET['filter_content'])));
|
481 |
$filtered_contacts = $wpdb->get_results($q);
|
482 |
|
483 |
$filtered_hashkeys = '';
|
@@ -505,6 +505,7 @@ if ( isset($_POST['export-all']) || isset($_POST['export-selected']) )
|
|
505 |
|
506 |
$q .= $mysql_contact_type_filter;
|
507 |
$q .= ( $mysql_search_filter ? $mysql_search_filter : "" );
|
|
|
508 |
$q .= " GROUP BY l.lead_email";
|
509 |
|
510 |
$leads = $wpdb->get_results($q);
|
338 |
{
|
339 |
global $wpdb;
|
340 |
|
341 |
+
$q = $wpdb->prepare("SELECT hashkey FROM li_leads WHERE lead_id = %d " . $wpdb->multisite_query, $lead_id);
|
342 |
$lead_hash = $wpdb->get_var($q);
|
343 |
|
344 |
+
$q = $wpdb->prepare("UPDATE li_pageviews SET pageview_deleted = 1 WHERE lead_hashkey = %s AND pageview_deleted = 0 " . $wpdb->multisite_query, $lead_hash);
|
345 |
$delete_pageviews = $wpdb->query($q);
|
346 |
|
347 |
+
$q = $wpdb->prepare("UPDATE li_submissions SET form_deleted = 1 WHERE lead_hashkey = %s AND form_deleted = 0 " . $wpdb->multisite_query, $lead_hash);
|
348 |
$delete_submissions = $wpdb->query($q);
|
349 |
|
350 |
+
$q = $wpdb->prepare("UPDATE li_leads SET lead_deleted = 1 WHERE lead_id = %d AND lead_deleted = 0 " . $wpdb->multisite_query, $lead_id);
|
351 |
$delete_lead = $wpdb->query($q);
|
352 |
|
353 |
return $delete_lead;
|
364 |
{
|
365 |
global $wpdb;
|
366 |
|
367 |
+
$q = $wpdb->prepare("UPDATE li_leads SET lead_status = %s WHERE lead_id = %d " . $wpdb->multisite_query, $contact_status, $lead_id);
|
368 |
$result = $wpdb->query($q);
|
369 |
|
370 |
return $result;
|
461 |
// filter for visiting a specific page
|
462 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'visited' )
|
463 |
{
|
464 |
+
$q = $wpdb->prepare("SELECT lead_hashkey FROM li_pageviews WHERE pageview_title LIKE '%%%s%%' GROUP BY lead_hashkey " . $wpdb->multisite_query, htmlspecialchars(urldecode($_GET['filter_content'])));
|
465 |
$filtered_contacts = $wpdb->get_results($q);
|
466 |
|
467 |
if ( count($filtered_contacts) )
|
477 |
// filter for a form submitted on a specific page
|
478 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'submitted' )
|
479 |
{
|
480 |
+
$q = $wpdb->prepare("SELECT lead_hashkey FROM li_submissions WHERE form_page_title LIKE '%%%s%%' " . $wpdb->multisite_query . " GROUP BY lead_hashkey", htmlspecialchars(urldecode($_GET['filter_content'])));
|
481 |
$filtered_contacts = $wpdb->get_results($q);
|
482 |
|
483 |
$filtered_hashkeys = '';
|
505 |
|
506 |
$q .= $mysql_contact_type_filter;
|
507 |
$q .= ( $mysql_search_filter ? $mysql_search_filter : "" );
|
508 |
+
$q .= $wpdb->multisite_query;
|
509 |
$q .= " GROUP BY l.lead_email";
|
510 |
|
511 |
$leads = $wpdb->get_results($q);
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: andygcook, nelsonjoyce
|
|
3 |
Tags: lead tracking, visitor tracking, analytics, crm, marketing automation, inbound marketing, subscription, marketing, lead generation, mailchimp
|
4 |
Requires at least: 3.7
|
5 |
Tested up to: 3.9.1
|
6 |
-
Stable tag: 1.
|
7 |
|
8 |
LeadIn is an easy-to-use marketing automation and lead tracking plugin for WordPress that helps you better understand your web site visitors.
|
9 |
|
@@ -90,8 +90,12 @@ To ensure quality we've tested the most popular WordPress form builder plugins.
|
|
90 |
|
91 |
== Changelog ==
|
92 |
|
93 |
-
- Current version: 1.
|
94 |
-
- Current version release: 2014-
|
|
|
|
|
|
|
|
|
95 |
|
96 |
= 1.2.0 (2014.06.25) =
|
97 |
- Bug fixes
|
3 |
Tags: lead tracking, visitor tracking, analytics, crm, marketing automation, inbound marketing, subscription, marketing, lead generation, mailchimp
|
4 |
Requires at least: 3.7
|
5 |
Tested up to: 3.9.1
|
6 |
+
Stable tag: 1.3.0
|
7 |
|
8 |
LeadIn is an easy-to-use marketing automation and lead tracking plugin for WordPress that helps you better understand your web site visitors.
|
9 |
|
90 |
|
91 |
== Changelog ==
|
92 |
|
93 |
+
- Current version: 1.3.0
|
94 |
+
- Current version release: 2014-07-14
|
95 |
+
|
96 |
+
= 1.3.0 (2014.07.14) =
|
97 |
+
= Enhancements =
|
98 |
+
- Multisite compatibility
|
99 |
|
100 |
= 1.2.0 (2014.06.25) =
|
101 |
- Bug fixes
|