Google Analytics to your WordPress site. Unlike other plugins, code is added to the <head> section, so you can authorize your site in Google Webmaster Tools. Author: Lukasz Nowicki Version: 0.5.1 Author URI: http://web.ujagody.pl/ License: GPLv2 */ class AnalyticsHead { // Basic informations protected $PluginName='Analytics Head'; protected $PluginCode='ln-plugin-analytics-head'; protected $PluginVersion='0.5.1'; protected $PluginURL='http://wordpress.ujagody.pl/plugins/google-analytics/'; protected $PluginFile='analytics_head.php'; private $OptionsName='wordpress_lnpo_ah'; private $Defaults=Array('GoogleID'=>'','HideForAdmins'=>true); private $Options=Array(); private $DirectCall=''; private $PluginUndercode=''; private $Footer=''; private $TD=''; public function __construct() { // Prepare die string for direct calls $this->DirectCall='
Hello, there!
Please, do not call me directly, because there is nothing I can do here.
I\'m just a plugin, so you should call me within Wordpress installation.
Learn more about '.$this->PluginName.' plugin.
'; // Die if plugin is called directly if (!function_exists('add_action')) die($this->DirectCall); // Prepare Plugin Underscore code-name $this->PluginUndercode=str_replace('-','_',$this->PluginCode); $this->TD=$this->PluginCode; // Load language domain if(!load_plugin_textdomain($this->TD,'/wp-content/languages/')) load_plugin_textdomain($this->TD,'/wp-content/plugins/'.dirname(plugin_basename(__FILE__))); // Footer information $this->Footer=__('This plugin is distributed under the terms of GPLv2. For more information see',$this->TD).': '.$this->PluginName.''; // Register hooks for plugin services register_activation_hook(__FILE__,Array($this,'plugin_activate')); register_deactivation_hook(__FILE__,Array($this,'plugin_deactivate')); // Add "settings" link to the plugin in the plugin list add_filter('plugin_action_links',Array($this,'action_links'),10,2); // Load options into $Options variable $this->serve_variables(); // Yhrow warning if user didn't provided Google ID if (((!isset($_POST['submit']))&&($this->Options['GoogleID']==''))||((isset($_POST['submit']))&&($_POST['google_id']==''))) add_action('admin_notices',Array($this,'warning')); // Adding admin menu add_action('admin_menu',Array($this,'menu')); // Add analytics code if it is possible and needed $this->check_add_code(); } public function add_code() { echo " "; } public function check_add_code() { $id=preg_match('([U][A][-][0-9]{1,16}[-][0-9]{1,4})',$this->Options['GoogleID'],$result); if ($id>0) $id=$result[0]; else $id=''; $a=$this->Options['HideForAdmins']; if ($id!='') if ((!is_admin())&&(($a==false)||(($a==true)&&(!current_user_can('manage_options'))))) add_action('wp_head',Array($this,'add_code')); } public function options() { // Check if user is saving options $this->submit_check(); // Show options page $this->options_body(); } public function menu() { add_options_page( __('Analytics Head plugin options',$this->TD), $this->PluginName, 'manage_options', $this->PluginCode, Array($this,'options') ); } public function warning() { echo ''.__('Plugin is almost ready for operation. You need to enter in the tracking code ID:',$this->TD).' '.$this->PluginName.'
'.__('Options saved.').'
'.__('This plugin has only two settings. Google Analytics code and the option of hiding the code for users logged on with administrator privileges. This will not count your visit that does not distort the results in the service.',$this->TD).'
'.__('',$this->TD).'
'.$this->Footer.'