HubSpot Tracking Code for WordPress - Version 1.2.2

Version Description

  • Get HubSpots new WordPress plugin
  • HubSpot is moving to a new WordPress plugin with more support and functionality. The old plugin will continue to work, but we will no longer support or update it.
  • To keep your WordPress and HubSpot accounts working together, please install the new plugin by September 25 at https://wordpress.org/plugins/leadin/

=

Download this release

Release Info

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

Code changes from version 1.2.1 to 1.2.2

admin/hubspot-tracking-code-admin.php CHANGED
@@ -2,8 +2,8 @@
2
 
3
  if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') )
4
  {
5
- header('HTTP/1.0 403 Forbidden');
6
- die;
7
  }
8
 
9
  //=============================================
@@ -11,7 +11,7 @@ if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') )
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
@@ -24,202 +24,217 @@ include_once(ABSPATH . 'wp-admin/includes/plugin.php');
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
  ?>
2
 
3
  if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') )
4
  {
5
+ header('HTTP/1.0 403 Forbidden');
6
+ die;
7
  }
8
 
9
  //=============================================
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
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_action('admin_notices', array($this, 'admin_notice'));
45
+ add_filter('plugin_action_links_' . HUBSPOT_TRACKING_CODE_PLUGIN_SLUG . '/hubspot-tracking-code.php', array($this, 'hubspot_plugin_settings_link'));
46
+ }
47
+
48
+ function hubspot_tracking_code_update_check ()
49
+ {
50
+ $options = get_option('hs_settings');
51
+
52
+ // Set the plugin version
53
+ hubspot_tracking_code_update_option('hs_settings', 'hs_version', HUBSPOT_TRACKING_CODE_PLUGIN_VERSION);
54
+ }
55
+
56
+ //=============================================
57
+ // Menus
58
+ //=============================================
59
+
60
+ function hubspot_add_menu_items ()
61
+ {
62
+ add_submenu_page('options-general.php', 'HubSpot Settings', 'HubSpot Settings', 'edit_posts', basename(__FILE__), array($this, 'hubspot_plugin_options'));
63
+ }
64
+
65
+
66
+ //=============================================
67
+ // Settings Page
68
+ //=============================================
69
+
70
+ /**
71
+ * Adds setting link for HubSpot to plugins management page
72
+ *
73
+ * @param array $links
74
+ * @return array
75
+ */
76
+ function hubspot_plugin_settings_link ( $links )
77
+ {
78
+ $url = get_admin_url() . 'options-general.php?page=hubspot-tracking-code-admin.php';
79
+ $settings_link = '<a href="' . $url . '">Settings</a>';
80
+ array_unshift($links, $settings_link);
81
+ return $links;
82
+ }
83
+
84
+ /**
85
+ * Creates settings options
86
+ */
87
+ function hubspot_build_settings_page ()
88
+ {
89
+ global $pagenow;
90
+ $options = get_option('hs_settings');
91
+
92
+ register_setting(
93
+ 'hubspot_settings_options',
94
+ 'hs_settings',
95
+ array($this, 'sanitize')
96
+ );
97
+
98
+ add_settings_section(
99
+ 'hubspot_settings_section',
100
+ '',
101
+ array($this, 'hs_settings_section_heading'),
102
+ HUBSPOT_TRACKING_CODE_ADMIN_PATH
103
+ );
104
+
105
+ add_settings_field(
106
+ 'hs_portal',
107
+ 'Hub ID',
108
+ array($this, 'hs_portal_callback'),
109
+ HUBSPOT_TRACKING_CODE_ADMIN_PATH,
110
+ 'hubspot_settings_section'
111
+ );
112
+ }
113
+
114
+ function hs_settings_section_heading ( )
115
+ {
116
+ $this->print_hidden_settings_fields();
117
+ }
118
+
119
+ function print_hidden_settings_fields ()
120
+ {
121
+ // Hacky solution to solve the Settings API overwriting the default values
122
+ $options = get_option('hs_settings');
123
+
124
+ $hs_installed = ( isset($options['hs_installed']) ? $options['hs_installed'] : 1 );
125
+ $hs_version = ( isset($options['hs_version']) ? $options['hs_version'] : HUBSPOT_TRACKING_CODE_PLUGIN_VERSION );
126
+
127
+ printf(
128
+ '<input id="hs_installed" type="hidden" name="hs_settings[hs_installed]" value="%d"/>',
129
+ $hs_installed
130
+ );
131
+
132
+ printf(
133
+ '<input id="hs_version" type="hidden" name="hs_settings[hs_version]" value="%s"/>',
134
+ $hs_version
135
+ );
136
+ }
137
+
138
+ /**
139
+ * Creates settings page
140
+ */
141
+ function hubspot_plugin_options ()
142
+ {
143
+ ?>
144
+ <div class="wrap">
145
+ <div class="dashboard-widgets-wrap">
146
+ <h2>HubSpot Tracking Code Settings</h2>
147
+ <form method="POST" action="options.php">
148
+ <div id="dashboard-widgets" class="metabox-holder">
149
+ <div class="postbox-container" style="width:100%;">
150
+ <div class="meta-box-sortables ui-sortable" style="min-height: auto;">
151
+ <div class="postbox" style="background-color: lightyellow;">
152
+ <div class="inside">
153
+ <h3 class="hndle"><span><b>Get HubSpot's new WordPress plugin</b></span></h3>
154
+ <p>HubSpot is moving to a new WordPress plugin with more support and functionality. This tracking code plugin will continue to work, but we will no longer support or update it.</p>
155
+ <p>To keep your WordPress and HubSpot accounts working together, please <a href="https://wordpress.org/plugins/leadin/" target="_blank">install the new plugin</a> by November 30. The video below will provide more context.</p>
156
+ <p>Got questions? Head over to the <a href="https://community.hubspot.com/" target="_blank">HubSpot Community</a>, or <a href="https://help.hubspot.com/" target="_blank">get in touch with our support team</a>.</p>
157
+ <iframe width="630" height="394" src="https://www.useloom.com/embed/91b3296ebb034879b93382056d412272" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
158
+ </div>
159
+ </div>
160
+ </div>
161
+ </div>
162
+ <div class="postbox-container" style="width:60%;">
163
+ <div class="meta-box-sortables ui-sortable">
164
+ <div class="postbox">
165
+ <h3 class="hndle"><span>Settings</span></h3>
166
+ <div class="inside">
167
+ Enter your Hub ID below to track your WordPress site in HubSpot's analytics system.
168
+ <?php
169
+ settings_fields('hubspot_settings_options');
170
+ do_settings_sections(HUBSPOT_TRACKING_CODE_ADMIN_PATH);
171
+ ?>
172
+ </div>
173
+
174
+ </div>
175
+ </div>
176
+ <?php submit_button('Save Settings'); ?>
177
+ </div>
178
+ <div class="postbox-container" style="width:40%;">
179
+ <div class="meta-box-sortables ui-sortable">
180
+ <div class="postbox">
181
+ <h3 class="hndle"><span>Where is my HubSpot Hub ID?</span></h3>
182
+ <div class="inside">
183
+ <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>
184
+ <img style="max-width: 100%;" src="http://cdn2.hubspot.net/hubfs/250707/CRM_Knowledge/Sidekick/HubID.jpg?t=1437426192644"/>
185
+ <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>
186
+ <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>
187
+ </div>
188
+ </div>
189
+ </div>
190
+ </div>
191
+ </div>
192
+ </form>
193
+ </div>
194
+ </div>
195
+ <?php
196
+ }
197
+
198
+ function admin_notice() {
199
+ printf( '<div class="notice notice-warning"><p>The HubSpot Tracking Code plugin is unsupported. <a href="%1$s">More details</a></p></div>', admin_url( 'options-general.php?page=hubspot-tracking-code-admin.php' ) );
200
+ }
201
+
202
+ /**
203
+ * Sanitize each setting field as needed
204
+ *
205
+ * @param array $input Contains all settings fields as array keys
206
+ */
207
+ public function sanitize ( $input )
208
+ {
209
+ $new_input = array();
210
+
211
+ $options = get_option('hs_settings');
212
+
213
+ if ( isset($input['hs_portal']) )
214
+ $new_input['hs_portal'] = $input['hs_portal'];
215
+
216
+ if ( isset($input['hs_installed']) )
217
+ $new_input['hs_installed'] = $input['hs_installed'];
218
+
219
+ if ( isset($input['hs_version']) )
220
+ $new_input['hs_version'] = $input['hs_version'];
221
+
222
+ return $new_input;
223
+ }
224
+
225
+ /**
226
+ * Prints Hub ID input for settings page
227
+ */
228
+ function hs_portal_callback ()
229
+ {
230
+ $options = get_option('hs_settings');
231
+ $hs_portal = ( isset($options['hs_portal']) && $options['hs_portal'] ? $options['hs_portal'] : '' );
232
+
233
+ printf(
234
+ '<input id="hs_portal" type="text" id="title" name="hs_settings[hs_portal]" style="width: 400px;" value="%s"/>',
235
+ $hs_portal
236
+ );
237
+
238
+ }
239
  }
 
240
  ?>
hubspot-tracking-code.php CHANGED
@@ -2,8 +2,8 @@
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
@@ -19,13 +19,13 @@ 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
@@ -45,30 +45,30 @@ require_once(HUBSPOT_TRACKING_CODE_PLUGIN_DIR . '/admin/hubspot-tracking-code-ad
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
  /**
@@ -76,30 +76,30 @@ function hubspot_tracking_code_activate ( $network_wide )
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
  /**
@@ -107,14 +107,14 @@ function hubspot_tracking_code_activate_on_new_blog ( $blog_id, $user_id, $domai
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
  }
@@ -123,24 +123,24 @@ 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
 
2
  /*
3
  Plugin Name: HubSpot Tracking Code for WordPress
4
  Plugin URI: http://hubspot.com
5
+ Description: HubSpot Tracking Code for WordPress is no longer being supported.
6
+ Version: 1.2.2
7
  Author: HubSpot
8
  Author URI: http://www.hubspot.com/integrations/wordpress
9
  License: GPL2
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.2');
29
 
30
  //=============================================
31
  // Include Needed Files
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
  /**
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
  /**
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
  }
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
 
inc/class-hubspot-tracking-code-analytics.php CHANGED
@@ -1,86 +1,86 @@
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
  ?>
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
  ?>
inc/class-hubspot-tracking-code.php CHANGED
@@ -5,54 +5,54 @@
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
  //=============================================
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
  //=============================================
inc/hubspot-tracking-code-functions.php CHANGED
@@ -2,8 +2,8 @@
2
 
3
  if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') )
4
  {
5
- header('HTTP/1.0 403 Forbidden');
6
- die;
7
  }
8
 
9
  /**
@@ -17,23 +17,23 @@ if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') )
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
  /**
@@ -43,13 +43,13 @@ function hubspot_tracking_code_update_option ( $option, $option_key, $new_value
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
  ?>
2
 
3
  if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') )
4
  {
5
+ header('HTTP/1.0 403 Forbidden');
6
+ die;
7
  }
8
 
9
  /**
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
  /**
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
  ?>
readme.txt CHANGED
@@ -3,18 +3,13 @@ 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
 
@@ -37,6 +32,11 @@ http://help.hubspot.com/articles/How_To_Doc/how-to-install-hubspot-javascript-tr
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 =
@@ -59,4 +59,3 @@ http://help.hubspot.com/articles/How_To_Doc/how-to-install-hubspot-javascript-tr
59
 
60
  = 1.0.0 =
61
  * Launched the plugin
62
-
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.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
 
10
  == Description ==
11
 
12
+ This plugin has been closed and is no longer available for download. Please install the new plugin, <a href="https://wordpress.org/plugins/leadin/" target="_blank">Contact Form Builder for WordPress - Conversion Tools by HubSpot</a>.
 
 
 
 
 
13
 
14
  == Installation ==
15
 
32
  4. Once Installed, click on the HubSpot plugin in your sidebar and go to "settings"
33
  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).
34
 
35
+ == Changelog ==
36
+ = 1.2.2 =
37
+ * Get HubSpot’s new WordPress plugin
38
+ * HubSpot is moving to a new WordPress plugin with more support and functionality. The old plugin will continue to work, but we will no longer support or update it.
39
+ * To keep your WordPress and HubSpot accounts working together, please install the new plugin by September 25 at https://wordpress.org/plugins/leadin/
40
 
41
  == Changelog ==
42
  = 1.2.1 =
59
 
60
  = 1.0.0 =
61
  * Launched the plugin