Version Description
(2018.05.22) = - Code cleanup
Download this release
Release Info
Developer | leadin |
Plugin | HubSpot – Free Marketing Plugin for WordPress |
Version | 6.1.5 |
Comparing to | |
See all releases |
Code changes from version 6.1.4 to 6.1.5
- admin/leadin-admin.php +212 -221
- inc/class-leadin-pointers.php +115 -117
- inc/class-leadin.php +114 -118
- inc/leadin-constants.php +13 -9
- inc/leadin-disconnect.php +18 -19
- inc/leadin-functions.php +90 -88
- inc/leadin-registration.php +32 -33
- leadin.php +156 -145
- readme.txt +6 -3
admin/leadin-admin.php
CHANGED
@@ -1,234 +1,225 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if (!defined('LEADIN_PLUGIN_VERSION')) {
|
4 |
-
|
5 |
-
|
6 |
}
|
7 |
|
8 |
-
|
9 |
// Define Constants
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
|
16 |
// Include Needed Files
|
17 |
-
|
18 |
-
|
19 |
-
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
20 |
|
21 |
-
if (!class_exists('LI_Pointers'))
|
22 |
-
|
|
|
23 |
|
24 |
-
|
25 |
// WPLeadInAdmin Class
|
26 |
-
|
27 |
-
class WPLeadInAdmin
|
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 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
$
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
{
|
223 |
-
if (isset($_REQUEST['action']) && -1 != $_REQUEST['action'])
|
224 |
-
return $_REQUEST['action'];
|
225 |
-
|
226 |
-
if (isset($_REQUEST['action2']) && -1 != $_REQUEST['action2'])
|
227 |
-
return $_REQUEST['action2'];
|
228 |
-
|
229 |
-
return FALSE;
|
230 |
-
}
|
231 |
|
232 |
}
|
233 |
|
234 |
-
|
1 |
<?php
|
2 |
|
3 |
+
if ( ! defined( 'LEADIN_PLUGIN_VERSION' ) ) {
|
4 |
+
header( 'HTTP/1.0 403 Forbidden' );
|
5 |
+
die;
|
6 |
}
|
7 |
|
8 |
+
// =============================================
|
9 |
// Define Constants
|
10 |
+
// =============================================
|
11 |
+
if ( ! defined( 'LEADIN_ADMIN_PATH' ) ) {
|
12 |
+
define( 'LEADIN_ADMIN_PATH', untrailingslashit( __FILE__ ) );
|
13 |
+
}
|
14 |
|
15 |
+
// =============================================
|
16 |
// Include Needed Files
|
17 |
+
// =============================================
|
18 |
+
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
|
|
19 |
|
20 |
+
if ( ! class_exists( 'LI_Pointers' ) ) {
|
21 |
+
require_once LEADIN_PLUGIN_DIR . '/inc/class-leadin-pointers.php';
|
22 |
+
}
|
23 |
|
24 |
+
// =============================================
|
25 |
// WPLeadInAdmin Class
|
26 |
+
// =============================================
|
27 |
+
class WPLeadInAdmin {
|
28 |
+
|
29 |
+
|
30 |
+
var $li_viewers;
|
31 |
+
var $stats_dashboard;
|
32 |
+
var $action;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Class constructor
|
36 |
+
*/
|
37 |
+
function __construct() {
|
38 |
+
// =============================================
|
39 |
+
// Hooks & Filters
|
40 |
+
// =============================================
|
41 |
+
$plugin_version = get_option( 'leadin_pluginVersion' );
|
42 |
+
|
43 |
+
$this->action = $this->leadin_current_action();
|
44 |
+
|
45 |
+
// If the plugin version matches the latest version escape the update function
|
46 |
+
if ( $plugin_version != LEADIN_PLUGIN_VERSION ) {
|
47 |
+
self::leadin_update_check();
|
48 |
+
}
|
49 |
+
|
50 |
+
add_action( 'admin_menu', array( &$this, 'leadin_add_menu_items' ) );
|
51 |
+
add_action( 'admin_print_scripts', array( &$this, 'add_leadin_admin_scripts' ) );
|
52 |
+
add_filter( 'plugin_action_links_' . 'leadin/leadin.php', array( $this, 'leadin_plugin_settings_link' ) );
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
function leadin_update_check() {
|
57 |
+
update_option( 'leadin_pluginVersion', LEADIN_PLUGIN_VERSION );
|
58 |
+
}
|
59 |
+
|
60 |
+
// =============================================
|
61 |
+
// Menus
|
62 |
+
// =============================================
|
63 |
+
/**
|
64 |
+
* Adds Leadin menu to /wp-admin sidebar
|
65 |
+
*/
|
66 |
+
function leadin_add_menu_items() {
|
67 |
+
$options = get_option( 'leadin_options' );
|
68 |
+
|
69 |
+
global $submenu;
|
70 |
+
global $wp_version;
|
71 |
+
|
72 |
+
// Block non-sanctioned users from accessing Leadin
|
73 |
+
$capability = 'activate_plugins';
|
74 |
+
if ( ! current_user_can( 'activate_plugins' ) ) {
|
75 |
+
if ( ! array_key_exists( 'li_grant_access_to_' . leadin_get_user_role(), $options ) ) {
|
76 |
+
return false;
|
77 |
+
} else {
|
78 |
+
if ( current_user_can( 'manage_network' ) ) { // super admin
|
79 |
+
$capability = 'manage_network';
|
80 |
+
} elseif ( current_user_can( 'edit_pages' ) ) { // editor
|
81 |
+
$capability = 'edit_pages';
|
82 |
+
} elseif ( current_user_can( 'publish_posts' ) ) { // author
|
83 |
+
$capability = 'publish_posts';
|
84 |
+
} elseif ( current_user_can( 'edit_posts' ) ) { // contributor
|
85 |
+
$capability = 'edit_posts';
|
86 |
+
} elseif ( current_user_can( 'read' ) ) { // subscriber
|
87 |
+
$capability = 'read';
|
88 |
+
}
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
$leadin_icon = LEADIN_PATH . '/images/leadin-icon-16x16-white.png';
|
93 |
+
|
94 |
+
add_menu_page( 'HubSpot', 'HubSpot', $capability, 'leadin', array( $this, 'leadin_build_app' ), $leadin_icon, '25.100713' );
|
95 |
+
|
96 |
+
if ( ! isset( $_GET['page'] ) || $_GET['page'] != ( 'leadin' || 'leadin_settings' || 'leadin_contacts' || 'leadin_flows' || 'leadin_collected_forms' ) ) { // WPCS: CSRF ok.
|
97 |
+
if ( ! get_option( 'leadin_portalId' ) ) {
|
98 |
+
$li_pointers = new LI_Pointers( true );
|
99 |
+
}
|
100 |
+
// else if ( ! get_option('leadin_portalId') && $options )
|
101 |
+
// $li_pointers = new LI_Pointers(FALSE);
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
// =============================================
|
106 |
+
// Settings Page
|
107 |
+
// =============================================
|
108 |
+
/**
|
109 |
+
* Adds setting link for Leadin to plugins management page
|
110 |
+
*
|
111 |
+
* @param array $links
|
112 |
+
* @return array
|
113 |
+
*/
|
114 |
+
function leadin_plugin_settings_link( $links ) {
|
115 |
+
$url = get_admin_url( get_current_blog_id(), 'admin.php?page=leadin' );
|
116 |
+
$settings_link = '<a href="' . $url . '">Settings</a>';
|
117 |
+
array_unshift( $links, $settings_link );
|
118 |
+
return $links;
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Creates leadin app
|
123 |
+
*/
|
124 |
+
|
125 |
+
function leadin_build_app() {
|
126 |
+
global $wp_version;
|
127 |
+
|
128 |
+
echo '<div id="leadin" class="wrap ' . ( $wp_version < 3.8 && ! is_plugin_active( 'mp6/mp6.php' ) ? 'pre-mp6' : '' ) . '"></div>';
|
129 |
+
|
130 |
+
wp_enqueue_style( 'leadin-css' );
|
131 |
+
wp_enqueue_script( 'leadin-app' );
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
function update_option_leadin_options_callback( $old_value, $new_value ) {
|
136 |
+
}
|
137 |
+
|
138 |
+
// =============================================
|
139 |
+
// Admin Styles & Scripts
|
140 |
+
// =============================================
|
141 |
+
/**
|
142 |
+
* Adds admin javascript
|
143 |
+
*/
|
144 |
+
function add_leadin_admin_scripts() {
|
145 |
+
global $pagenow;
|
146 |
+
global $wp_roles;
|
147 |
+
global $wp_version;
|
148 |
+
|
149 |
+
$ajaxUrl = get_admin_url( get_current_blog_id(), 'admin-ajax.php' );
|
150 |
+
|
151 |
+
$leadin_config = array(
|
152 |
+
'portalId' => get_option( 'leadin_portalId' ),
|
153 |
+
'hapikey' => get_option( 'leadin_hapikey' ),
|
154 |
+
'slumberMode' => get_option( 'leadin_slumber_mode' ),
|
155 |
+
'env' => constant( 'LEADIN_ENV' ),
|
156 |
+
'user' => $this->leadin_get_user_for_tracking(),
|
157 |
+
'allRoles' => $wp_roles->get_names(),
|
158 |
+
'leadinPluginVersion' => constant( 'LEADIN_PLUGIN_VERSION' ),
|
159 |
+
'wpVersion' => $wp_version,
|
160 |
+
'siteUrl' => get_site_url(),
|
161 |
+
'adminEmail' => get_option( 'admin_email' ),
|
162 |
+
'siteName' => get_bloginfo( 'name' ),
|
163 |
+
'adminBaseUrl' => get_admin_url( get_current_blog_id(), 'admin.php' ),
|
164 |
+
'leadinPluginDirectory' => LEADIN_PLUGIN_SLUG,
|
165 |
+
'ajaxUrl' => is_ssl() ? str_replace( 'http:', 'https:', $ajaxUrl ) : str_replace( 'https:', 'http:', $ajaxUrl ),
|
166 |
+
'locale' => get_locale(),
|
167 |
+
'timezone' => get_option( 'gmt_offset' ),
|
168 |
+
'timezoneString' => get_option( 'timezone_string' ), // If not set by the user manually it will be an empty string
|
169 |
+
);
|
170 |
+
|
171 |
+
if ( ( $pagenow == 'admin.php' && isset( $_GET['page'] ) && strstr( $_GET['page'], 'leadin' ) ) ) { // WPCS: CSRF ok.
|
172 |
+
wp_register_script( 'leadin-head-js', leadin_get_resource_url( '/bundle/head/head.js' ), false, false, false );
|
173 |
+
wp_localize_script( 'leadin-head-js', 'leadin_config', $leadin_config );
|
174 |
+
wp_enqueue_script( 'leadin-head-js' );
|
175 |
+
|
176 |
+
wp_register_script( 'leadin-app', leadin_get_resource_url( '/bundle/app.js' ), array( 'backbone' ), false, true );
|
177 |
+
wp_register_style( 'leadin-css', leadin_get_resource_url( '/bundle/app.css' ) );
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
// =============================================
|
182 |
+
// Internal Class Functions
|
183 |
+
// =============================================
|
184 |
+
function leadin_get_user_for_tracking() {
|
185 |
+
$leadin_user = leadin_get_current_user();
|
186 |
+
$tracking_leadin_user = array(
|
187 |
+
'hashed_wp_url' => $leadin_user['user_id'],
|
188 |
+
'name' => $leadin_user['alias'],
|
189 |
+
'email' => $leadin_user['email'],
|
190 |
+
'wp-url' => $leadin_user['wp_url'],
|
191 |
+
'wp-version' => $leadin_user['wp_version'],
|
192 |
+
'li-source' => LEADIN_SOURCE,
|
193 |
+
'website' => $leadin_user['wp_url'],
|
194 |
+
'company' => $leadin_user['wp_url'],
|
195 |
+
'utm_source' => $leadin_user['utm_source'],
|
196 |
+
'utm_medium' => $leadin_user['utm_medium'],
|
197 |
+
'utm_term' => $leadin_user['utm_term'],
|
198 |
+
'utm_content' => $leadin_user['utm_term'],
|
199 |
+
'utm_campaign' => $leadin_user['utm_campaign'],
|
200 |
+
'referral_source' => $leadin_user['referral_source'],
|
201 |
+
'user_email' => $leadin_user['user_email'],
|
202 |
+
);
|
203 |
+
return $tracking_leadin_user;
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* GET and set url actions into readable strings
|
208 |
+
*
|
209 |
+
* @return string if actions are set, bool if no actions set
|
210 |
+
*/
|
211 |
+
function leadin_current_action() {
|
212 |
+
if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) { // WPCS: CSRF ok.
|
213 |
+
return $_REQUEST['action']; // WPCS: CSRF ok.
|
214 |
+
}
|
215 |
+
|
216 |
+
if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) { // WPCS: CSRF ok.
|
217 |
+
return $_REQUEST['action2']; // WPCS: CSRF ok.
|
218 |
+
}
|
219 |
+
|
220 |
+
return false;
|
221 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
|
223 |
}
|
224 |
|
225 |
+
|
inc/class-leadin-pointers.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if (!defined('LEADIN_PLUGIN_VERSION')) {
|
4 |
-
|
5 |
-
|
6 |
}
|
7 |
|
8 |
/**
|
@@ -10,118 +10,116 @@ if (!defined('LEADIN_PLUGIN_VERSION')) {
|
|
10 |
*
|
11 |
* @todo Add an introdutory pointer on the edit post page too.
|
12 |
*/
|
13 |
-
class LI_Pointers
|
14 |
-
|
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 |
-
<?php
|
126 |
-
}
|
127 |
}
|
1 |
<?php
|
2 |
|
3 |
+
if ( ! defined( 'LEADIN_PLUGIN_VERSION' ) ) {
|
4 |
+
header( 'HTTP/1.0 403 Forbidden' );
|
5 |
+
die;
|
6 |
}
|
7 |
|
8 |
/**
|
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 |
+
// Hooks & Filters
|
22 |
+
// =============================================
|
23 |
+
if ( $new_install ) {
|
24 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_new_install_pointer' ) );
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Enqueue styles and scripts needed for the pointers.
|
30 |
+
*/
|
31 |
+
function enqueue_new_install_pointer() {
|
32 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
33 |
+
return;
|
34 |
+
}
|
35 |
+
|
36 |
+
wp_enqueue_style( 'wp-pointer' );
|
37 |
+
wp_enqueue_script( 'jquery-ui' );
|
38 |
+
wp_enqueue_script( 'wp-pointer' );
|
39 |
+
wp_enqueue_script( 'utils' );
|
40 |
+
|
41 |
+
add_action( 'admin_print_footer_scripts', array( $this, 'li_settings_popup_new' ) );
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Loads in the required scripts for the pointer
|
46 |
+
*/
|
47 |
+
function enqueue_pointer_scripts() {
|
48 |
+
wp_enqueue_style( 'wp-pointer' );
|
49 |
+
wp_enqueue_script( 'jquery-ui' );
|
50 |
+
wp_enqueue_script( 'wp-pointer' );
|
51 |
+
wp_enqueue_script( 'utils' );
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Shows a popup that asks for permission to allow tracking.
|
56 |
+
*/
|
57 |
+
function li_settings_popup_new() {
|
58 |
+
$id = '#toplevel_page_leadin';
|
59 |
+
|
60 |
+
$content = '<h3>' . __( 'So close...', 'leadin' ) . '</h3>';
|
61 |
+
$content .= '<p>' . __( 'HubSpot needs just a bit more info to get up and running. Click on \'Complete Setup\' to complete the setup.', 'leadin' ) . '</p>';
|
62 |
+
|
63 |
+
$opt_arr = array(
|
64 |
+
'content' => $content,
|
65 |
+
'position' => array(
|
66 |
+
'edge' => 'left',
|
67 |
+
'align' => 'center',
|
68 |
+
),
|
69 |
+
);
|
70 |
+
|
71 |
+
$function2 = 'li_redirect_to_leadin()';
|
72 |
+
|
73 |
+
$this->print_scripts( $id, $opt_arr, 'Complete Setup', false, '', $function2 );
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Prints the pointer script
|
78 |
+
*
|
79 |
+
* @param string $selector The CSS selector the pointer is attached to.
|
80 |
+
* @param array $options The options for the pointer.
|
81 |
+
* @param string $button1 Text for button 1
|
82 |
+
* @param string|bool $button2 Text for button 2 (or false to not show it, defaults to false)
|
83 |
+
* @param string $button2_function The JavaScript function to attach to button 2
|
84 |
+
* @param string $button1_function The JavaScript function to attach to button 1
|
85 |
+
*/
|
86 |
+
function print_scripts( $selector, $options, $button1, $button2 = false, $button2_function = '', $button1_function = '' ) {
|
87 |
+
?>
|
88 |
+
<script type="text/javascript">
|
89 |
+
//<![CDATA[
|
90 |
+
(function ($) {
|
91 |
+
|
92 |
+
var li_pointer_options = <?php echo json_encode( $options ); ?>, setup;
|
93 |
+
|
94 |
+
function li_redirect_to_leadin() {
|
95 |
+
window.location.href = "<?php echo esc_url( get_bloginfo( 'wpurl' ) ); ?>/wp-admin/admin.php?page=leadin";
|
96 |
+
}
|
97 |
+
|
98 |
+
li_pointer_options = $.extend(li_pointer_options, {
|
99 |
+
buttons: function (event, t) {
|
100 |
+
button = jQuery('<a id="pointer-close" style="margin-left:5px" class="button-secondary">' + '<?php echo esc_html( $button1 ); ?>' + '</a>');
|
101 |
+
button.bind('click.pointer', function () {
|
102 |
+
window.location.href = "<?php echo esc_url( get_bloginfo( 'wpurl' ) ); ?>/wp-admin/admin.php?page=leadin";
|
103 |
+
//t.element.pointer('close');
|
104 |
+
});
|
105 |
+
return button;
|
106 |
+
},
|
107 |
+
close: function () {
|
108 |
+
}
|
109 |
+
});
|
110 |
+
|
111 |
+
setup = function () {
|
112 |
+
$('<?php echo esc_attr( $selector ); ?>').pointer(li_pointer_options).pointer('open');
|
113 |
+
};
|
114 |
+
|
115 |
+
if (li_pointer_options.position && li_pointer_options.position.defer_loading)
|
116 |
+
$(window).bind('load.wp-pointers', setup);
|
117 |
+
else
|
118 |
+
$(document).ready(setup);
|
119 |
+
})(jQuery);
|
120 |
+
//]]>
|
121 |
+
|
122 |
+
</script>
|
123 |
+
<?php
|
124 |
+
}
|
|
|
|
|
125 |
}
|
inc/class-leadin.php
CHANGED
@@ -1,125 +1,121 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
// WPLeadIn Class
|
5 |
-
|
6 |
-
class WPLeadIn
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
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 |
-
return in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'));
|
118 |
-
}
|
119 |
}
|
120 |
|
121 |
-
|
122 |
// Leadin Init
|
123 |
-
|
124 |
-
|
125 |
global $li_wp_admin;
|
1 |
<?php
|
2 |
|
3 |
+
// =============================================
|
4 |
// WPLeadIn Class
|
5 |
+
// =============================================
|
6 |
+
class WPLeadIn {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class constructor
|
10 |
+
*/
|
11 |
+
function __construct() {
|
12 |
+
global $pagenow;
|
13 |
+
|
14 |
+
if ( is_user_logged_in() ) {
|
15 |
+
add_action( 'admin_bar_menu', array( $this, 'add_leadin_link_to_admin_bar' ), 999 );
|
16 |
+
}
|
17 |
+
|
18 |
+
if ( is_admin() ) {
|
19 |
+
if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {
|
20 |
+
$li_wp_admin = new WPLeadInAdmin();
|
21 |
+
}
|
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' ) );
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
// =============================================
|
33 |
+
// Scripts & Styles
|
34 |
+
// =============================================
|
35 |
+
/**
|
36 |
+
* Adds front end javascript + initializes ajax object
|
37 |
+
*/
|
38 |
+
|
39 |
+
function add_leadin_frontend_scripts() {
|
40 |
+
|
41 |
+
add_filter( 'script_loader_tag', array( $this, 'leadin_add_embed_script_attributes' ), 10, 2 );
|
42 |
+
|
43 |
+
$embedDomain = constant( 'LEADIN_SCRIPT_LOADER_DOMAIN' );
|
44 |
+
$portalId = get_option( 'leadin_portalId' );
|
45 |
+
$slumberMode = get_option( 'leadin_slumber_mode' );
|
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 . '/' . $portalId . '.js';
|
53 |
+
$embedId = 'leadin-scriptloader-js';
|
54 |
+
|
55 |
+
if ( is_single() ) {
|
56 |
+
$page_type = 'post';
|
57 |
+
} elseif ( is_front_page() ) {
|
58 |
+
$page_type = 'home';
|
59 |
+
} elseif ( is_archive() ) {
|
60 |
+
$page_type = 'archive';
|
61 |
+
} elseif ( $this->leadin_is_login_or_register_page() ) {
|
62 |
+
$page_type = 'login';
|
63 |
+
} elseif ( is_page() ) {
|
64 |
+
$page_type = 'page';
|
65 |
+
} else {
|
66 |
+
$page_type = 'other';
|
67 |
+
}
|
68 |
+
|
69 |
+
$leadin_wordpress_info = array(
|
70 |
+
'userRole' => ( is_user_logged_in() ) ? leadin_get_user_role() : 'visitor',
|
71 |
+
'pageType' => $page_type,
|
72 |
+
'leadinPluginVersion' => LEADIN_PLUGIN_VERSION,
|
73 |
+
);
|
74 |
+
|
75 |
+
wp_register_script( $embedId, $embedUrl, array( 'jquery' ), false, true );
|
76 |
+
wp_localize_script( $embedId, 'leadin_wordpress', $leadin_wordpress_info );
|
77 |
+
wp_enqueue_script( $embedId );
|
78 |
+
}
|
79 |
+
|
80 |
+
function leadin_add_embed_script_attributes( $tag, $handle ) {
|
81 |
+
if ( $handle == 'leadin-scriptloader-js' ) {
|
82 |
+
return str_replace( ' src', ' async defer src', $tag );
|
83 |
+
} else {
|
84 |
+
return $tag;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Adds Leadin link to top-level admin bar
|
90 |
+
*/
|
91 |
+
function add_leadin_link_to_admin_bar( $wp_admin_bar ) {
|
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 |
+
}
|
99 |
+
|
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">HubSpot</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' => 'HubSpot' ),
|
108 |
+
);
|
109 |
+
|
110 |
+
$wp_admin_bar->add_node( $args );
|
111 |
+
}
|
112 |
+
|
113 |
+
public static function leadin_is_login_or_register_page() {
|
114 |
+
return in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) );
|
115 |
+
}
|
|
|
|
|
|
|
116 |
}
|
117 |
|
118 |
+
// =============================================
|
119 |
// Leadin Init
|
120 |
+
// =============================================
|
|
|
121 |
global $li_wp_admin;
|
inc/leadin-constants.php
CHANGED
@@ -1,15 +1,19 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if (!defined('LEADIN_UTM_SOURCE'))
|
4 |
-
|
|
|
5 |
|
6 |
-
if (!defined('LEADIN_UTM_MEDIUM'))
|
7 |
-
|
|
|
8 |
|
9 |
-
if (!defined('LEADIN_UTM_CONTENT'))
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
if (!defined('LEADIN_UTM_CAMPAIGN'))
|
13 |
-
define('LEADIN_UTM_CAMPAIGN', 'one%20click%20updater');
|
14 |
|
15 |
-
?>
|
1 |
<?php
|
2 |
|
3 |
+
if ( ! defined( 'LEADIN_UTM_SOURCE' ) ) {
|
4 |
+
define( 'LEADIN_UTM_SOURCE', 'leadin%20repo%20plugin' );
|
5 |
+
}
|
6 |
|
7 |
+
if ( ! defined( 'LEADIN_UTM_MEDIUM' ) ) {
|
8 |
+
define( 'LEADIN_UTM_MEDIUM', 'referral' );
|
9 |
+
}
|
10 |
|
11 |
+
if ( ! defined( 'LEADIN_UTM_CONTENT' ) ) {
|
12 |
+
define( 'LEADIN_UTM_CONTENT', 'e10' );
|
13 |
+
}
|
14 |
+
|
15 |
+
if ( ! defined( 'LEADIN_UTM_CAMPAIGN' ) ) {
|
16 |
+
define( 'LEADIN_UTM_CAMPAIGN', 'one%20click%20updater' );
|
17 |
+
}
|
18 |
|
|
|
|
|
19 |
|
|
inc/leadin-disconnect.php
CHANGED
@@ -1,27 +1,26 @@
|
|
1 |
<?php
|
2 |
-
if (!defined('LEADIN_PLUGIN_VERSION')) {
|
3 |
-
|
4 |
-
|
5 |
}
|
6 |
|
7 |
-
if (is_admin()) {
|
8 |
-
|
9 |
}
|
10 |
|
11 |
-
function leadin_disconnect_ajax()
|
12 |
-
{
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
wp_die('{"message": "Success!"}');
|
19 |
-
} else {
|
20 |
-
error_log("Disconnect error");
|
21 |
-
header('HTTP/1.0 400 Bad Request');
|
22 |
-
wp_die('{"error": "No leadin_portalId found, cannot disconnect."}');
|
23 |
-
}
|
24 |
-
|
25 |
}
|
26 |
|
27 |
-
|
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_disconnect_ajax', 'leadin_disconnect_ajax' ); // Call when user in slumber mode would like to disconnect their account
|
9 |
}
|
10 |
|
11 |
+
function leadin_disconnect_ajax() {
|
12 |
+
if ( get_option( 'leadin_portalId' ) ) {
|
13 |
+
delete_option( 'leadin_portalId' );
|
14 |
+
delete_option( 'leadin_slumber_mode' );
|
15 |
+
delete_option( 'leadin_hapikey' );
|
16 |
+
|
17 |
+
wp_die( '{"message": "Success!"}' );
|
18 |
+
} else {
|
19 |
+
error_log( 'Disconnect error' );
|
20 |
+
header( 'HTTP/1.0 400 Bad Request' );
|
21 |
+
wp_die( '{"error": "No leadin_portalId found, cannot disconnect."}' );
|
22 |
+
}
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
|
26 |
+
|
inc/leadin-functions.php
CHANGED
@@ -1,24 +1,23 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if (!defined('LEADIN_PLUGIN_VERSION')) {
|
4 |
-
|
5 |
-
|
6 |
}
|
7 |
|
8 |
-
if (!defined('LEADIN_PORTAL_ID')) {
|
9 |
-
|
10 |
}
|
11 |
|
12 |
-
if (!defined('LEADIN_HAPIKEY')) {
|
13 |
-
|
14 |
}
|
15 |
|
16 |
|
17 |
-
function leadin_get_resource_url($path)
|
18 |
-
|
19 |
-
$resource_root = constant('LEADIN_ADMIN_ASSETS_BASE_URL');
|
20 |
|
21 |
-
|
22 |
}
|
23 |
|
24 |
/**
|
@@ -26,67 +25,72 @@ function leadin_get_resource_url($path)
|
|
26 |
*
|
27 |
* @return array
|
28 |
*/
|
29 |
-
function leadin_get_current_user()
|
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 |
/**
|
@@ -94,28 +98,26 @@ function leadin_get_current_user()
|
|
94 |
*
|
95 |
* @param string
|
96 |
*/
|
97 |
-
function leadin_log_debug($message)
|
98 |
-
{
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
}
|
106 |
|
107 |
/**
|
108 |
* Returns the user role for the current user
|
109 |
-
*
|
110 |
*/
|
111 |
-
function leadin_get_user_role()
|
112 |
-
|
113 |
-
global $current_user;
|
114 |
|
115 |
-
|
116 |
-
|
117 |
|
118 |
-
|
119 |
}
|
120 |
|
121 |
-
|
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 |
+
$resource_root = constant( 'LEADIN_ADMIN_ASSETS_BASE_URL' );
|
|
|
19 |
|
20 |
+
return $resource_root . $path;
|
21 |
}
|
22 |
|
23 |
/**
|
25 |
*
|
26 |
* @return array
|
27 |
*/
|
28 |
+
function leadin_get_current_user() {
|
29 |
+
global $wp_version;
|
30 |
+
|
31 |
+
$current_user = wp_get_current_user();
|
32 |
+
$li_user_id = md5( get_bloginfo( 'wpurl' ) );
|
33 |
+
|
34 |
+
$li_options = get_option( 'leadin_options' );
|
35 |
+
$leadinPortalId = get_option( 'leadin_portalId' );
|
36 |
+
|
37 |
+
if ( isset( $li_options['li_email'] ) ) {
|
38 |
+
$li_user_email = $li_options['li_email'];
|
39 |
+
} else {
|
40 |
+
$li_user_email = $current_user->user_email;
|
41 |
+
}
|
42 |
+
|
43 |
+
$leadin_user = array(
|
44 |
+
'user_id' => $li_user_id,
|
45 |
+
'email' => $li_user_email,
|
46 |
+
'alias' => $current_user->display_name,
|
47 |
+
'wp_url' => get_bloginfo( 'wpurl' ),
|
48 |
+
'li_version' => LEADIN_PLUGIN_VERSION,
|
49 |
+
'wp_version' => $wp_version,
|
50 |
+
'user_email' => $current_user->user_email,
|
51 |
+
);
|
52 |
+
|
53 |
+
if ( defined( 'LEADIN_REFERRAL_SOURCE' ) ) {
|
54 |
+
$leadin_user['referral_source'] = LEADIN_REFERRAL_SOURCE;
|
55 |
+
} else {
|
56 |
+
$leadin_user['referral_source'] = '';
|
57 |
+
}
|
58 |
+
|
59 |
+
if ( defined( 'LEADIN_UTM_SOURCE' ) ) {
|
60 |
+
$leadin_user['utm_source'] = LEADIN_UTM_SOURCE;
|
61 |
+
} else {
|
62 |
+
$leadin_user['utm_source'] = '';
|
63 |
+
}
|
64 |
+
|
65 |
+
if ( defined( 'LEADIN_UTM_MEDIUM' ) ) {
|
66 |
+
$leadin_user['utm_medium'] = LEADIN_UTM_MEDIUM;
|
67 |
+
} else {
|
68 |
+
$leadin_user['utm_medium'] = '';
|
69 |
+
}
|
70 |
+
|
71 |
+
if ( defined( 'LEADIN_UTM_TERM' ) ) {
|
72 |
+
$leadin_user['utm_term'] = LEADIN_UTM_TERM;
|
73 |
+
} else {
|
74 |
+
$leadin_user['utm_term'] = '';
|
75 |
+
}
|
76 |
+
|
77 |
+
if ( defined( 'LEADIN_UTM_CONTENT' ) ) {
|
78 |
+
$leadin_user['utm_content'] = LEADIN_UTM_CONTENT;
|
79 |
+
} else {
|
80 |
+
$leadin_user['utm_content'] = '';
|
81 |
+
}
|
82 |
+
|
83 |
+
if ( defined( 'LEADIN_UTM_CAMPAIGN' ) ) {
|
84 |
+
$leadin_user['utm_campaign'] = LEADIN_UTM_CAMPAIGN;
|
85 |
+
} else {
|
86 |
+
$leadin_user['utm_campaign'] = '';
|
87 |
+
}
|
88 |
+
|
89 |
+
if ( ! empty( $leadinPortalId ) ) {
|
90 |
+
$leadin_user['portal_id'] = $leadinPortalId;
|
91 |
+
}
|
92 |
+
|
93 |
+
return $leadin_user;
|
94 |
}
|
95 |
|
96 |
/**
|
98 |
*
|
99 |
* @param string
|
100 |
*/
|
101 |
+
function leadin_log_debug( $message ) {
|
102 |
+
if ( WP_DEBUG === true ) {
|
103 |
+
if ( is_array( $message ) || is_object( $message ) ) {
|
104 |
+
error_log( print_r( $message, true ) );
|
105 |
+
} else {
|
106 |
+
error_log( $message );
|
107 |
+
}
|
108 |
+
}
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
* Returns the user role for the current user
|
|
|
113 |
*/
|
114 |
+
function leadin_get_user_role() {
|
115 |
+
global $current_user;
|
|
|
116 |
|
117 |
+
$user_roles = $current_user->roles;
|
118 |
+
$user_role = array_shift( $user_roles );
|
119 |
|
120 |
+
return $user_role;
|
121 |
}
|
122 |
|
123 |
+
|
inc/leadin-registration.php
CHANGED
@@ -1,52 +1,51 @@
|
|
1 |
<?php
|
2 |
-
if (!defined('LEADIN_PLUGIN_VERSION')) {
|
3 |
-
|
4 |
-
|
5 |
}
|
6 |
|
7 |
-
if (is_admin()) {
|
8 |
-
|
9 |
-
|
10 |
}
|
11 |
|
12 |
-
function leadin_registration_ajax()
|
13 |
-
|
14 |
-
|
15 |
-
$existingHapikey = get_option('leadin_hapikey');
|
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 |
function leadin_deregistration_ajax() {
|
46 |
-
|
47 |
-
|
48 |
|
49 |
-
|
50 |
}
|
51 |
|
52 |
-
|
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 |
+
add_action( 'wp_ajax_leadin_deregistration_ajax', 'leadin_deregistration_ajax' );
|
10 |
}
|
11 |
|
12 |
+
function leadin_registration_ajax() {
|
13 |
+
$existingPortalId = get_option( 'leadin_portalId' );
|
14 |
+
$existingHapikey = get_option( 'leadin_hapikey' );
|
|
|
15 |
|
16 |
+
if ( ! empty( $existingPortalId ) ) {
|
17 |
+
header( 'HTTP/1.0 400 Bad Request' );
|
18 |
+
wp_die( '{"error": "Registration is already complete for this portal"}' );
|
19 |
+
}
|
20 |
|
21 |
+
$data = json_decode( file_get_contents( 'php://input' ), true );
|
22 |
|
23 |
+
$newPortalId = $data['portalId'];
|
24 |
+
$slumberMode = $data['slumberMode'];
|
25 |
|
26 |
+
error_log( $data['hapikey'] );
|
27 |
|
28 |
+
if ( empty( $newPortalId ) ) {
|
29 |
+
error_log( 'Registration error' );
|
30 |
+
header( 'HTTP/1.0 400 Bad Request' );
|
31 |
+
wp_die( '{"error": "Registration missing required fields"}' );
|
32 |
+
}
|
33 |
|
34 |
+
add_option( 'leadin_portalId', $newPortalId );
|
35 |
+
add_option( 'leadin_slumber_mode', '1' );
|
36 |
|
37 |
+
if ( ! empty( $existingHapikey ) ) {
|
38 |
+
delete_option( 'leadin_hapikey' );
|
39 |
+
}
|
40 |
|
41 |
+
wp_die( '{"message": "Success!"}' );
|
42 |
}
|
43 |
|
44 |
function leadin_deregistration_ajax() {
|
45 |
+
delete_option( 'leadin_portalId' );
|
46 |
+
delete_option( 'leadin_hapikey' );
|
47 |
|
48 |
+
wp_die( '{"message": "Success!"}' );
|
49 |
}
|
50 |
|
51 |
+
|
leadin.php
CHANGED
@@ -3,199 +3,210 @@
|
|
3 |
Plugin Name: HubSpot - Free Marketing Plugin for WordPress
|
4 |
Plugin URI: http://www.hubspot.com/products/marketing/free
|
5 |
Description: HubSpot Marketing Free is the ultimate marketing plugin for WordPress for building an email list, generating and tracking leads, and tracking user behavior on your website.
|
6 |
-
Version: 6.1.
|
7 |
Author: HubSpot
|
8 |
Author URI: http://www.hubspot.com
|
9 |
License: GPL2
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
// Define Constants
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
|
19 |
-
if (!defined('LEADIN_PLUGIN_DIR'))
|
20 |
-
|
|
|
21 |
|
22 |
-
if (!defined('LEADIN_PLUGIN_SLUG'))
|
23 |
-
|
|
|
24 |
|
25 |
-
if (file_exists(LEADIN_PLUGIN_DIR . '/inc/leadin-overrides.php'))
|
26 |
-
|
|
|
27 |
|
28 |
-
if (!defined('LEADIN_DB_VERSION'))
|
29 |
-
|
|
|
30 |
|
31 |
-
if (!defined('LEADIN_PLUGIN_VERSION'))
|
32 |
-
|
|
|
33 |
|
34 |
-
if (!defined('LEADIN_SOURCE'))
|
35 |
-
|
|
|
36 |
|
37 |
-
if (!defined('LEADIN_ADMIN_ASSETS_BASE_URL'))
|
38 |
-
|
|
|
39 |
|
40 |
-
if (!defined('LEADIN_SCRIPT_LOADER_DOMAIN'))
|
41 |
-
|
|
|
42 |
|
43 |
-
if (!defined('LEADIN_ENV'))
|
44 |
-
|
|
|
45 |
|
46 |
-
|
47 |
// Include Needed Files
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
|
53 |
-
require_once
|
54 |
-
require_once
|
55 |
-
require_once
|
56 |
-
require_once
|
57 |
|
58 |
-
require_once
|
59 |
|
60 |
|
61 |
-
|
62 |
// Hooks & Filters
|
63 |
-
|
64 |
-
|
65 |
/**
|
66 |
* Activate the plugin
|
67 |
*/
|
68 |
-
function activate_leadin($network_wide)
|
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 |
* Check Leadin installation and set options
|
101 |
*/
|
102 |
-
function add_leadin_defaults()
|
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 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
142 |
}
|
143 |
|
144 |
/**
|
145 |
* Deactivate Leadin plugin hook
|
146 |
*/
|
147 |
-
function deactivate_leadin($network_wide)
|
148 |
-
{
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
}
|
166 |
|
167 |
-
function activate_leadin_on_new_blog($blog_id, $user_id, $domain, $path, $site_id, $meta)
|
168 |
-
|
169 |
-
global $wpdb;
|
170 |
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
}
|
178 |
|
179 |
/**
|
180 |
* Checks the stored database version against the current data version + updates if needed
|
181 |
*/
|
182 |
-
function leadin_init()
|
183 |
-
|
184 |
-
$leadin_wp = new WPLeadIn();
|
185 |
}
|
186 |
|
187 |
|
188 |
-
add_action('plugins_loaded', 'leadin_init', 14);
|
189 |
|
190 |
-
if (is_admin()) {
|
191 |
-
|
192 |
-
|
193 |
|
194 |
-
|
195 |
-
|
196 |
|
197 |
-
|
198 |
-
|
199 |
}
|
200 |
|
201 |
-
|
3 |
Plugin Name: HubSpot - Free Marketing Plugin for WordPress
|
4 |
Plugin URI: http://www.hubspot.com/products/marketing/free
|
5 |
Description: HubSpot Marketing Free is the ultimate marketing plugin for WordPress for building an email list, generating and tracking leads, and tracking user behavior on your website.
|
6 |
+
Version: 6.1.5
|
7 |
Author: HubSpot
|
8 |
Author URI: http://www.hubspot.com
|
9 |
License: GPL2
|
10 |
*/
|
11 |
|
12 |
+
// =============================================
|
13 |
// Define Constants
|
14 |
+
// =============================================
|
15 |
+
if ( ! defined( 'LEADIN_PATH' ) ) {
|
16 |
+
define( 'LEADIN_PATH', untrailingslashit( plugins_url( '', __FILE__ ) ) );
|
17 |
+
}
|
18 |
|
19 |
+
if ( ! defined( 'LEADIN_PLUGIN_DIR' ) ) {
|
20 |
+
define( 'LEADIN_PLUGIN_DIR', untrailingslashit( dirname( __FILE__ ) ) );
|
21 |
+
}
|
22 |
|
23 |
+
if ( ! defined( 'LEADIN_PLUGIN_SLUG' ) ) {
|
24 |
+
define( 'LEADIN_PLUGIN_SLUG', basename( dirname( __FILE__ ) ) );
|
25 |
+
}
|
26 |
|
27 |
+
if ( file_exists( LEADIN_PLUGIN_DIR . '/inc/leadin-overrides.php' ) ) {
|
28 |
+
require_once LEADIN_PLUGIN_DIR . '/inc/leadin-overrides.php';
|
29 |
+
}
|
30 |
|
31 |
+
if ( ! defined( 'LEADIN_DB_VERSION' ) ) {
|
32 |
+
define( 'LEADIN_DB_VERSION', '2.2.5' );
|
33 |
+
}
|
34 |
|
35 |
+
if ( ! defined( 'LEADIN_PLUGIN_VERSION' ) ) {
|
36 |
+
define( 'LEADIN_PLUGIN_VERSION', '6.1.5' );
|
37 |
+
}
|
38 |
|
39 |
+
if ( ! defined( 'LEADIN_SOURCE' ) ) {
|
40 |
+
define( 'LEADIN_SOURCE', 'leadin.com' );
|
41 |
+
}
|
42 |
|
43 |
+
if ( ! defined( 'LEADIN_ADMIN_ASSETS_BASE_URL' ) ) {
|
44 |
+
define( 'LEADIN_ADMIN_ASSETS_BASE_URL', 'https://app.hubspot.com/leadin_admin_static_live' );
|
45 |
+
}
|
46 |
|
47 |
+
if ( ! defined( 'LEADIN_SCRIPT_LOADER_DOMAIN' ) ) {
|
48 |
+
define( 'LEADIN_SCRIPT_LOADER_DOMAIN', 'js.hs-scripts.com' );
|
49 |
+
}
|
50 |
|
51 |
+
if ( ! defined( 'LEADIN_ENV' ) ) {
|
52 |
+
define( 'LEADIN_ENV', 'prod' );
|
53 |
+
}
|
54 |
|
55 |
+
// =============================================
|
56 |
// Include Needed Files
|
57 |
+
// =============================================
|
58 |
+
if ( file_exists( LEADIN_PLUGIN_DIR . '/inc/leadin-constants.php' ) ) {
|
59 |
+
require_once LEADIN_PLUGIN_DIR . '/inc/leadin-constants.php';
|
60 |
+
}
|
61 |
|
62 |
+
require_once LEADIN_PLUGIN_DIR . '/inc/leadin-functions.php';
|
63 |
+
require_once LEADIN_PLUGIN_DIR . '/inc/leadin-registration.php';
|
64 |
+
require_once LEADIN_PLUGIN_DIR . '/inc/leadin-disconnect.php';
|
65 |
+
require_once LEADIN_PLUGIN_DIR . '/admin/leadin-admin.php';
|
66 |
|
67 |
+
require_once LEADIN_PLUGIN_DIR . '/inc/class-leadin.php';
|
68 |
|
69 |
|
70 |
+
// =============================================
|
71 |
// Hooks & Filters
|
72 |
+
// =============================================
|
|
|
73 |
/**
|
74 |
* Activate the plugin
|
75 |
*/
|
76 |
+
function activate_leadin( $network_wide ) {
|
77 |
+
|
78 |
+
// Check activation on entire network or one blog
|
79 |
+
if ( is_multisite() && $network_wide ) {
|
80 |
+
global $wpdb;
|
81 |
+
|
82 |
+
// Get this so we can switch back to it later
|
83 |
+
$current_blog = $wpdb->blogid;
|
84 |
+
// For storing the list of activated blogs
|
85 |
+
$activated = array();
|
86 |
+
|
87 |
+
// Get all blogs in the network and activate plugin on each one
|
88 |
+
$blog_ids = $wpdb->get_col(
|
89 |
+
"SELECT blog_id FROM $wpdb->blogs"
|
90 |
+
);
|
91 |
+
foreach ( $blog_ids as $blog_id ) {
|
92 |
+
switch_to_blog( $blog_id );
|
93 |
+
add_leadin_defaults();
|
94 |
+
$activated[] = $blog_id;
|
95 |
+
}
|
96 |
+
|
97 |
+
// Switch back to the current blog
|
98 |
+
switch_to_blog( $current_blog );
|
99 |
+
|
100 |
+
// Store the array for a later function
|
101 |
+
update_site_option( 'leadin_activated', $activated );
|
102 |
+
} else {
|
103 |
+
add_leadin_defaults();
|
104 |
+
}
|
105 |
}
|
106 |
|
107 |
/**
|
108 |
* Check Leadin installation and set options
|
109 |
*/
|
110 |
+
function add_leadin_defaults() {
|
111 |
+
global $wpdb;
|
112 |
+
$options = get_option( 'leadin_options' );
|
113 |
+
|
114 |
+
if ( ( $options['li_installed'] != 1 ) || ( ! is_array( $options ) ) ) {
|
115 |
+
$opt = array(
|
116 |
+
'li_installed' => 1,
|
117 |
+
'leadin_version' => LEADIN_PLUGIN_VERSION,
|
118 |
+
'li_email' => get_bloginfo( 'admin_email' ),
|
119 |
+
'li_updates_subscription' => 1,
|
120 |
+
'onboarding_step' => 1,
|
121 |
+
'onboarding_complete' => 0,
|
122 |
+
'ignore_settings_popup' => 0,
|
123 |
+
'data_recovered' => 1,
|
124 |
+
'delete_flags_fixed' => 1,
|
125 |
+
'beta_tester' => 0,
|
126 |
+
'converted_to_tags' => 1,
|
127 |
+
'names_added_to_contacts' => 1,
|
128 |
+
);
|
129 |
+
|
130 |
+
// Add the Pro flag if this is a pro installation
|
131 |
+
if ( ( defined( 'LEADIN_UTM_SOURCE' ) && LEADIN_UTM_SOURCE != 'leadin%20repo%20plugin' ) || ! defined( 'LEADIN_UTM_SOURCE' ) ) {
|
132 |
+
$opt['pro'] = 1;
|
133 |
+
}
|
134 |
+
|
135 |
+
// this is a hack because multisite doesn't recognize local options using either update_option or update_site_option...
|
136 |
+
if ( is_multisite() ) {
|
137 |
+
$multisite_prefix = ( is_multisite() ? $wpdb->prefix : '' );
|
138 |
+
$wpdb->query(
|
139 |
+
$wpdb->prepare(
|
140 |
+
"
|
141 |
+
INSERT INTO %soptions
|
142 |
+
( option_name, option_value )
|
143 |
+
VALUES ('leadin_options', %s)",
|
144 |
+
$multisite_prefix,
|
145 |
+
serialize( $opt )
|
146 |
+
)
|
147 |
+
);
|
148 |
+
// TODO: Glob settings for multisite
|
149 |
+
} else {
|
150 |
+
update_option( 'leadin_options', $opt );
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
setcookie( 'ignore_social_share', '1', 2592000, '/' );
|
155 |
}
|
156 |
|
157 |
/**
|
158 |
* Deactivate Leadin plugin hook
|
159 |
*/
|
160 |
+
function deactivate_leadin( $network_wide ) {
|
161 |
+
if ( is_multisite() && $network_wide ) {
|
162 |
+
global $wpdb;
|
163 |
+
|
164 |
+
// Get this so we can switch back to it later
|
165 |
+
$current_blog = $wpdb->blogid;
|
166 |
+
|
167 |
+
// Get all blogs in the network and activate plugin on each one
|
168 |
+
$blog_ids = $wpdb->get_col(
|
169 |
+
"SELECT blog_id FROM $wpdb->blogs"
|
170 |
+
);
|
171 |
+
foreach ( $blog_ids as $blog_id ) {
|
172 |
+
switch_to_blog( $blog_id );
|
173 |
+
}
|
174 |
+
|
175 |
+
// Switch back to the current blog
|
176 |
+
switch_to_blog( $current_blog );
|
177 |
+
}
|
178 |
}
|
179 |
|
180 |
+
function activate_leadin_on_new_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
|
181 |
+
global $wpdb;
|
|
|
182 |
|
183 |
+
if ( is_plugin_active_for_network( 'leadin/leadin.php' ) ) {
|
184 |
+
$current_blog = $wpdb->blogid;
|
185 |
+
switch_to_blog( $blog_id );
|
186 |
+
add_leadin_defaults();
|
187 |
+
switch_to_blog( $current_blog );
|
188 |
+
}
|
189 |
}
|
190 |
|
191 |
/**
|
192 |
* Checks the stored database version against the current data version + updates if needed
|
193 |
*/
|
194 |
+
function leadin_init() {
|
195 |
+
$leadin_wp = new WPLeadIn();
|
|
|
196 |
}
|
197 |
|
198 |
|
199 |
+
add_action( 'plugins_loaded', 'leadin_init', 14 );
|
200 |
|
201 |
+
if ( is_admin() ) {
|
202 |
+
// Activate + install Leadin
|
203 |
+
register_activation_hook( __FILE__, 'activate_leadin' );
|
204 |
|
205 |
+
// Deactivate Leadin
|
206 |
+
register_deactivation_hook( __FILE__, 'deactivate_leadin' );
|
207 |
|
208 |
+
// Activate on newly created wpmu blog
|
209 |
+
add_action( 'wpmu_new_blog', 'activate_leadin_on_new_blog', 10, 6 );
|
210 |
}
|
211 |
|
212 |
+
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: leadin, sredmond, HubSpotDev
|
|
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.8
|
6 |
-
Stable tag: 6.1.
|
7 |
|
8 |
Add the free HubSpot Marketing plugin to your WordPress site! Easy to set up. The plugin has everything you need to capture, track, and convert leads.
|
9 |
|
@@ -147,8 +147,11 @@ Please <a href="https://community.hubspot.com/" target="_blank">head over to our
|
|
147 |
|
148 |
== Changelog ==
|
149 |
|
150 |
-
- Current version: 6.1.
|
151 |
-
- Current version release: 2017-
|
|
|
|
|
|
|
152 |
|
153 |
= 6.1.4 (2017.07.25) =
|
154 |
- Updated supported version of WordPress
|
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.8
|
6 |
+
Stable tag: 6.1.5
|
7 |
|
8 |
Add the free HubSpot Marketing plugin to your WordPress site! Easy to set up. The plugin has everything you need to capture, track, and convert leads.
|
9 |
|
147 |
|
148 |
== Changelog ==
|
149 |
|
150 |
+
- Current version: 6.1.5
|
151 |
+
- Current version release: 2017-05-22
|
152 |
+
|
153 |
+
= 6.1.5 (2018.05.22) =
|
154 |
+
- Code cleanup
|
155 |
|
156 |
= 6.1.4 (2017.07.25) =
|
157 |
- Updated supported version of WordPress
|