Version Description
- Fix issue with custom post type posts being labeled with "blog-post"
- Fix deprecated warnings
- Improve validation
Download this release
Release Info
Developer | gcorne |
Plugin | HubSpot Tracking Code for WordPress |
Version | 1.1.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.1.0
admin/hubspot-tracking-code-admin.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') )
|
4 |
{
|
5 |
header('HTTP/1.0 403 Forbidden');
|
6 |
die;
|
@@ -22,7 +22,7 @@ include_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
|
22 |
//=============================================
|
23 |
// HubSpotTrackingCodeAdmin Class
|
24 |
//=============================================
|
25 |
-
class HubSpotTrackingCodeAdmin
|
26 |
{
|
27 |
/**
|
28 |
* Class constructor
|
@@ -38,7 +38,7 @@ class HubSpotTrackingCodeAdmin
|
|
38 |
// If the plugin version matches the latest version escape the update function
|
39 |
if ( $options['hs_version'] != HUBSPOT_TRACKING_CODE_PLUGIN_VERSION )
|
40 |
self::hubspot_tracking_code_update_check();
|
41 |
-
|
42 |
add_action('admin_menu', array(&$this, 'hubspot_add_menu_items'));
|
43 |
add_action('admin_init', array(&$this, 'hubspot_build_settings_page'));
|
44 |
add_filter('plugin_action_links_' . HUBSPOT_TRACKING_CODE_PLUGIN_SLUG . '/hubspot-tracking-code.php', array($this, 'hubspot_plugin_settings_link'));
|
@@ -51,12 +51,12 @@ class HubSpotTrackingCodeAdmin
|
|
51 |
// Set the plugin version
|
52 |
hubspot_tracking_code_update_option('hs_settings', 'hs_version', HUBSPOT_TRACKING_CODE_PLUGIN_VERSION);
|
53 |
}
|
54 |
-
|
55 |
//=============================================
|
56 |
// Menus
|
57 |
//=============================================
|
58 |
|
59 |
-
function hubspot_add_menu_items ()
|
60 |
{
|
61 |
add_submenu_page('options-general.php', 'HubSpot Settings', 'HubSpot Settings', 'edit_posts', basename(__FILE__), array($this, 'hubspot_plugin_options'));
|
62 |
}
|
@@ -67,7 +67,7 @@ class HubSpotTrackingCodeAdmin
|
|
67 |
//=============================================
|
68 |
|
69 |
/**
|
70 |
-
* Adds setting link for HubSpot to plugins management page
|
71 |
*
|
72 |
* @param array $links
|
73 |
* @return array
|
@@ -84,7 +84,7 @@ class HubSpotTrackingCodeAdmin
|
|
84 |
* Creates settings options
|
85 |
*/
|
86 |
function hubspot_build_settings_page ()
|
87 |
-
{
|
88 |
global $pagenow;
|
89 |
$options = get_option('hs_settings');
|
90 |
|
@@ -93,14 +93,14 @@ class HubSpotTrackingCodeAdmin
|
|
93 |
'hs_settings',
|
94 |
array($this, 'sanitize')
|
95 |
);
|
96 |
-
|
97 |
add_settings_section(
|
98 |
'hubspot_settings_section',
|
99 |
'',
|
100 |
array($this, 'hs_settings_section_heading'),
|
101 |
HUBSPOT_TRACKING_CODE_ADMIN_PATH
|
102 |
);
|
103 |
-
|
104 |
add_settings_field(
|
105 |
'hs_portal',
|
106 |
'Hub ID',
|
@@ -145,25 +145,25 @@ class HubSpotTrackingCodeAdmin
|
|
145 |
<h2>HubSpot Tracking Code Settings</h2>
|
146 |
<form method="POST" action="options.php">
|
147 |
<div id="dashboard-widgets" class="metabox-holder">
|
148 |
-
<div class="postbox-container" style="width:60%;">
|
149 |
<div class="meta-box-sortables ui-sortable">
|
150 |
<div class="postbox">
|
151 |
<h3 class="hndle"><span>Settings</span></h3>
|
152 |
<div class="inside">
|
153 |
Enter your Hub ID below to track your WordPress site in HubSpot's analytics system.
|
154 |
-
<?php
|
155 |
settings_fields('hubspot_settings_options');
|
156 |
do_settings_sections(HUBSPOT_TRACKING_CODE_ADMIN_PATH);
|
157 |
?>
|
158 |
</div>
|
159 |
-
|
160 |
</div>
|
161 |
</div>
|
162 |
<?php submit_button('Save Settings'); ?>
|
163 |
</div>
|
164 |
|
165 |
<div class="postbox-container" style="width:40%;">
|
166 |
-
<div class="meta-box-sortables ui-sortable">
|
167 |
<div class="postbox">
|
168 |
<h3 class="hndle"><span>Where is my HubSpot Hub ID?</span></h3>
|
169 |
<div class="inside">
|
@@ -212,7 +212,7 @@ class HubSpotTrackingCodeAdmin
|
|
212 |
{
|
213 |
$options = get_option('hs_settings');
|
214 |
$hs_portal = ( isset($options['hs_portal']) && $options['hs_portal'] ? $options['hs_portal'] : '' );
|
215 |
-
|
216 |
printf(
|
217 |
'<input id="hs_portal" type="text" id="title" name="hs_settings[hs_portal]" style="width: 400px;" value="%s"/>',
|
218 |
$hs_portal
|
@@ -222,4 +222,4 @@ class HubSpotTrackingCodeAdmin
|
|
222 |
}
|
223 |
}
|
224 |
|
225 |
-
?>
|
1 |
<?php
|
2 |
|
3 |
+
if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') )
|
4 |
{
|
5 |
header('HTTP/1.0 403 Forbidden');
|
6 |
die;
|
22 |
//=============================================
|
23 |
// HubSpotTrackingCodeAdmin Class
|
24 |
//=============================================
|
25 |
+
class HubSpotTrackingCodeAdmin
|
26 |
{
|
27 |
/**
|
28 |
* Class constructor
|
38 |
// If the plugin version matches the latest version escape the update function
|
39 |
if ( $options['hs_version'] != HUBSPOT_TRACKING_CODE_PLUGIN_VERSION )
|
40 |
self::hubspot_tracking_code_update_check();
|
41 |
+
|
42 |
add_action('admin_menu', array(&$this, 'hubspot_add_menu_items'));
|
43 |
add_action('admin_init', array(&$this, 'hubspot_build_settings_page'));
|
44 |
add_filter('plugin_action_links_' . HUBSPOT_TRACKING_CODE_PLUGIN_SLUG . '/hubspot-tracking-code.php', array($this, 'hubspot_plugin_settings_link'));
|
51 |
// Set the plugin version
|
52 |
hubspot_tracking_code_update_option('hs_settings', 'hs_version', HUBSPOT_TRACKING_CODE_PLUGIN_VERSION);
|
53 |
}
|
54 |
+
|
55 |
//=============================================
|
56 |
// Menus
|
57 |
//=============================================
|
58 |
|
59 |
+
function hubspot_add_menu_items ()
|
60 |
{
|
61 |
add_submenu_page('options-general.php', 'HubSpot Settings', 'HubSpot Settings', 'edit_posts', basename(__FILE__), array($this, 'hubspot_plugin_options'));
|
62 |
}
|
67 |
//=============================================
|
68 |
|
69 |
/**
|
70 |
+
* Adds setting link for HubSpot to plugins management page
|
71 |
*
|
72 |
* @param array $links
|
73 |
* @return array
|
84 |
* Creates settings options
|
85 |
*/
|
86 |
function hubspot_build_settings_page ()
|
87 |
+
{
|
88 |
global $pagenow;
|
89 |
$options = get_option('hs_settings');
|
90 |
|
93 |
'hs_settings',
|
94 |
array($this, 'sanitize')
|
95 |
);
|
96 |
+
|
97 |
add_settings_section(
|
98 |
'hubspot_settings_section',
|
99 |
'',
|
100 |
array($this, 'hs_settings_section_heading'),
|
101 |
HUBSPOT_TRACKING_CODE_ADMIN_PATH
|
102 |
);
|
103 |
+
|
104 |
add_settings_field(
|
105 |
'hs_portal',
|
106 |
'Hub ID',
|
145 |
<h2>HubSpot Tracking Code Settings</h2>
|
146 |
<form method="POST" action="options.php">
|
147 |
<div id="dashboard-widgets" class="metabox-holder">
|
148 |
+
<div class="postbox-container" style="width:60%;">
|
149 |
<div class="meta-box-sortables ui-sortable">
|
150 |
<div class="postbox">
|
151 |
<h3 class="hndle"><span>Settings</span></h3>
|
152 |
<div class="inside">
|
153 |
Enter your Hub ID below to track your WordPress site in HubSpot's analytics system.
|
154 |
+
<?php
|
155 |
settings_fields('hubspot_settings_options');
|
156 |
do_settings_sections(HUBSPOT_TRACKING_CODE_ADMIN_PATH);
|
157 |
?>
|
158 |
</div>
|
159 |
+
|
160 |
</div>
|
161 |
</div>
|
162 |
<?php submit_button('Save Settings'); ?>
|
163 |
</div>
|
164 |
|
165 |
<div class="postbox-container" style="width:40%;">
|
166 |
+
<div class="meta-box-sortables ui-sortable">
|
167 |
<div class="postbox">
|
168 |
<h3 class="hndle"><span>Where is my HubSpot Hub ID?</span></h3>
|
169 |
<div class="inside">
|
212 |
{
|
213 |
$options = get_option('hs_settings');
|
214 |
$hs_portal = ( isset($options['hs_portal']) && $options['hs_portal'] ? $options['hs_portal'] : '' );
|
215 |
+
|
216 |
printf(
|
217 |
'<input id="hs_portal" type="text" id="title" name="hs_settings[hs_portal]" style="width: 400px;" value="%s"/>',
|
218 |
$hs_portal
|
222 |
}
|
223 |
}
|
224 |
|
225 |
+
?>
|
hubspot-tracking-code.php
CHANGED
@@ -3,13 +3,13 @@
|
|
3 |
Plugin Name: HubSpot Tracking Code for WordPress
|
4 |
Plugin URI: http://hubspot.com
|
5 |
Description: HubSpot's WordPress plugin allows existing HubSpot customers and trial users to install the HubSpot tracking code on their existing WordPress blogs and websites.
|
6 |
-
Version: 1.
|
7 |
-
Author:
|
8 |
Author URI: http://www.hubspot.com/integrations/wordpress
|
9 |
License: GPL2
|
10 |
*/
|
11 |
|
12 |
-
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
13 |
|
14 |
//=============================================
|
15 |
// Define Constants
|
@@ -25,7 +25,7 @@ if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_SLUG') )
|
|
25 |
define('HUBSPOT_TRACKING_CODE_PLUGIN_SLUG', basename(dirname(__FILE__)));
|
26 |
|
27 |
if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') )
|
28 |
-
define('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION', '1.
|
29 |
|
30 |
//=============================================
|
31 |
// Include Needed Files
|
@@ -46,22 +46,22 @@ require_once(HUBSPOT_TRACKING_CODE_PLUGIN_DIR . '/admin/hubspot-tracking-code-ad
|
|
46 |
function hubspot_tracking_code_activate ( $network_wide )
|
47 |
{
|
48 |
// Check activation on entire network or one blog
|
49 |
-
if ( is_multisite() && $network_wide )
|
50 |
-
{
|
51 |
global $wpdb;
|
52 |
-
|
53 |
// Get this so we can switch back to it later
|
54 |
$current_blog = $wpdb->blogid;
|
55 |
-
|
56 |
// Get all blogs in the network and activate plugin on each one
|
57 |
$q = "SELECT blog_id FROM $wpdb->blogs";
|
58 |
$blog_ids = $wpdb->get_col($q);
|
59 |
-
foreach ( $blog_ids as $blog_id )
|
60 |
{
|
61 |
switch_to_blog($blog_id);
|
62 |
hubspot_tracking_code_setup_plugin();
|
63 |
}
|
64 |
-
|
65 |
// Switch back to the current blog
|
66 |
switch_to_blog($current_blog);
|
67 |
}
|
@@ -92,8 +92,8 @@ function hubspot_tracking_code_setup_plugin ( )
|
|
92 |
|
93 |
$multisite_prefix = ( is_multisite() ? $wpdb->prefix : '' );
|
94 |
$q = $wpdb->prepare("
|
95 |
-
INSERT INTO " . $multisite_prefix . "options
|
96 |
-
( option_name, option_value )
|
97 |
VALUES ('hs_settings', %s)", serialize($opt));
|
98 |
$wpdb->query($q);
|
99 |
}
|
@@ -120,7 +120,7 @@ function hubspot_tracking_code_activate_on_new_blog ( $blog_id, $user_id, $domai
|
|
120 |
*/
|
121 |
function hubspot_tracking_code_init ()
|
122 |
{
|
123 |
-
if ( is_plugin_active('hubspot/hubspot.php') )
|
124 |
{
|
125 |
remove_action( 'plugins_loaded', 'hubspot_tracking_code_init' );
|
126 |
deactivate_plugins(plugin_basename( __FILE__ ));
|
@@ -134,7 +134,7 @@ function hubspot_tracking_code_init ()
|
|
134 |
|
135 |
add_action( 'plugins_loaded', 'hubspot_tracking_code_init', 14 );
|
136 |
|
137 |
-
if ( is_admin() )
|
138 |
{
|
139 |
// Activate + install Super Simple Landing Pages
|
140 |
register_activation_hook( __FILE__, 'hubspot_tracking_code_activate');
|
@@ -143,12 +143,12 @@ if ( is_admin() )
|
|
143 |
add_action('wpmu_new_blog', 'hubspot_tracking_code_activate_on_new_blog', 10, 6);
|
144 |
}
|
145 |
|
146 |
-
function deactivate_hubspot_tracking_code_notice ()
|
147 |
{
|
148 |
?>
|
149 |
<div id="message" class="error">
|
150 |
-
<?php _e(
|
151 |
-
'<p><h3>HubSpot Tracking Code plugin wasn\'t activated because your HubSpot for WordPress plugin is still activated...</h3></p>' .
|
152 |
'<p>HubSpot Tracking Code and HubSpot for WordPress are like two rival siblings - they don\'t play nice together, but don\'t panic - it\'s an easy fix. Deactivate <b><i>HubSpot for WordPress</i></b> and then try activating <b><i>HubSpot Tracking Code for WordPress</i></b> again, and everything should work fine.</p>' .
|
153 |
'<p>By the way - make sure you replace all your form and CTA shortcodes with <a href="http://help.hubspot.com/articles/KCS_Article/Integrations/How-to-switch-from-the-HubSpot-for-Wordpress-plugin-to-the-HubSpot-Tracking-code-for-Wordpress-plugin" target="_blank">HubSpot embed codes</a></p>',
|
154 |
'my-text-domain'
|
@@ -157,4 +157,4 @@ function deactivate_hubspot_tracking_code_notice ()
|
|
157 |
<?php
|
158 |
}
|
159 |
|
160 |
-
?>
|
3 |
Plugin Name: HubSpot Tracking Code for WordPress
|
4 |
Plugin URI: http://hubspot.com
|
5 |
Description: HubSpot's WordPress plugin allows existing HubSpot customers and trial users to install the HubSpot tracking code on their existing WordPress blogs and websites.
|
6 |
+
Version: 1.1.0
|
7 |
+
Author: HubSpot
|
8 |
Author URI: http://www.hubspot.com/integrations/wordpress
|
9 |
License: GPL2
|
10 |
*/
|
11 |
|
12 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
13 |
|
14 |
//=============================================
|
15 |
// Define Constants
|
25 |
define('HUBSPOT_TRACKING_CODE_PLUGIN_SLUG', basename(dirname(__FILE__)));
|
26 |
|
27 |
if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') )
|
28 |
+
define('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION', '1.1.0');
|
29 |
|
30 |
//=============================================
|
31 |
// Include Needed Files
|
46 |
function hubspot_tracking_code_activate ( $network_wide )
|
47 |
{
|
48 |
// Check activation on entire network or one blog
|
49 |
+
if ( is_multisite() && $network_wide )
|
50 |
+
{
|
51 |
global $wpdb;
|
52 |
+
|
53 |
// Get this so we can switch back to it later
|
54 |
$current_blog = $wpdb->blogid;
|
55 |
+
|
56 |
// Get all blogs in the network and activate plugin on each one
|
57 |
$q = "SELECT blog_id FROM $wpdb->blogs";
|
58 |
$blog_ids = $wpdb->get_col($q);
|
59 |
+
foreach ( $blog_ids as $blog_id )
|
60 |
{
|
61 |
switch_to_blog($blog_id);
|
62 |
hubspot_tracking_code_setup_plugin();
|
63 |
}
|
64 |
+
|
65 |
// Switch back to the current blog
|
66 |
switch_to_blog($current_blog);
|
67 |
}
|
92 |
|
93 |
$multisite_prefix = ( is_multisite() ? $wpdb->prefix : '' );
|
94 |
$q = $wpdb->prepare("
|
95 |
+
INSERT INTO " . $multisite_prefix . "options
|
96 |
+
( option_name, option_value )
|
97 |
VALUES ('hs_settings', %s)", serialize($opt));
|
98 |
$wpdb->query($q);
|
99 |
}
|
120 |
*/
|
121 |
function hubspot_tracking_code_init ()
|
122 |
{
|
123 |
+
if ( is_plugin_active('hubspot/hubspot.php') )
|
124 |
{
|
125 |
remove_action( 'plugins_loaded', 'hubspot_tracking_code_init' );
|
126 |
deactivate_plugins(plugin_basename( __FILE__ ));
|
134 |
|
135 |
add_action( 'plugins_loaded', 'hubspot_tracking_code_init', 14 );
|
136 |
|
137 |
+
if ( is_admin() )
|
138 |
{
|
139 |
// Activate + install Super Simple Landing Pages
|
140 |
register_activation_hook( __FILE__, 'hubspot_tracking_code_activate');
|
143 |
add_action('wpmu_new_blog', 'hubspot_tracking_code_activate_on_new_blog', 10, 6);
|
144 |
}
|
145 |
|
146 |
+
function deactivate_hubspot_tracking_code_notice ()
|
147 |
{
|
148 |
?>
|
149 |
<div id="message" class="error">
|
150 |
+
<?php _e(
|
151 |
+
'<p><h3>HubSpot Tracking Code plugin wasn\'t activated because your HubSpot for WordPress plugin is still activated...</h3></p>' .
|
152 |
'<p>HubSpot Tracking Code and HubSpot for WordPress are like two rival siblings - they don\'t play nice together, but don\'t panic - it\'s an easy fix. Deactivate <b><i>HubSpot for WordPress</i></b> and then try activating <b><i>HubSpot Tracking Code for WordPress</i></b> again, and everything should work fine.</p>' .
|
153 |
'<p>By the way - make sure you replace all your form and CTA shortcodes with <a href="http://help.hubspot.com/articles/KCS_Article/Integrations/How-to-switch-from-the-HubSpot-for-Wordpress-plugin-to-the-HubSpot-Tracking-code-for-Wordpress-plugin" target="_blank">HubSpot embed codes</a></p>',
|
154 |
'my-text-domain'
|
157 |
<?php
|
158 |
}
|
159 |
|
160 |
+
?>
|
inc/class-hubspot-tracking-code-analytics.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
-
class HubSpotTrackingCodeAnalytics
|
3 |
{
|
4 |
-
function HubSpotTrackingCodeAnalytics ()
|
5 |
{
|
6 |
add_action('wp_footer', array(&$this, 'hubspot_analytics_insert'));
|
7 |
}
|
@@ -11,26 +11,25 @@ class HubSpotTrackingCodeAnalytics
|
|
11 |
//=============================================
|
12 |
function hubspot_analytics_insert ()
|
13 |
{
|
14 |
-
global $current_user;
|
15 |
wp_reset_query();
|
16 |
|
17 |
-
|
18 |
$options = array();
|
19 |
$options = get_option('hs_settings');
|
20 |
|
21 |
if ( isset($options['hs_portal']) && $options['hs_portal'] != '' )
|
22 |
{
|
23 |
// Identify the current user if logged in
|
24 |
-
if ( $current_user->user_email )
|
25 |
{
|
26 |
$hs_identify_name = $current_user->user_login;
|
27 |
$hs_identify_email = $current_user->user_email;
|
28 |
$hs_identify_id = md5($current_user->user_email);
|
29 |
-
}
|
30 |
-
else
|
31 |
{
|
32 |
$commenter = wp_get_current_commenter();
|
33 |
-
if ( $commenter['comment_author_email'] )
|
34 |
{
|
35 |
$hs_identify_name = $commenter['comment_author'];
|
36 |
$hs_identify_email = $commenter['comment_author_email'];
|
@@ -38,13 +37,13 @@ class HubSpotTrackingCodeAnalytics
|
|
38 |
}
|
39 |
}
|
40 |
|
41 |
-
if ( isset($hs_identify_email) )
|
42 |
{
|
43 |
-
echo "\n" . '<!-- DO NOT COPY THIS SNIPPET!
|
44 |
echo '<script type="text/javascript">'."\n";
|
45 |
echo "(function(d,w) {\n";
|
46 |
// Wrap `identify` call in hubspotutk check to help prevent accidental copy-paste
|
47 |
-
if ( isset($_COOKIE['hubspotutk']) )
|
48 |
{
|
49 |
echo "var match = d.cookie.match('(^|;) ?hubspotutk=([^;]*)(;|$)');\n";
|
50 |
echo "if (match && match[2] == \"" . $_COOKIE['hubspotutk'] . "\") {\n";
|
@@ -55,28 +54,28 @@ class HubSpotTrackingCodeAnalytics
|
|
55 |
echo " \"name\" : \"" . $hs_identify_name . "\",\n";
|
56 |
echo " \"id\" : \"" . $hs_identify_id . "\"\n";
|
57 |
echo "}]);\n";
|
58 |
-
if ( isset($_COOKIE['hubspotutk']) )
|
59 |
{
|
60 |
echo "}\n";
|
61 |
}
|
62 |
echo "})(document, window);\n";
|
63 |
echo '</script>' . "\n";
|
64 |
-
echo '<!-- End of HubSpot User Identification Code
|
65 |
}
|
66 |
|
67 |
echo "\n".'<!-- Start of Async HubSpot Analytics Code for WordPress v' . HUBSPOT_TRACKING_CODE_PLUGIN_VERSION . ' -->' . "\n";
|
68 |
echo '<script type="text/javascript">' . "\n";
|
69 |
echo 'var _hsq = _hsq || [];' . "\n";
|
70 |
// Pass along the correct content-type
|
71 |
-
if (
|
72 |
{
|
73 |
-
echo '_hsq.push(["setContentType", "blog-post"]);' . "\n";
|
74 |
-
}
|
75 |
else if ( is_archive () || is_search() )
|
76 |
{
|
77 |
echo '_hsq.push(["setContentType", "listing-page"]);' . "\n";
|
78 |
-
}
|
79 |
-
else
|
80 |
{
|
81 |
echo '_hsq.push(["setContentType", "standard-page"]);' . "\n";
|
82 |
}
|
1 |
<?php
|
2 |
+
class HubSpotTrackingCodeAnalytics
|
3 |
{
|
4 |
+
function HubSpotTrackingCodeAnalytics ()
|
5 |
{
|
6 |
add_action('wp_footer', array(&$this, 'hubspot_analytics_insert'));
|
7 |
}
|
11 |
//=============================================
|
12 |
function hubspot_analytics_insert ()
|
13 |
{
|
|
|
14 |
wp_reset_query();
|
15 |
|
16 |
+
$current_user = wp_get_current_user();
|
17 |
$options = array();
|
18 |
$options = get_option('hs_settings');
|
19 |
|
20 |
if ( isset($options['hs_portal']) && $options['hs_portal'] != '' )
|
21 |
{
|
22 |
// Identify the current user if logged in
|
23 |
+
if ( $current_user->user_email )
|
24 |
{
|
25 |
$hs_identify_name = $current_user->user_login;
|
26 |
$hs_identify_email = $current_user->user_email;
|
27 |
$hs_identify_id = md5($current_user->user_email);
|
28 |
+
}
|
29 |
+
else
|
30 |
{
|
31 |
$commenter = wp_get_current_commenter();
|
32 |
+
if ( $commenter['comment_author_email'] )
|
33 |
{
|
34 |
$hs_identify_name = $commenter['comment_author'];
|
35 |
$hs_identify_email = $commenter['comment_author_email'];
|
37 |
}
|
38 |
}
|
39 |
|
40 |
+
if ( isset($hs_identify_email) )
|
41 |
{
|
42 |
+
echo "\n" . '<!-- DO NOT COPY THIS SNIPPET! — HubSpot User Identification Code -->' . "\n";
|
43 |
echo '<script type="text/javascript">'."\n";
|
44 |
echo "(function(d,w) {\n";
|
45 |
// Wrap `identify` call in hubspotutk check to help prevent accidental copy-paste
|
46 |
+
if ( isset($_COOKIE['hubspotutk']) )
|
47 |
{
|
48 |
echo "var match = d.cookie.match('(^|;) ?hubspotutk=([^;]*)(;|$)');\n";
|
49 |
echo "if (match && match[2] == \"" . $_COOKIE['hubspotutk'] . "\") {\n";
|
54 |
echo " \"name\" : \"" . $hs_identify_name . "\",\n";
|
55 |
echo " \"id\" : \"" . $hs_identify_id . "\"\n";
|
56 |
echo "}]);\n";
|
57 |
+
if ( isset($_COOKIE['hubspotutk']) )
|
58 |
{
|
59 |
echo "}\n";
|
60 |
}
|
61 |
echo "})(document, window);\n";
|
62 |
echo '</script>' . "\n";
|
63 |
+
echo '<!-- End of HubSpot User Identification Code — DO NOT COPY THIS SNIPPET! -->' . "\n";
|
64 |
}
|
65 |
|
66 |
echo "\n".'<!-- Start of Async HubSpot Analytics Code for WordPress v' . HUBSPOT_TRACKING_CODE_PLUGIN_VERSION . ' -->' . "\n";
|
67 |
echo '<script type="text/javascript">' . "\n";
|
68 |
echo 'var _hsq = _hsq || [];' . "\n";
|
69 |
// Pass along the correct content-type
|
70 |
+
if ( is_singular('post') )
|
71 |
{
|
72 |
+
echo '_hsq.push(["setContentType", "blog-post"]);' . "\n";
|
73 |
+
}
|
74 |
else if ( is_archive () || is_search() )
|
75 |
{
|
76 |
echo '_hsq.push(["setContentType", "listing-page"]);' . "\n";
|
77 |
+
}
|
78 |
+
else
|
79 |
{
|
80 |
echo '_hsq.push(["setContentType", "standard-page"]);' . "\n";
|
81 |
}
|
inc/class-hubspot-tracking-code.php
CHANGED
@@ -32,9 +32,9 @@ class HubSpotTrackingCode
|
|
32 |
if ( isset($_GET['page']) && $_GET['page'] == 'hubspot-tracking-code-admin.php' )
|
33 |
return FALSE;
|
34 |
|
35 |
-
$html = '';
|
36 |
if ( ! isset($options['hs_portal']) || ( isset($options['hs_portal']) && ! $options['hs_portal'] ) )
|
37 |
-
{
|
38 |
$html = '<div class="updated" style="border-color: #f47621">';
|
39 |
$html .= '<p>';
|
40 |
$html .= __("Almost done! <a href='options-general.php?page=hubspot-tracking-code-admin.php'>Enter your HubSpot Hub ID</a> and you'll be ready to rock.");
|
@@ -59,4 +59,4 @@ class HubSpotTrackingCode
|
|
59 |
// Leadin Init
|
60 |
//=============================================
|
61 |
|
62 |
-
global $hubspot_wp_admin, $hubspot_analytics;
|
32 |
if ( isset($_GET['page']) && $_GET['page'] == 'hubspot-tracking-code-admin.php' )
|
33 |
return FALSE;
|
34 |
|
35 |
+
$html = '';
|
36 |
if ( ! isset($options['hs_portal']) || ( isset($options['hs_portal']) && ! $options['hs_portal'] ) )
|
37 |
+
{
|
38 |
$html = '<div class="updated" style="border-color: #f47621">';
|
39 |
$html .= '<p>';
|
40 |
$html .= __("Almost done! <a href='options-general.php?page=hubspot-tracking-code-admin.php'>Enter your HubSpot Hub ID</a> and you'll be ready to rock.");
|
59 |
// Leadin Init
|
60 |
//=============================================
|
61 |
|
62 |
+
global $hubspot_wp_admin, $hubspot_analytics;
|
inc/hubspot-tracking-code-functions.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') )
|
4 |
{
|
5 |
header('HTTP/1.0 403 Forbidden');
|
6 |
die;
|
@@ -15,7 +15,7 @@ if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') )
|
|
15 |
*
|
16 |
* @return bool True if option value has changed, false if not or if update failed.
|
17 |
*/
|
18 |
-
function hubspot_tracking_code_update_option ( $option, $option_key, $new_value )
|
19 |
{
|
20 |
$options_array = get_option($option);
|
21 |
|
@@ -47,9 +47,9 @@ function hubspot_log_debug ( $message )
|
|
47 |
{
|
48 |
if ( is_array($message) || is_object($message) )
|
49 |
error_log(print_r($message, TRUE));
|
50 |
-
else
|
51 |
error_log($message);
|
52 |
}
|
53 |
}
|
54 |
|
55 |
-
?>
|
1 |
<?php
|
2 |
|
3 |
+
if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') )
|
4 |
{
|
5 |
header('HTTP/1.0 403 Forbidden');
|
6 |
die;
|
15 |
*
|
16 |
* @return bool True if option value has changed, false if not or if update failed.
|
17 |
*/
|
18 |
+
function hubspot_tracking_code_update_option ( $option, $option_key, $new_value )
|
19 |
{
|
20 |
$options_array = get_option($option);
|
21 |
|
47 |
{
|
48 |
if ( is_array($message) || is_object($message) )
|
49 |
error_log(print_r($message, TRUE));
|
50 |
+
else
|
51 |
error_log($message);
|
52 |
}
|
53 |
}
|
54 |
|
55 |
+
?>
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== HubSpot Tracking Code for WordPress ===
|
2 |
-
Contributors: HubSpotDev
|
3 |
Tags: analytics, marketing analytics, hubspot, tracking code, inbound marketing, marketing
|
4 |
Requires at least: 3.7
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 1.
|
7 |
|
8 |
HubSpot's WordPress plugin allows existing HubSpot customers and trial users to install the HubSpot tracking code on their existing WordPress blogs and websites.
|
9 |
|
@@ -40,6 +40,11 @@ http://help.hubspot.com/articles/How_To_Doc/how-to-install-hubspot-javascript-tr
|
|
40 |
|
41 |
== Changelog ==
|
42 |
|
|
|
|
|
|
|
|
|
|
|
43 |
= 1.0.0 =
|
44 |
* Launched the plugin
|
45 |
|
1 |
=== HubSpot Tracking Code for WordPress ===
|
2 |
+
Contributors: HubSpotDev, gcorne
|
3 |
Tags: analytics, marketing analytics, hubspot, tracking code, inbound marketing, marketing
|
4 |
Requires at least: 3.7
|
5 |
+
Tested up to: 4.5.2
|
6 |
+
Stable tag: 1.1.0
|
7 |
|
8 |
HubSpot's WordPress plugin allows existing HubSpot customers and trial users to install the HubSpot tracking code on their existing WordPress blogs and websites.
|
9 |
|
40 |
|
41 |
== Changelog ==
|
42 |
|
43 |
+
= 1.1.0 =
|
44 |
+
* Fix issue with custom post type posts being labeled with "blog-post"
|
45 |
+
* Fix deprecated warnings
|
46 |
+
* Improve validation
|
47 |
+
|
48 |
= 1.0.0 =
|
49 |
* Launched the plugin
|
50 |
|