HubSpot Tracking Code for WordPress - Version 1.2.1

Version Description

  • Fix bug with loading the analytics script against the wrong hub
Download this release

Release Info

Developer gcorne
Plugin Icon 128x128 HubSpot Tracking Code for WordPress
Version 1.2.1
Comparing to
See all releases

Code changes from version 1.2.0 to 1.2.1

hubspot-tracking-code.php CHANGED
@@ -3,7 +3,7 @@
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.2.0
7
  Author: HubSpot
8
  Author URI: http://www.hubspot.com/integrations/wordpress
9
  License: GPL2
@@ -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.2.0');
29
 
30
  //=============================================
31
  // Include Needed Files
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.2.1
7
  Author: HubSpot
8
  Author URI: http://www.hubspot.com/integrations/wordpress
9
  License: GPL2
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.2.1');
29
 
30
  //=============================================
31
  // Include Needed Files
inc/class-hubspot-tracking-code-analytics.php CHANGED
@@ -78,7 +78,7 @@ class HubSpotTrackingCodeAnalytics
78
  echo '</script>' . "\n";
79
  echo '<!-- End of HubSpot Identification Code &mdash; DO NOT COPY THIS SNIPPET! -->' . "\n";
80
  echo "\n".'<!-- Start of Async HubSpot Analytics Code for WordPress v' . HUBSPOT_TRACKING_CODE_PLUGIN_VERSION . ' -->' . "\n";
81
- echo '<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/1724875.js"></script>' . "\n";
82
  echo '<!-- End of Async HubSpot Analytics Code -->' . "\n";
83
  }
84
  }
78
  echo '</script>' . "\n";
79
  echo '<!-- End of HubSpot Identification Code &mdash; DO NOT COPY THIS SNIPPET! -->' . "\n";
80
  echo "\n".'<!-- Start of Async HubSpot Analytics Code for WordPress v' . HUBSPOT_TRACKING_CODE_PLUGIN_VERSION . ' -->' . "\n";
81
+ echo '<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/' . $options['hs_portal'] . '.js"></script>' . "\n";
82
  echo '<!-- End of Async HubSpot Analytics Code -->' . "\n";
83
  }
84
  }
readme.txt CHANGED
@@ -2,8 +2,8 @@
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.7
6
- Stable tag: 1.1.2
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
 
@@ -39,6 +39,8 @@ http://help.hubspot.com/articles/How_To_Doc/how-to-install-hubspot-javascript-tr
39
 
40
 
41
  == Changelog ==
 
 
42
 
43
  = 1.2.0 =
44
  * Upgrade to the latest version of the HubSpot analytics tracking script
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.8
6
+ Stable tag: 1.2.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
 
39
 
40
 
41
  == Changelog ==
42
+ = 1.2.1 =
43
+ * Fix bug with loading the analytics script against the wrong hub
44
 
45
  = 1.2.0 =
46
  * Upgrade to the latest version of the HubSpot analytics tracking script
trunk/admin/hubspot-tracking-code-admin.php DELETED
@@ -1,225 +0,0 @@
1
- <?php
2
-
3
- if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') )
4
- {
5
- header('HTTP/1.0 403 Forbidden');
6
- die;
7
- }
8
-
9
- //=============================================
10
- // Define Constants
11
- //=============================================
12
-
13
- if ( !defined('HUBSPOT_TRACKING_CODE_ADMIN_PATH') )
14
- define('HUBSPOT_TRACKING_CODE_ADMIN_PATH', untrailingslashit(__FILE__));
15
-
16
- //=============================================
17
- // Include Needed Files
18
- //=============================================
19
-
20
- include_once(ABSPATH . 'wp-admin/includes/plugin.php');
21
-
22
- //=============================================
23
- // HubSpotTrackingCodeAdmin Class
24
- //=============================================
25
- class HubSpotTrackingCodeAdmin
26
- {
27
- /**
28
- * Class constructor
29
- */
30
- function __construct ()
31
- {
32
- //=============================================
33
- // Hooks & Filters
34
- //=============================================
35
-
36
- $options = get_option('hs_settings');
37
-
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'));
45
- }
46
-
47
- function hubspot_tracking_code_update_check ()
48
- {
49
- $options = get_option('hs_settings');
50
-
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
- }
63
-
64
-
65
- //=============================================
66
- // Settings Page
67
- //=============================================
68
-
69
- /**
70
- * Adds setting link for HubSpot to plugins management page
71
- *
72
- * @param array $links
73
- * @return array
74
- */
75
- function hubspot_plugin_settings_link ( $links )
76
- {
77
- $url = get_admin_url() . 'options-general.php?page=hubspot-tracking-code-admin.php';
78
- $settings_link = '<a href="' . $url . '">Settings</a>';
79
- array_unshift($links, $settings_link);
80
- return $links;
81
- }
82
-
83
- /**
84
- * Creates settings options
85
- */
86
- function hubspot_build_settings_page ()
87
- {
88
- global $pagenow;
89
- $options = get_option('hs_settings');
90
-
91
- register_setting(
92
- 'hubspot_settings_options',
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',
107
- array($this, 'hs_portal_callback'),
108
- HUBSPOT_TRACKING_CODE_ADMIN_PATH,
109
- 'hubspot_settings_section'
110
- );
111
- }
112
-
113
- function hs_settings_section_heading ( )
114
- {
115
- $this->print_hidden_settings_fields();
116
- }
117
-
118
- function print_hidden_settings_fields ()
119
- {
120
- // Hacky solution to solve the Settings API overwriting the default values
121
- $options = get_option('hs_settings');
122
-
123
- $hs_installed = ( isset($options['hs_installed']) ? $options['hs_installed'] : 1 );
124
- $hs_version = ( isset($options['hs_version']) ? $options['hs_version'] : HUBSPOT_TRACKING_CODE_PLUGIN_VERSION );
125
-
126
- printf(
127
- '<input id="hs_installed" type="hidden" name="hs_settings[hs_installed]" value="%d"/>',
128
- $hs_installed
129
- );
130
-
131
- printf(
132
- '<input id="hs_version" type="hidden" name="hs_settings[hs_version]" value="%s"/>',
133
- $hs_version
134
- );
135
- }
136
-
137
- /**
138
- * Creates settings page
139
- */
140
- function hubspot_plugin_options ()
141
- {
142
- ?>
143
- <div class="wrap">
144
- <div class="dashboard-widgets-wrap">
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">
170
- <p><b>I'm setting up HubSpot for myself</b><br><a target='_blank' href='https://app.hubspot.com/'>Log in to HubSpot</a>. Your Hub ID is in the upper right corner of the screen.</p>
171
- <img style="max-width: 100%;" src="http://cdn2.hubspot.net/hubfs/250707/CRM_Knowledge/Sidekick/HubID.jpg?t=1437426192644"/>
172
- <p><b>I'm setting up HubSpot for someone else</b><br>If you received a "HubSpot Tracking Code Instructions" email, this contains the Hub ID.</p>
173
- <p><b>I'm interested in trying HubSpot</b><br> <a target='_blank' href='http://offers.hubspot.com/free-trial'>Sign up for a free 30-day trial</a> to get your Hub ID assigned.</a></p>
174
- </div>
175
- </div>
176
- </div>
177
- </div>
178
- </div>
179
- </form>
180
- </div>
181
- </div>
182
- <?php
183
- }
184
-
185
- /**
186
- * Sanitize each setting field as needed
187
- *
188
- * @param array $input Contains all settings fields as array keys
189
- */
190
- public function sanitize ( $input )
191
- {
192
- $new_input = array();
193
-
194
- $options = get_option('hs_settings');
195
-
196
- if ( isset($input['hs_portal']) )
197
- $new_input['hs_portal'] = $input['hs_portal'];
198
-
199
- if ( isset($input['hs_installed']) )
200
- $new_input['hs_installed'] = $input['hs_installed'];
201
-
202
- if ( isset($input['hs_version']) )
203
- $new_input['hs_version'] = $input['hs_version'];
204
-
205
- return $new_input;
206
- }
207
-
208
- /**
209
- * Prints Hub ID input for settings page
210
- */
211
- function hs_portal_callback ()
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
219
- );
220
-
221
- //echo '<p><a href="http://help.hubspot.com/articles/KCS_Article/Account/Where-can-I-find-my-HUB-ID" target="_blank">Where can I find my HUB ID?</a></p>';
222
- }
223
- }
224
-
225
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/hubspot-tracking-code.php DELETED
@@ -1,147 +0,0 @@
1
- <?php
2
- /*
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.2.1
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
16
- //=============================================
17
-
18
- if ( !defined('HUBSPOT_TRACKING_CODE_PATH') )
19
- define('HUBSPOT_TRACKING_CODE_PATH', untrailingslashit(plugins_url('', __FILE__ )));
20
-
21
- if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_DIR') )
22
- define('HUBSPOT_TRACKING_CODE_PLUGIN_DIR', untrailingslashit(dirname( __FILE__ )));
23
-
24
- 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.2.1');
29
-
30
- //=============================================
31
- // Include Needed Files
32
- //=============================================
33
-
34
- require_once(HUBSPOT_TRACKING_CODE_PLUGIN_DIR . '/inc/hubspot-tracking-code-functions.php');
35
- require_once(HUBSPOT_TRACKING_CODE_PLUGIN_DIR . '/inc/class-hubspot-tracking-code.php');
36
- require_once(HUBSPOT_TRACKING_CODE_PLUGIN_DIR . '/inc/class-hubspot-tracking-code-analytics.php');
37
- require_once(HUBSPOT_TRACKING_CODE_PLUGIN_DIR . '/admin/hubspot-tracking-code-admin.php');
38
-
39
- //=============================================
40
- // Hooks & Filters
41
- //=============================================
42
-
43
- /**
44
- * Activate the plugin
45
- */
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
- }
68
- else
69
- {
70
- hubspot_tracking_code_setup_plugin();
71
- }
72
- }
73
-
74
- /**
75
- * Check Super Simple Landing Pages installation and register custom post type
76
- */
77
- function hubspot_tracking_code_setup_plugin ( )
78
- {
79
- $options = get_option('hs_settings');
80
-
81
- if ( ! isset($options['hs_installed']) || $options['hs_installed'] != "on" || (!is_array($options)) )
82
- {
83
- $opt = array(
84
- 'hs_installed' => "on",
85
- 'hs_version' => HUBSPOT_TRACKING_CODE_PLUGIN_VERSION
86
- );
87
-
88
- update_option('hs_settings', $opt);
89
- }
90
- }
91
-
92
- function hubspot_tracking_code_activate_on_new_blog ( $blog_id, $user_id, $domain, $path, $site_id, $meta )
93
- {
94
- global $wpdb;
95
-
96
- if ( is_plugin_active_for_network('hubspot-tracking-code/hubspot-tracking-code.php') )
97
- {
98
- $current_blog = $wpdb->blogid;
99
- switch_to_blog($blog_id);
100
- hubspot_tracking_code_setup_plugin();
101
- switch_to_blog($current_blog);
102
- }
103
- }
104
-
105
- /**
106
- * Checks the stored database version against the current data version + updates if needed
107
- */
108
- function hubspot_tracking_code_init ()
109
- {
110
- if ( is_plugin_active('hubspot/hubspot.php') )
111
- {
112
- remove_action( 'plugins_loaded', 'hubspot_tracking_code_init' );
113
- deactivate_plugins(plugin_basename( __FILE__ ));
114
-
115
- add_action( 'admin_notices', 'deactivate_hubspot_tracking_code_notice' );
116
- return;
117
- }
118
-
119
- $hubspot_wp = new HubSpotTrackingCode();
120
- }
121
-
122
- add_action( 'plugins_loaded', 'hubspot_tracking_code_init', 14 );
123
-
124
- if ( is_admin() )
125
- {
126
- // Activate + install Super Simple Landing Pages
127
- register_activation_hook( __FILE__, 'hubspot_tracking_code_activate');
128
-
129
- // Activate on newly created wpmu blog
130
- add_action('wpmu_new_blog', 'hubspot_tracking_code_activate_on_new_blog', 10, 6);
131
- }
132
-
133
- function deactivate_hubspot_tracking_code_notice ()
134
- {
135
- ?>
136
- <div id="message" class="error">
137
- <?php _e(
138
- '<p><h3>HubSpot Tracking Code plugin wasn\'t activated because your HubSpot for WordPress plugin is still activated...</h3></p>' .
139
- '<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>' .
140
- '<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>',
141
- 'my-text-domain'
142
- ); ?>
143
- </div>
144
- <?php
145
- }
146
-
147
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/inc/class-hubspot-tracking-code-analytics.php DELETED
@@ -1,86 +0,0 @@
1
- <?php
2
- class HubSpotTrackingCodeAnalytics
3
- {
4
- function __construct()
5
- {
6
- add_action('wp_footer', array($this, 'hubspot_analytics_insert'));
7
- }
8
-
9
- //=============================================
10
- // Insert tracking code
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'];
36
- $hs_identify_id = md5($commenter['comment_author_email']);
37
- }
38
- }
39
-
40
- echo "\n" . '<!-- DO NOT COPY THIS SNIPPET! &mdash; HubSpot Identification Code -->' . "\n";
41
- echo '<script type="text/javascript">'."\n";
42
- echo "(function(d,w) {\n";
43
- echo "w._hsq = w._hsq || [];\n";
44
- if ( isset($hs_identify_email) )
45
- {
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";
51
- }
52
- echo " w._hsq.push([\"identify\", {\n";
53
- echo " \"email\" : \"" . $hs_identify_email . "\",\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
- }
62
-
63
- // Pass along the correct content-type
64
- if ( is_singular('post') )
65
- {
66
- echo 'w._hsq.push(["setContentType", "blog-post"]);' . "\n";
67
- }
68
- else if ( is_archive () || is_search() )
69
- {
70
- echo 'w._hsq.push(["setContentType", "listing-page"]);' . "\n";
71
- }
72
- else
73
- {
74
- echo 'w._hsq.push(["setContentType", "standard-page"]);' . "\n";
75
- }
76
-
77
- echo "})(document, window);\n";
78
- echo '</script>' . "\n";
79
- echo '<!-- End of HubSpot Identification Code &mdash; DO NOT COPY THIS SNIPPET! -->' . "\n";
80
- echo "\n".'<!-- Start of Async HubSpot Analytics Code for WordPress v' . HUBSPOT_TRACKING_CODE_PLUGIN_VERSION . ' -->' . "\n";
81
- echo '<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/' . $options['hs_portal'] . '.js"></script>' . "\n";
82
- echo '<!-- End of Async HubSpot Analytics Code -->' . "\n";
83
- }
84
- }
85
- }
86
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/inc/class-hubspot-tracking-code.php DELETED
@@ -1,62 +0,0 @@
1
- <?php
2
-
3
- //=============================================
4
- // HubSpotTrackingCode Class
5
- //=============================================
6
- class HubSpotTrackingCode
7
- {
8
- /**
9
- * Class constructor
10
- */
11
- function __construct ()
12
- {
13
- if ( is_admin() )
14
- {
15
- if ( ! defined('DOING_AJAX') || ! DOING_AJAX )
16
- {
17
- $hubspot_wp_admin = new HubSpotTrackingCodeAdmin();
18
- add_action('admin_notices', array($this, 'plugin_activation'));
19
- }
20
- }
21
- else
22
- {
23
- global $hubspot_analytics;
24
- $hubspot_analytics = new HubSpotTrackingCodeAnalytics();
25
- }
26
- }
27
-
28
- function plugin_activation ()
29
- {
30
- $options = get_option('hs_settings');
31
-
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.");
41
- $html .= '</p>';
42
- $html .= '</div>';
43
- }
44
- else if ( isset($options['hs_portal']) && ! is_numeric($options['hs_portal']) )
45
- {
46
- $html = '<div class="updated" style="border-color: #f47621">';
47
- $html .= '<p>';
48
- $html .= __("Your HubID should be a number, and it looks like the HubID you entered contains some shady characters... <a href='options-general.php?page=hubspot-tracking-code-admin.php'>Re-enter your HubSpot Hub ID</a> and you'll be ready to rock.");
49
- $html .= '</p>';
50
- $html .= '</div>';
51
- }
52
-
53
- if ( $html )
54
- echo $html;
55
- }
56
- }
57
-
58
- //=============================================
59
- // Leadin Init
60
- //=============================================
61
-
62
- global $hubspot_wp_admin, $hubspot_analytics;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/inc/hubspot-tracking-code-functions.php DELETED
@@ -1,55 +0,0 @@
1
- <?php
2
-
3
- if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') )
4
- {
5
- header('HTTP/1.0 403 Forbidden');
6
- die;
7
- }
8
-
9
- /**
10
- * Updates an option in the multi-dimensional option array
11
- *
12
- * @param string $option option_name in wp_options
13
- * @param string $option_key key for array
14
- * @param string $option new value for array
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
-
22
- if ( isset($options_array[$option_key]) )
23
- {
24
- if ( $options_array[$option_key] == $new_value )
25
- return false; // Don't update an option if it already is set to the value
26
- }
27
-
28
- if ( ! is_array( $options_array ) ) {
29
- $options_array = array();
30
- }
31
-
32
- $options_array[$option_key] = $new_value;
33
- update_option($option, $options_array);
34
-
35
- $options_array = get_option($option);
36
- return update_option($option, $options_array);
37
- }
38
-
39
- /**
40
- * Logs a debug statement to /wp-content/debug.log
41
- *
42
- * @param string
43
- */
44
- function hubspot_log_debug ( $message )
45
- {
46
- if ( WP_DEBUG === TRUE )
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
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/readme.txt DELETED
@@ -1,62 +0,0 @@
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.8
6
- Stable tag: 1.2.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
-
10
- == Description ==
11
-
12
- HubSpot's WordPress plugin allows existing HubSpot customers and trial users to install the HubSpot tracking code on their existing WordPress blogs and websites.
13
-
14
- If you don't have an account yet, <a href="http://offers.hubspot.com/free-trial?utm_campaign=Connect%20Partner%20Free%20Trial%20Conversions&utm_source=hswordpressplugin">sign up for a free 30 day trial.</a>
15
-
16
- Note: HubSpot collects usage information about this plugin so that we can better serve our customers and know what features to add. By installing and activating the HubSpot for WordPress plugin you agree to these terms.
17
-
18
-
19
- == Installation ==
20
-
21
- *(using the Wordpress Admin Console)*
22
-
23
- 1. From your dashboard, click on "Plugins" in the left sidebar
24
- 2. Add a new plugin
25
- 3. Search for "HubSpot"
26
- 4. Install "HubSpot Tracking Code”
27
- 5. Once Installed, click Settings → HubSpot Settings
28
- 6. Enter your Hub ID and press “Save Settings” (your Hub ID can be found with the product version at the bottom of your HubSpot Dashboard. Once you've entered it into the plugin settings, click the Click here to authenticate button. You'll be asked to login to HubSpot and give access).
29
-
30
- http://help.hubspot.com/articles/How_To_Doc/how-to-install-hubspot-javascript-tracking-code-on-wordpress
31
-
32
- *(manually via FTP)*
33
-
34
- 1. Delete any existing 'hubspot' folder from the '/wp-content/plugins/' directory
35
- 2. Upload the 'hubspot' folder to the '/wp-content/plugins/' directory
36
- 3. Activate the plugin through the 'Plugins' menu in WordPress
37
- 4. Once Installed, click on the HubSpot plugin in your sidebar and go to "settings"
38
- 5. Enter your Hub ID and press “Save Settings” (your Hub ID can be found with the product version at the bottom of your HubSpot Dashboard. Once you've entered it into the plugin settings, click the Click here to authenticate button. You'll be asked to login to HubSpot and give access).
39
-
40
-
41
- == Changelog ==
42
- = 1.2.1 =
43
- * Fix bug with loading the analytics script against the wrong hub
44
-
45
- = 1.2.0 =
46
- * Upgrade to the latest version of the HubSpot analytics tracking script
47
- * Remove multisite workaround that is no longer needed
48
-
49
- = 1.1.2 =
50
- * Fix PHP 7 deprecation notice
51
-
52
- = 1.1.1 =
53
- * Bump compatibility
54
-
55
- = 1.1.0 =
56
- * Fix issue with custom post type posts being labeled with "blog-post"
57
- * Fix deprecated warnings
58
- * Improve validation
59
-
60
- = 1.0.0 =
61
- * Launched the plugin
62
-