PluginProbe ʕ •ᴥ•ʔ
ShareThis Dashboard for Google Analytics / 1.0.7
ShareThis Dashboard for Google Analytics v1.0.7
3.3.2 trunk 1.0.7 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.5 2.3.5 2.3.6 2.3.7 2.3.8 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.0.0 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.3.0 3.3.1
googleanalytics / googleanalytics.php
googleanalytics Last commit date
LICENSE 9 years ago googleanalytics.php 9 years ago options.php 13 years ago readme.txt 9 years ago screenshot-1.png 13 years ago screenshot-2.png 13 years ago
googleanalytics.php
68 lines
1 <?php
2 /*
3 Plugin Name: Google Analytics
4 Plugin URI: http://wordpress.org/extend/plugins/googleanalytics/
5 Description: Enables <a href="http://www.google.com/analytics/">Google Analytics</a> on all pages.
6 Version: 1.0.7
7 Author: Kevin Sylvestre
8 Author URI: http://ksylvest.com/
9 */
10
11 if (!defined('WP_CONTENT_URL'))
12 define('WP_CONTENT_URL', get_option('siteurl').'/wp-content');
13 if (!defined('WP_CONTENT_DIR'))
14 define('WP_CONTENT_DIR', ABSPATH.'wp-content');
15 if (!defined('WP_PLUGIN_URL'))
16 define('WP_PLUGIN_URL', WP_CONTENT_URL.'/plugins');
17 if (!defined('WP_PLUGIN_DIR'))
18 define('WP_PLUGIN_DIR', WP_CONTENT_DIR.'/plugins');
19
20 function activate_googleanalytics() {
21 add_option('web_property_id', 'UA-0000000-0');
22 }
23
24 function deactive_googleanalytics() {
25 delete_option('web_property_id');
26 }
27
28 function admin_init_googleanalytics() {
29 register_setting('googleanalytics', 'web_property_id');
30 }
31
32 function admin_menu_googleanalytics() {
33 add_options_page('Google Analytics', 'Google Analytics', 'manage_options', 'googleanalytics', 'options_page_googleanalytics');
34 }
35
36 function options_page_googleanalytics() {
37 include(WP_PLUGIN_DIR.'/googleanalytics/options.php');
38 }
39
40 function googleanalytics() {
41 $web_property_id = get_option('web_property_id');
42 ?>
43 <script>
44 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
45 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
46 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
47 })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
48
49 ga('create', '<?php echo $web_property_id ?>', 'auto');
50 ga('send', 'pageview');
51 </script>
52 <?php
53 }
54
55 register_activation_hook(__FILE__, 'activate_googleanalytics');
56 register_deactivation_hook(__FILE__, 'deactive_googleanalytics');
57
58 if (is_admin()) {
59 add_action('admin_init', 'admin_init_googleanalytics');
60 add_action('admin_menu', 'admin_menu_googleanalytics');
61 }
62
63 if (!is_admin()) {
64 add_action('wp_head', 'googleanalytics');
65 }
66
67 ?>
68