section add_action( 'wp_head', array( &$this, 'wp_head' ) ); // Extra content just before add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); // RSS tagging add_filter( 'the_permalink_rss', array( &$this, 'the_permalink_rss' ) ); add_filter( 'the_content', array( &$this, 'the_content' ) ); // Modify post excerpt and comments for various reasons add_filter( 'the_excerpt', array( &$this, 'the_excerpt' ) ); // Modify post content and comments for various reasons add_filter( 'comment_text', array( &$this, 'comment_text' ) ); } // Initialise plugin function init() { load_plugin_textdomain( 'google-integration-toolkit', false, dirname( plugin_basename( __FILE__ ) ).'/lang' ); } // Plugin initialisation - admin function admin_init() { // Register plugin options register_setting( 'google-integration-toolkit', 'git_gwt_mode', array( &$this, 'sanitize_gwt_mode' ) ); register_setting( 'google-integration-toolkit', 'git_gwt_meta', array( &$this, 'sanitize_metaverify' ) ); register_setting( 'google-integration-toolkit', 'git_gwt_filename', 'trim' ); register_setting( 'google-integration-toolkit', 'git_analytics_id', 'trim' ); register_setting( 'google-integration-toolkit', 'git_analytics_adsense', array( &$this, 'sanitize_bool' ) ); register_setting( 'google-integration-toolkit', 'git_rss_tagging', array( &$this, 'sanitize_bool' ) ); register_setting( 'google-integration-toolkit', 'git_rss_tag_source', 'trim' ); register_setting( 'google-integration-toolkit', 'git_rss_tag_medium', 'trim' ); register_setting( 'google-integration-toolkit', 'git_rss_tag_campaign', 'trim' ); register_setting( 'google-integration-toolkit', 'git_adsense_tag_posts', array( &$this, 'sanitize_bool' ) ); register_setting( 'google-integration-toolkit', 'git_adsense_tag_comments', array( &$this, 'sanitize_bool' ) ); register_setting( 'google-integration-toolkit', 'git_analytics_track_404', array( &$this, 'sanitize_bool' ) ); register_setting( 'google-integration-toolkit', 'git_analytics_track_404_prefix', 'trim' ); } // Add Admin menu option function admin_menu() { // admin_init is called later, so need to use proxy method here add_submenu_page( 'options-general.php', 'Google Integration Toolkit', 'Google Integration Toolkit', 'manage_options', __FILE__, array( $this, 'options_panel' ) ); } // URL handler for GWT verification function status_header( $status_header, $header ) { if ( ( $header == 404 ) && ( get_option( 'git_gwt_mode' ) == 'file' ) ) { $filename = get_option( 'git_gwt_filename' ); if ( $filename != '' ) { // Extract root dir from blog url $root = '/'; if ( preg_match( '#^http://[^/]+(/.+)$#', get_option( 'siteurl' ), $matches ) ) { $root = $matches[1]; } // Make sure it ends with slash if ( $root[ strlen($root) - 1 ] != '/' ) { $root .= '/'; } // Check if request is for GWT verification file if ( $root.$filename == $_SERVER['REQUEST_URI'] ) { //wp_die( 'Welcome, Google!', '200 OK', array( 'response' => 200 ) ); echo 'google-site-verification: ', $filename; exit(); } } } return $status_header; } // Extra entries in section function wp_head() { // Google Webmasters Tools $gwt_mode = get_option( 'git_gwt_mode' ); $meta = get_option( 'git_gwt_meta' ); if ( ( $gwt_mode == 'meta2' ) && ( $meta != '' ) ) { echo '', "\n"; } elseif ( ( $gwt_mode == 'meta' ) && ( $meta != '' ) ) { echo '', "\n"; } // Google Analytics integration with Google AdSense $analytics_id = get_option( 'git_analytics_id' ); if ( ( $analytics_id != '' ) && get_option( 'git_analytics_adsense' ) ) { echo << window.google_analytics_uacct = "$analytics_id"; EOT; } } // Extra content just before function wp_footer() { $analytics_id = get_option( 'git_analytics_id' ); if ( $analytics_id != '' ) { echo << var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); EOT; } } // Add tags to the rss links function tag_rss_link( $link, $use_hash ) { $tag = 'utm_source='.get_option( 'git_rss_tag_source' ) .'&utm_medium='.get_option( 'git_rss_tag_medium' ) .'&utm_campaign='.get_option( 'git_rss_tag_campaign' ); if ( $use_hash ) { return $link.'#'.$tag; } elseif ( strpos( $link, '?' ) === false ) { return $link.'?'.$tag; } else { return $link.'&'.$tag; } } // RSS tagging - tag links in RSS function the_permalink_rss( $link ) { if ( get_option( 'git_rss_tagging' ) ) { return $this->tag_rss_link( $link, true ); } else { return $link; } } // Helper function for tagging links in RSS - tag links in text function update_rss_link( $matches ) { $url = $matches[2]; if ( preg_match( '/^https?:/', $url ) ) { // Tag links from this blog only $blogurl = get_option( 'siteurl' ); if ( substr( $url, 0, strlen( $blogurl ) ) == $blogurl ) { return $matches[1].$this->tag_rss_link( $url, true ); } else { return $matches[1].$url; } } else { return $matches[1].$this->tag_rss_link( $url, true ); } } // Content modification function function the_content( $content ) { // RSS tagging - tag links in RSS' text if ( is_feed() && get_option( 'git_rss_tagging' ) ) { $content = preg_replace_callback( '/(<\s*a\s[^>]*?\bhref\s*=\s*")([^"]+)/', array( &$this, 'update_rss_link' ), $content ); } // AdSense section targetting if ( !is_feed() && get_option( 'git_adsense_tag_posts' ) ) { return ''.$content.''; } return $content; } // Content excerpts modification function function the_excerpt( $content ) { // AdSense section targetting if ( !is_feed() && get_option( 'git_adsense_tag_posts' ) ) { return ''.$content.''; } return $content; } // Comments modification function function comment_text( $content ) { // AdSense section targetting if ( !is_feed() && get_option( 'git_adsense_tag_comments' ) ) { return ''.$content.''; } return $content; } // Handle options panel function options_panel() { $message = null; if ( isset($_POST['action']) ) { check_admin_referer( 'google-integration-toolkit-options' ); $message = __('Configuration has been saved.', 'google-integration-toolkit'); echo '

', $message, '

', "\n"; } // HTML settings form here ?>

/>
/>
/>
Note: Please use google-site-verification meta tag or file to verify new websites. Meta tag verify-v1 is supported for backward compatibility only.', 'google-integration-toolkit'); ?>


<meta name="google-site-verification" content="abcdefghijklmnopqrstuvwzyz123456789abcdefghi" />

<meta name="verify-v1" content="abcdefghijklmnopqrstuvwzyz123456789abcdefghi" />
marked part only to the field above.', 'google-integration-toolkit'); ?>

googleabcdefghijklmnop.html' ); ?>



var pageTracker = _gat._getTracker("UA-0000000-0");
/>

/>

utm_source parameter.', 'google-integration-toolkit'); ?>

utm_medium parameter.', 'google-integration-toolkit'); ?>

utm_campaign parameter.', 'google-integration-toolkit'); ?>

/>
here.', 'google-integration-toolkit'); ?>
/>

/>

/404.html?page=[pagename.html?queryparameter]&from=[referrer], where [pagename.html?queryparameters] is the missing page name and referrer is the page URL from where the user reached the 404 page. You can change prefix /404.html to something else using this option.', 'google-integration-toolkit'); ?>