Changeset 1931823
- Timestamp:
- 08/28/2018 02:45:04 PM (8 years ago)
- Location:
- hubspot-tracking-code/trunk
- Files:
-
- 7 edited
-
. (modified) (1 prop)
-
admin/hubspot-tracking-code-admin.php (modified) (3 diffs)
-
hubspot-tracking-code.php (modified) (7 diffs)
-
inc/class-hubspot-tracking-code-analytics.php (modified) (1 diff)
-
inc/class-hubspot-tracking-code.php (modified) (2 diffs)
-
inc/hubspot-tracking-code-functions.php (modified) (3 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
hubspot-tracking-code/trunk
-
Property
svn:mergeinfo
set to
/hubspot-tracking-code/branches/deprecation-version-bump merged eligible
-
Property
svn:mergeinfo
set to
-
hubspot-tracking-code/trunk/admin/hubspot-tracking-code-admin.php
r1446896 r1931823 3 3 if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') ) 4 4 { 5 header('HTTP/1.0 403 Forbidden');6 die;5 header('HTTP/1.0 403 Forbidden'); 6 die; 7 7 } 8 8 … … 12 12 13 13 if ( !defined('HUBSPOT_TRACKING_CODE_ADMIN_PATH') ) 14 define('HUBSPOT_TRACKING_CODE_ADMIN_PATH', untrailingslashit(__FILE__));14 define('HUBSPOT_TRACKING_CODE_ADMIN_PATH', untrailingslashit(__FILE__)); 15 15 16 16 //============================================= … … 25 25 class HubSpotTrackingCodeAdmin 26 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 } 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 } 223 239 } 224 225 240 ?> -
hubspot-tracking-code/trunk/hubspot-tracking-code.php
r1693986 r1931823 3 3 Plugin Name: HubSpot Tracking Code for WordPress 4 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. 15 Description: HubSpot Tracking Code for WordPress is no longer being supported. 6 Version: 1.2.2 7 7 Author: HubSpot 8 8 Author URI: http://www.hubspot.com/integrations/wordpress … … 20 20 21 21 if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_DIR') ) 22 define('HUBSPOT_TRACKING_CODE_PLUGIN_DIR', untrailingslashit(dirname( __FILE__ )));22 define('HUBSPOT_TRACKING_CODE_PLUGIN_DIR', untrailingslashit(dirname( __FILE__ ))); 23 23 24 24 if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_SLUG') ) 25 define('HUBSPOT_TRACKING_CODE_PLUGIN_SLUG', basename(dirname(__FILE__)));25 define('HUBSPOT_TRACKING_CODE_PLUGIN_SLUG', basename(dirname(__FILE__))); 26 26 27 27 if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') ) 28 define('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION', '1.2.1');28 define('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION', '1.2.2'); 29 29 30 30 //============================================= … … 46 46 function hubspot_tracking_code_activate ( $network_wide ) 47 47 { 48 // Check activation on entire network or one blog49 if ( is_multisite() && $network_wide )50 {51 global $wpdb;48 // Check activation on entire network or one blog 49 if ( is_multisite() && $network_wide ) 50 { 51 global $wpdb; 52 52 53 // Get this so we can switch back to it later54 $current_blog = $wpdb->blogid;53 // Get this so we can switch back to it later 54 $current_blog = $wpdb->blogid; 55 55 56 // Get all blogs in the network and activate plugin on each one57 $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 }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 64 65 // Switch back to the current blog66 switch_to_blog($current_blog);67 }68 else69 {70 hubspot_tracking_code_setup_plugin();71 }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 72 } 73 73 … … 77 77 function hubspot_tracking_code_setup_plugin ( ) 78 78 { 79 $options = get_option('hs_settings');79 $options = get_option('hs_settings'); 80 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_VERSION86 );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 87 88 update_option('hs_settings', $opt);89 }88 update_option('hs_settings', $opt); 89 } 90 90 } 91 91 92 92 function hubspot_tracking_code_activate_on_new_blog ( $blog_id, $user_id, $domain, $path, $site_id, $meta ) 93 93 { 94 global $wpdb;94 global $wpdb; 95 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 }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 103 } 104 104 … … 108 108 function hubspot_tracking_code_init () 109 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__ ));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 114 115 add_action( 'admin_notices', 'deactivate_hubspot_tracking_code_notice' );116 return;117 }115 add_action( 'admin_notices', 'deactivate_hubspot_tracking_code_notice' ); 116 return; 117 } 118 118 119 119 $hubspot_wp = new HubSpotTrackingCode(); … … 124 124 if ( is_admin() ) 125 125 { 126 // Activate + install Super Simple Landing Pages127 register_activation_hook( __FILE__, 'hubspot_tracking_code_activate');126 // Activate + install Super Simple Landing Pages 127 register_activation_hook( __FILE__, 'hubspot_tracking_code_activate'); 128 128 129 // Activate on newly created wpmu blog130 add_action('wpmu_new_blog', 'hubspot_tracking_code_activate_on_new_blog', 10, 6);129 // Activate on newly created wpmu blog 130 add_action('wpmu_new_blog', 'hubspot_tracking_code_activate_on_new_blog', 10, 6); 131 131 } 132 132 … … 134 134 { 135 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>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 144 <?php 145 145 } -
hubspot-tracking-code/trunk/inc/class-hubspot-tracking-code-analytics.php
r1693985 r1931823 2 2 class HubSpotTrackingCodeAnalytics 3 3 { 4 function __construct()5 {6 add_action('wp_footer', array($this, 'hubspot_analytics_insert'));7 }4 function __construct() 5 { 6 add_action('wp_footer', array($this, 'hubspot_analytics_insert')); 7 } 8 8 9 //=============================================10 // Insert tracking code11 //=============================================12 function hubspot_analytics_insert ()13 {14 wp_reset_query();9 //============================================= 10 // Insert tracking code 11 //============================================= 12 function hubspot_analytics_insert () 13 { 14 wp_reset_query(); 15 15 16 $current_user = wp_get_current_user();17 $options = array();18 $options = get_option('hs_settings');16 $current_user = wp_get_current_user(); 17 $options = array(); 18 $options = get_option('hs_settings'); 19 19 20 if ( isset($options['hs_portal']) && $options['hs_portal'] != '' )21 {22 // Identify the current user if logged in23 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 else30 {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 }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 39 40 echo "\n" . '<!-- DO NOT COPY THIS SNIPPET! — HubSpot Identification Code -->' . "\n";41 echo '<script type="text/javascript">'."\n";42 echo "(function(d,w) {\n";40 echo "\n" . '<!-- DO NOT COPY THIS SNIPPET! — HubSpot Identification Code -->' . "\n"; 41 echo '<script type="text/javascript">'."\n"; 42 echo "(function(d,w) {\n"; 43 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-paste47 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 }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 62 63 // Pass along the correct content-type64 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 else73 {74 echo 'w._hsq.push(["setContentType", "standard-page"]);' . "\n";75 }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 76 77 echo "})(document, window);\n";78 echo '</script>' . "\n";79 echo '<!-- End of HubSpot Identification Code — 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="https://plugins.trac.wordpress.org//js.hs-scripts.com/" . $options['hs_portal'] . '.js"></script>' . "\n";82 echo '<!-- End of Async HubSpot Analytics Code -->' . "\n";83 }84 }77 echo "})(document, window);\n"; 78 echo '</script>' . "\n"; 79 echo '<!-- End of HubSpot Identification Code — 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="https://plugins.trac.wordpress.org//js.hs-scripts.com/" . $options['hs_portal'] . '.js"></script>' . "\n"; 82 echo '<!-- End of Async HubSpot Analytics Code -->' . "\n"; 83 } 84 } 85 85 } 86 86 ?> -
hubspot-tracking-code/trunk/inc/class-hubspot-tracking-code.php
r1446875 r1931823 6 6 class HubSpotTrackingCode 7 7 { 8 /**9 * Class constructor10 */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 else22 {23 global $hubspot_analytics;24 $hubspot_analytics = new HubSpotTrackingCodeAnalytics();25 }26 }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 27 28 function plugin_activation ()29 {30 $options = get_option('hs_settings');28 function plugin_activation () 29 { 30 $options = get_option('hs_settings'); 31 31 32 if ( isset($_GET['page']) && $_GET['page'] == 'hubspot-tracking-code-admin.php' )33 return FALSE;32 if ( isset($_GET['page']) && $_GET['page'] == 'hubspot-tracking-code-admin.php' ) 33 return FALSE; 34 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">';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 39 $html .= '<p>'; 40 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."); … … 43 43 } 44 44 else if ( isset($options['hs_portal']) && ! is_numeric($options['hs_portal']) ) 45 {46 $html = '<div class="updated" style="border-color: #f47621">';45 { 46 $html = '<div class="updated" style="border-color: #f47621">'; 47 47 $html .= '<p>'; 48 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 49 $html .= '</p>'; 50 50 $html .= '</div>'; 51 }51 } 52 52 53 53 if ( $html ) 54 54 echo $html; 55 }55 } 56 56 } 57 57 -
hubspot-tracking-code/trunk/inc/hubspot-tracking-code-functions.php
r1446875 r1931823 3 3 if ( !defined('HUBSPOT_TRACKING_CODE_PLUGIN_VERSION') ) 4 4 { 5 header('HTTP/1.0 403 Forbidden');6 die;5 header('HTTP/1.0 403 Forbidden'); 6 die; 7 7 } 8 8 … … 18 18 function hubspot_tracking_code_update_option ( $option, $option_key, $new_value ) 19 19 { 20 $options_array = get_option($option);20 $options_array = get_option($option); 21 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 value26 }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 27 28 if ( ! is_array( $options_array ) ) {29 $options_array = array();30 }28 if ( ! is_array( $options_array ) ) { 29 $options_array = array(); 30 } 31 31 32 $options_array[$option_key] = $new_value;33 update_option($option, $options_array);32 $options_array[$option_key] = $new_value; 33 update_option($option, $options_array); 34 34 35 $options_array = get_option($option);36 return update_option($option, $options_array);35 $options_array = get_option($option); 36 return update_option($option, $options_array); 37 37 } 38 38 … … 44 44 function hubspot_log_debug ( $message ) 45 45 { 46 if ( WP_DEBUG === TRUE )47 {48 if ( is_array($message) || is_object($message) )49 error_log(print_r($message, TRUE));50 else51 error_log($message);52 }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 53 } 54 54 -
hubspot-tracking-code/trunk/readme.txt
r1693989 r1931823 10 10 == Description == 11 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 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>. 18 13 19 14 == Installation == … … 38 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). 39 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 40 41 41 == Changelog == … … 60 60 = 1.0.0 = 61 61 * Launched the plugin 62
Note: See TracChangeset
for help on using the changeset viewer.