Version Description
(2015.12.14) = - Renamed "stats" to "dashboard" in the menu - Fixed a bug where deactivating the plugin in multisite mode would cause a PHP error - Removed old PHP that was used before Leadin was hosted in an iFrame, as it is now - Updated screenshots
Download this release
Release Info
Developer | leadin |
Plugin | HubSpot – Free Marketing Plugin for WordPress |
Version | 4.5.0 |
Comparing to | |
See all releases |
Code changes from version 4.4.0 to 4.5.0
- admin/leadin-admin.php +40 -45
- assets/fonts/icomoon.eot +0 -0
- assets/fonts/icomoon.svg +0 -28
- assets/fonts/icomoon.ttf +0 -0
- assets/fonts/icomoon.woff +0 -0
- inc/class-leadin-pointers.php +115 -116
- inc/class-leadin.php +28 -33
- inc/leadin-constants.php +8 -8
- inc/leadin-functions.php +22 -48
- inc/leadin-proxy.php +0 -193
- inc/leadin-registration.php +8 -8
- leadin.php +123 -141
- lib/segment/lib/Segment.php +0 -145
- lib/segment/lib/Segment/Client.php +0 -201
- lib/segment/lib/Segment/Consumer.php +0 -104
- lib/segment/lib/Segment/Consumer/File.php +0 -111
- lib/segment/lib/Segment/Consumer/ForkCurl.php +0 -59
- lib/segment/lib/Segment/Consumer/Socket.php +0 -174
- lib/segment/lib/Segment/QueueConsumer.php +0 -138
- lib/segment/send.php +0 -106
- readme.txt +17 -11
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- screenshot-4.png +0 -0
- screenshot-5.png +0 -0
admin/leadin-admin.php
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if (
|
4 |
-
{
|
5 |
header('HTTP/1.0 403 Forbidden');
|
6 |
die;
|
7 |
}
|
@@ -10,7 +9,7 @@ if ( !defined('LEADIN_PLUGIN_VERSION') )
|
|
10 |
// Define Constants
|
11 |
//=============================================
|
12 |
|
13 |
-
if (
|
14 |
define('LEADIN_ADMIN_PATH', untrailingslashit(__FILE__));
|
15 |
|
16 |
//=============================================
|
@@ -19,14 +18,15 @@ if ( !defined('LEADIN_ADMIN_PATH') )
|
|
19 |
|
20 |
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
21 |
|
22 |
-
if (
|
23 |
require_once LEADIN_PLUGIN_DIR . '/inc/class-leadin-pointers.php';
|
24 |
|
25 |
//=============================================
|
26 |
// WPLeadInAdmin Class
|
27 |
//=============================================
|
28 |
-
class WPLeadInAdmin
|
29 |
-
|
|
|
30 |
var $li_viewers;
|
31 |
var $stats_dashboard;
|
32 |
var $action;
|
@@ -34,7 +34,7 @@ class WPLeadInAdmin {
|
|
34 |
/**
|
35 |
* Class constructor
|
36 |
*/
|
37 |
-
function __construct
|
38 |
{
|
39 |
//=============================================
|
40 |
// Hooks & Filters
|
@@ -45,16 +45,16 @@ class WPLeadInAdmin {
|
|
45 |
$this->action = $this->leadin_current_action();
|
46 |
|
47 |
// If the plugin version matches the latest version escape the update function
|
48 |
-
if (
|
49 |
self::leadin_update_check();
|
50 |
-
|
51 |
add_action('admin_menu', array(&$this, 'leadin_add_menu_items'));
|
52 |
add_action('admin_print_scripts', array(&$this, 'add_leadin_admin_scripts'));
|
53 |
add_filter('plugin_action_links_' . 'leadin/leadin.php', array($this, 'leadin_plugin_settings_link'));
|
54 |
|
55 |
}
|
56 |
|
57 |
-
function leadin_update_check
|
58 |
{
|
59 |
update_option('leadin_pluginVersion', LEADIN_PLUGIN_VERSION);
|
60 |
}
|
@@ -66,30 +66,28 @@ class WPLeadInAdmin {
|
|
66 |
/**
|
67 |
* Adds Leadin menu to /wp-admin sidebar
|
68 |
*/
|
69 |
-
function leadin_add_menu_items
|
70 |
{
|
71 |
$options = get_option('leadin_options');
|
72 |
|
73 |
global $submenu;
|
74 |
-
global
|
75 |
|
76 |
// Block non-sanctioned users from accessing Leadin
|
77 |
$capability = 'activate_plugins';
|
78 |
-
if (
|
79 |
-
|
80 |
-
if ( ! array_key_exists('li_grant_access_to_' . leadin_get_user_role(), $options ) )
|
81 |
return FALSE;
|
82 |
-
else
|
83 |
-
|
84 |
-
if ( current_user_can('manage_network') ) // super admin
|
85 |
$capability = 'manage_network';
|
86 |
-
else if (
|
87 |
$capability = 'edit_pages';
|
88 |
-
else if (
|
89 |
$capability = 'publish_posts';
|
90 |
-
else if (
|
91 |
$capability = 'edit_posts';
|
92 |
-
else if (
|
93 |
$capability = 'read';
|
94 |
|
95 |
}
|
@@ -97,19 +95,18 @@ class WPLeadInAdmin {
|
|
97 |
|
98 |
$leadin_icon = LEADIN_PATH . '/images/leadin-icon-16x16-white.png';
|
99 |
|
100 |
-
add_menu_page('Leadin', 'Leadin', $capability, 'leadin', array($this, 'leadin_build_app'),
|
101 |
|
102 |
add_submenu_page('leadin', 'Contacts', 'Contacts', 'activate_plugins', 'leadin_contacts', array($this, 'leadin_build_app'));
|
103 |
add_submenu_page('leadin', 'Settings', 'Settings', 'activate_plugins', 'leadin_settings', array($this, 'leadin_build_app'));
|
104 |
|
105 |
-
$submenu['leadin'][0][0] = '
|
106 |
|
107 |
-
if (
|
108 |
-
|
109 |
-
if ( ! get_option('leadin_portalId') )
|
110 |
$li_pointers = new LI_Pointers(TRUE);
|
111 |
//else if ( ! get_option('leadin_portalId') && $options )
|
112 |
-
|
113 |
}
|
114 |
}
|
115 |
|
@@ -118,12 +115,12 @@ class WPLeadInAdmin {
|
|
118 |
//=============================================
|
119 |
|
120 |
/**
|
121 |
-
* Adds setting link for Leadin to plugins management page
|
122 |
*
|
123 |
* @param array $links
|
124 |
* @return array
|
125 |
*/
|
126 |
-
function leadin_plugin_settings_link
|
127 |
{
|
128 |
$url = get_admin_url(get_current_blog_id(), 'admin.php?page=leadin_settings');
|
129 |
$settings_link = '<a href="' . $url . '">Settings</a>';
|
@@ -135,17 +132,18 @@ class WPLeadInAdmin {
|
|
135 |
* Creates leadin app
|
136 |
*/
|
137 |
|
138 |
-
function leadin_build_app
|
|
|
139 |
global $wp_version;
|
140 |
|
141 |
-
echo '<div id="leadin" class="wrap '. (
|
142 |
|
143 |
wp_enqueue_style('leadin-css');
|
144 |
wp_enqueue_script('leadin-app');
|
145 |
|
146 |
}
|
147 |
|
148 |
-
function update_option_leadin_options_callback
|
149 |
{
|
150 |
}
|
151 |
|
@@ -156,7 +154,7 @@ class WPLeadInAdmin {
|
|
156 |
/**
|
157 |
* Adds admin javascript
|
158 |
*/
|
159 |
-
function add_leadin_admin_scripts
|
160 |
{
|
161 |
global $pagenow;
|
162 |
global $wp_roles;
|
@@ -176,8 +174,6 @@ class WPLeadInAdmin {
|
|
176 |
'adminEmail' => get_option('admin_email'),
|
177 |
'siteName' => get_bloginfo('name'),
|
178 |
'adminBaseUrl' => get_admin_url(get_current_blog_id(), 'admin.php'),
|
179 |
-
'apiBaseUrl' => constant('LEADIN_API_BASE_URL'),
|
180 |
-
'assetsBaseUrl' => constant('LEADIN_ADMIN_ASSETS_BASE_URL'),
|
181 |
'leadinPluginDirectory' => LEADIN_PLUGIN_SLUG,
|
182 |
'ajaxUrl' => is_ssl() ? str_replace('http:', 'https:', $ajaxUrl) : str_replace('https:', 'http:', $ajaxUrl),
|
183 |
'locale' => get_locale(),
|
@@ -185,14 +181,13 @@ class WPLeadInAdmin {
|
|
185 |
'timezoneString' => get_option('timezone_string') // If not set by the user manually it will be an empty string
|
186 |
);
|
187 |
|
188 |
-
if (
|
189 |
-
{
|
190 |
wp_register_script('leadin-head-js', leadin_get_resource_url('/bundle/head/head.js'), FALSE, FALSE, FALSE);
|
191 |
wp_localize_script('leadin-head-js', 'leadin_config', $leadin_config);
|
192 |
wp_enqueue_script('leadin-head-js');
|
193 |
|
194 |
-
wp_register_script('leadin-app', leadin_get_resource_url('/bundle/app.js'), array(
|
195 |
-
wp_register_style('leadin-css', leadin_get_resource_url('/bundle/app.css'));
|
196 |
}
|
197 |
}
|
198 |
|
@@ -200,7 +195,7 @@ class WPLeadInAdmin {
|
|
200 |
// Internal Class Functions
|
201 |
//=============================================
|
202 |
|
203 |
-
function leadin_get_user_for_tracking
|
204 |
{
|
205 |
$leadin_user = leadin_get_current_user();
|
206 |
$tracking_leadin_user = array(
|
@@ -227,16 +222,16 @@ class WPLeadInAdmin {
|
|
227 |
* GET and set url actions into readable strings
|
228 |
* @return string if actions are set, bool if no actions set
|
229 |
*/
|
230 |
-
function leadin_current_action
|
231 |
{
|
232 |
-
if (
|
233 |
return $_REQUEST['action'];
|
234 |
|
235 |
-
if (
|
236 |
return $_REQUEST['action2'];
|
237 |
|
238 |
return FALSE;
|
239 |
-
}
|
240 |
|
241 |
}
|
242 |
|
1 |
<?php
|
2 |
|
3 |
+
if (!defined('LEADIN_PLUGIN_VERSION')) {
|
|
|
4 |
header('HTTP/1.0 403 Forbidden');
|
5 |
die;
|
6 |
}
|
9 |
// Define Constants
|
10 |
//=============================================
|
11 |
|
12 |
+
if (!defined('LEADIN_ADMIN_PATH'))
|
13 |
define('LEADIN_ADMIN_PATH', untrailingslashit(__FILE__));
|
14 |
|
15 |
//=============================================
|
18 |
|
19 |
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
20 |
|
21 |
+
if (!class_exists('LI_Pointers'))
|
22 |
require_once LEADIN_PLUGIN_DIR . '/inc/class-leadin-pointers.php';
|
23 |
|
24 |
//=============================================
|
25 |
// WPLeadInAdmin Class
|
26 |
//=============================================
|
27 |
+
class WPLeadInAdmin
|
28 |
+
{
|
29 |
+
|
30 |
var $li_viewers;
|
31 |
var $stats_dashboard;
|
32 |
var $action;
|
34 |
/**
|
35 |
* Class constructor
|
36 |
*/
|
37 |
+
function __construct()
|
38 |
{
|
39 |
//=============================================
|
40 |
// Hooks & Filters
|
45 |
$this->action = $this->leadin_current_action();
|
46 |
|
47 |
// If the plugin version matches the latest version escape the update function
|
48 |
+
if ($plugin_version != LEADIN_PLUGIN_VERSION)
|
49 |
self::leadin_update_check();
|
50 |
+
|
51 |
add_action('admin_menu', array(&$this, 'leadin_add_menu_items'));
|
52 |
add_action('admin_print_scripts', array(&$this, 'add_leadin_admin_scripts'));
|
53 |
add_filter('plugin_action_links_' . 'leadin/leadin.php', array($this, 'leadin_plugin_settings_link'));
|
54 |
|
55 |
}
|
56 |
|
57 |
+
function leadin_update_check()
|
58 |
{
|
59 |
update_option('leadin_pluginVersion', LEADIN_PLUGIN_VERSION);
|
60 |
}
|
66 |
/**
|
67 |
* Adds Leadin menu to /wp-admin sidebar
|
68 |
*/
|
69 |
+
function leadin_add_menu_items()
|
70 |
{
|
71 |
$options = get_option('leadin_options');
|
72 |
|
73 |
global $submenu;
|
74 |
+
global $wp_version;
|
75 |
|
76 |
// Block non-sanctioned users from accessing Leadin
|
77 |
$capability = 'activate_plugins';
|
78 |
+
if (!current_user_can('activate_plugins')) {
|
79 |
+
if (!array_key_exists('li_grant_access_to_' . leadin_get_user_role(), $options))
|
|
|
80 |
return FALSE;
|
81 |
+
else {
|
82 |
+
if (current_user_can('manage_network')) // super admin
|
|
|
83 |
$capability = 'manage_network';
|
84 |
+
else if (current_user_can('edit_pages')) // editor
|
85 |
$capability = 'edit_pages';
|
86 |
+
else if (current_user_can('publish_posts')) // author
|
87 |
$capability = 'publish_posts';
|
88 |
+
else if (current_user_can('edit_posts')) // contributor
|
89 |
$capability = 'edit_posts';
|
90 |
+
else if (current_user_can('read')) // subscriber
|
91 |
$capability = 'read';
|
92 |
|
93 |
}
|
95 |
|
96 |
$leadin_icon = LEADIN_PATH . '/images/leadin-icon-16x16-white.png';
|
97 |
|
98 |
+
add_menu_page('Leadin', 'Leadin', $capability, 'leadin', array($this, 'leadin_build_app'), $leadin_icon, '25.100713');
|
99 |
|
100 |
add_submenu_page('leadin', 'Contacts', 'Contacts', 'activate_plugins', 'leadin_contacts', array($this, 'leadin_build_app'));
|
101 |
add_submenu_page('leadin', 'Settings', 'Settings', 'activate_plugins', 'leadin_settings', array($this, 'leadin_build_app'));
|
102 |
|
103 |
+
$submenu['leadin'][0][0] = 'Dashboard';
|
104 |
|
105 |
+
if (!isset($_GET['page']) || $_GET['page'] != ('leadin' || 'leadin_settings' || 'leadin_contacts')) {
|
106 |
+
if (!get_option('leadin_portalId'))
|
|
|
107 |
$li_pointers = new LI_Pointers(TRUE);
|
108 |
//else if ( ! get_option('leadin_portalId') && $options )
|
109 |
+
//$li_pointers = new LI_Pointers(FALSE);
|
110 |
}
|
111 |
}
|
112 |
|
115 |
//=============================================
|
116 |
|
117 |
/**
|
118 |
+
* Adds setting link for Leadin to plugins management page
|
119 |
*
|
120 |
* @param array $links
|
121 |
* @return array
|
122 |
*/
|
123 |
+
function leadin_plugin_settings_link($links)
|
124 |
{
|
125 |
$url = get_admin_url(get_current_blog_id(), 'admin.php?page=leadin_settings');
|
126 |
$settings_link = '<a href="' . $url . '">Settings</a>';
|
132 |
* Creates leadin app
|
133 |
*/
|
134 |
|
135 |
+
function leadin_build_app()
|
136 |
+
{
|
137 |
global $wp_version;
|
138 |
|
139 |
+
echo '<div id="leadin" class="wrap ' . ($wp_version < 3.8 && !is_plugin_active('mp6/mp6.php') ? 'pre-mp6' : '') . '"></div>';
|
140 |
|
141 |
wp_enqueue_style('leadin-css');
|
142 |
wp_enqueue_script('leadin-app');
|
143 |
|
144 |
}
|
145 |
|
146 |
+
function update_option_leadin_options_callback($old_value, $new_value)
|
147 |
{
|
148 |
}
|
149 |
|
154 |
/**
|
155 |
* Adds admin javascript
|
156 |
*/
|
157 |
+
function add_leadin_admin_scripts()
|
158 |
{
|
159 |
global $pagenow;
|
160 |
global $wp_roles;
|
174 |
'adminEmail' => get_option('admin_email'),
|
175 |
'siteName' => get_bloginfo('name'),
|
176 |
'adminBaseUrl' => get_admin_url(get_current_blog_id(), 'admin.php'),
|
|
|
|
|
177 |
'leadinPluginDirectory' => LEADIN_PLUGIN_SLUG,
|
178 |
'ajaxUrl' => is_ssl() ? str_replace('http:', 'https:', $ajaxUrl) : str_replace('https:', 'http:', $ajaxUrl),
|
179 |
'locale' => get_locale(),
|
181 |
'timezoneString' => get_option('timezone_string') // If not set by the user manually it will be an empty string
|
182 |
);
|
183 |
|
184 |
+
if (($pagenow == 'admin.php' && isset($_GET['page']) && strstr($_GET['page'], 'leadin'))) {
|
|
|
185 |
wp_register_script('leadin-head-js', leadin_get_resource_url('/bundle/head/head.js'), FALSE, FALSE, FALSE);
|
186 |
wp_localize_script('leadin-head-js', 'leadin_config', $leadin_config);
|
187 |
wp_enqueue_script('leadin-head-js');
|
188 |
|
189 |
+
wp_register_script('leadin-app', leadin_get_resource_url('/bundle/app.js'), array('backbone'), FALSE, TRUE);
|
190 |
+
wp_register_style('leadin-css', leadin_get_resource_url('/bundle/app.css'));
|
191 |
}
|
192 |
}
|
193 |
|
195 |
// Internal Class Functions
|
196 |
//=============================================
|
197 |
|
198 |
+
function leadin_get_user_for_tracking()
|
199 |
{
|
200 |
$leadin_user = leadin_get_current_user();
|
201 |
$tracking_leadin_user = array(
|
222 |
* GET and set url actions into readable strings
|
223 |
* @return string if actions are set, bool if no actions set
|
224 |
*/
|
225 |
+
function leadin_current_action()
|
226 |
{
|
227 |
+
if (isset($_REQUEST['action']) && -1 != $_REQUEST['action'])
|
228 |
return $_REQUEST['action'];
|
229 |
|
230 |
+
if (isset($_REQUEST['action2']) && -1 != $_REQUEST['action2'])
|
231 |
return $_REQUEST['action2'];
|
232 |
|
233 |
return FALSE;
|
234 |
+
}
|
235 |
|
236 |
}
|
237 |
|
assets/fonts/icomoon.eot
DELETED
Binary file
|
assets/fonts/icomoon.svg
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
<?xml version="1.0" standalone="no"?>
|
2 |
-
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
3 |
-
<svg xmlns="http://www.w3.org/2000/svg">
|
4 |
-
<metadata>Generated by IcoMoon</metadata>
|
5 |
-
<defs>
|
6 |
-
<font id="icomoon" horiz-adv-x="1024">
|
7 |
-
<font-face units-per-em="1024" ascent="960" descent="-64" />
|
8 |
-
<missing-glyph horiz-adv-x="1024" />
|
9 |
-
<glyph unicode=" " d="" horiz-adv-x="512" />
|
10 |
-
<glyph unicode="" d="M1242.414 890.048l-289.937-953.74h295.903c40.846 0 83.256 30.586 94.704 68.244l269.191 885.496c11.458 37.69-12.402 68.244-53.212 68.244h-221.945c-40.846 0-83.256-30.586-94.704-68.244zM686.168 617.6l-207.113-681.292h295.903c40.846 0 83.243 30.542 94.68 68.163l207.113 681.292h-295.903c-40.846 0-83.243-30.542-94.68-68.163zM129.923 345.155l-103.594-340.769c-11.43-37.599 12.452-68.078 53.262-68.078h221.945c40.846 0 83.248 30.559 94.654 68.078l124.29 408.847h-295.903c-40.846 0-83.248-30.559-94.654-68.078z" horiz-adv-x="1638" />
|
11 |
-
<glyph unicode="" d="M864 960h-768c-52.8 0-96-43.2-96-96v-832c0-52.8 43.2-96 96-96h768c52.8 0 96 43.2 96 96v832c0 52.8-43.2 96-96 96zM832 64h-704v768h704v-768zM256 384h448v-64h-448zM256 256h448v-64h-448zM320 672c0 53.020 42.98 96 96 96s96-42.98 96-96c0-53.020-42.98-96-96-96s-96 42.98-96 96zM480 576h-128c-52.8 0-96-28.8-96-64v-64h320v64c0 35.2-43.2 64-96 64z" />
|
12 |
-
<glyph unicode="" d="M927.812 960h-288.562c-52.906 0-126.796-30.606-164.204-68.014l-446.99-446.99c-37.408-37.408-37.408-98.624 0-136.032l344.91-344.906c37.408-37.41 98.622-37.41 136.030 0l446.99 446.988c37.408 37.41 68.014 111.302 68.014 164.204v288.562c0 52.904-43.286 96.188-96.188 96.188zM800 640c-53.020 0-96 42.98-96 96s42.98 96 96 96 96-42.98 96-96-42.98-96-96-96z" />
|
13 |
-
<glyph unicode="" d="M928 832h-832c-52.8 0-96-43.2-96-96v-640c0-52.8 43.2-96 96-96h832c52.8 0 96 43.2 96 96v640c0 52.8-43.2 96-96 96zM398.74 409.628l-270.74-210.892v501.642l270.74-290.75zM176.38 704h671.24l-335.62-252-335.62 252zM409.288 398.302l102.712-110.302 102.71 110.302 210.554-270.302h-626.528l210.552 270.302zM625.26 409.628l270.74 290.75v-501.642l-270.74 210.892z" />
|
14 |
-
<glyph unicode="" d="M256 640c0 141.384 114.616 256 256 256s256-114.616 256-256c0-141.384-114.616-256-256-256s-256 114.616-256 256zM768 320h-512c-141.384 0-256-114.618-256-256v-64h1024v64c0 141.382-114.616 256-256 256z" />
|
15 |
-
<glyph unicode="" d="M1024 351.906v192.188l-146.774 24.462c-5.958 18.132-13.222 35.668-21.694 52.5l86.454 121.034-135.896 135.898-120.826-86.304c-16.91 8.554-34.538 15.888-52.768 21.902l-24.402 146.414h-192.188l-24.402-146.416c-18.23-6.014-35.858-13.348-52.766-21.902l-120.828 86.304-135.898-135.898 86.454-121.036c-8.47-16.83-15.734-34.366-21.692-52.498l-146.774-24.46v-192.188l147.118-24.52c5.96-17.968 13.21-35.348 21.642-52.030l-86.748-121.448 135.898-135.896 121.654 86.894c16.602-8.35 33.89-15.528 51.764-21.434l24.578-147.472h192.188l24.578 147.474c17.874 5.906 35.162 13.084 51.766 21.432l121.652-86.892 135.896 135.896-86.744 121.446c8.432 16.682 15.678 34.062 21.64 52.032l147.118 24.518zM512 320c-70.692 0-128 57.306-128 128s57.308 128 128 128c70.694 0 128-57.308 128-128s-57.306-128-128-128z" />
|
16 |
-
<glyph unicode="" d="M0 128h1024v-128h-1024zM128 384h128v-192h-128zM320 640h128v-448h-128zM512 448h128v-256h-128zM704 832h128v-640h-128z" />
|
17 |
-
<glyph unicode="" d="M956.29 155.518l-316.29 527.024v213.458h32c17.6 0 32 14.4 32 32s-14.4 32-32 32h-320c-17.6 0-32-14.4-32-32s14.4-32 32-32h32v-213.458l-316.288-527.024c-72.442-120.734-16.512-219.518 124.288-219.518h640c140.8 0 196.73 98.784 124.29 219.518zM241.038 320l206.962 344.938v231.062h128v-231.062l206.964-344.938h-541.926z" />
|
18 |
-
<glyph unicode="" d="M512 960c-194.432 0-352-157.568-352-352 0-128.992 118.016-265.696 160.992-385.76 64.096-179.040 56.992-286.24 191.008-286.24 136 0 126.88 106.688 191.008 285.504 43.104 120.32 160.992 258.496 160.992 386.496 0 194.432-157.632 352-352 352zM594.944 90.368l-158.656-19.808c-5.664 16.384-11.744 35.552-19.136 60.576-0.096 0.32-0.224 0.672-0.288 0.992l198.016 24.736c-2.816-9.44-5.824-19.36-8.448-28.256-4.192-14.368-7.936-26.848-11.488-38.24zM407.552 162.944c-5.824 19.264-12.384 39.552-19.68 61.056h248.512c-3.936-11.488-7.872-23.008-11.264-33.888l-217.568-27.168zM512 0c-32.416 0-47.328 3.744-63.904 40l135.616 16.992c-19.648-52.928-33.952-56.992-71.712-56.992zM661.504 288h-298.656c-15.936 34.56-35.072 69.12-53.952 102.944-41.76 74.72-84.896 152-84.896 217.056 0 158.816 129.184 288 288 288s288-129.184 288-288c0-64.576-43.2-142.272-84.992-217.44-18.688-33.696-37.696-68.192-53.504-102.56zM512 800c8.8 0 16-7.168 16-16s-7.168-16-16-16c-88.224 0-160-71.776-160-160 0-8.832-7.168-16-16-16s-16 7.168-16 16c0 105.888 86.112 192 192 192z" />
|
19 |
-
<glyph unicode="" d="M992 896h-224c-52.8 0-126.546-30.546-163.882-67.882l-376.236-376.236c-37.334-37.334-37.334-98.428 0-135.764l280.236-280.234c37.334-37.336 98.428-37.336 135.764 0l376.234 376.234c37.338 37.336 67.884 111.082 67.884 163.882v224c0 52.8-43.2 96-96 96zM864 576c-53.020 0-96 42.98-96 96s42.98 96 96 96 96-42.98 96-96-42.98-96-96-96zM86.626 361.374l342.378-342.378c-36.264-19.16-82.462-13.538-112.886 16.888l-280.236 280.234c-37.334 37.336-37.334 98.43 0 135.764l376.236 376.236c37.336 37.336 111.082 67.882 163.882 67.882l-489.374-489.372c-12.444-12.446-12.444-32.808 0-45.254z" horiz-adv-x="1088" />
|
20 |
-
<glyph unicode="" d="M575.488 770.528v-258.016h256v128l192.512-192.512-192.512-192.48v130.976h-256v-258.016h128.992l-192.48-192.48-192.512 192.48h128v258.016h-256v-129.984l-191.488 191.488 191.488 191.488v-126.976h256v258.016h-124.992l189.504 189.472 189.504-189.472h-126.016z" />
|
21 |
-
<glyph unicode="" d="M950.857 91.428v438.857q-18.286-20.571-39.429-37.714-153.143-117.714-243.429-193.143-29.143-24.571-47.429-38.286t-49.429-27.714-58.571-14h-1.143q-27.429 0-58.571 14t-49.429 27.714-47.429 38.286q-90.286 75.429-243.429 193.143-21.143 17.143-39.429 37.714v-438.857q0-7.429 5.429-12.857t12.857-5.429h841.143q7.429 0 12.857 5.429t5.429 12.857zM950.857 692v14t-0.286 7.429-1.714 7.143-3.143 5.143-5.143 4.286-8 1.429h-841.143q-7.429 0-12.857-5.429t-5.429-12.857q0-96 84-162.286 110.286-86.857 229.143-181.143 3.429-2.857 20-16.857t26.286-21.429 25.429-18 28.857-15.714 24.571-5.143h1.143q11.429 0 24.571 5.143t28.857 15.714 25.429 18 26.286 21.429 20 16.857q118.857 94.286 229.143 181.143 30.857 24.571 57.429 66t26.571 75.143zM1024 713.143v-621.714q0-37.714-26.857-64.571t-64.571-26.857h-841.143q-37.714 0-64.571 26.857t-26.857 64.571v621.714q0 37.714 26.857 64.571t64.571 26.857h841.143q37.714 0 64.571-26.857t26.857-64.571z" />
|
22 |
-
<glyph unicode="" d="M1024 545.143v-453.714q0-37.714-26.857-64.571t-64.571-26.857h-841.143q-37.714 0-64.571 26.857t-26.857 64.571v453.714q25.143-28 57.714-49.714 206.857-140.571 284-197.143 32.571-24 52.857-37.429t54-27.429 62.857-14h1.143q29.143 0 62.857 14t54 27.429 52.857 37.429q97.143 70.286 284.571 197.143 32.571 22.286 57.143 49.714zM1024 713.143q0-45.143-28-86.286t-69.714-70.286q-214.857-149.143-267.429-185.714-5.714-4-24.286-17.429t-30.857-21.714-29.714-18.571-32.857-15.429-28.571-5.143h-1.143q-13.143 0-28.571 5.143t-32.857 15.429-29.714 18.571-30.857 21.714-24.286 17.429q-52 36.571-149.714 104.286t-117.143 81.429q-35.429 24-66.857 66t-31.429 78q0 44.571 23.714 74.286t67.714 29.714h841.143q37.143 0 64.286-26.857t27.143-64.571z" />
|
23 |
-
<glyph unicode="" d="M925.714 717.714q-38.286-56-92.571-95.429 0.571-8 0.571-24 0-74.286-21.714-148.286t-66-142-105.429-120.286-147.429-83.429-184.571-31.143q-154.857 0-283.429 82.857 20-2.286 44.571-2.286 128.571 0 229.143 78.857-60 1.143-107.429 36.857t-65.143 91.143q18.857-2.857 34.857-2.857 24.571 0 48.571 6.286-64 13.143-106 63.714t-42 117.429v2.286q38.857-21.714 83.429-23.429-37.714 25.143-60 65.714t-22.286 88q0 50.286 25.143 93.143 69.143-85.143 168.286-136.286t212.286-56.857q-4.571 21.714-4.571 42.286 0 76.571 54 130.571t130.571 54q80 0 134.857-58.286 62.286 12 117.143 44.571-21.143-65.714-81.143-101.714 53.143 5.714 106.286 28.571z" horiz-adv-x="951" />
|
24 |
-
<glyph unicode="" d="M199.429 593.714v-566.286h-188.571v566.286h188.571zM211.429 768.571q0.571-41.714-28.857-69.714t-77.429-28h-1.143q-46.857 0-75.429 28t-28.571 69.714q0 42.286 29.429 70t76.857 27.714 76-27.714 29.143-70zM877.714 352v-324.571h-188v302.857q0 60-23.143 94t-72.286 34q-36 0-60.286-19.714t-36.286-48.857q-6.286-17.143-6.286-46.286v-316h-188q1.143 228 1.143 369.714t-0.571 169.143l-0.571 27.429h188v-82.286h-1.143q11.429 18.286 23.429 32t32.286 29.714 49.714 24.857 65.429 8.857q97.714 0 157.143-64.857t59.429-190z" />
|
25 |
-
<glyph unicode="" d="M548 944v-150.857h-89.714q-49.143 0-66.286-20.571t-17.143-61.714v-108h167.429l-22.286-169.143h-145.143v-433.714h-174.857v433.714h-145.714v169.143h145.714v124.571q0 106.286 59.429 164.857t158.286 58.571q84 0 130.286-6.857z" horiz-adv-x="585" />
|
26 |
-
<glyph unicode="" d="M72.571 438.857q0 93.143 38.286 178.857l209.714-574.286q-112 54.286-180 160.571t-68 234.857zM808.571 461.143q0-10.857-1.429-22t-5.714-28.286-6.571-25.143-10-33.714-10-33.143l-43.429-146.286-158.857 472q26.286 1.714 50.286 4.571 10.857 1.143 14.857 10.571t-1.429 17.714-16.286 7.714l-117.143-5.714q-42.857 0.571-115.429 5.714-6.857 0.571-11.714-2.857t-6.571-8.571-0.857-10.571 5.143-9.429 11.143-4.571l45.714-4.571 68.571-187.429-96-288-160 475.429q26.286 1.714 50.286 4.571 10.857 1.143 14.857 10.571t-1.429 17.714-16.286 7.714l-117.143-5.714q-4 0-13.143 0.286t-14.857 0.286q60 91.429 156.857 144.857t210 53.429q84 0 160.286-30.286t136.286-85.143h-5.714q-31.429 0-52.571-23.143t-21.143-54.571q0-6.857 1.143-13.714t2.286-12.286 4.571-13.143 5.143-12 6.857-12.857 7.143-12 8.286-13.714 8-13.143q36-61.143 36-121.143zM519.429 400.571l135.429-369.714q0.571-3.429 2.857-6.286-72-25.143-145.714-25.143-64 0-124 18.286zM897.143 649.714q54.286-99.429 54.286-210.857 0-119.429-59.429-220.286t-159.429-159.143l134.286 387.429q33.714 96.571 33.714 157.714 0 24-3.429 45.143zM512 950.857q104 0 198.857-40.571t163.429-109.143 109.143-163.429 40.571-198.857-40.571-198.857-109.143-163.429-163.429-109.143-198.857-40.571-198.857 40.571-163.429 109.143-109.143 163.429-40.571 198.857 40.571 198.857 109.143 163.429 163.429 109.143 198.857 40.571zM512-49.714q98.857 0 189.429 38.857t156 104.286 104.286 156 38.857 189.429-38.857 189.429-104.286 156-156 104.286-189.429 38.857-189.429-38.857-156-104.286-104.286-156-38.857-189.429 38.857-189.429 104.286-156 156-104.286 189.429-38.857z" />
|
27 |
-
<glyph unicode="" d="M420 496q0-20.571 18.286-40.286t44.286-38.857 51.714-42 44-59.429 18.286-81.143q0-51.429-27.429-98.857-41.143-69.714-120.571-102.571t-170.286-32.857q-75.429 0-140.857 23.714t-98 78.571q-21.143 34.286-21.143 74.857 0 46.286 25.429 85.714t67.714 65.714q74.857 46.857 230.857 57.143-18.286 24-27.143 42.286t-8.857 41.714q0 20.571 12 48.571-26.286-2.286-38.857-2.286-84.571 0-142.571 55.143t-58 139.714q0 46.857 20.571 90.857t56.571 74.857q44 37.714 104.286 56t124.286 18.286h238.857l-78.857-50.286h-74.857q42.286-36 64-76t21.714-91.429q0-41.143-14-74t-33.714-53.143-39.714-37.143-34-35.143-14-37.714zM336.571 550.857q21.714 0 44.571 9.429t37.714 24.857q30.286 32.571 30.286 90.857 0 33.143-9.714 71.429t-27.714 74-48.286 59.143-66.857 23.429q-24 0-47.143-11.143t-37.429-30q-26.857-33.714-26.857-91.429 0-26.286 5.714-55.714t18-58.857 29.714-52.857 42.857-38.286 55.143-14.857zM337.714 52q33.143 0 63.714 7.429t56.571 22.286 41.714 41.714 15.714 62.286q0 14.286-4 28t-8.286 24-15.429 23.714-16.857 20-22 19.714-20.857 16.571-23.714 17.143-20.857 14.857q-9.143 1.143-27.429 1.143-30.286 0-60-4t-61.429-14.286-55.429-26.286-39.143-42.571-15.429-60.286q0-40 20-70.571t52.286-47.429 68-25.143 72.857-8.286zM800.571 552.571h121.714v-61.714h-121.714v-125.143h-60v125.143h-121.143v61.714h121.143v124h60v-124z" horiz-adv-x="951" />
|
28 |
-
</font></defs></svg>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/fonts/icomoon.ttf
DELETED
Binary file
|
assets/fonts/icomoon.woff
DELETED
Binary file
|
inc/class-leadin-pointers.php
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if (
|
4 |
-
{
|
5 |
header('HTTP/1.0 403 Forbidden');
|
6 |
die;
|
7 |
}
|
@@ -11,118 +10,118 @@ if ( !defined('LEADIN_PLUGIN_VERSION') )
|
|
11 |
*
|
12 |
* @todo Add an introdutory pointer on the edit post page too.
|
13 |
*/
|
14 |
-
class LI_Pointers
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
}
|
1 |
<?php
|
2 |
|
3 |
+
if (!defined('LEADIN_PLUGIN_VERSION')) {
|
|
|
4 |
header('HTTP/1.0 403 Forbidden');
|
5 |
die;
|
6 |
}
|
10 |
*
|
11 |
* @todo Add an introdutory pointer on the edit post page too.
|
12 |
*/
|
13 |
+
class LI_Pointers
|
14 |
+
{
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Class constructor.
|
18 |
+
*/
|
19 |
+
function __construct($new_install = FALSE)
|
20 |
+
{
|
21 |
+
//=============================================
|
22 |
+
// Hooks & Filters
|
23 |
+
//=============================================
|
24 |
+
|
25 |
+
if ($new_install) {
|
26 |
+
add_action('admin_enqueue_scripts', array($this, 'enqueue_new_install_pointer'));
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Enqueue styles and scripts needed for the pointers.
|
32 |
+
*/
|
33 |
+
function enqueue_new_install_pointer()
|
34 |
+
{
|
35 |
+
if (!current_user_can('manage_options'))
|
36 |
+
return;
|
37 |
+
|
38 |
+
wp_enqueue_style('wp-pointer');
|
39 |
+
wp_enqueue_script('jquery-ui');
|
40 |
+
wp_enqueue_script('wp-pointer');
|
41 |
+
wp_enqueue_script('utils');
|
42 |
+
|
43 |
+
add_action('admin_print_footer_scripts', array($this, 'li_settings_popup_new'));
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Loads in the required scripts for the pointer
|
48 |
+
*/
|
49 |
+
function enqueue_pointer_scripts()
|
50 |
+
{
|
51 |
+
wp_enqueue_style('wp-pointer');
|
52 |
+
wp_enqueue_script('jquery-ui');
|
53 |
+
wp_enqueue_script('wp-pointer');
|
54 |
+
wp_enqueue_script('utils');
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Shows a popup that asks for permission to allow tracking.
|
59 |
+
*/
|
60 |
+
function li_settings_popup_new()
|
61 |
+
{
|
62 |
+
$id = '#toplevel_page_leadin';
|
63 |
+
|
64 |
+
$content = '<h3>' . __('So close...', 'leadin') . '</h3>';
|
65 |
+
$content .= '<p>' . __('Leadin needs just a bit more info to get up and running. Click on \'Complete Setup\' to complete the setup.', 'leadin') . '</p>';
|
66 |
+
|
67 |
+
$opt_arr = array(
|
68 |
+
'content' => $content,
|
69 |
+
'position' => array('edge' => 'left', 'align' => 'center')
|
70 |
+
);
|
71 |
+
|
72 |
+
$function2 = 'li_redirect_to_settings()';
|
73 |
+
|
74 |
+
$this->print_scripts($id, $opt_arr, 'Complete Setup', FALSE, '', $function2);
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Prints the pointer script
|
79 |
+
*
|
80 |
+
* @param string $selector The CSS selector the pointer is attached to.
|
81 |
+
* @param array $options The options for the pointer.
|
82 |
+
* @param string $button1 Text for button 1
|
83 |
+
* @param string|bool $button2 Text for button 2 (or false to not show it, defaults to false)
|
84 |
+
* @param string $button2_function The JavaScript function to attach to button 2
|
85 |
+
* @param string $button1_function The JavaScript function to attach to button 1
|
86 |
+
*/
|
87 |
+
function print_scripts($selector, $options, $button1, $button2 = FALSE, $button2_function = '', $button1_function = '')
|
88 |
+
{
|
89 |
+
?>
|
90 |
+
<script type="text/javascript">
|
91 |
+
//<![CDATA[
|
92 |
+
(function ($) {
|
93 |
+
|
94 |
+
var li_pointer_options = <?php echo json_encode( $options ); ?>, setup;
|
95 |
+
|
96 |
+
function li_redirect_to_settings() {
|
97 |
+
window.location.href = "<?php echo get_bloginfo('wpurl'); ?>/wp-admin/admin.php?page=leadin_settings";
|
98 |
+
}
|
99 |
+
|
100 |
+
li_pointer_options = $.extend(li_pointer_options, {
|
101 |
+
buttons: function (event, t) {
|
102 |
+
button = jQuery('<a id="pointer-close" style="margin-left:5px" class="button-secondary">' + '<?php echo $button1; ?>' + '</a>');
|
103 |
+
button.bind('click.pointer', function () {
|
104 |
+
window.location.href = "<?php echo get_bloginfo('wpurl'); ?>/wp-admin/admin.php?page=leadin_settings";
|
105 |
+
//t.element.pointer('close');
|
106 |
+
});
|
107 |
+
return button;
|
108 |
+
},
|
109 |
+
close: function () {
|
110 |
+
}
|
111 |
+
});
|
112 |
+
|
113 |
+
setup = function () {
|
114 |
+
$('<?php echo $selector; ?>').pointer(li_pointer_options).pointer('open');
|
115 |
+
};
|
116 |
+
|
117 |
+
if (li_pointer_options.position && li_pointer_options.position.defer_loading)
|
118 |
+
$(window).bind('load.wp-pointers', setup);
|
119 |
+
else
|
120 |
+
$(document).ready(setup);
|
121 |
+
})(jQuery);
|
122 |
+
//]]>
|
123 |
+
|
124 |
+
</script>
|
125 |
+
<?php
|
126 |
+
}
|
127 |
}
|
inc/class-leadin.php
CHANGED
@@ -3,30 +3,25 @@
|
|
3 |
//=============================================
|
4 |
// WPLeadIn Class
|
5 |
//=============================================
|
6 |
-
class WPLeadIn
|
|
|
7 |
/**
|
8 |
* Class constructor
|
9 |
*/
|
10 |
-
function __construct
|
11 |
{
|
12 |
global $pagenow;
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
if ( is_user_logged_in() )
|
17 |
-
{
|
18 |
add_action('admin_bar_menu', array($this, 'add_leadin_link_to_admin_bar'), 999);
|
19 |
}
|
20 |
-
|
21 |
-
if (
|
22 |
-
|
23 |
-
if ( ! defined('DOING_AJAX') || ! DOING_AJAX )
|
24 |
$li_wp_admin = new WPLeadInAdmin();
|
25 |
-
}
|
26 |
-
else
|
27 |
-
{
|
28 |
// Adds the leadin-tracking script to wp-login.php page which doesnt hook into the enqueue logic
|
29 |
-
if (
|
30 |
add_action('login_enqueue_scripts', array($this, 'add_leadin_frontend_scripts'));
|
31 |
else
|
32 |
add_action('wp_enqueue_scripts', array($this, 'add_leadin_frontend_scripts'));
|
@@ -41,7 +36,7 @@ class WPLeadIn {
|
|
41 |
* Adds front end javascript + initializes ajax object
|
42 |
*/
|
43 |
|
44 |
-
function add_leadin_frontend_scripts
|
45 |
{
|
46 |
|
47 |
add_filter('script_loader_tag', array($this, 'leadin_add_embed_script_attributes'), 10, 2);
|
@@ -49,23 +44,23 @@ class WPLeadIn {
|
|
49 |
$embedDomain = constant('LEADIN_EMBED_DOMAIN');
|
50 |
$portalId = get_option('leadin_portalId');
|
51 |
|
52 |
-
if (
|
53 |
echo '<!-- Leadin embed JS disabled as a portalId has not yet been configured -->';
|
54 |
return;
|
55 |
}
|
56 |
|
57 |
-
$embedUrl = '//'
|
58 |
|
59 |
|
60 |
-
if (
|
61 |
$page_type = 'post';
|
62 |
-
else if (
|
63 |
$page_type = 'home';
|
64 |
-
else if (
|
65 |
$page_type = 'archive';
|
66 |
-
else if (
|
67 |
$page_type = 'login';
|
68 |
-
else if (
|
69 |
$page_type = 'page';
|
70 |
else
|
71 |
$page_type = 'other';
|
@@ -76,12 +71,13 @@ class WPLeadIn {
|
|
76 |
'leadinPluginVersion' => LEADIN_PLUGIN_VERSION
|
77 |
);
|
78 |
|
79 |
-
wp_register_script('leadin-embed-js', $embedUrl, array
|
80 |
wp_localize_script('leadin-embed-js', 'leadin_wordpress', $leadin_wordpress_info);
|
81 |
wp_enqueue_script('leadin-embed-js');
|
82 |
}
|
83 |
|
84 |
-
function leadin_add_embed_script_attributes
|
|
|
85 |
if ('leadin-embed-js' !== $handle)
|
86 |
return $tag;
|
87 |
else
|
@@ -91,13 +87,12 @@ class WPLeadIn {
|
|
91 |
/**
|
92 |
* Adds Leadin link to top-level admin bar
|
93 |
*/
|
94 |
-
function add_leadin_link_to_admin_bar
|
95 |
{
|
96 |
global $wp_version;
|
97 |
|
98 |
-
if (
|
99 |
-
|
100 |
-
if ( ! array_key_exists('li_grant_access_to_' . leadin_get_user_role(), get_option('leadin_options') ) )
|
101 |
return FALSE;
|
102 |
}
|
103 |
|
@@ -105,19 +100,19 @@ class WPLeadIn {
|
|
105 |
$leadin_icon = '<img src="' . LEADIN_PATH . '/images/leadin-icon-16x16-white.png' . '">';
|
106 |
|
107 |
$args = array(
|
108 |
-
'id'
|
109 |
-
'title'
|
110 |
'parent' => FALSE, // set parent to false to make it a top level (parent) node
|
111 |
'href' => get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin',
|
112 |
'meta' => array('title' => 'Leadin')
|
113 |
);
|
114 |
|
115 |
-
$wp_admin_bar->add_node(
|
116 |
}
|
117 |
|
118 |
-
public static function leadin_is_login_or_register_page
|
119 |
{
|
120 |
-
return in_array(
|
121 |
}
|
122 |
}
|
123 |
|
3 |
//=============================================
|
4 |
// WPLeadIn Class
|
5 |
//=============================================
|
6 |
+
class WPLeadIn
|
7 |
+
{
|
8 |
/**
|
9 |
* Class constructor
|
10 |
*/
|
11 |
+
function __construct()
|
12 |
{
|
13 |
global $pagenow;
|
14 |
|
15 |
+
if (is_user_logged_in()) {
|
|
|
|
|
|
|
16 |
add_action('admin_bar_menu', array($this, 'add_leadin_link_to_admin_bar'), 999);
|
17 |
}
|
18 |
+
|
19 |
+
if (is_admin()) {
|
20 |
+
if (!defined('DOING_AJAX') || !DOING_AJAX)
|
|
|
21 |
$li_wp_admin = new WPLeadInAdmin();
|
22 |
+
} else {
|
|
|
|
|
23 |
// Adds the leadin-tracking script to wp-login.php page which doesnt hook into the enqueue logic
|
24 |
+
if ($this->leadin_is_login_or_register_page())
|
25 |
add_action('login_enqueue_scripts', array($this, 'add_leadin_frontend_scripts'));
|
26 |
else
|
27 |
add_action('wp_enqueue_scripts', array($this, 'add_leadin_frontend_scripts'));
|
36 |
* Adds front end javascript + initializes ajax object
|
37 |
*/
|
38 |
|
39 |
+
function add_leadin_frontend_scripts()
|
40 |
{
|
41 |
|
42 |
add_filter('script_loader_tag', array($this, 'leadin_add_embed_script_attributes'), 10, 2);
|
44 |
$embedDomain = constant('LEADIN_EMBED_DOMAIN');
|
45 |
$portalId = get_option('leadin_portalId');
|
46 |
|
47 |
+
if (empty($portalId)) {
|
48 |
echo '<!-- Leadin embed JS disabled as a portalId has not yet been configured -->';
|
49 |
return;
|
50 |
}
|
51 |
|
52 |
+
$embedUrl = '//' . $embedDomain . '/js/v1/' . $portalId . '.js';
|
53 |
|
54 |
|
55 |
+
if (is_single())
|
56 |
$page_type = 'post';
|
57 |
+
else if (is_front_page())
|
58 |
$page_type = 'home';
|
59 |
+
else if (is_archive())
|
60 |
$page_type = 'archive';
|
61 |
+
else if ($this->leadin_is_login_or_register_page())
|
62 |
$page_type = 'login';
|
63 |
+
else if (is_page())
|
64 |
$page_type = 'page';
|
65 |
else
|
66 |
$page_type = 'other';
|
71 |
'leadinPluginVersion' => LEADIN_PLUGIN_VERSION
|
72 |
);
|
73 |
|
74 |
+
wp_register_script('leadin-embed-js', $embedUrl, array('jquery'), FALSE, TRUE);
|
75 |
wp_localize_script('leadin-embed-js', 'leadin_wordpress', $leadin_wordpress_info);
|
76 |
wp_enqueue_script('leadin-embed-js');
|
77 |
}
|
78 |
|
79 |
+
function leadin_add_embed_script_attributes($tag, $handle)
|
80 |
+
{
|
81 |
if ('leadin-embed-js' !== $handle)
|
82 |
return $tag;
|
83 |
else
|
87 |
/**
|
88 |
* Adds Leadin link to top-level admin bar
|
89 |
*/
|
90 |
+
function add_leadin_link_to_admin_bar($wp_admin_bar)
|
91 |
{
|
92 |
global $wp_version;
|
93 |
|
94 |
+
if (!current_user_can('activate_plugins')) {
|
95 |
+
if (!array_key_exists('li_grant_access_to_' . leadin_get_user_role(), get_option('leadin_options')))
|
|
|
96 |
return FALSE;
|
97 |
}
|
98 |
|
100 |
$leadin_icon = '<img src="' . LEADIN_PATH . '/images/leadin-icon-16x16-white.png' . '">';
|
101 |
|
102 |
$args = array(
|
103 |
+
'id' => 'leadin-admin-menu',
|
104 |
+
'title' => '<span class="ab-icon" ' . ($wp_version < 3.8 && !is_plugin_active('mp6/mp6.php') ? ' style="margin-top: 3px;"' : '') . '>' . $leadin_icon . '</span><span class="ab-label">Leadin</span>', // alter the title of existing node
|
105 |
'parent' => FALSE, // set parent to false to make it a top level (parent) node
|
106 |
'href' => get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin',
|
107 |
'meta' => array('title' => 'Leadin')
|
108 |
);
|
109 |
|
110 |
+
$wp_admin_bar->add_node($args);
|
111 |
}
|
112 |
|
113 |
+
public static function leadin_is_login_or_register_page()
|
114 |
{
|
115 |
+
return in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'));
|
116 |
}
|
117 |
}
|
118 |
|
inc/leadin-constants.php
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if (
|
4 |
-
|
5 |
|
6 |
-
if (
|
7 |
-
|
8 |
|
9 |
-
if (
|
10 |
-
|
11 |
|
12 |
-
if (
|
13 |
-
|
14 |
|
15 |
?>
|
1 |
<?php
|
2 |
|
3 |
+
if (!defined('LEADIN_UTM_SOURCE'))
|
4 |
+
define('LEADIN_UTM_SOURCE', 'leadin%20repo%20plugin');
|
5 |
|
6 |
+
if (!defined('LEADIN_UTM_MEDIUM'))
|
7 |
+
define('LEADIN_UTM_MEDIUM', 'referral');
|
8 |
|
9 |
+
if (!defined('LEADIN_UTM_CONTENT'))
|
10 |
+
define('LEADIN_UTM_CONTENT', 'e10');
|
11 |
|
12 |
+
if (!defined('LEADIN_UTM_CAMPAIGN'))
|
13 |
+
define('LEADIN_UTM_CAMPAIGN', 'one%20click%20updater');
|
14 |
|
15 |
?>
|
inc/leadin-functions.php
CHANGED
@@ -1,33 +1,24 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if (
|
4 |
-
{
|
5 |
header('HTTP/1.0 403 Forbidden');
|
6 |
die;
|
7 |
}
|
8 |
|
9 |
-
if (
|
10 |
-
{
|
11 |
DEFINE('LEADIN_PORTAL_ID', intval(get_option('leadin_portalId')));
|
12 |
}
|
13 |
|
14 |
-
if (
|
15 |
-
{
|
16 |
DEFINE('LEADIN_HAPIKEY', get_option('leadin_hapikey'));
|
17 |
}
|
18 |
|
19 |
|
20 |
-
function leadin_get_resource_url(
|
21 |
{
|
22 |
$resource_root = constant('LEADIN_ADMIN_ASSETS_BASE_URL');
|
23 |
|
24 |
-
return $resource_root
|
25 |
-
}
|
26 |
-
|
27 |
-
function leadin_build_api_url_with_auth( $path )
|
28 |
-
{
|
29 |
-
$auth_string = '?portalId=' . LEADIN_PORTAL_ID . '&hapikey=' . LEADIN_HAPIKEY;
|
30 |
-
return LEADIN_API_BASE_URL.$path.$auth_string;
|
31 |
}
|
32 |
|
33 |
/**
|
@@ -35,7 +26,7 @@ function leadin_build_api_url_with_auth( $path )
|
|
35 |
*
|
36 |
* @return array
|
37 |
*/
|
38 |
-
function leadin_get_current_user
|
39 |
{
|
40 |
global $wp_version;
|
41 |
global $current_user;
|
@@ -45,11 +36,10 @@ function leadin_get_current_user ()
|
|
45 |
|
46 |
$li_options = get_option('leadin_options');
|
47 |
$leadinPortalId = get_option('leadin_portalId');
|
48 |
-
|
49 |
-
if (
|
50 |
$li_user_email = $li_options['li_email'];
|
51 |
-
}
|
52 |
-
else {
|
53 |
$li_user_email = $current_user->user_email;
|
54 |
}
|
55 |
|
@@ -63,37 +53,37 @@ function leadin_get_current_user ()
|
|
63 |
'user_email' => $current_user->user_email
|
64 |
);
|
65 |
|
66 |
-
if (
|
67 |
$leadin_user['referral_source'] = LEADIN_REFERRAL_SOURCE;
|
68 |
else
|
69 |
$leadin_user['referral_source'] = '';
|
70 |
|
71 |
-
if (
|
72 |
$leadin_user['utm_source'] = LEADIN_UTM_SOURCE;
|
73 |
else
|
74 |
$leadin_user['utm_source'] = '';
|
75 |
|
76 |
-
if (
|
77 |
$leadin_user['utm_medium'] = LEADIN_UTM_MEDIUM;
|
78 |
else
|
79 |
$leadin_user['utm_medium'] = '';
|
80 |
|
81 |
-
if (
|
82 |
$leadin_user['utm_term'] = LEADIN_UTM_TERM;
|
83 |
else
|
84 |
$leadin_user['utm_term'] = '';
|
85 |
|
86 |
-
if (
|
87 |
$leadin_user['utm_content'] = LEADIN_UTM_CONTENT;
|
88 |
else
|
89 |
$leadin_user['utm_content'] = '';
|
90 |
|
91 |
-
if (
|
92 |
$leadin_user['utm_campaign'] = LEADIN_UTM_CAMPAIGN;
|
93 |
else
|
94 |
$leadin_user['utm_campaign'] = '';
|
95 |
|
96 |
-
if (
|
97 |
$leadin_user['portal_id'] = $leadinPortalId;
|
98 |
}
|
99 |
|
@@ -105,37 +95,21 @@ function leadin_get_current_user ()
|
|
105 |
*
|
106 |
* @param string
|
107 |
*/
|
108 |
-
function leadin_log_debug
|
109 |
{
|
110 |
-
if (
|
111 |
-
|
112 |
-
if ( is_array($message) || is_object($message) )
|
113 |
error_log(print_r($message, TRUE));
|
114 |
-
else
|
115 |
error_log($message);
|
116 |
}
|
117 |
}
|
118 |
|
119 |
-
/**
|
120 |
-
* Calculates the hour difference between MySQL timestamps and the current local WordPress time
|
121 |
-
*
|
122 |
-
*/
|
123 |
-
function leadin_set_mysql_timezone_offset ()
|
124 |
-
{
|
125 |
-
global $wpdb;
|
126 |
-
|
127 |
-
$mysql_timestamp = $wpdb->get_var("SELECT CURRENT_TIMESTAMP");
|
128 |
-
$diff = strtotime($mysql_timestamp) - strtotime(current_time('mysql'));
|
129 |
-
$hours = $diff / (60 * 60);
|
130 |
-
|
131 |
-
$wpdb->db_hour_offset = $hours;
|
132 |
-
}
|
133 |
-
|
134 |
/**
|
135 |
* Returns the user role for the current user
|
136 |
-
*
|
137 |
*/
|
138 |
-
function leadin_get_user_role
|
139 |
{
|
140 |
global $current_user;
|
141 |
|
1 |
<?php
|
2 |
|
3 |
+
if (!defined('LEADIN_PLUGIN_VERSION')) {
|
|
|
4 |
header('HTTP/1.0 403 Forbidden');
|
5 |
die;
|
6 |
}
|
7 |
|
8 |
+
if (!defined('LEADIN_PORTAL_ID')) {
|
|
|
9 |
DEFINE('LEADIN_PORTAL_ID', intval(get_option('leadin_portalId')));
|
10 |
}
|
11 |
|
12 |
+
if (!defined('LEADIN_HAPIKEY')) {
|
|
|
13 |
DEFINE('LEADIN_HAPIKEY', get_option('leadin_hapikey'));
|
14 |
}
|
15 |
|
16 |
|
17 |
+
function leadin_get_resource_url($path)
|
18 |
{
|
19 |
$resource_root = constant('LEADIN_ADMIN_ASSETS_BASE_URL');
|
20 |
|
21 |
+
return $resource_root . $path;
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
}
|
23 |
|
24 |
/**
|
26 |
*
|
27 |
* @return array
|
28 |
*/
|
29 |
+
function leadin_get_current_user()
|
30 |
{
|
31 |
global $wp_version;
|
32 |
global $current_user;
|
36 |
|
37 |
$li_options = get_option('leadin_options');
|
38 |
$leadinPortalId = get_option('leadin_portalId');
|
39 |
+
|
40 |
+
if (isset($li_options['li_email'])) {
|
41 |
$li_user_email = $li_options['li_email'];
|
42 |
+
} else {
|
|
|
43 |
$li_user_email = $current_user->user_email;
|
44 |
}
|
45 |
|
53 |
'user_email' => $current_user->user_email
|
54 |
);
|
55 |
|
56 |
+
if (defined('LEADIN_REFERRAL_SOURCE'))
|
57 |
$leadin_user['referral_source'] = LEADIN_REFERRAL_SOURCE;
|
58 |
else
|
59 |
$leadin_user['referral_source'] = '';
|
60 |
|
61 |
+
if (defined('LEADIN_UTM_SOURCE'))
|
62 |
$leadin_user['utm_source'] = LEADIN_UTM_SOURCE;
|
63 |
else
|
64 |
$leadin_user['utm_source'] = '';
|
65 |
|
66 |
+
if (defined('LEADIN_UTM_MEDIUM'))
|
67 |
$leadin_user['utm_medium'] = LEADIN_UTM_MEDIUM;
|
68 |
else
|
69 |
$leadin_user['utm_medium'] = '';
|
70 |
|
71 |
+
if (defined('LEADIN_UTM_TERM'))
|
72 |
$leadin_user['utm_term'] = LEADIN_UTM_TERM;
|
73 |
else
|
74 |
$leadin_user['utm_term'] = '';
|
75 |
|
76 |
+
if (defined('LEADIN_UTM_CONTENT'))
|
77 |
$leadin_user['utm_content'] = LEADIN_UTM_CONTENT;
|
78 |
else
|
79 |
$leadin_user['utm_content'] = '';
|
80 |
|
81 |
+
if (defined('LEADIN_UTM_CAMPAIGN'))
|
82 |
$leadin_user['utm_campaign'] = LEADIN_UTM_CAMPAIGN;
|
83 |
else
|
84 |
$leadin_user['utm_campaign'] = '';
|
85 |
|
86 |
+
if (!empty($leadinPortalId)) {
|
87 |
$leadin_user['portal_id'] = $leadinPortalId;
|
88 |
}
|
89 |
|
95 |
*
|
96 |
* @param string
|
97 |
*/
|
98 |
+
function leadin_log_debug($message)
|
99 |
{
|
100 |
+
if (WP_DEBUG === TRUE) {
|
101 |
+
if (is_array($message) || is_object($message))
|
|
|
102 |
error_log(print_r($message, TRUE));
|
103 |
+
else
|
104 |
error_log($message);
|
105 |
}
|
106 |
}
|
107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
/**
|
109 |
* Returns the user role for the current user
|
110 |
+
*
|
111 |
*/
|
112 |
+
function leadin_get_user_role()
|
113 |
{
|
114 |
global $current_user;
|
115 |
|
inc/leadin-proxy.php
DELETED
@@ -1,193 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( !defined('LEADIN_PLUGIN_VERSION') )
|
3 |
-
{
|
4 |
-
header( 'HTTP/1.0 403 Forbidden' );
|
5 |
-
wp_die();
|
6 |
-
}
|
7 |
-
|
8 |
-
if ( is_admin() ) {
|
9 |
-
add_action('wp_ajax_leadin_admin_ajax', 'leadin_admin_ajax'); // Call when user logged in
|
10 |
-
}
|
11 |
-
|
12 |
-
function leadin_admin_ajax() {
|
13 |
-
$baseUrl = constant('LEADIN_API_BASE_URL');
|
14 |
-
$_REQUEST['csurl'] = $baseUrl.$_GET['path'];
|
15 |
-
leadin_proxy_ajax();
|
16 |
-
wp_die();
|
17 |
-
}
|
18 |
-
|
19 |
-
function leadin_proxy_ajax ()
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* AJAX Cross Domain (PHP) Proxy 0.8
|
23 |
-
* by Iacovos Constantinou (http://www.iacons.net)
|
24 |
-
*
|
25 |
-
* Released under CC-GNU GPL
|
26 |
-
*/
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Enables or disables filtering for cross domain requests.
|
30 |
-
* Recommended value: true
|
31 |
-
*/
|
32 |
-
define( 'CSAJAX_FILTERS', true );
|
33 |
-
|
34 |
-
/**
|
35 |
-
* If set to true, $valid_requests should hold only domains i.e. a.example.com, b.example.com, usethisdomain.com
|
36 |
-
* If set to false, $valid_requests should hold the whole URL ( without the parameters ) i.e. http://example.com/this/is/long/url/
|
37 |
-
* Recommended value: false (for security reasons - do not forget that anyone can access your proxy)
|
38 |
-
*/
|
39 |
-
define( 'CSAJAX_FILTER_DOMAIN', true );
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Set debugging to true to receive additional messages - really helpful on development
|
43 |
-
*/
|
44 |
-
define( 'CSAJAX_DEBUG', false );
|
45 |
-
|
46 |
-
/**
|
47 |
-
* A set of valid cross domain requests
|
48 |
-
*/
|
49 |
-
$valid_requests = array(
|
50 |
-
'api.leadin.com',
|
51 |
-
'api.leadinqa.com',
|
52 |
-
'local.leadinqa.com'
|
53 |
-
);
|
54 |
-
|
55 |
-
/* * * STOP EDITING HERE UNLESS YOU KNOW WHAT YOU ARE DOING * * */
|
56 |
-
|
57 |
-
// identify request headers
|
58 |
-
$request_headers = array( );
|
59 |
-
foreach ( $_SERVER as $key => $value ) {
|
60 |
-
if ( substr( $key, 0, 5 ) == 'HTTP_' ) {
|
61 |
-
$headername = str_replace( '_', ' ', substr( $key, 5 ) );
|
62 |
-
$headername = str_replace( ' ', '-', ucwords( strtolower( $headername ) ) );
|
63 |
-
if ( !in_array( $headername, array( 'Host', 'X-Proxy-Url' ) ) ) {
|
64 |
-
$request_headers[] = "$headername: $value";
|
65 |
-
}
|
66 |
-
} else if ($key == 'CONTENT_TYPE') {
|
67 |
-
$request_headers[] = "Content-Type: $value";
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
// identify request method, url and params
|
72 |
-
$request_method = $_SERVER['REQUEST_METHOD'];
|
73 |
-
if ( 'GET' == $request_method ) {
|
74 |
-
$request_params = $_GET;
|
75 |
-
} elseif ( 'POST' == $request_method ) {
|
76 |
-
$request_params = $_POST;
|
77 |
-
if ( empty( $request_params ) ) {
|
78 |
-
$data = file_get_contents( 'php://input' );
|
79 |
-
if ( !empty( $data ) ) {
|
80 |
-
$request_params = $data;
|
81 |
-
}
|
82 |
-
}
|
83 |
-
} elseif ( 'PUT' == $request_method || 'DELETE' == $request_method || 'PATCH' == $request_method) {
|
84 |
-
$request_params = file_get_contents( 'php://input' );
|
85 |
-
} else {
|
86 |
-
$request_params = null;
|
87 |
-
}
|
88 |
-
|
89 |
-
// Get URL from `csurl` in GET or POST data, before falling back to X-Proxy-URL header.
|
90 |
-
if ( isset( $_REQUEST['csurl'] ) ) {
|
91 |
-
$request_url = urldecode( $_REQUEST['csurl'] );
|
92 |
-
} else if ( isset( $_SERVER['HTTP_X_PROXY_URL'] ) ) {
|
93 |
-
$request_url = urldecode( $_SERVER['HTTP_X_PROXY_URL'] );
|
94 |
-
} else {
|
95 |
-
header( $_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
|
96 |
-
header( 'Status: 404 Not Found' );
|
97 |
-
$_SERVER['REDIRECT_STATUS'] = 404;
|
98 |
-
exit;
|
99 |
-
}
|
100 |
-
|
101 |
-
$p_request_url = parse_url( $request_url );
|
102 |
-
|
103 |
-
// csurl may exist in GET request methods
|
104 |
-
if ( is_array( $request_params ) && array_key_exists('csurl', $request_params ) )
|
105 |
-
unset( $request_params['csurl'] );
|
106 |
-
|
107 |
-
// ignore requests for proxy :)
|
108 |
-
if ( preg_match( '!' . $_SERVER['SCRIPT_NAME'] . '!', $request_url ) || empty( $request_url ) || count( $p_request_url ) == 1 ) {
|
109 |
-
csajax_debug_message( 'Invalid request - make sure that csurl variable is not empty' );
|
110 |
-
exit;
|
111 |
-
}
|
112 |
-
|
113 |
-
// check against valid requests
|
114 |
-
if ( CSAJAX_FILTERS ) {
|
115 |
-
$parsed = $p_request_url;
|
116 |
-
if ( CSAJAX_FILTER_DOMAIN ) {
|
117 |
-
if ( !in_array( $parsed['host'], $valid_requests ) ) {
|
118 |
-
csajax_debug_message( 'Invalid domain - ' . $parsed['host'] . ' does not included in valid requests' );
|
119 |
-
exit;
|
120 |
-
}
|
121 |
-
} else {
|
122 |
-
$check_url = isset( $parsed['scheme'] ) ? $parsed['scheme'] . '://' : '';
|
123 |
-
$check_url .= isset( $parsed['user'] ) ? $parsed['user'] . ($parsed['pass'] ? ':' . $parsed['pass'] : '') . '@' : '';
|
124 |
-
$check_url .= isset( $parsed['host'] ) ? $parsed['host'] : '';
|
125 |
-
$check_url .= isset( $parsed['port'] ) ? ':' . $parsed['port'] : '';
|
126 |
-
$check_url .= isset( $parsed['path'] ) ? $parsed['path'] : '';
|
127 |
-
if ( !in_array( $check_url, $valid_requests ) ) {
|
128 |
-
csajax_debug_message( 'Invalid domain - ' . $request_url . ' does not included in valid requests' );
|
129 |
-
exit;
|
130 |
-
}
|
131 |
-
}
|
132 |
-
}
|
133 |
-
|
134 |
-
// append query string for GET requests
|
135 |
-
if ( $request_method == 'GET' && count( $request_params ) > 0 && (!array_key_exists( 'query', $p_request_url ) || empty( $p_request_url['query'] ) ) ) {
|
136 |
-
$request_url .= '?' . http_build_query( $request_params );
|
137 |
-
}
|
138 |
-
|
139 |
-
// let the request begin
|
140 |
-
$ch = curl_init( $request_url );
|
141 |
-
curl_setopt( $ch, CURLOPT_HTTPHEADER, $request_headers ); // (re-)send headers
|
142 |
-
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); // return response
|
143 |
-
curl_setopt( $ch, CURLOPT_HEADER, true ); // enabled response headers
|
144 |
-
// add data for POST, PUT or DELETE requests
|
145 |
-
if ( 'POST' == $request_method ) {
|
146 |
-
$post_data = is_array( $request_params ) ? http_build_query( $request_params ) : $request_params;
|
147 |
-
curl_setopt( $ch, CURLOPT_POST, true );
|
148 |
-
curl_setopt( $ch, CURLOPT_POSTFIELDS, $post_data );
|
149 |
-
} elseif ( 'PUT' == $request_method || 'DELETE' == $request_method || 'PATCH' == $request_method) {
|
150 |
-
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, $request_method );
|
151 |
-
curl_setopt( $ch, CURLOPT_POSTFIELDS, $request_params );
|
152 |
-
}
|
153 |
-
|
154 |
-
// retrieve response (headers and content)
|
155 |
-
$response = curl_exec( $ch );
|
156 |
-
|
157 |
-
if ( curl_error( $ch ) ) {
|
158 |
-
$error = curl_error ( $ch );
|
159 |
-
$errorNoNewlines = trim(preg_replace('/\s+/', ' ', $error));
|
160 |
-
header( 'HTTP/1.0 500 Internal Server Error' );
|
161 |
-
wp_die( '{"error": "Bad cURL response: '. $errorNoNewlines .'"}' );
|
162 |
-
}
|
163 |
-
|
164 |
-
curl_close( $ch );
|
165 |
-
|
166 |
-
// split response to header and content
|
167 |
-
list($response_headers, $response_content) = array_pad(preg_split( '/(\r\n){2}/', $response, 2 ), 2, '');
|
168 |
-
|
169 |
-
// (re-)send the headers
|
170 |
-
$response_headers = preg_split( '/(\r\n){1}/', $response_headers );
|
171 |
-
foreach ( $response_headers as $key => $response_header ) {
|
172 |
-
// Rewrite the `Location` header, so clients will also use the proxy for redirects.
|
173 |
-
if ( preg_match( '/^Location:/', $response_header ) ) {
|
174 |
-
list($header, $value) = preg_split( '/: /', $response_header, 2 );
|
175 |
-
$response_header = 'Location: ' . $_SERVER['REQUEST_URI'] . '?csurl=' . $value;
|
176 |
-
}
|
177 |
-
if ( !preg_match( '/^([T|t]ransfer-[E|e]ncoding):/', $response_header ) ) {
|
178 |
-
header( $response_header, false );
|
179 |
-
}
|
180 |
-
}
|
181 |
-
|
182 |
-
// finally, output the content
|
183 |
-
print( $response_content );
|
184 |
-
}
|
185 |
-
|
186 |
-
function csajax_debug_message( $message )
|
187 |
-
{
|
188 |
-
if ( true == CSAJAX_DEBUG ) {
|
189 |
-
print $message . PHP_EOL;
|
190 |
-
}
|
191 |
-
}
|
192 |
-
|
193 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/leadin-registration.php
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
<?php
|
2 |
-
if (
|
3 |
-
|
4 |
-
header( 'HTTP/1.0 403 Forbidden' );
|
5 |
wp_die();
|
6 |
}
|
7 |
|
8 |
-
if (
|
9 |
add_action('wp_ajax_leadin_registration_ajax', 'leadin_registration_ajax'); // Call when user logged in
|
10 |
}
|
11 |
|
12 |
-
function leadin_registration_ajax()
|
|
|
13 |
$existingPortalId = get_option('leadin_portalId');
|
14 |
$existingHapikey = get_option('leadin_hapikey');
|
15 |
|
16 |
if (!empty($existingPortalId) || !empty($existingHapikey)) {
|
17 |
-
header(
|
18 |
wp_die('{"error": "Registration is already complete for this portal"}');
|
19 |
}
|
20 |
|
@@ -25,9 +25,9 @@ function leadin_registration_ajax() {
|
|
25 |
|
26 |
error_log($data['hapikey']);
|
27 |
|
28 |
-
if (
|
29 |
error_log("Registration error");
|
30 |
-
header(
|
31 |
wp_die('{"error": "Registration missing required fields"}');
|
32 |
}
|
33 |
|
1 |
<?php
|
2 |
+
if (!defined('LEADIN_PLUGIN_VERSION')) {
|
3 |
+
header('HTTP/1.0 403 Forbidden');
|
|
|
4 |
wp_die();
|
5 |
}
|
6 |
|
7 |
+
if (is_admin()) {
|
8 |
add_action('wp_ajax_leadin_registration_ajax', 'leadin_registration_ajax'); // Call when user logged in
|
9 |
}
|
10 |
|
11 |
+
function leadin_registration_ajax()
|
12 |
+
{
|
13 |
$existingPortalId = get_option('leadin_portalId');
|
14 |
$existingHapikey = get_option('leadin_hapikey');
|
15 |
|
16 |
if (!empty($existingPortalId) || !empty($existingHapikey)) {
|
17 |
+
header('HTTP/1.0 400 Bad Request');
|
18 |
wp_die('{"error": "Registration is already complete for this portal"}');
|
19 |
}
|
20 |
|
25 |
|
26 |
error_log($data['hapikey']);
|
27 |
|
28 |
+
if (empty($newPortalId) || empty($newHapiKey)) {
|
29 |
error_log("Registration error");
|
30 |
+
header('HTTP/1.0 400 Bad Request');
|
31 |
wp_die('{"error": "Registration missing required fields"}');
|
32 |
}
|
33 |
|
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: 4.
|
7 |
Author: Leadin
|
8 |
Author URI: http://leadin.com
|
9 |
License: GPL2
|
@@ -13,56 +13,50 @@ License: GPL2
|
|
13 |
// Define Constants
|
14 |
//=============================================
|
15 |
|
16 |
-
if (
|
17 |
-
define('LEADIN_PATH', untrailingslashit(plugins_url('', __FILE__
|
18 |
|
19 |
-
if (
|
20 |
-
|
21 |
|
22 |
-
if (
|
23 |
-
|
24 |
|
25 |
-
if (
|
26 |
-
|
27 |
|
28 |
-
if (
|
29 |
-
|
30 |
|
31 |
-
if (
|
32 |
-
|
33 |
|
34 |
-
if (
|
35 |
define('LEADIN_SOURCE', 'leadin.com');
|
36 |
|
37 |
-
if (
|
38 |
-
|
39 |
|
40 |
-
if (
|
41 |
-
|
42 |
|
43 |
-
if (
|
44 |
-
|
45 |
-
|
46 |
-
if ( !defined('LEADIN_ENV') )
|
47 |
-
define('LEADIN_ENV', "prod");
|
48 |
|
49 |
//=============================================
|
50 |
// Include Needed Files
|
51 |
//=============================================
|
52 |
|
53 |
-
if (
|
54 |
-
|
55 |
|
56 |
require_once(LEADIN_PLUGIN_DIR . '/inc/leadin-functions.php');
|
57 |
-
require_once(LEADIN_PLUGIN_DIR . '/inc/leadin-proxy.php');
|
58 |
require_once(LEADIN_PLUGIN_DIR . '/inc/leadin-registration.php');
|
59 |
require_once(LEADIN_PLUGIN_DIR . '/admin/leadin-admin.php');
|
60 |
|
61 |
-
require_once(LEADIN_PLUGIN_DIR . '/lib/segment/lib/Segment.php');
|
62 |
require_once(LEADIN_PLUGIN_DIR . '/inc/class-leadin.php');
|
63 |
|
64 |
|
65 |
-
|
66 |
//=============================================
|
67 |
// Hooks & Filters
|
68 |
//=============================================
|
@@ -70,149 +64,137 @@ require_once(LEADIN_PLUGIN_DIR . '/inc/class-leadin.php');
|
|
70 |
/**
|
71 |
* Activate the plugin
|
72 |
*/
|
73 |
-
function activate_leadin
|
74 |
{
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
else
|
103 |
-
{
|
104 |
-
add_leadin_defaults();
|
105 |
-
}
|
106 |
}
|
107 |
|
108 |
/**
|
109 |
* Check Leadin installation and set options
|
110 |
*/
|
111 |
-
function add_leadin_defaults
|
112 |
{
|
113 |
-
|
114 |
-
|
115 |
-
|
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 |
-
INSERT INTO " . $multisite_prefix . "options
|
143 |
-
( option_name, option_value )
|
144 |
VALUES ('leadin_options', %s)", serialize($opt));
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
setcookie ( "ignore_social_share" , "1", 2592000, "/" );
|
154 |
}
|
155 |
|
156 |
/**
|
157 |
* Deactivate Leadin plugin hook
|
158 |
*/
|
159 |
-
function deactivate_leadin
|
160 |
{
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
// Switch back to the current blog
|
178 |
-
switch_to_blog($current_blog);
|
179 |
-
}
|
180 |
}
|
181 |
|
182 |
-
function activate_leadin_on_new_blog
|
183 |
{
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
}
|
193 |
}
|
194 |
|
195 |
/**
|
196 |
* Checks the stored database version against the current data version + updates if needed
|
197 |
*/
|
198 |
-
function leadin_init
|
199 |
{
|
200 |
$leadin_wp = new WPLeadIn();
|
201 |
}
|
202 |
|
203 |
|
204 |
-
add_action(
|
205 |
|
206 |
-
if (
|
207 |
-
|
208 |
-
|
209 |
-
register_activation_hook( __FILE__, 'activate_leadin');
|
210 |
|
211 |
-
|
212 |
-
|
213 |
|
214 |
-
|
215 |
-
|
216 |
}
|
217 |
|
218 |
-
?>
|
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: 4.5.0
|
7 |
Author: Leadin
|
8 |
Author URI: http://leadin.com
|
9 |
License: GPL2
|
13 |
// Define Constants
|
14 |
//=============================================
|
15 |
|
16 |
+
if (!defined('LEADIN_PATH'))
|
17 |
+
define('LEADIN_PATH', untrailingslashit(plugins_url('', __FILE__)));
|
18 |
|
19 |
+
if (!defined('LEADIN_PLUGIN_DIR'))
|
20 |
+
define('LEADIN_PLUGIN_DIR', untrailingslashit(dirname(__FILE__)));
|
21 |
|
22 |
+
if (!defined('LEADIN_PLUGIN_SLUG'))
|
23 |
+
define('LEADIN_PLUGIN_SLUG', basename(dirname(__FILE__)));
|
24 |
|
25 |
+
if (file_exists(LEADIN_PLUGIN_DIR . '/inc/leadin-overrides.php'))
|
26 |
+
include_once(LEADIN_PLUGIN_DIR . '/inc/leadin-overrides.php');
|
27 |
|
28 |
+
if (!defined('LEADIN_DB_VERSION'))
|
29 |
+
define('LEADIN_DB_VERSION', '2.2.5');
|
30 |
|
31 |
+
if (!defined('LEADIN_PLUGIN_VERSION'))
|
32 |
+
define('LEADIN_PLUGIN_VERSION', '4.5.0');
|
33 |
|
34 |
+
if (!defined('LEADIN_SOURCE'))
|
35 |
define('LEADIN_SOURCE', 'leadin.com');
|
36 |
|
37 |
+
if (!defined('LEADIN_ADMIN_ASSETS_BASE_URL'))
|
38 |
+
define('LEADIN_ADMIN_ASSETS_BASE_URL', "//appjs.leadin.com/leadin_admin_static_live");
|
39 |
|
40 |
+
if (!defined('LEADIN_EMBED_DOMAIN'))
|
41 |
+
define('LEADIN_EMBED_DOMAIN', "js.leadin.com");
|
42 |
|
43 |
+
if (!defined('LEADIN_ENV'))
|
44 |
+
define('LEADIN_ENV', "prod");
|
|
|
|
|
|
|
45 |
|
46 |
//=============================================
|
47 |
// Include Needed Files
|
48 |
//=============================================
|
49 |
|
50 |
+
if (file_exists(LEADIN_PLUGIN_DIR . '/inc/leadin-constants.php'))
|
51 |
+
include_once(LEADIN_PLUGIN_DIR . '/inc/leadin-constants.php');
|
52 |
|
53 |
require_once(LEADIN_PLUGIN_DIR . '/inc/leadin-functions.php');
|
|
|
54 |
require_once(LEADIN_PLUGIN_DIR . '/inc/leadin-registration.php');
|
55 |
require_once(LEADIN_PLUGIN_DIR . '/admin/leadin-admin.php');
|
56 |
|
|
|
57 |
require_once(LEADIN_PLUGIN_DIR . '/inc/class-leadin.php');
|
58 |
|
59 |
|
|
|
60 |
//=============================================
|
61 |
// Hooks & Filters
|
62 |
//=============================================
|
64 |
/**
|
65 |
* Activate the plugin
|
66 |
*/
|
67 |
+
function activate_leadin($network_wide)
|
68 |
{
|
69 |
|
70 |
+
// Check activation on entire network or one blog
|
71 |
+
if (is_multisite() && $network_wide) {
|
72 |
+
global $wpdb;
|
73 |
+
|
74 |
+
// Get this so we can switch back to it later
|
75 |
+
$current_blog = $wpdb->blogid;
|
76 |
+
// For storing the list of activated blogs
|
77 |
+
$activated = array();
|
78 |
+
|
79 |
+
// Get all blogs in the network and activate plugin on each one
|
80 |
+
$q = "SELECT blog_id FROM $wpdb->blogs";
|
81 |
+
$blog_ids = $wpdb->get_col($q);
|
82 |
+
foreach ($blog_ids as $blog_id) {
|
83 |
+
switch_to_blog($blog_id);
|
84 |
+
add_leadin_defaults();
|
85 |
+
$activated[] = $blog_id;
|
86 |
+
}
|
87 |
+
|
88 |
+
// Switch back to the current blog
|
89 |
+
switch_to_blog($current_blog);
|
90 |
+
|
91 |
+
// Store the array for a later function
|
92 |
+
update_site_option('leadin_activated', $activated);
|
93 |
+
} else {
|
94 |
+
add_leadin_defaults();
|
95 |
+
}
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
|
98 |
/**
|
99 |
* Check Leadin installation and set options
|
100 |
*/
|
101 |
+
function add_leadin_defaults()
|
102 |
{
|
103 |
+
global $wpdb;
|
104 |
+
$options = get_option('leadin_options');
|
105 |
+
|
106 |
+
if (($options['li_installed'] != 1) || (!is_array($options))) {
|
107 |
+
$opt = array(
|
108 |
+
'li_installed' => 1,
|
109 |
+
'leadin_version' => LEADIN_PLUGIN_VERSION,
|
110 |
+
'li_email' => get_bloginfo('admin_email'),
|
111 |
+
'li_updates_subscription' => 1,
|
112 |
+
'onboarding_step' => 1,
|
113 |
+
'onboarding_complete' => 0,
|
114 |
+
'ignore_settings_popup' => 0,
|
115 |
+
'data_recovered' => 1,
|
116 |
+
'delete_flags_fixed' => 1,
|
117 |
+
'beta_tester' => 0,
|
118 |
+
'converted_to_tags' => 1,
|
119 |
+
'names_added_to_contacts' => 1
|
120 |
+
);
|
121 |
+
|
122 |
+
// Add the Pro flag if this is a pro installation
|
123 |
+
if ((defined('LEADIN_UTM_SOURCE') && LEADIN_UTM_SOURCE != 'leadin%20repo%20plugin') || !defined('LEADIN_UTM_SOURCE'))
|
124 |
+
$opt['pro'] = 1;
|
125 |
+
|
126 |
+
// this is a hack because multisite doesn't recognize local options using either update_option or update_site_option...
|
127 |
+
if (is_multisite()) {
|
128 |
+
$multisite_prefix = (is_multisite() ? $wpdb->prefix : '');
|
129 |
+
$q = $wpdb->prepare("
|
130 |
+
INSERT INTO " . $multisite_prefix . "options
|
131 |
+
( option_name, option_value )
|
|
|
|
|
132 |
VALUES ('leadin_options', %s)", serialize($opt));
|
133 |
+
$wpdb->query($q);
|
134 |
+
// TODO: Glob settings for multisite
|
135 |
+
} else
|
136 |
+
update_option('leadin_options', $opt);
|
137 |
+
|
138 |
+
}
|
139 |
+
|
140 |
+
setcookie("ignore_social_share", "1", 2592000, "/");
|
|
|
141 |
}
|
142 |
|
143 |
/**
|
144 |
* Deactivate Leadin plugin hook
|
145 |
*/
|
146 |
+
function deactivate_leadin($network_wide)
|
147 |
{
|
148 |
+
if (is_multisite() && $network_wide) {
|
149 |
+
global $wpdb;
|
150 |
+
|
151 |
+
// Get this so we can switch back to it later
|
152 |
+
$current_blog = $wpdb->blogid;
|
153 |
+
|
154 |
+
// Get all blogs in the network and activate plugin on each one
|
155 |
+
$q = "SELECT blog_id FROM $wpdb->blogs";
|
156 |
+
$blog_ids = $wpdb->get_col($q);
|
157 |
+
foreach ($blog_ids as $blog_id) {
|
158 |
+
switch_to_blog($blog_id);
|
159 |
+
}
|
160 |
+
|
161 |
+
// Switch back to the current blog
|
162 |
+
switch_to_blog($current_blog);
|
163 |
+
}
|
|
|
|
|
|
|
164 |
}
|
165 |
|
166 |
+
function activate_leadin_on_new_blog($blog_id, $user_id, $domain, $path, $site_id, $meta)
|
167 |
{
|
168 |
+
global $wpdb;
|
169 |
+
|
170 |
+
if (is_plugin_active_for_network('leadin/leadin.php')) {
|
171 |
+
$current_blog = $wpdb->blogid;
|
172 |
+
switch_to_blog($blog_id);
|
173 |
+
add_leadin_defaults();
|
174 |
+
switch_to_blog($current_blog);
|
175 |
+
}
|
|
|
176 |
}
|
177 |
|
178 |
/**
|
179 |
* Checks the stored database version against the current data version + updates if needed
|
180 |
*/
|
181 |
+
function leadin_init()
|
182 |
{
|
183 |
$leadin_wp = new WPLeadIn();
|
184 |
}
|
185 |
|
186 |
|
187 |
+
add_action('plugins_loaded', 'leadin_init', 14);
|
188 |
|
189 |
+
if (is_admin()) {
|
190 |
+
// Activate + install Leadin
|
191 |
+
register_activation_hook(__FILE__, 'activate_leadin');
|
|
|
192 |
|
193 |
+
// Deactivate Leadin
|
194 |
+
register_deactivation_hook(__FILE__, 'deactivate_leadin');
|
195 |
|
196 |
+
// Activate on newly created wpmu blog
|
197 |
+
add_action('wpmu_new_blog', 'activate_leadin_on_new_blog', 10, 6);
|
198 |
}
|
199 |
|
200 |
+
?>
|
lib/segment/lib/Segment.php
DELETED
@@ -1,145 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if (!function_exists('json_encode')) {
|
4 |
-
throw new Exception('Segment needs the JSON PHP extension.');
|
5 |
-
}
|
6 |
-
|
7 |
-
require(dirname(__FILE__) . '/Segment/Client.php');
|
8 |
-
|
9 |
-
|
10 |
-
class Segment {
|
11 |
-
|
12 |
-
private static $client;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Initializes the default client to use. Uses the socket consumer by default.
|
16 |
-
* @param string $secret your project's secret key
|
17 |
-
* @param array $options passed straight to the client
|
18 |
-
*/
|
19 |
-
public static function init($secret, $options = array()) {
|
20 |
-
self::assert($secret, "Segment::init() requires secret");
|
21 |
-
self::$client = new Segment_Client($secret, $options);
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Tracks a user action
|
26 |
-
*
|
27 |
-
* @param array $message
|
28 |
-
* @return boolean whether the track call succeeded
|
29 |
-
*/
|
30 |
-
public static function track(array $message) {
|
31 |
-
self::checkClient();
|
32 |
-
$event = !empty($message["event"]);
|
33 |
-
self::assert($event, "Segment::track() expects an event");
|
34 |
-
self::validate($message, "track");
|
35 |
-
return self::$client->track($message);
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Tags traits about the user.
|
40 |
-
*
|
41 |
-
* @param array $message
|
42 |
-
* @return boolean whether the identify call succeeded
|
43 |
-
*/
|
44 |
-
public static function identify(array $message) {
|
45 |
-
self::checkClient();
|
46 |
-
$message["type"] = "identify";
|
47 |
-
self::validate($message, "identify");
|
48 |
-
return self::$client->identify($message);
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Tags traits about the group.
|
53 |
-
*
|
54 |
-
* @param array $message
|
55 |
-
* @return boolean whether the group call succeeded
|
56 |
-
*/
|
57 |
-
public static function group(array $message) {
|
58 |
-
self::checkClient();
|
59 |
-
$groupId = !empty($message["groupId"]);
|
60 |
-
$userId = !empty($message["userId"]);
|
61 |
-
self::assert($groupId && $userId, "Segment::group() expects userId and groupId");
|
62 |
-
return self::$client->group($message);
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Tracks a page view
|
67 |
-
*
|
68 |
-
* @param array $message
|
69 |
-
* @return boolean whether the page call succeeded
|
70 |
-
*/
|
71 |
-
public static function page(array $message) {
|
72 |
-
self::checkClient();
|
73 |
-
self::validate($message, "page");
|
74 |
-
return self::$client->page($message);
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Tracks a screen view
|
79 |
-
*
|
80 |
-
* @param array $message
|
81 |
-
* @return boolean whether the screen call succeeded
|
82 |
-
*/
|
83 |
-
public static function screen(array $message) {
|
84 |
-
self::checkClient();
|
85 |
-
self::validate($message, "screen");
|
86 |
-
return self::$client->screen($message);
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Aliases the user id from a temporary id to a permanent one
|
91 |
-
*
|
92 |
-
* @param array $from user id to alias from
|
93 |
-
* @return boolean whether the alias call succeeded
|
94 |
-
*/
|
95 |
-
public static function alias(array $message) {
|
96 |
-
self::checkClient();
|
97 |
-
$userId = !empty($message["userId"]);
|
98 |
-
$previousId = !empty($message["previousId"]);
|
99 |
-
self::assert($userId && $previousId, "Segment::alias() requires both userId and previousId");
|
100 |
-
return self::$client->alias($message);
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Validate common properties.
|
105 |
-
*
|
106 |
-
* @param array $msg
|
107 |
-
* @param string $type
|
108 |
-
*/
|
109 |
-
public static function validate($msg, $type){
|
110 |
-
$userId = !empty($msg["userId"]);
|
111 |
-
$anonId = !empty($msg["anonymousId"]);
|
112 |
-
self::assert($userId || $anonId, "Segment::$type() requires userId or anonymousId");
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* Flush the client
|
117 |
-
*/
|
118 |
-
|
119 |
-
public static function flush(){
|
120 |
-
self::checkClient();
|
121 |
-
return self::$client->flush();
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* Check the client.
|
126 |
-
*
|
127 |
-
* @throws Exception
|
128 |
-
*/
|
129 |
-
private static function checkClient(){
|
130 |
-
if (null != self::$client) return;
|
131 |
-
throw new Exception("Analytics::init() must be called before any other tracking method.");
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Assert `value` or throw.
|
136 |
-
*
|
137 |
-
* @param array $value
|
138 |
-
* @param string $msg
|
139 |
-
* @throws Exception
|
140 |
-
*/
|
141 |
-
private static function assert($value, $msg){
|
142 |
-
if (!$value) throw new Exception($msg);
|
143 |
-
}
|
144 |
-
|
145 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/segment/lib/Segment/Client.php
DELETED
@@ -1,201 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require(dirname(__FILE__) . '/Consumer.php');
|
4 |
-
require(dirname(__FILE__) . '/QueueConsumer.php');
|
5 |
-
require(dirname(__FILE__) . '/Consumer/File.php');
|
6 |
-
require(dirname(__FILE__) . '/Consumer/ForkCurl.php');
|
7 |
-
require(dirname(__FILE__) . '/Consumer/Socket.php');
|
8 |
-
|
9 |
-
class Segment_Client {
|
10 |
-
|
11 |
-
/**
|
12 |
-
* VERSION
|
13 |
-
*/
|
14 |
-
|
15 |
-
const VERSION = "1.1.0";
|
16 |
-
|
17 |
-
private $consumer;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Create a new analytics object with your app's secret
|
21 |
-
* key
|
22 |
-
*
|
23 |
-
* @param string $secret
|
24 |
-
* @param array $options array of consumer options [optional]
|
25 |
-
* @param string Consumer constructor to use, socket by default.
|
26 |
-
*/
|
27 |
-
public function __construct($secret, $options = array()) {
|
28 |
-
|
29 |
-
$consumers = array(
|
30 |
-
"socket" => "Segment_Consumer_Socket",
|
31 |
-
"file" => "Segment_Consumer_File",
|
32 |
-
"fork_curl" => "Segment_Consumer_ForkCurl"
|
33 |
-
);
|
34 |
-
|
35 |
-
# Use our socket consumer by default
|
36 |
-
$consumer_type = isset($options["consumer"]) ? $options["consumer"] :
|
37 |
-
"socket";
|
38 |
-
$Consumer = $consumers[$consumer_type];
|
39 |
-
|
40 |
-
$this->consumer = new $Consumer($secret, $options);
|
41 |
-
}
|
42 |
-
|
43 |
-
public function __destruct() {
|
44 |
-
$this->consumer->__destruct();
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Tracks a user action
|
49 |
-
*
|
50 |
-
* @param array $message
|
51 |
-
* @return [boolean] whether the track call succeeded
|
52 |
-
*/
|
53 |
-
public function track(array $message) {
|
54 |
-
$message = $this->message($message, "properties");
|
55 |
-
$message["type"] = "track";
|
56 |
-
return $this->consumer->track($message);
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Tags traits about the user.
|
61 |
-
*
|
62 |
-
* @param [array] $message
|
63 |
-
* @return [boolean] whether the track call succeeded
|
64 |
-
*/
|
65 |
-
public function identify(array $message) {
|
66 |
-
$message = $this->message($message, "traits");
|
67 |
-
$message["type"] = "identify";
|
68 |
-
return $this->consumer->identify($message);
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Tags traits about the group.
|
73 |
-
*
|
74 |
-
* @param [array] $message
|
75 |
-
* @return [boolean] whether the group call succeeded
|
76 |
-
*/
|
77 |
-
public function group(array $message) {
|
78 |
-
$message = $this->message($message, "traits");
|
79 |
-
$message["type"] = "group";
|
80 |
-
return $this->consumer->group($message);
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Tracks a page view.
|
85 |
-
*
|
86 |
-
* @param [array] $message
|
87 |
-
* @return [boolean] whether the page call succeeded
|
88 |
-
*/
|
89 |
-
public function page(array $message) {
|
90 |
-
$message = $this->message($message, "properties");
|
91 |
-
$message["type"] = "page";
|
92 |
-
return $this->consumer->page($message);
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Tracks a screen view.
|
97 |
-
*
|
98 |
-
* @param [array] $message
|
99 |
-
* @return [boolean] whether the screen call succeeded
|
100 |
-
*/
|
101 |
-
public function screen(array $message) {
|
102 |
-
$message = $this->message($message, "properties");
|
103 |
-
$message["type"] = "screen";
|
104 |
-
return $this->consumer->screen($message);
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Aliases from one user id to another
|
109 |
-
*
|
110 |
-
* @param array $message
|
111 |
-
* @return boolean whether the alias call succeeded
|
112 |
-
*/
|
113 |
-
public function alias(array $message) {
|
114 |
-
$message = $this->message($message);
|
115 |
-
$message["type"] = "alias";
|
116 |
-
return $this->consumer->alias($message);
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Flush any async consumers
|
121 |
-
*/
|
122 |
-
public function flush() {
|
123 |
-
if (!method_exists($this->consumer, 'flush')) return;
|
124 |
-
$this->consumer->flush();
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* Formats a timestamp by making sure it is set
|
129 |
-
* and converting it to iso8601.
|
130 |
-
*
|
131 |
-
* The timestamp can be time in seconds `time()` or `microseconds(true)`.
|
132 |
-
* any other input is considered an error and the method will return a new date.
|
133 |
-
*
|
134 |
-
* Note: php's date() "u" format (for microseconds) has a bug in it
|
135 |
-
* it always shows `.000` for microseconds since `date()` only accepts
|
136 |
-
* ints, so we have to construct the date ourselves if microtime is passed.
|
137 |
-
*
|
138 |
-
* @param time $timestamp - time in seconds (time())
|
139 |
-
*/
|
140 |
-
private function formatTime($ts) {
|
141 |
-
if ($ts == null) $ts = time();
|
142 |
-
if ("integer" == gettype($ts)) return date("c", $ts);
|
143 |
-
if (-1 == ($pos = strrpos($ts, "."))) return date("c");
|
144 |
-
$sec = substr($ts, 0, $pos);
|
145 |
-
$usec = substr($ts, $pos);
|
146 |
-
$fmt = sprintf("Y-m-d\TH:i:s%sP", $usec);
|
147 |
-
return date($fmt, (int)$sec);
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* Add common fields to the gvien `message`
|
152 |
-
*
|
153 |
-
* @param array $msg
|
154 |
-
* @param string $def
|
155 |
-
* @return array
|
156 |
-
*/
|
157 |
-
|
158 |
-
private function message($msg, $def = ""){
|
159 |
-
if ($def && !isset($msg[$def])) $msg[$def] = array();
|
160 |
-
if ($def && empty($msg[$def])) $msg[$def] = (object)$msg[$def];
|
161 |
-
if (!isset($msg["context"])) $msg["context"] = array();
|
162 |
-
if (!isset($msg["timestamp"])) $msg["timestamp"] = null;
|
163 |
-
$msg["context"] = array_merge($msg["context"], $this->getContext());
|
164 |
-
$msg["timestamp"] = $this->formatTime($msg["timestamp"]);
|
165 |
-
$msg["messageId"] = self::messageId();
|
166 |
-
return $msg;
|
167 |
-
}
|
168 |
-
|
169 |
-
/**
|
170 |
-
* Generate a random messageId.
|
171 |
-
*
|
172 |
-
* https://gist.github.com/dahnielson/508447#file-uuid-php-L74
|
173 |
-
*
|
174 |
-
* @return string
|
175 |
-
*/
|
176 |
-
|
177 |
-
private static function messageId(){
|
178 |
-
return sprintf("%04x%04x-%04x-%04x-%04x-%04x%04x%04x"
|
179 |
-
, mt_rand(0, 0xffff)
|
180 |
-
, mt_rand(0, 0xffff)
|
181 |
-
, mt_rand(0, 0xffff)
|
182 |
-
, mt_rand(0, 0x0fff) | 0x4000
|
183 |
-
, mt_rand(0, 0x3fff) | 0x8000
|
184 |
-
, mt_rand(0, 0xffff)
|
185 |
-
, mt_rand(0, 0xffff)
|
186 |
-
, mt_rand(0, 0xffff));
|
187 |
-
}
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Add the segment.io context to the request
|
191 |
-
* @return array additional context
|
192 |
-
*/
|
193 |
-
private function getContext () {
|
194 |
-
return array(
|
195 |
-
"library" => array(
|
196 |
-
"name" => "analytics-php",
|
197 |
-
"version" => self::VERSION
|
198 |
-
)
|
199 |
-
);
|
200 |
-
}
|
201 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/segment/lib/Segment/Consumer.php
DELETED
@@ -1,104 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
abstract class Segment_Consumer {
|
3 |
-
|
4 |
-
protected $type = "Consumer";
|
5 |
-
|
6 |
-
protected $options;
|
7 |
-
protected $secret;
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Store our secret and options as part of this consumer
|
11 |
-
* @param string $secret
|
12 |
-
* @param array $options
|
13 |
-
*/
|
14 |
-
public function __construct($secret, $options = array()) {
|
15 |
-
$this->secret = $secret;
|
16 |
-
$this->options = $options;
|
17 |
-
}
|
18 |
-
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Tracks a user action
|
22 |
-
*
|
23 |
-
* @param array $message
|
24 |
-
* @return boolean whether the track call succeeded
|
25 |
-
*/
|
26 |
-
abstract public function track(array $message);
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Tags traits about the user.
|
30 |
-
*
|
31 |
-
* @param array $message
|
32 |
-
* @return boolean whether the identify call succeeded
|
33 |
-
*/
|
34 |
-
abstract public function identify(array $message);
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Tags traits about the group.
|
38 |
-
*
|
39 |
-
* @param array $message
|
40 |
-
* @return boolean whether the group call succeeded
|
41 |
-
*/
|
42 |
-
abstract public function group(array $message);
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Tracks a page view.
|
46 |
-
*
|
47 |
-
* @param array $message
|
48 |
-
* @return boolean whether the page call succeeded
|
49 |
-
*/
|
50 |
-
abstract public function page(array $message);
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Tracks a screen view.
|
54 |
-
*
|
55 |
-
* @param array $message
|
56 |
-
* @return boolean whether the group call succeeded
|
57 |
-
*/
|
58 |
-
abstract public function screen(array $message);
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Aliases from one user id to another
|
62 |
-
*
|
63 |
-
* @param array $message
|
64 |
-
* @return boolean whether the alias call succeeded
|
65 |
-
*/
|
66 |
-
abstract public function alias(array $message);
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Check whether debug mode is enabled
|
70 |
-
* @return boolean
|
71 |
-
*/
|
72 |
-
protected function debug() {
|
73 |
-
return isset($this->options["debug"]) ? $this->options["debug"] : false;
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Check whether we should connect to the API using SSL. This is enabled by
|
78 |
-
* default with connections which make batching requests. For connections
|
79 |
-
* which can save on round-trip times, we disable it.
|
80 |
-
* @return boolean
|
81 |
-
*/
|
82 |
-
protected function ssl() {
|
83 |
-
return isset($this->options["ssl"]) ? $this->options["ssl"] : false;
|
84 |
-
}
|
85 |
-
|
86 |
-
|
87 |
-
/**
|
88 |
-
* On an error, try and call the error handler, if debugging output to
|
89 |
-
* error_log as well.
|
90 |
-
* @param string $code
|
91 |
-
* @param string $msg
|
92 |
-
*/
|
93 |
-
protected function handleError($code, $msg) {
|
94 |
-
|
95 |
-
if (isset($this->options['error_handler'])) {
|
96 |
-
$handler = $this->options['error_handler'];
|
97 |
-
$handler($code, $msg);
|
98 |
-
}
|
99 |
-
|
100 |
-
if ($this->debug()) {
|
101 |
-
error_log("[Analytics][" . $this->type . "] " . $msg);
|
102 |
-
}
|
103 |
-
}
|
104 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/segment/lib/Segment/Consumer/File.php
DELETED
@@ -1,111 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Segment_Consumer_File extends Segment_Consumer {
|
4 |
-
|
5 |
-
private $file_handle;
|
6 |
-
protected $type = "File";
|
7 |
-
|
8 |
-
/**
|
9 |
-
* The file consumer writes track and identify calls to a file.
|
10 |
-
* @param string $secret
|
11 |
-
* @param array $options
|
12 |
-
* string "filename" - where to log the analytics calls
|
13 |
-
*/
|
14 |
-
public function __construct($secret, $options = array()) {
|
15 |
-
|
16 |
-
if (!isset($options["filename"]))
|
17 |
-
$options["filename"] = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "analytics.log";
|
18 |
-
|
19 |
-
parent::__construct($secret, $options);
|
20 |
-
|
21 |
-
try {
|
22 |
-
$this->file_handle = fopen($options["filename"], "a");
|
23 |
-
chmod($options["filename"], 0777);
|
24 |
-
} catch (Exception $e) {
|
25 |
-
$this->handleError($e->getCode(), $e->getMessage());
|
26 |
-
}
|
27 |
-
}
|
28 |
-
|
29 |
-
public function __destruct() {
|
30 |
-
if ($this->file_handle &&
|
31 |
-
get_resource_type($this->file_handle) != "Unknown") {
|
32 |
-
fclose($this->file_handle);
|
33 |
-
}
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Tracks a user action
|
38 |
-
*
|
39 |
-
* @param array $message
|
40 |
-
* @return [boolean] whether the track call succeeded
|
41 |
-
*/
|
42 |
-
public function track(array $message) {
|
43 |
-
return $this->write($message);
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Tags traits about the user.
|
48 |
-
*
|
49 |
-
* @param array $message
|
50 |
-
* @return [boolean] whether the identify call succeeded
|
51 |
-
*/
|
52 |
-
public function identify(array $message) {
|
53 |
-
return $this->write($message);
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Tags traits about the group.
|
58 |
-
*
|
59 |
-
* @param array $message
|
60 |
-
* @return [boolean] whether the group call succeeded
|
61 |
-
*/
|
62 |
-
public function group(array $message) {
|
63 |
-
return $this->write($message);
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Tracks a page view.
|
68 |
-
*
|
69 |
-
* @param array $message
|
70 |
-
* @return [boolean] whether the page call succeeded
|
71 |
-
*/
|
72 |
-
public function page(array $message) {
|
73 |
-
return $this->write($message);
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Tracks a screen view.
|
78 |
-
*
|
79 |
-
* @param array $message
|
80 |
-
* @return [boolean] whether the screen call succeeded
|
81 |
-
*/
|
82 |
-
public function screen(array $message) {
|
83 |
-
return $this->write($message);
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Aliases from one user id to another
|
88 |
-
*
|
89 |
-
* @param array $message
|
90 |
-
* @return boolean whether the alias call succeeded
|
91 |
-
*/
|
92 |
-
public function alias(array $message) {
|
93 |
-
return $this->write($message);
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Writes the API call to a file as line-delimited json
|
98 |
-
* @param [array] $body post body content.
|
99 |
-
* @return [boolean] whether the request succeeded
|
100 |
-
*/
|
101 |
-
private function write($body) {
|
102 |
-
|
103 |
-
if (!$this->file_handle)
|
104 |
-
return false;
|
105 |
-
|
106 |
-
$content = json_encode($body);
|
107 |
-
$content.= "\n";
|
108 |
-
|
109 |
-
return fwrite($this->file_handle, $content) == strlen($content);
|
110 |
-
}
|
111 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/segment/lib/Segment/Consumer/ForkCurl.php
DELETED
@@ -1,59 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Segment_Consumer_ForkCurl extends Segment_QueueConsumer {
|
4 |
-
|
5 |
-
protected $type = "ForkCurl";
|
6 |
-
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Creates a new queued fork consumer which queues fork and identify
|
10 |
-
* calls before adding them to
|
11 |
-
* @param string $secret
|
12 |
-
* @param array $options
|
13 |
-
* boolean "debug" - whether to use debug output, wait for response.
|
14 |
-
* number "max_queue_size" - the max size of messages to enqueue
|
15 |
-
* number "batch_size" - how many messages to send in a single request
|
16 |
-
*/
|
17 |
-
public function __construct($secret, $options = array()) {
|
18 |
-
parent::__construct($secret, $options);
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Make an async request to our API. Fork a curl process, immediately send
|
23 |
-
* to the API. If debug is enabled, we wait for the response.
|
24 |
-
* @param array $messages array of all the messages to send
|
25 |
-
* @return boolean whether the request succeeded
|
26 |
-
*/
|
27 |
-
public function flushBatch($messages) {
|
28 |
-
|
29 |
-
$body = array(
|
30 |
-
"batch" => $messages,
|
31 |
-
);
|
32 |
-
|
33 |
-
$payload = json_encode($body);
|
34 |
-
|
35 |
-
# Escape for shell usage.
|
36 |
-
$payload = escapeshellarg($payload);
|
37 |
-
$secret = $this->secret;
|
38 |
-
|
39 |
-
$protocol = $this->ssl() ? "https://" : "http://";
|
40 |
-
$host = "api.segment.io";
|
41 |
-
$path = "/v1/import";
|
42 |
-
$url = $protocol . $host . $path;
|
43 |
-
|
44 |
-
$cmd = "curl -u $secret: -X POST -H 'Content-Type: application/json'";
|
45 |
-
$cmd.= " -d " . $payload . " '" . $url . "'";
|
46 |
-
|
47 |
-
if (!$this->debug()) {
|
48 |
-
$cmd .= " > /dev/null 2>&1 &";
|
49 |
-
}
|
50 |
-
|
51 |
-
exec($cmd, $output, $exit);
|
52 |
-
|
53 |
-
if ($exit != 0) {
|
54 |
-
$this->handleError($exit, $output);
|
55 |
-
}
|
56 |
-
|
57 |
-
return $exit == 0;
|
58 |
-
}
|
59 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/segment/lib/Segment/Consumer/Socket.php
DELETED
@@ -1,174 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Segment_Consumer_Socket extends Segment_QueueConsumer {
|
4 |
-
|
5 |
-
protected $type = "Socket";
|
6 |
-
private $socket_failed;
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Creates a new socket consumer for dispatching async requests immediately
|
10 |
-
* @param string $secret
|
11 |
-
* @param array $options
|
12 |
-
* number "timeout" - the timeout for connecting
|
13 |
-
* function "error_handler" - function called back on errors.
|
14 |
-
* boolean "debug" - whether to use debug output, wait for response.
|
15 |
-
*/
|
16 |
-
public function __construct($secret, $options = array()) {
|
17 |
-
|
18 |
-
if (!isset($options["timeout"]))
|
19 |
-
$options["timeout"] = 0.5;
|
20 |
-
|
21 |
-
if (!isset($options["host"]))
|
22 |
-
$options["host"] = "api.segment.io";
|
23 |
-
|
24 |
-
parent::__construct($secret, $options);
|
25 |
-
}
|
26 |
-
|
27 |
-
|
28 |
-
public function flushBatch($batch) {
|
29 |
-
$socket = $this->createSocket();
|
30 |
-
|
31 |
-
if (!$socket)
|
32 |
-
return;
|
33 |
-
|
34 |
-
$payload = array("batch" => $batch);
|
35 |
-
|
36 |
-
$payload = json_encode($payload);
|
37 |
-
|
38 |
-
$body = $this->createBody($this->options["host"], $payload);
|
39 |
-
return $this->makeRequest($socket, $body);
|
40 |
-
}
|
41 |
-
|
42 |
-
|
43 |
-
private function createSocket() {
|
44 |
-
|
45 |
-
if ($this->socket_failed)
|
46 |
-
return false;
|
47 |
-
|
48 |
-
$protocol = $this->ssl() ? "ssl" : "tcp";
|
49 |
-
$host = $this->options["host"];
|
50 |
-
$port = $this->ssl() ? 443 : 80;
|
51 |
-
$timeout = $this->options["timeout"];
|
52 |
-
|
53 |
-
try {
|
54 |
-
# Open our socket to the API Server.
|
55 |
-
# Since we're try catch'ing prevent PHP logs.
|
56 |
-
$socket = @pfsockopen($protocol . "://" . $host, $port, $errno,
|
57 |
-
$errstr, $timeout);
|
58 |
-
|
59 |
-
# If we couldn't open the socket, handle the error.
|
60 |
-
if ($errno != 0) {
|
61 |
-
$this->handleError($errno, $errstr);
|
62 |
-
$this->socket_failed = true;
|
63 |
-
return false;
|
64 |
-
}
|
65 |
-
|
66 |
-
return $socket;
|
67 |
-
|
68 |
-
} catch (Exception $e) {
|
69 |
-
$this->handleError($e->getCode(), $e->getMessage());
|
70 |
-
$this->socket_failed = true;
|
71 |
-
return false;
|
72 |
-
}
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Attempt to write the request to the socket, wait for response if debug
|
77 |
-
* mode is enabled.
|
78 |
-
* @param stream $socket the handle for the socket
|
79 |
-
* @param string $req request body
|
80 |
-
* @return boolean $success
|
81 |
-
*/
|
82 |
-
private function makeRequest($socket, $req, $retry = true) {
|
83 |
-
|
84 |
-
$bytes_written = 0;
|
85 |
-
$bytes_total = strlen($req);
|
86 |
-
$closed = false;
|
87 |
-
|
88 |
-
# Write the request
|
89 |
-
while (!$closed && $bytes_written < $bytes_total) {
|
90 |
-
try {
|
91 |
-
# Since we're try catch'ing prevent PHP logs.
|
92 |
-
$written = @fwrite($socket, substr($req, $bytes_written));
|
93 |
-
} catch (Exception $e) {
|
94 |
-
$this->handleError($e->getCode(), $e->getMessage());
|
95 |
-
$closed = true;
|
96 |
-
}
|
97 |
-
if (!isset($written) || !$written) {
|
98 |
-
$closed = true;
|
99 |
-
} else {
|
100 |
-
$bytes_written += $written;
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
# If the socket has been closed, attempt to retry a single time.
|
105 |
-
if ($closed) {
|
106 |
-
fclose($socket);
|
107 |
-
|
108 |
-
if ($retry) {
|
109 |
-
$socket = $this->createSocket();
|
110 |
-
if ($socket) return $this->makeRequest($socket, $req, false);
|
111 |
-
}
|
112 |
-
return false;
|
113 |
-
}
|
114 |
-
|
115 |
-
|
116 |
-
$success = true;
|
117 |
-
|
118 |
-
if ($this->debug()) {
|
119 |
-
$res = $this->parseResponse(fread($socket, 2048));
|
120 |
-
|
121 |
-
if ($res["status"] != "200") {
|
122 |
-
$this->handleError($res["status"], $res["message"]);
|
123 |
-
$success = false;
|
124 |
-
}
|
125 |
-
}
|
126 |
-
|
127 |
-
return $success;
|
128 |
-
}
|
129 |
-
|
130 |
-
|
131 |
-
/**
|
132 |
-
* Create the body to send as the post request.
|
133 |
-
* @param string $host
|
134 |
-
* @param string $content
|
135 |
-
* @return string body
|
136 |
-
*/
|
137 |
-
private function createBody($host, $content) {
|
138 |
-
|
139 |
-
$req = "";
|
140 |
-
$req.= "POST /v1/import HTTP/1.1\r\n";
|
141 |
-
$req.= "Host: " . $host . "\r\n";
|
142 |
-
$req.= "Content-Type: application/json\r\n";
|
143 |
-
$req.= "Authorization: Basic " . base64_encode($this->secret . ":") . "\r\n";
|
144 |
-
$req.= "Accept: application/json\r\n";
|
145 |
-
$req.= "Content-length: " . strlen($content) . "\r\n";
|
146 |
-
$req.= "\r\n";
|
147 |
-
$req.= $content;
|
148 |
-
|
149 |
-
return $req;
|
150 |
-
}
|
151 |
-
|
152 |
-
|
153 |
-
/**
|
154 |
-
* Parse our response from the server, check header and body.
|
155 |
-
* @param string $res
|
156 |
-
* @return array
|
157 |
-
* string $status HTTP code, e.g. "200"
|
158 |
-
* string $message JSON response from the api
|
159 |
-
*/
|
160 |
-
private function parseResponse($res) {
|
161 |
-
|
162 |
-
$contents = explode("\n", $res);
|
163 |
-
|
164 |
-
# Response comes back as HTTP/1.1 200 OK
|
165 |
-
# Final line contains HTTP response.
|
166 |
-
$status = explode(" ", $contents[0], 3);
|
167 |
-
$result = $contents[count($contents) - 1];
|
168 |
-
|
169 |
-
return array(
|
170 |
-
"status" => isset($status[1]) ? $status[1] : null,
|
171 |
-
"message" => $result
|
172 |
-
);
|
173 |
-
}
|
174 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/segment/lib/Segment/QueueConsumer.php
DELETED
@@ -1,138 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
abstract class Segment_QueueConsumer extends Segment_Consumer {
|
3 |
-
|
4 |
-
protected $type = "QueueConsumer";
|
5 |
-
|
6 |
-
protected $queue;
|
7 |
-
protected $max_queue_size = 1000;
|
8 |
-
protected $batch_size = 100;
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Store our secret and options as part of this consumer
|
12 |
-
* @param string $secret
|
13 |
-
* @param array $options
|
14 |
-
*/
|
15 |
-
public function __construct($secret, $options = array()) {
|
16 |
-
parent::__construct($secret, $options);
|
17 |
-
|
18 |
-
if (isset($options["max_queue_size"]))
|
19 |
-
$this->max_queue_size = $options["max_queue_size"];
|
20 |
-
|
21 |
-
if (isset($options["batch_size"]))
|
22 |
-
$this->batch_size = $options["batch_size"];
|
23 |
-
|
24 |
-
$this->queue = array();
|
25 |
-
}
|
26 |
-
|
27 |
-
public function __destruct() {
|
28 |
-
# Flush our queue on destruction
|
29 |
-
$this->flush();
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Tracks a user action
|
34 |
-
*
|
35 |
-
* @param array $message
|
36 |
-
* @return boolean whether the track call succeeded
|
37 |
-
*/
|
38 |
-
public function track(array $message) {
|
39 |
-
return $this->enqueue($message);
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Tags traits about the user.
|
44 |
-
*
|
45 |
-
* @param array $message
|
46 |
-
* @return boolean whether the identify call succeeded
|
47 |
-
*/
|
48 |
-
public function identify(array $message) {
|
49 |
-
return $this->enqueue($message);
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Tags traits about the group.
|
54 |
-
*
|
55 |
-
* @param array $message
|
56 |
-
* @return boolean whether the group call succeeded
|
57 |
-
*/
|
58 |
-
public function group(array $message) {
|
59 |
-
return $this->enqueue($message);
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Tracks a page view.
|
64 |
-
*
|
65 |
-
* @param array $message
|
66 |
-
* @return boolean whether the page call succeeded
|
67 |
-
*/
|
68 |
-
public function page(array $message) {
|
69 |
-
return $this->enqueue($message);
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Tracks a screen view.
|
74 |
-
*
|
75 |
-
* @param array $message
|
76 |
-
* @return boolean whether the screen call succeeded
|
77 |
-
*/
|
78 |
-
public function screen(array $message) {
|
79 |
-
return $this->enqueue($message);
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Aliases from one user id to another
|
84 |
-
*
|
85 |
-
* @param array $message
|
86 |
-
* @return boolean whether the alias call succeeded
|
87 |
-
*/
|
88 |
-
public function alias(array $message) {
|
89 |
-
return $this->enqueue($message);
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Adds an item to our queue.
|
94 |
-
* @param mixed $item
|
95 |
-
* @return boolean whether the queue has room
|
96 |
-
*/
|
97 |
-
protected function enqueue($item) {
|
98 |
-
|
99 |
-
$count = count($this->queue);
|
100 |
-
|
101 |
-
if ($count > $this->max_queue_size)
|
102 |
-
return false;
|
103 |
-
|
104 |
-
$count = array_push($this->queue, $item);
|
105 |
-
|
106 |
-
if ($count > $this->batch_size)
|
107 |
-
$this->flush();
|
108 |
-
|
109 |
-
return true;
|
110 |
-
}
|
111 |
-
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Flushes our queue of messages by batching them to the server
|
115 |
-
*/
|
116 |
-
public function flush() {
|
117 |
-
|
118 |
-
$count = count($this->queue);
|
119 |
-
$success = true;
|
120 |
-
|
121 |
-
while($count > 0 && $success) {
|
122 |
-
|
123 |
-
$batch = array_splice($this->queue, 0, min($this->batch_size, $count));
|
124 |
-
$success = $this->flushBatch($batch);
|
125 |
-
|
126 |
-
$count = count($this->queue);
|
127 |
-
}
|
128 |
-
|
129 |
-
return $success;
|
130 |
-
}
|
131 |
-
|
132 |
-
/**
|
133 |
-
* Flushes a batch of messages.
|
134 |
-
* @param [type] $batch [description]
|
135 |
-
* @return [type] [description]
|
136 |
-
*/
|
137 |
-
abstract function flushBatch($batch);
|
138 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/segment/send.php
DELETED
@@ -1,106 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* require client
|
5 |
-
*/
|
6 |
-
|
7 |
-
require(dirname(__FILE__) . "/lib/Segment.php");
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Args
|
11 |
-
*/
|
12 |
-
|
13 |
-
$args = parse($argv);
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Make sure both are set
|
17 |
-
*/
|
18 |
-
|
19 |
-
if (!isset($args["secret"])) die("--secret must be given");
|
20 |
-
if (!isset($args["file"])) die("--file must be given");
|
21 |
-
|
22 |
-
$file = $args["file"];
|
23 |
-
if ($file[0] != '/') $file = dirname(__FILE__) . "/" . $file;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Rename the file so we don't write the same calls
|
27 |
-
* multiple times
|
28 |
-
*/
|
29 |
-
|
30 |
-
$dir = dirname($file);
|
31 |
-
$old = $file;
|
32 |
-
$file = $dir . '/analytics-' . rand() . '.log';
|
33 |
-
|
34 |
-
if(!file_exists($old)) {
|
35 |
-
print("file: $old does not exist");
|
36 |
-
exit(0);
|
37 |
-
}
|
38 |
-
|
39 |
-
if (!rename($old, $file)) {
|
40 |
-
print("error renaming from $old to $new\n");
|
41 |
-
exit(1);
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* File contents.
|
46 |
-
*/
|
47 |
-
|
48 |
-
$contents = file_get_contents($file);
|
49 |
-
$lines = explode("\n", $contents);
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Initialize the client.
|
53 |
-
*/
|
54 |
-
|
55 |
-
Segment::init($args["secret"], array(
|
56 |
-
"debug" => true,
|
57 |
-
"on_error" => function($code, $msg){
|
58 |
-
print("$code: $msg\n");
|
59 |
-
exit(1);
|
60 |
-
}
|
61 |
-
));
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Payloads
|
65 |
-
*/
|
66 |
-
|
67 |
-
$total = 0;
|
68 |
-
$successful = 0;
|
69 |
-
foreach ($lines as $line) {
|
70 |
-
if (!trim($line)) continue;
|
71 |
-
$payload = json_decode($line, true);
|
72 |
-
$dt = new DateTime($payload["timestamp"]);
|
73 |
-
$ts = floatval($dt->getTimestamp() . "." . $dt->format("u"));
|
74 |
-
$payload["timestamp"] = $ts;
|
75 |
-
$type = $payload["type"];
|
76 |
-
$ret = call_user_func_array(array("Segment", $type), array($payload));
|
77 |
-
if ($ret) $successful++;
|
78 |
-
$total++;
|
79 |
-
if ($total % 100 === 0) Segment::flush();
|
80 |
-
}
|
81 |
-
|
82 |
-
Segment::flush();
|
83 |
-
unlink($file);
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Sent
|
87 |
-
*/
|
88 |
-
|
89 |
-
print("sent $successful from $total requests successfully");
|
90 |
-
exit(0);
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Parse arguments
|
94 |
-
*/
|
95 |
-
|
96 |
-
function parse($argv){
|
97 |
-
$ret = array();
|
98 |
-
|
99 |
-
for ($i = 0; $i < count($argv); ++$i) {
|
100 |
-
$arg = $argv[$i];
|
101 |
-
if ('--' != substr($arg, 0, 2)) continue;
|
102 |
-
$ret[substr($arg, 2, strlen($arg))] = trim($argv[++$i]);
|
103 |
-
}
|
104 |
-
|
105 |
-
return $ret;
|
106 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -2,16 +2,16 @@
|
|
2 |
Contributors: leadin, sredmond
|
3 |
Tags: crm, contacts, lead tracking, click tracking, visitor tracking, analytics, marketing automation, inbound marketing, subscription, marketing, lead generation, mailchimp, constant contact, newsletter, popup, popover, email list, email, contacts database, contact form, forms, form widget, popup form
|
4 |
Requires at least: 3.7
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 4.
|
7 |
|
8 |
-
Leadin is an easy-to-use marketing automation and lead tracking plugin for
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
= Get to know your website visitors =
|
13 |
|
14 |
-
<a href="
|
15 |
|
16 |
[youtube https://www.youtube.com/watch?v=tcMYv2r3ecg]
|
17 |
|
@@ -44,7 +44,7 @@ Our simple analytics show you what sources of traffic and content are driving th
|
|
44 |
**<a href="http://thewpvalet.com/wordpress-lead-tracking/" target="_blank">Adam W. Warner</a>**: *“…the Leadin plugin has been very useful so far in giving us an idea of the actual visitor paths to our contact forms vs. the paths we’ve intended.”*
|
45 |
|
46 |
|
47 |
-
Having trouble? Check out our <a href="
|
48 |
|
49 |
== Installation ==
|
50 |
|
@@ -52,25 +52,31 @@ Having trouble? Check out our <a href="http://support.leadin.com/">help document
|
|
52 |
2. Activate the plugin through the 'Plugins' menu in WordPress
|
53 |
3. Add an email address under 'Leadin' in your settings panel
|
54 |
|
55 |
-
Having trouble? Check out our <a href="
|
56 |
|
57 |
== Frequently Asked Questions ==
|
58 |
-
= <a href="
|
59 |
|
60 |
== Screenshots ==
|
61 |
|
62 |
1. See the visit history of each contact.
|
63 |
2. Get an email notification for every new lead.
|
64 |
-
3. Leadin
|
65 |
4. All your contacts stored safely in one place.
|
66 |
5. Collect more contacts with the pop-up subscribe widget.
|
67 |
|
68 |
== Changelog ==
|
69 |
|
70 |
-
- Current version: 4.
|
71 |
-
- Current version release:
|
72 |
|
73 |
-
= 4.
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
- Remove migration code
|
75 |
|
76 |
= 4.3.2 (2015.12.02) =
|
2 |
Contributors: leadin, sredmond
|
3 |
Tags: crm, contacts, lead tracking, click tracking, visitor tracking, analytics, marketing automation, inbound marketing, subscription, marketing, lead generation, mailchimp, constant contact, newsletter, popup, popover, email list, email, contacts database, contact form, forms, form widget, popup form
|
4 |
Requires at least: 3.7
|
5 |
+
Tested up to: 4.4.1
|
6 |
+
Stable tag: 4.5.0
|
7 |
|
8 |
+
Leadin is an easy-to-use marketing automation and lead tracking plugin for your website that helps you better understand your web site visitors.
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
= Get to know your website visitors =
|
13 |
|
14 |
+
<a href="https://leadin.hubspot.com" alt="WordPress marketing automation and lead tracking plugin" target="_blank">Leadin</a> is an easy-to-use marketing automation and lead tracking plugin for WordPress that helps you better understand your web site visitors.
|
15 |
|
16 |
[youtube https://www.youtube.com/watch?v=tcMYv2r3ecg]
|
17 |
|
44 |
**<a href="http://thewpvalet.com/wordpress-lead-tracking/" target="_blank">Adam W. Warner</a>**: *“…the Leadin plugin has been very useful so far in giving us an idea of the actual visitor paths to our contact forms vs. the paths we’ve intended.”*
|
45 |
|
46 |
|
47 |
+
Having trouble? Check out our <a href="https://leadin.hubspot.com/knowledge/">help documentation & support</a>
|
48 |
|
49 |
== Installation ==
|
50 |
|
52 |
2. Activate the plugin through the 'Plugins' menu in WordPress
|
53 |
3. Add an email address under 'Leadin' in your settings panel
|
54 |
|
55 |
+
Having trouble? Check out our <a href="https://leadin.hubspot.com/knowledge/" target="_blank">help documentation & support</a>
|
56 |
|
57 |
== Frequently Asked Questions ==
|
58 |
+
= <a href="https://leadin.hubspot.com/knowledge/frequently-asked-questions" target="_blank">Full FAQ Here</a> =
|
59 |
|
60 |
== Screenshots ==
|
61 |
|
62 |
1. See the visit history of each contact.
|
63 |
2. Get an email notification for every new lead.
|
64 |
+
3. Leadin Dashboard shows you where your leads are coming from.
|
65 |
4. All your contacts stored safely in one place.
|
66 |
5. Collect more contacts with the pop-up subscribe widget.
|
67 |
|
68 |
== Changelog ==
|
69 |
|
70 |
+
- Current version: 4.5.0
|
71 |
+
- Current version release: 2016-01-14
|
72 |
|
73 |
+
= 4.5.0 (2015.12.14) =
|
74 |
+
- Renamed "stats" to "dashboard" in the menu
|
75 |
+
- Fixed a bug where deactivating the plugin in multisite mode would cause a PHP error
|
76 |
+
- Removed old PHP that was used before Leadin was hosted in an iFrame, as it is now
|
77 |
+
- Updated screenshots
|
78 |
+
|
79 |
+
= 4.4.0 (2015.12.14) =
|
80 |
- Remove migration code
|
81 |
|
82 |
= 4.3.2 (2015.12.02) =
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-2.png
CHANGED
Binary file
|
screenshot-3.png
CHANGED
Binary file
|
screenshot-4.png
CHANGED
Binary file
|
screenshot-5.png
CHANGED
Binary file
|