= '3.0') { add_action('contextual_help', array(&$this, 'hs_add_help_text'), 10, 3); } // Add dashboard widget if RSS feed is in settings if(trim($hs_settings['hs_hubfeed_url']) != ""){ add_action('wp_dashboard_setup', array(&$this, 'add_dashboard_widgets')); } add_action('admin_print_scripts', array(&$this, 'add_hs_admin_scripts')); add_action('admin_print_styles', array(&$this, 'add_hs_admin_styles')); add_action('admin_menu', array(&$this, 'add_hs_options_subpanel')); add_action('admin_head', array(&$this, 'custom_admin_style')); add_filter('plugin_action_links_' . HUBSPOT_BASENAME, array(&$this, 'hs_plugin_settings_link')); } } //============================================= // Add contextual help //============================================= function hs_add_help_text($contextual_help, $screen_id, $screen) { $hs_settings = get_option('hs_settings'); //$contextual_help .= var_dump($screen); // use this to help determine $screen->id if ($screen_id == 'hs-action') { $contextual_help = '

' . __('Things to remember when adding or editing an action:') . '

' . ''; } elseif ($screen_id == 'edit-hs-action'){ $contextual_help = '

' . __('What are Actions?') . '

' . '

' . __('An action is a request for your reader to do something. You can use the Call to Action manager below to create calls to action. You can then use the [hs_action] shortcode or sidebar widget to randomly display your actions. The manager keeps track of clicks, impressions and CTR.') . '

' ; } elseif ($screen_id == 'hubspot_page_hubspot_settings') { $contextual_help = '

' . __('HubSpot Configuration.') . '

' . '

' . __('Enter your HubSpot Portal ID and Application Domain to set up HubSpot Analytics.') . '

' . '

' . __('Learn where to find your HubSpot Portal ID and Application Domain in the Help Section.') . '

' . '

' . __('Entering your HubSpot HubFeed RSS will create a widget on your Dashboard displaying your HubFeed for easy access. To get your HubFeed, navigate to your HubSpot dashboard. The RSS feed is the RSS icon next to \'HubFeed\'.') . '

' . '

' . __('You can also enter your Feedburner URL to have al links to your RSS feed redirect to your Feedburner feed. You can learn how to find your Feedburner URL in the Help Section.') . '

' . '

' . __('Call To Action Settings') . '

' . '

' . __('These settings allow you to disable the \'Actions\' post type or to prevent the plugin from tracking clicks and impressions.') . '

' ; } elseif ($screen_id == 'toplevel_page_hubspot_dashboard') { $contextual_help = '

' . __('If you have your App Domain and Portal ID filled in on the HubSpot Settings Page you should be able to access you HubSpot dashboard below. Your dashboard is loaded in an iFrame so this plugin does not save any username or password information.') . '

' ; } elseif ($screen_id == 'dashboard_page_dashboard_hs-admin') { $contextual_help = '

' . __('If you have your App Domain and Portal ID filled in on the HubSpot Settings Page you should be able to access you HubSpot Analytics Sources below. Your stats are loaded in an iFrame so this plugin does not save any username or password information.') . '

' ; } elseif ($screen_id == 'hubspot_page_hubspot_shortcodes') { $contextual_help = '

What are Shortcodes?

' . '

Shortcodes are small bits of code that make the creation of advanced HTML elements easy. The HubSpot WordPress plugin uses shortcodes to display contact info [hs_contact], team info [hs_team], custom forms [hs_form] and Calls to Action [hs_action] to make inserting and managing the content associated with these pages effortless.

' . '

' . __('Contact Shortcode Settings') . '

' . '

' . __('Fill in the Contact Shortcode Settings and use the [hs_contact] shortcode to display your company info with a map on any page.') . '

' . '

' . __('You can use the HubSpot button on the visual editor of any page, post or custom post type to easily insert the shortcode or to enter a custom address.') . '

' . '

' . __('Team Page Shortcode Settings') . '

' . '

' . __('Add Team Members as new users in the Users Section and use the [hs_team] shortcode to display a list of your team members with an image, bio and links to their social media profiles. You can choose to hide user images and the site admin from the Team Page listing on this page.') . '

' . '

' . __('You can use the HubSpot button on the visual editor of any page, post or custom post type to easily insert the team page shortcode or to select which team members to display on a specific page.') . '

' . '

' . __('Lead Form Shortcode Settings') . '

' . '

' . __('HubSpot customers can paste HTML into the \'Custom Form HTML\' field from your HubSpot Form Manager to use a custom form. Each time you save a custom form a new text area will appear to allow multiple forms. You can use the HubSpot button on the visual editor of any page, post or custom post type to easily insert a specific form.') . '

' ; } return $contextual_help; } //============================================= // Add admin options panel link //============================================= function add_hs_options_subpanel() { if (function_exists('add_menu_page') && current_user_can('manage_options')) { global $submenu, $myhubspotwp; add_menu_page('HubSpot', 'HubSpot', 'manage_options', 'hubspot_dashboard', array($this, 'hs_dashboard'), HUBSPOT_URL.'images/hubspot-logo.png'); add_submenu_page('hubspot_dashboard','Settings','Settings','manage_options', 'hubspot_settings', array($this, 'hs_settings_options')); add_submenu_page('hubspot_dashboard','Shortcodes','Shortcodes','manage_options', 'hubspot_shortcodes', array($this, 'hs_shortcodes_options')); add_submenu_page('hubspot_dashboard','Help','Help','manage_options', 'hubspot_help', array($this, 'hs_help')); $hs_settings = get_option('hs_settings'); if($myhubspotwp->hs_is_customer()){ add_submenu_page('index.php',__('Hubspot Stats'),__('Hubspot Stats'),'manage_options','dashboard_'.basename(__FILE__),array($this, 'hs_stats')); } $submenu['hubspot_dashboard'][0][0] = 'Dashboard'; } } //============================================= // Display Hubspot stats in an iFrame //============================================= function hs_stats() { $hs_settings = get_option('hs_settings'); echo '

'.__('Hubspot Stats').'

'; } //============================================= // Display the Hubspot Dashboard in an iFrame //============================================= function hs_dashboard() { global $myhubspotwp; if($myhubspotwp->hs_is_customer()){ $hs_settings = get_option('hs_settings'); echo '

'.__('Hubspot Dashboard').'

'; } else { $content = ""; $content .= "

HubSpot Customers can insert their App Domain and Portal ID on the Settings page to display their HubSpot Dashboard here.

"; $content .= "

HubSpot Customers also benefit from:

"; $wrapped_content = $this->hs_postbox('hubspot-dashboard', 'Dashboard', $content); $this->hs_admin_wrap('HubSpot WordPress Plugin Help', $wrapped_content); } } //============================================= // Help page content //============================================= function hs_help(){ $content = ""; $content = "
  1. Where do I find my HubSpot Application Domain and HubSpot Portal ID number?
  2. Where do I find my feedburner feed?
  3. What are shortcodes?
  4. How do I insert the 'HubSpot Follow Me' buttons into my sidebar?
  5. How does the HubSpot WordPress plugin forward to my feedburner?
  6. How do I change the names displayed on my Team Page?
  7. What are Actions?

1) Where do I find my HubSpot Application Domain and HubSpot Portal ID number?

Find your HubSpot Portal Number and Application domain, a number with between 2 and 6 digits, and a string of text that ends in hubspot.com, as shown below:

portal ID

Once you have entered your portal number and application domain in the box above your pages will be trackable by HubSpot Analytics.

2) Where do I find my feedburner feed?

Your feedburner feed will look something like http://feeds.feedburner.com/myfeedid. Go to http://feedburner.google.com and right-click on the RSS icon next to the Feed Title and click 'Copy Link Address'. You can also just left-click on the RSS icon next to the Feed Title and copy the URL in the addressbar on the next page.

3) What are shortcodes?

Shortcodes are small bits of code that make the creation of advanced HTML elements easy. The HubSpot WordPress plugin uses shortcodes to display contact info, [hs_contact], and team info, [hs_team], to make inserting and managing the content associated with these pages effortless.

4) How do I insert the 'HubSpot Follow Me' buttons into my sidebar?

Make sure you have input the proper HubSpot Portal ID on the HubSpot WordPress plugin configuration page. You can then use the widget under Appearance->Widgets titled "HubSpot: Follow Widget".

5) How does the HubSpot WordPress plugin forward to my feedburner?

The plugin forwards all requests to http://www.yoursite.com/feed with a 302 redirect. The plugin also replaces all links with your Feedburner address.

6) How do I change the names displayed on my Team Page?

Go to the profile page of the name you want to change. Make sure you filled out your first and last name, then select the full name you would like to display for 'Display name publicly as'.

7) What are Actions?

An action is a request for your reader to do something. The HubSpot plugin comes with a Call to Action manager that allows you to create calls to action. You can then use the [hs_action] shortcode or sidebar widget to randomly display your actions. The manager keeps track of clicks, impressions and CTR.

"; $wrapped_content = $this->hs_postbox('hubspot-help', 'FAQ', $content); $this->hs_admin_wrap('HubSpot WordPress Plugin Help', $wrapped_content); } //============================================= // Process contact page form data //============================================= function hs_process_shortcodes_options() { $myhubspotsettings_notice = new WPHubspotNotice('shortcode-settings-update'); if ( !empty($_POST['hs_option_submitted']) ){ //$hs_settings=get_option('hs_settings'); $hs_settings=get_option('hs_settings'); if($_GET['page'] == 'hubspot_shortcodes' && check_admin_referer('hubspot-shortcode-update-options')){ if(isset($_POST['hs_company_name'])){ $hs_settings['hs_company_name']=$_POST['hs_company_name']; } if(isset($_POST['hs_company_address'])){ $hs_settings['hs_company_address']=$_POST['hs_company_address']; } if(isset($_POST['hs_company_citystate'])){ $hs_settings['hs_company_citystate']=$_POST['hs_company_citystate']; } if(isset($_POST['hs_company_phone'])){ $hs_settings['hs_company_phone']=$_POST['hs_company_phone']; } if(isset($_POST['hs_team_avatars'])){ $hs_settings['hs_team_avatars']=$_POST['hs_team_avatars']; } else { $hs_settings['hs_team_avatars']=''; } if(isset($_POST['hs_team_admin'])){ $hs_settings['hs_team_admin']=$_POST['hs_team_admin']; } else { $hs_settings['hs_team_admin']=''; } if(isset($_POST['hs_leads_enabled'])){ $hs_settings['hs_leads_enabled']=$_POST['hs_leads_enabled']; } else { $hs_settings['hs_leads_enabled']=''; } // Process all custom HTML forms (if any) $formid = 0; foreach($_POST['hs_leads_html'] as $form){ if($formid == (count($_POST['hs_leads_html']) - 1) && htmlentities(stripslashes($form)) == ""){ // Do Nothing } else{ $hs_settings['hs_leads_html'][$formid] = htmlentities(stripslashes($form)); } $formid++; } $myhubspotsettings_notice->display_notice(3); update_option("hs_settings", $hs_settings); } }//updated $hs_settings=get_option('hs_settings'); return $hs_settings; } //============================================= // Contact page options //============================================= function hs_shortcodes_options(){ global $myhubspotwp; $hs_settings = $this->hs_process_shortcodes_options(); $contact_content = ""; $team_content = ""; $contact_content = ''; if ( function_exists('wp_nonce_field') ){ $contact_content .= wp_nonce_field('hubspot-shortcode-update-options','_wpnonce',true,false); } $contact_content .= ''; $contact_content .= ''; $contact_content .= ''; $contact_content .= ''; $contact_content .= ''; $contact_content .= '
Insert [hs_contact] into any page or post to display your contact information with a Google Map.
'; $team_content = ''; $team_content .= ''; $team_content .= ''; $team_content .= ''; $team_content .= '
Insert [hs_team] into any page or post to display a list of your team members with an image, bio and links to their social media profiles. To add team members just add new WordPress users and configure their profiles.
'; if($myhubspotwp->hs_is_customer($hs_settings['hs_portal'], $hs_settings['hs_appdomain']) ){ $form_content = ''; $form_content .= ''; $form_content .= ''; // Loop through all saved custom forms (if any) and display forms plus an empty text area for a new form for ($formid = 0; $formid < count($hs_settings['hs_leads_html']); $formid++){ if ($hs_settings['hs_leads_html'][$formid] != ""){ $formcontent = $hs_settings['hs_leads_html'][$formid]; } else { $formcontent = ""; } $form_content .= ''; if ($formid == (count($hs_settings['hs_leads_html'])-1) && $hs_settings['hs_leads_html'][$formid] != ""){ $form_content .= ''; } } $form_content .= ''; $form_content .= '
Copy and paste HTML from your HubSpot Form Manager here.
[hs_form id="' . $formid . '"]
[hs_form id="' . ($formid + 1) . '"]
Insert [hs_form id="#"] into any page or post to display a contact form that sends leads to your HubSpot Account.
'; } $wrapped_content = $this->hs_postbox('hubspot-company-settings', 'Contact Shortcode Settings', $contact_content); $wrapped_content .= $this->hs_postbox('hubspot-team-settings', 'Team Page Shortcode Settings', $team_content); if($myhubspotwp->hs_is_customer($hs_settings['hs_portal'], $hs_settings['hs_appdomain']) ){ $wrapped_content .= $this->hs_postbox('hubspot-team-settings', 'Lead Form Shortcode Settings', $form_content); } $this->hs_admin_wrap('HubSpot Shortcode Settings', $wrapped_content); } //============================================= // Process settings page form data //============================================= function hs_process_settings_options() { $myhubspotsettings_notice = new WPHubspotNotice('main-settings-update'); if ( !empty($_POST['hs_option_submitted']) ){ $hs_settings=get_option('hs_settings'); if($_GET['page'] == 'hubspot_settings' && check_admin_referer('hubspot-dashboard-update-options')){ if(isset($_POST['hs_portal'])){ $hs_settings['hs_portal']=$_POST['hs_portal']; } // Check to be sure app domain does not have 'http' or 'www' if(isset($_POST['hs_appdomain'])){ $hs_settings['hs_appdomain'] = $_POST['hs_appdomain']; $hs_settings['hs_appdomain']=str_replace('http://', '', $hs_settings['hs_appdomain']); $hs_settings['hs_appdomain']=str_replace('www.', '', $hs_settings['hs_appdomain']); } // Check to be sure HubFeed contains the base 'app.hubspot.com/hf/feed' if(isset($_POST['hs_hubfeed_url'])){ if(trim($_POST['hs_hubfeed_url']) == '' || strpos($_POST['hs_hubfeed_url'], 'app.hubspot.com/hf/feed') !== false){ $hs_settings['hs_hubfeed_url']=$_POST['hs_hubfeed_url']; } else { $hs_settings['hs_hubfeed_url']=''; $myhubspotsettings_notice->add_notice('Please enter a valid HubFeed URL'); } } // Check to be sure feedburner URL is a valid URL if(isset($_POST['hs_feedburner_url'])){ if(trim($_POST['hs_feedburner_url']) == '' || strpos($_POST['hs_feedburner_url'], 'feeds.feedburner.com') !== false){ $hs_settings['hs_feedburner_url']=$_POST['hs_feedburner_url']; } else { $hs_settings['hs_feedburner_url']=''; $myhubspotsettings_notice->add_notice('Please enter a valid Feedburner URL'); } } if(isset($_POST['hs_actions_disabled'])){ $hs_settings['hs_actions_disabled']=$_POST['hs_actions_disabled']; } else { $hs_settings['hs_actions_disabled']=''; } if(isset($_POST['hs_actions_stats_disabled'])){ $hs_settings['hs_actions_stats_disabled']=$_POST['hs_actions_stats_disabled']; } else { $hs_settings['hs_actions_stats_disabled']=''; } if(isset($_POST['hs_config_notice'])){ $hs_settings['hs_config_notice']=$_POST['hs_config_notice']; } else { $hs_settings['hs_config_notice']=''; } $myhubspotsettings_notice->display_notice(3); update_option("hs_settings", $hs_settings); } }//updated $hs_settings=get_option('hs_settings'); // Warning notice is disabled for this page so it needs to be called here. This is so updating customer info or disabling the warning has an immediate effect without having to refresh if(!$hs_settings['hs_config_notice'] && !WPHubspot::hs_is_customer($hs_settings['hs_portal'], $hs_settings['hs_appdomain'])){ $myhubspotwp_notice = new WPHubspotNotice('configuration-warning'); $myhubspotwp_notice->display_notice(10); } return $hs_settings; } //============================================= // Settings page options //============================================= function hs_settings_options(){ $hs_settings = $this->hs_process_settings_options(); $content = ""; $action_content = ""; $content = '

'.__('HubSpot customers can input their Portal ID and App Domain to enable analytics and other cool features').'.

'; $content .= ''; if ( function_exists('wp_nonce_field') ){ $content .= wp_nonce_field('hubspot-dashboard-update-options','_wpnonce',true,false); } $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= '
'; $action_content = ''; $action_content .= ''; $action_content .= ''; $action_content .= '
'; $wrapped_content = $this->hs_postbox('hubspot-settings', 'HubSpot Configuration', $content); if (substr(get_bloginfo('version'), 0, 3) >= '3.0') { $wrapped_content .= $this->hs_postbox('hubspot-action-settings', 'Call To Action Settings', $action_content); } $this->hs_admin_wrap('General HubSpot Settings', $wrapped_content); } //============================================= // Add settings link to plugins page //============================================= function hs_plugin_settings_link($links) { $settings_link = '' . __('Settings') . ''; array_unshift( $links, $settings_link ); return $links; } //============================================= // Custom admin styles //============================================= function custom_admin_style() { global $pagenow; if ($pagenow == 'index.php') { echo ''; } } //============================================= // Load admin styles //============================================= function add_hs_admin_styles() { global $pagenow; if ( $pagenow == 'admin.php' && isset($_GET['page']) && strstr($_GET['page'],"hubspot_")) { wp_enqueue_style('dashboard'); wp_enqueue_style('global'); wp_enqueue_style('wp-admin'); } } //============================================= // Load admin scripts //============================================= function add_hs_admin_scripts() { global $pagenow; if ( $pagenow == 'admin.php' && isset($_GET['page']) && strstr($_GET['page'],"hubspot_")) { wp_enqueue_script('postbox'); wp_enqueue_script('dashboard'); } } //============================================= // Display support info //============================================= function hs_show_plugin_support() { $content = '

'.__('Please check the Help Section first. If you have any problems with this plugin or good ideas for improvements or new features, please contact us at').' wordpress-support-groups@hubspot.com or use the WordPress Plugin Support Forum.

'; return $this->hs_postbox('hubspot-support', 'Need support?', $content); } //============================================= // Display HubSpot feed //============================================= function hs_show_blogfeed() { include_once(ABSPATH . WPINC . '/feed.php'); $content = ""; $maxitems = 0; $rss = fetch_feed("http://feeds.feedburner.com/HubSpot"); if (!is_wp_error( $rss ) ) { $maxitems = $rss->get_item_quantity(3); $rss_items = $rss->get_items(0, $maxitems); } if ($maxitems == 0) { $content .= "

No Posts

"; } else { foreach ( $rss_items as $item ) { $content .= "" . $item->get_title() . "
- " . $item->get_date('n/j/Y') . "

"; } $content .= "

Go To HubSpot Blog »

"; } return $this->hs_postbox('hubspot-blog-rss', 'HubSpot Blog', $content); } //============================================= // Create postbox for admin //============================================= function hs_postbox($id, $title, $content) { $postbox_wrap = ""; $postbox_wrap .= '
'; $postbox_wrap .= '

'; $postbox_wrap .= '

' . $title . '

'; $postbox_wrap .= '
' . $content . '
'; $postbox_wrap .= '
'; return $postbox_wrap; } //============================================= // Admin page wrap //============================================= function hs_admin_wrap($title, $content) { ?>

hs_show_plugin_support(); echo $this->hs_show_blogfeed(); ?>
get_item_quantity(5); $rss_items = $rss->get_items(0, $maxitems); } $content .= '
'; echo $content; } } ?>