Google Analyticator - Version 5.0

Version Description

  • Adds a new admin dashboard widget that displays a graph of the last 30 days of visitors, a summary of site usage, the top pages, the top referrers, and the top searches.
  • Changes the Google authentication method to AuthSub. This removes the Google username / password requirement. Users who had previously entered their username / password in the settings page will need to revisit the settings page and authenticate for the widget to continue to function.
  • Adds support for automatically retrieving an Analytics account's UID if Google Analyticator is authenticated with Google.
  • Updates the Google Analytics API class to use the WordPress HTTP API, thus removing cURL as a core requirement for the widget.
  • Updates the UID setting help to remove old urchin.js references and provide additional help for finding a UID.
  • Prepares all strings for localization. If you would like to translate Google Analyticator, visit our forums.
Download this release

Release Info

Developer cavemonkey50
Plugin Icon 128x128 Google Analyticator
Version 5.0
Comparing to
See all releases

Code changes from version 4.3.4 to 5.0

class.analytics.stats.php CHANGED
@@ -21,54 +21,93 @@ class GoogleAnalyticsStats
21
  var $baseFeed = 'https://www.google.com/analytics/feeds';
22
  var $accountId;
23
  var $token = false;
 
24
 
25
  /**
26
  * Constructor
27
  *
28
- * @param user - the google account's username
29
- * @param pass - the google account's password
30
  **/
31
- function GoogleAnalyticsStats($user, $pass)
32
  {
33
- # Encode the login details for sending over HTTP
34
- $user = urlencode($user);
35
- $pass = urlencode($pass);
36
-
37
- # Request authentication with Google
38
- $response = $this->curl('https://www.google.com/accounts/ClientLogin', 'accountType=GOOGLE&Email=' . $user . '&Passwd=' . $pass);
 
39
 
40
- # Get the authentication token
41
- $this->token = substr(strstr($response, "Auth="), 5);
 
 
 
 
 
 
 
 
 
 
 
42
  }
43
 
44
  /**
45
- * Connects over cURL to get data
46
  *
47
  * @param url - url to request
48
- * @param post - post data to pass through curl
49
- * @return the raw curl response
50
  **/
51
- function curl($url, $post = false, $header = 1)
52
  {
53
- $curl = curl_init();
54
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
55
- curl_setopt($curl, CURLOPT_HEADER, $header);
56
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
57
- curl_setopt($curl, CURLOPT_URL, $url);
58
 
59
- # Include the authentication token if known
 
 
 
 
 
 
 
 
 
60
  if ( $this->token ) {
61
- curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: GoogleLogin auth=' . $this->token));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  }
63
 
64
- # Include optional post fields
65
- if ( $post ) {
66
- $post .= '&service=analytics&source=wp-google-stats';
67
- curl_setopt($curl, CURLOPT_POST, 1);
68
- curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
 
 
 
69
  }
70
 
71
- return curl_exec($curl);
 
72
  }
73
 
74
  /**
@@ -102,7 +141,7 @@ class GoogleAnalyticsStats
102
  function getAnalyticsAccounts()
103
  {
104
  # Request the list of accounts
105
- $response = $this->curl($this->baseFeed . '/accounts/default', false, '0');
106
 
107
  # Check if the response received exists, else stop processing now
108
  if ( $response == '' )
@@ -120,10 +159,24 @@ class GoogleAnalyticsStats
120
  foreach ( $accounts AS $account ) {
121
  $id = array();
122
 
123
- $item_info = $account->get_item_tags('http://schemas.google.com/analytics/2009', 'tableId');
 
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  $id['title'] = $account->get_title();
126
- $id['id'] = $item_info[0]['data'];
127
 
128
  $ids[] = $id;
129
  }
@@ -144,8 +197,8 @@ class GoogleAnalyticsStats
144
  # Ensure the start date is after Jan 1 2005
145
  $startDate = $this->verifyStartDate($startDate);
146
 
147
- # Request the list of accounts
148
- $response = $this->curl($this->baseFeed . "/data?ids=$this->accountId&start-date=$startDate&end-date=$endDate&metrics=$metric", false, '0');
149
 
150
  # Parse the XML using SimplePie
151
  $simplePie = new SimplePie();
@@ -161,6 +214,97 @@ class GoogleAnalyticsStats
161
  }
162
  }
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  /**
165
  * Checks the date against Jan. 1 2005 because GA API only works until that date
166
  *
21
  var $baseFeed = 'https://www.google.com/analytics/feeds';
22
  var $accountId;
23
  var $token = false;
24
+ var $responseHash = array();
25
 
26
  /**
27
  * Constructor
28
  *
29
+ * @param token - a one-time use token to be exchanged for a real token
 
30
  **/
31
+ function GoogleAnalyticsStats($token = false)
32
  {
33
+ # If we need to request a permanent token
34
+ if ( $token ) {
35
+
36
+ $this->token = $token;
37
+
38
+ # Request authentication with Google
39
+ $response = $this->http('https://www.google.com/accounts/AuthSubSessionToken', $post);
40
 
41
+ # Get the authentication token
42
+ $this->token = substr(strstr($response, "Token="), 6);
43
+
44
+ # Save the token for future use
45
+ update_option('ga_google_token', $this->token);
46
+
47
+ # Remove the old username and password fields if they still exists
48
+ delete_option('google_stats_user');
49
+ delete_option('google_stats_password');
50
+
51
+ } else {
52
+ $this->token = get_option('ga_google_token');
53
+ }
54
  }
55
 
56
  /**
57
+ * Connects using the WordPress HTTP API to get data
58
  *
59
  * @param url - url to request
60
+ * @param post - post data to pass through WordPress
61
+ * @return the raw http response
62
  **/
63
+ function http($url, $post = false)
64
  {
65
+ # Set the arguments to pass to WordPress
66
+ $args = array(
67
+ 'sslverify' => false
68
+ );
 
69
 
70
+ # Add the optional post values
71
+ if ( $post ) {
72
+ $post .= '&service=analytics&source=google-analyticator-' . GOOGLE_ANALYTICATOR_VERSION;
73
+ $args['body'] = $post;
74
+ }
75
+
76
+ # Set the content to form data
77
+ $args['headers'] = array('Content-Type' => 'application/x-www-form-urlencoded');
78
+
79
+ # Add the token information
80
  if ( $this->token ) {
81
+ $args['headers']['Authorization'] = 'AuthSub token="' . $this->token . '"';
82
+ }
83
+
84
+ # Disable the fopen transport since it doesn't work with the Google API
85
+ add_filter('use_fopen_transport', create_function('$a', 'return false;'));
86
+
87
+ # Make the connection
88
+ if ( $post )
89
+ $response = wp_remote_post($url, $args);
90
+ else
91
+ $response = wp_remote_get($url, $args);
92
+
93
+ # Check for WordPress error
94
+ if ( is_wp_error($response) ) {
95
+ $this->responseHash['error'] = __('WordPress HTTP error.', 'google-analyticator');
96
+ return '';
97
  }
98
 
99
+ # Build an array of messages
100
+ foreach( explode("\n", $response['body']) as $line ) {
101
+ if ( trim($line) != '' ) {
102
+ $pos = strpos($line, '=');
103
+ if ( $pos !== false ) {
104
+ $this->responseHash[strtolower(substr($line, 0, $pos))] = substr($line, $pos+1);
105
+ }
106
+ }
107
  }
108
 
109
+ # Return the body of the response
110
+ return $response['body'];
111
  }
112
 
113
  /**
141
  function getAnalyticsAccounts()
142
  {
143
  # Request the list of accounts
144
+ $response = $this->http($this->baseFeed . '/accounts/default');
145
 
146
  # Check if the response received exists, else stop processing now
147
  if ( $response == '' )
159
  foreach ( $accounts AS $account ) {
160
  $id = array();
161
 
162
+ # Get the list of properties
163
+ $properties = $account->get_item_tags('http://schemas.google.com/analytics/2009', 'property');
164
 
165
+ # Loop through the properties
166
+ foreach ( $properties AS $property ) {
167
+
168
+ # Get the property information
169
+ $name = $property['attribs']['']['name'];
170
+ $value = $property['attribs']['']['value'];
171
+
172
+ # Add the propery data to the id array
173
+ $id[$name] = $value;
174
+
175
+ }
176
+
177
+ # Add the backward compatibility array items
178
  $id['title'] = $account->get_title();
179
+ $id['id'] = 'ga:' . $id['ga:profileId'];
180
 
181
  $ids[] = $id;
182
  }
197
  # Ensure the start date is after Jan 1 2005
198
  $startDate = $this->verifyStartDate($startDate);
199
 
200
+ # Request the metric data
201
+ $response = $this->http($this->baseFeed . "/data?ids=$this->accountId&start-date=$startDate&end-date=$endDate&metrics=$metric");
202
 
203
  # Parse the XML using SimplePie
204
  $simplePie = new SimplePie();
214
  }
215
  }
216
 
217
+ /**
218
+ * Get a specific data metrics
219
+ *
220
+ * @param metrics - the metrics to get
221
+ * @param startDate - the start date to get
222
+ * @param endDate - the end date to get
223
+ * @param dimensions - the dimensions to grab
224
+ * @param sort - the properties to sort on
225
+ * @param filter - the property to filter on
226
+ * @param limit - the number of items to get
227
+ * @return the specific metrics in array form
228
+ **/
229
+ function getMetrics($metric, $startDate, $endDate, $dimensions = false, $sort = false, $filter = false, $limit = false)
230
+ {
231
+ # Ensure the start date is after Jan 1 2005
232
+ $startDate = $this->verifyStartDate($startDate);
233
+
234
+ # Build the query url
235
+ $url = $this->baseFeed . "/data?ids=$this->accountId&start-date=$startDate&end-date=$endDate&metrics=$metric";
236
+
237
+ # Add optional dimensions
238
+ if ( $dimensions )
239
+ $url .= "&dimensions=$dimensions";
240
+
241
+ # Add optional sort
242
+ if ( $sort )
243
+ $url .= "&sort=$sort";
244
+
245
+ # Add optional filter
246
+ if ( $filter )
247
+ $url .= "&filters=$filter";
248
+
249
+ # Add optional limit
250
+ if ( $limit )
251
+ $url .= "&max-results=$limit";
252
+
253
+ # Request the metric data
254
+ $response = $this->http($url);
255
+
256
+ # Parse the XML using SimplePie
257
+ $simplePie = new SimplePie();
258
+ $simplePie->set_raw_data($response);
259
+ $simplePie->enable_order_by_date(false);
260
+ $simplePie->init();
261
+ $simplePie->handle_content_type();
262
+ $datas = $simplePie->get_items();
263
+
264
+ $ids = array();
265
+
266
+ # Read out the data until the metric is found
267
+ foreach ( $datas AS $data ) {
268
+ $metrics = $data->get_item_tags('http://schemas.google.com/analytics/2009', 'metric');
269
+ $dimensions = $data->get_item_tags('http://schemas.google.com/analytics/2009', 'dimension');
270
+ $id = array();
271
+
272
+ $id['title'] = $data->get_title();
273
+
274
+ # Loop through the dimensions
275
+ if ( is_array($dimensions) ) {
276
+ foreach ( $dimensions AS $property ) {
277
+
278
+ # Get the property information
279
+ $name = $property['attribs']['']['name'];
280
+ $value = $property['attribs']['']['value'];
281
+
282
+ # Add the propery data to the id array
283
+ $id[$name] = $value;
284
+
285
+ }
286
+ }
287
+
288
+ # Loop through the metrics
289
+ if ( is_array($metrics) ) {
290
+ foreach ( $metrics AS $property ) {
291
+
292
+ # Get the property information
293
+ $name = $property['attribs']['']['name'];
294
+ $value = $property['attribs']['']['value'];
295
+
296
+ # Add the propery data to the id array
297
+ $id[$name] = $value;
298
+
299
+ }
300
+ }
301
+
302
+ $ids[] = $id;
303
+ }
304
+
305
+ return $ids;
306
+ }
307
+
308
  /**
309
  * Checks the date against Jan. 1 2005 because GA API only works until that date
310
  *
google-analyticator.php CHANGED
@@ -1,27 +1,29 @@
1
  <?php
2
  /*
3
  * Plugin Name: Google Analyticator
4
- * Version: 4.3.4
5
  * Plugin URI: http://plugins.spiralwebconsulting.com/analyticator.html
6
  * Description: Adds the necessary JavaScript code to enable <a href="http://www.google.com/analytics/">Google's Analytics</a>. After enabling this plugin visit <a href="options-general.php?page=google-analyticator.php">the settings page</a> and enter your Google Analytics' UID and enable logging.
7
  * Author: Spiral Web Consulting
8
  * Author URI: http://spiralwebconsulting.com/
 
9
  */
10
 
11
- define('GOOGLE_ANALYTICATOR_VERSION', '4.3.4');
12
 
13
  # Include Google Analytics Stats widget
14
- if ( function_exists('curl_init') ) {
15
-
16
- # Check if we have a version of WordPress greater than 2.8
17
- if ( function_exists('register_widget') ) {
18
- require_once('google-analytics-stats-widget.php');
19
- } else {
20
- require_once('google-analytics-stats.php');
21
- $google_analytics_stats = new GoogleStatsWidget();
22
- }
23
  }
24
 
 
 
 
 
25
  // Constants for enabled/disabled state
26
  define("ga_enabled", "enabled", true);
27
  define("ga_disabled", "disabled", true);
@@ -75,6 +77,7 @@ add_option(key_ga_downloads, ga_downloads_default, 'Download extensions to track
75
  add_option(key_ga_downloads_prefix, ga_downloads_prefix_default, 'Download extensions to track with Google Analyticator');
76
  add_option(key_ga_footer, ga_footer_default, 'If Google Analyticator is outputting in the footer');
77
  add_option(key_ga_specify_http, ga_specify_http_default, 'Automatically detect the http/https settings');
 
78
 
79
  // Create a option page for settings
80
  add_action('admin_init', 'ga_admin_init');
@@ -82,6 +85,10 @@ add_action('admin_menu', 'add_ga_option_page');
82
 
83
  // Initialize the options
84
  function ga_admin_init() {
 
 
 
 
85
  // Register out options so WordPress knows about them
86
  if ( function_exists('register_setting') ) {
87
  register_setting('google-analyticator', key_ga_status, '');
@@ -116,7 +123,7 @@ add_action('plugin_action_links_' . plugin_basename(__FILE__), 'ga_filter_plugin
116
  function ga_filter_plugin_actions($links) {
117
  $new_links = array();
118
 
119
- $new_links[] = '<a href="options-general.php?page=google-analyticator.php">Settings</a>';
120
 
121
  return array_merge($new_links, $links);
122
  }
@@ -128,9 +135,9 @@ function ga_filter_plugin_links($links, $file)
128
  {
129
  if ( $file == plugin_basename(__FILE__) )
130
  {
131
- $links[] = '<a href="http://plugins.spiralwebconsulting.com/forums/viewforum.php?f=5">FAQ</a>';
132
- $links[] = '<a href="http://plugins.spiralwebconsulting.com/forums/viewforum.php?f=6">Support</a>';
133
- $links[] = '<a href="http://plugins.spiralwebconsulting.com/analyticator.html#donate">Donate</a>';
134
  }
135
 
136
  return $links;
@@ -222,13 +229,9 @@ function ga_options_page() {
222
  if ( $ga_specify_http == '' )
223
  $ga_specify_http = 'auto';
224
  update_option(key_ga_specify_http, $ga_specify_http);
225
-
226
- # Update the stat options
227
- update_option('google_stats_user', $_POST['google_stats_user']);
228
- update_option('google_stats_password', $_POST['google_stats_password']);
229
 
230
  // Give an updated message
231
- echo "<div class='updated fade'><p><strong>Google Analyticator settings saved.</strong></p></div>";
232
  // }
233
  }
234
 
@@ -237,7 +240,7 @@ function ga_options_page() {
237
 
238
  <div class="wrap">
239
 
240
- <h2>Google Analyticator Settings</h2>
241
 
242
  <div style="float: right;">
243
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
@@ -251,24 +254,24 @@ function ga_options_page() {
251
  <form method="post" action="options-general.php?page=google-analyticator.php">
252
 
253
  <p><em>
254
- Google Analyticator is brought to you for free by <a href="http://spiralwebconsulting.com/">Spiral Web Consulting</a>. Spiral Web Consulting is a small web development firm specializing in PHP development. Visit our website to learn more, and don't hesitate to ask us to develop your next big WordPress plugin idea.
255
  </em></p>
256
 
257
- <h3>Basic Settings</h3>
258
  <?php if (get_option(key_ga_status) == ga_disabled) { ?>
259
  <div style="margin:10px auto; border:3px #f00 solid; background-color:#fdd; color:#000; padding:10px; text-align:center;">
260
- Google Analytics integration is currently <strong>DISABLED</strong>.
261
  </div>
262
  <?php } ?>
263
  <?php if ((get_option(key_ga_uid) == "XX-XXXXX-X") && (get_option(key_ga_status) != ga_disabled)) { ?>
264
  <div style="margin:10px auto; border:3px #f00 solid; background-color:#fdd; color:#000; padding:10px; text-align:center;">
265
- Google Analytics integration is currently enabled, but you did not enter a UID. Tracking will not occur.
266
  </div>
267
  <?php } ?>
268
  <table class="form-table" cellspacing="2" cellpadding="5" width="100%">
269
  <tr>
270
  <th width="30%" valign="top" style="padding-top: 10px;">
271
- <label for="<?php echo key_ga_status ?>">Google Analytics logging is:</label>
272
  </th>
273
  <td>
274
  <?php
@@ -277,57 +280,81 @@ function ga_options_page() {
277
  echo "<option value='".ga_enabled."'";
278
  if(get_option(key_ga_status) == ga_enabled)
279
  echo " selected='selected'";
280
- echo ">Enabled</option>\n";
281
 
282
  echo "<option value='".ga_disabled."'";
283
  if(get_option(key_ga_status) == ga_disabled)
284
  echo" selected='selected'";
285
- echo ">Disabled</option>\n";
286
 
287
  echo "</select>\n";
288
  ?>
289
  </td>
290
  </tr>
 
 
 
 
291
  <tr>
292
- <th valign="top" style="padding-top: 10px;">
293
- <label for="<?php echo key_ga_uid; ?>">Your Google Analytics' UID:</label>
294
  </th>
295
  <td>
296
- <?php
297
- echo "<input type='text' size='50' ";
298
- echo "name='".key_ga_uid."' ";
299
- echo "id='".key_ga_uid."' ";
300
- echo "value='".get_option(key_ga_uid)."' />\n";
301
- ?>
302
- <p style="margin: 5px 10px;" class="setting-description">Enter your Google Analytics' UID in this box. The UID is needed for Google Analytics to log your website stats. Your UID can be found by looking in the JavaScript Google Analytics gives you to put on your page. Look for your UID in between <strong>_uacct = "UA-11111-1";</strong> in the JavaScript. In this example you would put <strong>UA-11111-1</strong> in the UID box.</p>
303
  </td>
304
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
  </table>
306
- <h3>Advanced Settings</h3>
307
  <table class="form-table" cellspacing="2" cellpadding="5" width="100%">
308
- <?php if ( function_exists('curl_init') ) { ?>
309
- <tr valign="top">
310
- <th scope="row">
311
- <label for="google_stats_user">Google Username:</label>
312
- </th>
313
- <td>
314
- <input type="text" size="40" name="google_stats_user" id="google_stats_user" value="<?php echo stripslashes(get_option('google_stats_user')); ?>" />
315
- <p style="margin: 5px 10px;" class="setting-description">Your Google Analytics account's username. This is needed to authenticate with Google for use with the stats widget.</p>
316
- </td>
317
- </tr>
318
- <tr valign="top">
319
- <th scope="row">
320
- <label for="google_stats_password">Google Password:</label>
321
- </th>
322
- <td>
323
- <input type="password" size="40" name="google_stats_password" id="google_stats_password" value="<?php echo stripslashes(get_option('google_stats_password')); ?>" />
324
- <p style="margin: 5px 10px;" class="setting-description">Your Google Analytics account's password. This is needed to authenticate with Google for use with the stats widget.</p>
325
- </td>
326
- </tr>
327
- <?php } ?>
328
  <tr>
329
  <th width="30%" valign="top" style="padding-top: 10px;">
330
- <label for="<?php echo key_ga_admin ?>">WordPress admin logging:</label>
331
  </th>
332
  <td>
333
  <?php
@@ -336,49 +363,51 @@ function ga_options_page() {
336
  echo "<option value='".ga_enabled."'";
337
  if(get_option(key_ga_admin) == ga_enabled)
338
  echo " selected='selected'";
339
- echo ">Enabled</option>\n";
340
 
341
  echo "<option value='".ga_disabled."'";
342
  if(get_option(key_ga_admin) == ga_disabled)
343
  echo" selected='selected'";
344
- echo ">Disabled</option>\n";
345
 
346
  echo "</select>\n";
347
- ?>
348
- <p style="margin: 5px 10px;" class="setting-description">Disabling this option will prevent all logged in WordPress admins from showing up on your Google Analytics reports. A WordPress admin is defined as a user with a level <?php
349
- echo "<input type='text' size='2' ";
350
- echo "name='".key_ga_admin_level."' ";
351
- echo "id='".key_ga_admin_level."' ";
352
- echo "value='".stripslashes(get_option(key_ga_admin_level))."' />\n";
353
- ?> or higher. Your user level is <?php
 
354
  if ( current_user_can('level_10') )
355
- echo '10';
356
  elseif ( current_user_can('level_9') )
357
- echo '9';
358
  elseif ( current_user_can('level_8') )
359
- echo '8';
360
  elseif ( current_user_can('level_7') )
361
- echo '7';
362
  elseif ( current_user_can('level_6') )
363
- echo '6';
364
  elseif ( current_user_can('level_5') )
365
- echo '5';
366
  elseif ( current_user_can('level_4') )
367
- echo '4';
368
  elseif ( current_user_can('level_3') )
369
- echo '3';
370
  elseif ( current_user_can('level_2') )
371
- echo '2';
372
  elseif ( current_user_can('level_1') )
373
- echo '1';
374
  else
375
- echo '0';
376
- ?>.</p>
 
377
  </td>
378
  </tr>
379
  <tr>
380
  <th width="30%" valign="top" style="padding-top: 10px;">
381
- <label for="<?php echo key_ga_admin_disable ?>">Admin tracking disable method:</label>
382
  </th>
383
  <td>
384
  <?php
@@ -387,21 +416,21 @@ function ga_options_page() {
387
  echo "<option value='remove'";
388
  if(get_option(key_ga_admin_disable) == 'remove')
389
  echo " selected='selected'";
390
- echo ">Remove</option>\n";
391
 
392
  echo "<option value='admin'";
393
  if(get_option(key_ga_admin_disable) == 'admin')
394
  echo" selected='selected'";
395
- echo ">Use 'admin' variable</option>\n";
396
 
397
  echo "</select>\n";
398
  ?>
399
- <p style="margin: 5px 10px;" class="setting-description">Selecting the "Remove" option will physically remove the tracking code from logged in admin users. Selecting the "Use 'admin' variable" option will assign a variable called 'admin' to logged in admin users. This option will allow Google Analytics' site overlay feature to work, but you will have to manually configure Google Analytics to exclude tracking from hits with the 'admin' variable.</p>
400
  </td>
401
  </tr>
402
  <tr>
403
  <th width="30%" valign="top" style="padding-top: 10px;">
404
- <label for="<?php echo key_ga_footer ?>">Footer tracking code:</label>
405
  </th>
406
  <td>
407
  <?php
@@ -410,21 +439,21 @@ function ga_options_page() {
410
  echo "<option value='".ga_enabled."'";
411
  if(get_option(key_ga_footer) == ga_enabled)
412
  echo " selected='selected'";
413
- echo ">Enabled</option>\n";
414
 
415
  echo "<option value='".ga_disabled."'";
416
  if(get_option(key_ga_footer) == ga_disabled)
417
  echo" selected='selected'";
418
- echo ">Disabled</option>\n";
419
 
420
  echo "</select>\n";
421
  ?>
422
- <p style="margin: 5px 10px;" class="setting-description">Enabling this option will insert the Google Analytics tracking code in your site's footer instead of your header. This will speed up your page loading if turned on. Not all themes support code in the footer, so if you turn this option on, be sure to check the Analytics code is still displayed on your site.</p>
423
  </td>
424
  </tr>
425
  <tr>
426
  <th width="30%" valign="top" style="padding-top: 10px;">
427
- <label for="<?php echo key_ga_outbound ?>">Outbound link tracking:</label>
428
  </th>
429
  <td>
430
  <?php
@@ -433,21 +462,21 @@ function ga_options_page() {
433
  echo "<option value='".ga_enabled."'";
434
  if(get_option(key_ga_outbound) == ga_enabled)
435
  echo " selected='selected'";
436
- echo ">Enabled</option>\n";
437
 
438
  echo "<option value='".ga_disabled."'";
439
  if(get_option(key_ga_outbound) == ga_disabled)
440
  echo" selected='selected'";
441
- echo ">Disabled</option>\n";
442
 
443
  echo "</select>\n";
444
  ?>
445
- <p style="margin: 5px 10px;" class="setting-description">Disabling this option will turn off the tracking of outbound links. It's recommended not to disable this option unless you're a privacy advocate (now why would you be using Google Analytics in the first place?) or it's causing some kind of weird issue.</p>
446
  </td>
447
  </tr>
448
  <tr>
449
  <th width="30%" valign="top" style="padding-top: 10px;">
450
- <label for="<?php echo key_ga_event ?>">Event tracking:</label>
451
  </th>
452
  <td>
453
  <?php
@@ -456,21 +485,21 @@ function ga_options_page() {
456
  echo "<option value='".ga_enabled."'";
457
  if(get_option(key_ga_event) == ga_enabled)
458
  echo " selected='selected'";
459
- echo ">Enabled</option>\n";
460
 
461
  echo "<option value='".ga_disabled."'";
462
  if(get_option(key_ga_event) == ga_disabled)
463
  echo" selected='selected'";
464
- echo ">Disabled</option>\n";
465
 
466
  echo "</select>\n";
467
  ?>
468
- <p style="margin: 5px 10px;" class="setting-description">Enabling this option will treat outbound links and downloads as events instead of pageviews. Since the introduction of <a href="http://code.google.com/apis/analytics/docs/tracking/eventTrackerOverview.html">event tracking in Analytics</a>, this is the recommended way to track these types of actions. Only disable this option if you must use the old pageview tracking method.</p>
469
  </td>
470
  </tr>
471
  <tr>
472
  <th valign="top" style="padding-top: 10px;">
473
- <label for="<?php echo key_ga_downloads; ?>">Download extensions to track:</label>
474
  </th>
475
  <td>
476
  <?php
@@ -479,12 +508,12 @@ function ga_options_page() {
479
  echo "id='".key_ga_downloads."' ";
480
  echo "value='".stripslashes(get_option(key_ga_downloads))."' />\n";
481
  ?>
482
- <p style="margin: 5px 10px;" class="setting-description">Enter any extensions of files you would like to be tracked as a download. For example to track all MP3s and PDFs enter <strong>mp3,pdf</strong>. <em>Outbound link tracking must be enabled for downloads to be tracked.</em></p>
483
  </td>
484
  </tr>
485
  <tr>
486
  <th valign="top" style="padding-top: 10px;">
487
- <label for="<?php echo key_ga_outbound_prefix; ?>">Prefix external links with:</label>
488
  </th>
489
  <td>
490
  <?php
@@ -493,12 +522,12 @@ function ga_options_page() {
493
  echo "id='".key_ga_outbound_prefix."' ";
494
  echo "value='".stripslashes(get_option(key_ga_outbound_prefix))."' />\n";
495
  ?>
496
- <p style="margin: 5px 10px;" class="setting-description">Enter a name for the section tracked external links will appear under. This option has no effect if event tracking is enabled.</em></p>
497
  </td>
498
  </tr>
499
  <tr>
500
  <th valign="top" style="padding-top: 10px;">
501
- <label for="<?php echo key_ga_downloads_prefix; ?>">Prefix download links with:</label>
502
  </th>
503
  <td>
504
  <?php
@@ -507,12 +536,12 @@ function ga_options_page() {
507
  echo "id='".key_ga_download_sprefix."' ";
508
  echo "value='".stripslashes(get_option(key_ga_downloads_prefix))."' />\n";
509
  ?>
510
- <p style="margin: 5px 10px;" class="setting-description">Enter a name for the section tracked download links will appear under. This option has no effect if event tracking is enabled.</em></p>
511
  </td>
512
  </tr>
513
  <tr>
514
  <th valign="top" style="padding-top: 10px;">
515
- <label for="<?php echo key_ga_adsense; ?>">Google Adsense ID:</label>
516
  </th>
517
  <td>
518
  <?php
@@ -521,12 +550,12 @@ function ga_options_page() {
521
  echo "id='".key_ga_adsense."' ";
522
  echo "value='".get_option(key_ga_adsense)."' />\n";
523
  ?>
524
- <p style="margin: 5px 10px;" class="setting-description">Enter your Google Adsense ID assigned by Google Analytics in this box. This enables Analytics tracking of Adsense information if your Adsense and Analytics accounts are linked. Note: Google recommends the Analytics tracking code is placed in the header with this option enabled, however, a fix is included in this plugin. To follow the official specs, do not enable footer tracking.</p>
525
  </td>
526
  </tr>
527
  <tr>
528
  <th valign="top" style="padding-top: 10px;">
529
- <label for="<?php echo key_ga_extra; ?>">Additional tracking code<br />(before tracker initialization):</label>
530
  </th>
531
  <td>
532
  <?php
@@ -535,12 +564,12 @@ function ga_options_page() {
535
  echo "id='".key_ga_extra."'>";
536
  echo stripslashes(get_option(key_ga_extra))."</textarea>\n";
537
  ?>
538
- <p style="margin: 5px 10px;" class="setting-description">Enter any additional lines of tracking code that you would like to include in the Google Analytics tracking script. The code in this section will be displayed <strong>before</strong> the Google Analytics tracker is initialized. Read <a href="http://www.google.com/analytics/InstallingGATrackingCode.pdf">Google Analytics tracker manual</a> to learn what code goes here and how to use it.</p>
539
  </td>
540
  </tr>
541
  <tr>
542
  <th valign="top" style="padding-top: 10px;">
543
- <label for="<?php echo key_ga_extra_after; ?>">Additional tracking code<br />(after tracker initialization):</label>
544
  </th>
545
  <td>
546
  <?php
@@ -549,12 +578,12 @@ function ga_options_page() {
549
  echo "id='".key_ga_extra_after."'>";
550
  echo stripslashes(get_option(key_ga_extra_after))."</textarea>\n";
551
  ?>
552
- <p style="margin: 5px 10px;" class="setting-description">Enter any additional lines of tracking code that you would like to include in the Google Analytics tracking script. The code in this section will be displayed <strong>after</strong> the Google Analytics tracker is initialized. Read <a href="http://www.google.com/analytics/InstallingGATrackingCode.pdf">Google Analytics tracker manual</a> to learn what code goes here and how to use it.</p>
553
  </td>
554
  </tr>
555
  <tr>
556
  <th width="30%" valign="top" style="padding-top: 10px;">
557
- <label for="<?php echo key_ga_specify_http; ?>">Specify HTTP detection:</label>
558
  </th>
559
  <td>
560
  <?php
@@ -563,27 +592,27 @@ function ga_options_page() {
563
  echo "<option value='auto'";
564
  if(get_option(key_ga_specify_http) == 'auto')
565
  echo " selected='selected'";
566
- echo ">Auto Detect</option>\n";
567
 
568
  echo "<option value='http'";
569
  if(get_option(key_ga_specify_http) == 'http')
570
  echo " selected='selected'";
571
- echo ">HTTP</option>\n";
572
 
573
  echo "<option value='https'";
574
  if(get_option(key_ga_specify_http) == 'https')
575
  echo " selected='selected'";
576
- echo ">HTTPS</option>\n";
577
 
578
  echo "</select>\n";
579
  ?>
580
- <p style="margin: 5px 10px;" class="setting-description">Explicitly set the type of HTTP connection your website uses. Setting this option instead of relying on the auto detect may resolve the _gat is undefined error message.</p>
581
  </td>
582
  </tr>
583
  </table>
584
  <p class="submit">
585
  <?php if ( function_exists('settings_fields') ) settings_fields('google-analyticator'); ?>
586
- <input type="submit" name="info_update" value="Save Changes" />
587
  </p>
588
  </div>
589
  </form>
@@ -591,6 +620,38 @@ function ga_options_page() {
591
  <?php
592
  }
593
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
594
  // Add the script
595
  $ga_in_footer = false;
596
  if (get_option(key_ga_footer) == ga_enabled) {
1
  <?php
2
  /*
3
  * Plugin Name: Google Analyticator
4
+ * Version: 5.0
5
  * Plugin URI: http://plugins.spiralwebconsulting.com/analyticator.html
6
  * Description: Adds the necessary JavaScript code to enable <a href="http://www.google.com/analytics/">Google's Analytics</a>. After enabling this plugin visit <a href="options-general.php?page=google-analyticator.php">the settings page</a> and enter your Google Analytics' UID and enable logging.
7
  * Author: Spiral Web Consulting
8
  * Author URI: http://spiralwebconsulting.com/
9
+ * Text Domain: google-analyticator
10
  */
11
 
12
+ define('GOOGLE_ANALYTICATOR_VERSION', '5.0');
13
 
14
  # Include Google Analytics Stats widget
15
+ # Check if we have a version of WordPress greater than 2.8
16
+ if ( function_exists('register_widget') ) {
17
+ require_once('google-analytics-stats-widget.php');
18
+ } else {
19
+ require_once('google-analytics-stats.php');
20
+ $google_analytics_stats = new GoogleStatsWidget();
 
 
 
21
  }
22
 
23
+ # Include the Google Analytics Summary widget
24
+ require_once('google-analytics-summary-widget.php');
25
+ $google_analytics_summary = new GoogleAnalyticsSummary();
26
+
27
  // Constants for enabled/disabled state
28
  define("ga_enabled", "enabled", true);
29
  define("ga_disabled", "disabled", true);
77
  add_option(key_ga_downloads_prefix, ga_downloads_prefix_default, 'Download extensions to track with Google Analyticator');
78
  add_option(key_ga_footer, ga_footer_default, 'If Google Analyticator is outputting in the footer');
79
  add_option(key_ga_specify_http, ga_specify_http_default, 'Automatically detect the http/https settings');
80
+ add_option('ga_google_token', '', 'The token used to authenticate with Google');
81
 
82
  // Create a option page for settings
83
  add_action('admin_init', 'ga_admin_init');
85
 
86
  // Initialize the options
87
  function ga_admin_init() {
88
+ # Load the localization information
89
+ $plugin_dir = basename(dirname(__FILE__));
90
+ load_plugin_textdomain('google-analyticator', 'wp-content/plugins/' . $plugin_dir . '/localizations', $plugin_dir . '/localizations');
91
+
92
  // Register out options so WordPress knows about them
93
  if ( function_exists('register_setting') ) {
94
  register_setting('google-analyticator', key_ga_status, '');
123
  function ga_filter_plugin_actions($links) {
124
  $new_links = array();
125
 
126
+ $new_links[] = '<a href="options-general.php?page=google-analyticator.php">' . __('Settings', 'google-analyticator') . '</a>';
127
 
128
  return array_merge($new_links, $links);
129
  }
135
  {
136
  if ( $file == plugin_basename(__FILE__) )
137
  {
138
+ $links[] = '<a href="http://plugins.spiralwebconsulting.com/forums/viewforum.php?f=5">' . __('FAQ', 'google-analyticator') . '</a>';
139
+ $links[] = '<a href="http://plugins.spiralwebconsulting.com/forums/viewforum.php?f=6">' . __('Support', 'google-analyticator') . '</a>';
140
+ $links[] = '<a href="http://plugins.spiralwebconsulting.com/analyticator.html#donate">' . __('Donate', 'google-analyticator') . '</a>';
141
  }
142
 
143
  return $links;
229
  if ( $ga_specify_http == '' )
230
  $ga_specify_http = 'auto';
231
  update_option(key_ga_specify_http, $ga_specify_http);
 
 
 
 
232
 
233
  // Give an updated message
234
+ echo "<div class='updated fade'><p><strong>" . __('Google Analyticator settings saved.', 'google-analyticator') . "</strong></p></div>";
235
  // }
236
  }
237
 
240
 
241
  <div class="wrap">
242
 
243
+ <h2><?php _e('Google Analyticator Settings', 'google-analyticator'); ?></h2>
244
 
245
  <div style="float: right;">
246
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
254
  <form method="post" action="options-general.php?page=google-analyticator.php">
255
 
256
  <p><em>
257
+ <?php _e('Google Analyticator is brought to you for free by <a href="http://spiralwebconsulting.com/">Spiral Web Consulting</a>. Spiral Web Consulting is a small web development firm specializing in PHP development. Visit our website to learn more, and don\'t hesitate to ask us to develop your next big WordPress plugin idea.', 'google-analyticator'); ?>
258
  </em></p>
259
 
260
+ <h3><?php _e('Basic Settings', 'google-analyticator'); ?></h3>
261
  <?php if (get_option(key_ga_status) == ga_disabled) { ?>
262
  <div style="margin:10px auto; border:3px #f00 solid; background-color:#fdd; color:#000; padding:10px; text-align:center;">
263
+ <?php _e('Google Analytics integration is currently <strong>DISABLED</strong>.', 'google-analyticator'); ?>
264
  </div>
265
  <?php } ?>
266
  <?php if ((get_option(key_ga_uid) == "XX-XXXXX-X") && (get_option(key_ga_status) != ga_disabled)) { ?>
267
  <div style="margin:10px auto; border:3px #f00 solid; background-color:#fdd; color:#000; padding:10px; text-align:center;">
268
+ <?php _e('Google Analytics integration is currently enabled, but you did not enter a UID. Tracking will not occur.', 'google-analyticator') ?>
269
  </div>
270
  <?php } ?>
271
  <table class="form-table" cellspacing="2" cellpadding="5" width="100%">
272
  <tr>
273
  <th width="30%" valign="top" style="padding-top: 10px;">
274
+ <label for="<?php echo key_ga_status ?>"><?php _e('Google Analytics logging is', 'google-analyticator'); ?>:</label>
275
  </th>
276
  <td>
277
  <?php
280
  echo "<option value='".ga_enabled."'";
281
  if(get_option(key_ga_status) == ga_enabled)
282
  echo " selected='selected'";
283
+ echo ">" . __('Enabled', 'google-analyticator') . "</option>\n";
284
 
285
  echo "<option value='".ga_disabled."'";
286
  if(get_option(key_ga_status) == ga_disabled)
287
  echo" selected='selected'";
288
+ echo ">" . __('Disabled', 'google-analyticator') . "</option>\n";
289
 
290
  echo "</select>\n";
291
  ?>
292
  </td>
293
  </tr>
294
+ <?php
295
+ # Get the list of accounts if available
296
+ $ga_accounts = ga_get_analytics_accounts();
297
+ ?>
298
  <tr>
299
+ <th width="30%" valign="top" style="padding-top: 10px;">
300
+ <label><?php _e('Authenticate with Google', 'google-analyticator'); ?>:</label>
301
  </th>
302
  <td>
303
+ <?php if ( get_option('ga_google_token') == '' ) { ?>
304
+ <p style="margin-top: 7px;"><a href="https://www.google.com/accounts/AuthSubRequest?&amp;next=<?php echo urlencode(admin_url('/options-general.php?page=google-analyticator.php')); ?>&amp;scope=https://www.google.com/analytics/feeds/&amp;secure=0&amp;session=1"><?php _e('Click here to login to Google, thus authenticating Google Analyticator with your Analytics account.', 'google-analyticator'); ?></a></p>
305
+ <?php } else { ?>
306
+ <p style="margin-top: 7px;"><?php _e('Currently authenticated with Google.', 'google-analyticator'); ?> <a href="https://www.google.com/accounts/AuthSubRequest?&amp;next=<?php echo urlencode(admin_url('/options-general.php?page=google-analyticator.php')); ?>&amp;scope=https://www.google.com/analytics/feeds/&amp;secure=0&amp;session=1"><?php _e('Click here to authenticate again.', 'google-analyticator'); ?></a></p>
307
+ <?php } ?>
308
+ <p style="margin: 5px 10px;" class="setting-description"><?php _e('Clicking the above link will authenticate Google Analyticator with Google. Authentication with Google is needed for use with the stats widget. In addition, authenticating will enable you to select your Analytics account through a drop-down instead of searching for your UID. If you are not going to use the stat widget, <strong>authenticating with Google is optional</strong>.', 'google-analyticator'); ?></p>
 
309
  </td>
310
  </tr>
311
+ <tr>
312
+ <?php
313
+
314
+ # If we have a accounts, create a list, if not, use input box
315
+ if ( $ga_accounts !== false ) :
316
+ ?>
317
+ <th valign="top" style="padding-top: 10px;">
318
+ <label for="<?php echo key_ga_uid; ?>"><?php _e('Google Analytics account', 'google-analyticator'); ?>:</label>
319
+ </th>
320
+ <td>
321
+ <?php
322
+ # Create a select box
323
+ echo '<select name="' . key_ga_uid . '" id="' . key_ga_uid . '">';
324
+ echo '<option value="XX-XXXXX-X">' . __('Select an Account', 'google-analyticator') . '</option>';
325
+
326
+ # The list of accounts
327
+ foreach ( $ga_accounts AS $account ) {
328
+ $select = ( get_option(key_ga_uid) == $account['ga:webPropertyId'] ) ? ' selected="selected"' : '';
329
+ echo '<option value="' . $account['ga:webPropertyId'] . '"' . $select . '>' . $account['title'] . '</option>';
330
+ }
331
+
332
+ # Close the select box
333
+ echo '</select>';
334
+ ?>
335
+ <p style="margin: 5px 10px;" class="setting-description"><?php _e('Select the Analytics account you wish to enable tracking for. An account must be selected for tracking to occur.', 'google-analyticator'); ?></p>
336
+ </td>
337
+ <?php else: ?>
338
+ <th valign="top" style="padding-top: 10px;">
339
+ <label for="<?php echo key_ga_uid; ?>"><?php _e('Google Analytics UID', 'google-analyticator'); ?>:</label>
340
+ </th>
341
+ <td>
342
+ <?php
343
+ echo "<input type='text' size='50' ";
344
+ echo "name='".key_ga_uid."' ";
345
+ echo "id='".key_ga_uid."' ";
346
+ echo "value='".get_option(key_ga_uid)."' />\n";
347
+ ?>
348
+ <p style="margin: 5px 10px;" class="setting-description"><?php _e('Enter your Google Analytics\' UID in this box (<a href="http://plugins.spiralwebconsulting.com/forums/viewtopic.php?f=5&amp;t=6">where can I find my UID?</a>). The UID is needed for Google Analytics to log your website stats. <strong>If you are having trouble finding your UID, authenticate with Google in the above field. After returning from Google, you will be able to select your account through a drop-down box.', 'google-analyticator'); ?></p>
349
+ </td>
350
+ <?php endif; ?>
351
+ </tr>
352
  </table>
353
+ <h3><?php _e('Advanced Settings', 'google-analyticator'); ?></h3>
354
  <table class="form-table" cellspacing="2" cellpadding="5" width="100%">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
355
  <tr>
356
  <th width="30%" valign="top" style="padding-top: 10px;">
357
+ <label for="<?php echo key_ga_admin ?>"><?php _e('WordPress admin logging', 'google-analyticator'); ?>:</label>
358
  </th>
359
  <td>
360
  <?php
363
  echo "<option value='".ga_enabled."'";
364
  if(get_option(key_ga_admin) == ga_enabled)
365
  echo " selected='selected'";
366
+ echo ">" . __('Enabled', 'google-analyticator') . "</option>\n";
367
 
368
  echo "<option value='".ga_disabled."'";
369
  if(get_option(key_ga_admin) == ga_disabled)
370
  echo" selected='selected'";
371
+ echo ">" . __('Disabled', 'google-analyticator') . "</option>\n";
372
 
373
  echo "</select>\n";
374
+
375
+ # Generate the user level box
376
+ $level = "<input type='text' size='2' ";
377
+ $level .= "name='".key_ga_admin_level."' ";
378
+ $level .= "id='".key_ga_admin_level."' ";
379
+ $level .= "value='".stripslashes(get_option(key_ga_admin_level))."' />\n";
380
+
381
+ # Output the current user level
382
  if ( current_user_can('level_10') )
383
+ $user = '10';
384
  elseif ( current_user_can('level_9') )
385
+ $user = '9';
386
  elseif ( current_user_can('level_8') )
387
+ $user = '8';
388
  elseif ( current_user_can('level_7') )
389
+ $user = '7';
390
  elseif ( current_user_can('level_6') )
391
+ $user = '6';
392
  elseif ( current_user_can('level_5') )
393
+ $user = '5';
394
  elseif ( current_user_can('level_4') )
395
+ $user = '4';
396
  elseif ( current_user_can('level_3') )
397
+ $user = '3';
398
  elseif ( current_user_can('level_2') )
399
+ $user = '2';
400
  elseif ( current_user_can('level_1') )
401
+ $user = '1';
402
  else
403
+ $user = '0';
404
+ ?>
405
+ <p style="margin: 5px 10px;" class="setting-description"><?php printf(__('Disabling this option will prevent all logged in WordPress admins from showing up on your Google Analytics reports. A WordPress admin is defined as a user with a level %s or higher. Your user level is %d.', 'google-analyticator'), $level, $user); ?></p>
406
  </td>
407
  </tr>
408
  <tr>
409
  <th width="30%" valign="top" style="padding-top: 10px;">
410
+ <label for="<?php echo key_ga_admin_disable ?>"><?php _e('Admin tracking disable method', 'google-analyticator'); ?>:</label>
411
  </th>
412
  <td>
413
  <?php
416
  echo "<option value='remove'";
417
  if(get_option(key_ga_admin_disable) == 'remove')
418
  echo " selected='selected'";
419
+ echo ">" . __('Remove', 'google-analyticator') . "</option>\n";
420
 
421
  echo "<option value='admin'";
422
  if(get_option(key_ga_admin_disable) == 'admin')
423
  echo" selected='selected'";
424
+ echo ">" . __('Use \'admin\' variable', 'google-analyticator') . "</option>\n";
425
 
426
  echo "</select>\n";
427
  ?>
428
+ <p style="margin: 5px 10px;" class="setting-description"><?php _e('Selecting the "Remove" option will physically remove the tracking code from logged in admin users. Selecting the "Use \'admin\' variable" option will assign a variable called \'admin\' to logged in admin users. This option will allow Google Analytics\' site overlay feature to work, but you will have to manually configure Google Analytics to exclude tracking from hits with the \'admin\' variable.', 'google-analyticator'); ?></p>
429
  </td>
430
  </tr>
431
  <tr>
432
  <th width="30%" valign="top" style="padding-top: 10px;">
433
+ <label for="<?php echo key_ga_footer ?>"><?php _e('Footer tracking code', 'google-analyticator'); ?>:</label>
434
  </th>
435
  <td>
436
  <?php
439
  echo "<option value='".ga_enabled."'";
440
  if(get_option(key_ga_footer) == ga_enabled)
441
  echo " selected='selected'";
442
+ echo ">" . __('Enabled', 'google-analyticator') . "</option>\n";
443
 
444
  echo "<option value='".ga_disabled."'";
445
  if(get_option(key_ga_footer) == ga_disabled)
446
  echo" selected='selected'";
447
+ echo ">" . __('Disabled', 'google-analyticator') . "</option>\n";
448
 
449
  echo "</select>\n";
450
  ?>
451
+ <p style="margin: 5px 10px;" class="setting-description"><?php _e('Enabling this option will insert the Google Analytics tracking code in your site\'s footer instead of your header. This will speed up your page loading if turned on. Not all themes support code in the footer, so if you turn this option on, be sure to check the Analytics code is still displayed on your site.', 'google-analyticator'); ?></p>
452
  </td>
453
  </tr>
454
  <tr>
455
  <th width="30%" valign="top" style="padding-top: 10px;">
456
+ <label for="<?php echo key_ga_outbound ?>"><?php _e('Outbound link tracking', 'google-analyticator'); ?>:</label>
457
  </th>
458
  <td>
459
  <?php
462
  echo "<option value='".ga_enabled."'";
463
  if(get_option(key_ga_outbound) == ga_enabled)
464
  echo " selected='selected'";
465
+ echo ">" . __('Enabled', 'google-analyticator') . "</option>\n";
466
 
467
  echo "<option value='".ga_disabled."'";
468
  if(get_option(key_ga_outbound) == ga_disabled)
469
  echo" selected='selected'";
470
+ echo ">" . __('Disabled', 'google-analyticator') . "</option>\n";
471
 
472
  echo "</select>\n";
473
  ?>
474
+ <p style="margin: 5px 10px;" class="setting-description"><?php _e('Disabling this option will turn off the tracking of outbound links. It\'s recommended not to disable this option unless you\'re a privacy advocate (now why would you be using Google Analytics in the first place?) or it\'s causing some kind of weird issue.', 'google-analyticator'); ?></p>
475
  </td>
476
  </tr>
477
  <tr>
478
  <th width="30%" valign="top" style="padding-top: 10px;">
479
+ <label for="<?php echo key_ga_event ?>"><?php _e('Event tracking', 'google-analyticator'); ?>:</label>
480
  </th>
481
  <td>
482
  <?php
485
  echo "<option value='".ga_enabled."'";
486
  if(get_option(key_ga_event) == ga_enabled)
487
  echo " selected='selected'";
488
+ echo ">" . __('Enabled', 'google-analyticator') . "</option>\n";
489
 
490
  echo "<option value='".ga_disabled."'";
491
  if(get_option(key_ga_event) == ga_disabled)
492
  echo" selected='selected'";
493
+ echo ">" . __('Disabled', 'google-analyticator') . "</option>\n";
494
 
495
  echo "</select>\n";
496
  ?>
497
+ <p style="margin: 5px 10px;" class="setting-description"><?php _e('Enabling this option will treat outbound links and downloads as events instead of pageviews. Since the introduction of <a href="http://code.google.com/apis/analytics/docs/tracking/eventTrackerOverview.html">event tracking in Analytics</a>, this is the recommended way to track these types of actions. Only disable this option if you must use the old pageview tracking method.', 'google-analyticator'); ?></p>
498
  </td>
499
  </tr>
500
  <tr>
501
  <th valign="top" style="padding-top: 10px;">
502
+ <label for="<?php echo key_ga_downloads; ?>"><?php _e('Download extensions to track', 'google-analyticator'); ?>:</label>
503
  </th>
504
  <td>
505
  <?php
508
  echo "id='".key_ga_downloads."' ";
509
  echo "value='".stripslashes(get_option(key_ga_downloads))."' />\n";
510
  ?>
511
+ <p style="margin: 5px 10px;" class="setting-description"><?php _e('Enter any extensions of files you would like to be tracked as a download. For example to track all MP3s and PDFs enter <strong>mp3,pdf</strong>. <em>Outbound link tracking must be enabled for downloads to be tracked.</em>', 'google-analyticator'); ?></p>
512
  </td>
513
  </tr>
514
  <tr>
515
  <th valign="top" style="padding-top: 10px;">
516
+ <label for="<?php echo key_ga_outbound_prefix; ?>"><?php _e('Prefix external links with', 'google-analyticator'); ?>:</label>
517
  </th>
518
  <td>
519
  <?php
522
  echo "id='".key_ga_outbound_prefix."' ";
523
  echo "value='".stripslashes(get_option(key_ga_outbound_prefix))."' />\n";
524
  ?>
525
+ <p style="margin: 5px 10px;" class="setting-description"><?php _e('Enter a name for the section tracked external links will appear under. This option has no effect if event tracking is enabled.', 'google-analyticator'); ?></em></p>
526
  </td>
527
  </tr>
528
  <tr>
529
  <th valign="top" style="padding-top: 10px;">
530
+ <label for="<?php echo key_ga_downloads_prefix; ?>"><?php _e('Prefix download links with', 'google-analyticator'); ?>:</label>
531
  </th>
532
  <td>
533
  <?php
536
  echo "id='".key_ga_download_sprefix."' ";
537
  echo "value='".stripslashes(get_option(key_ga_downloads_prefix))."' />\n";
538
  ?>
539
+ <p style="margin: 5px 10px;" class="setting-description"><?php _e('Enter a name for the section tracked download links will appear under. This option has no effect if event tracking is enabled.', 'google-analyticator'); ?></em></p>
540
  </td>
541
  </tr>
542
  <tr>
543
  <th valign="top" style="padding-top: 10px;">
544
+ <label for="<?php echo key_ga_adsense; ?>"><?php _e('Google Adsense ID', 'google-analyticator'); ?>:</label>
545
  </th>
546
  <td>
547
  <?php
550
  echo "id='".key_ga_adsense."' ";
551
  echo "value='".get_option(key_ga_adsense)."' />\n";
552
  ?>
553
+ <p style="margin: 5px 10px;" class="setting-description"><?php _e('Enter your Google Adsense ID assigned by Google Analytics in this box. This enables Analytics tracking of Adsense information if your Adsense and Analytics accounts are linked. Note: Google recommends the Analytics tracking code is placed in the header with this option enabled, however, a fix is included in this plugin. To follow the official specs, do not enable footer tracking.', 'google-analyticator'); ?></p>
554
  </td>
555
  </tr>
556
  <tr>
557
  <th valign="top" style="padding-top: 10px;">
558
+ <label for="<?php echo key_ga_extra; ?>"><?php _e('Additional tracking code', 'google-analyticator'); ?><br />(<?php _e('before tracker initialization', 'google-analyticator'); ?>):</label>
559
  </th>
560
  <td>
561
  <?php
564
  echo "id='".key_ga_extra."'>";
565
  echo stripslashes(get_option(key_ga_extra))."</textarea>\n";
566
  ?>
567
+ <p style="margin: 5px 10px;" class="setting-description"><?php _e('Enter any additional lines of tracking code that you would like to include in the Google Analytics tracking script. The code in this section will be displayed <strong>before</strong> the Google Analytics tracker is initialized. Read <a href="http://www.google.com/analytics/InstallingGATrackingCode.pdf">Google Analytics tracker manual</a> to learn what code goes here and how to use it.', 'google-analyticator'); ?></p>
568
  </td>
569
  </tr>
570
  <tr>
571
  <th valign="top" style="padding-top: 10px;">
572
+ <label for="<?php echo key_ga_extra_after; ?>"><?php _e('Additional tracking code', 'google-analyticator'); ?><br />(<?php _e('after tracker initialization', 'google-analyticator'); ?>):</label>
573
  </th>
574
  <td>
575
  <?php
578
  echo "id='".key_ga_extra_after."'>";
579
  echo stripslashes(get_option(key_ga_extra_after))."</textarea>\n";
580
  ?>
581
+ <p style="margin: 5px 10px;" class="setting-description"><?php _e('Enter any additional lines of tracking code that you would like to include in the Google Analytics tracking script. The code in this section will be displayed <strong>after</strong> the Google Analytics tracker is initialized. Read <a href="http://www.google.com/analytics/InstallingGATrackingCode.pdf">Google Analytics tracker manual</a> to learn what code goes here and how to use it.', 'google-analyticator'); ?></p>
582
  </td>
583
  </tr>
584
  <tr>
585
  <th width="30%" valign="top" style="padding-top: 10px;">
586
+ <label for="<?php echo key_ga_specify_http; ?>"><?php _e('Specify HTTP detection', 'google-analyticator'); ?>:</label>
587
  </th>
588
  <td>
589
  <?php
592
  echo "<option value='auto'";
593
  if(get_option(key_ga_specify_http) == 'auto')
594
  echo " selected='selected'";
595
+ echo ">" . __('Auto Detect', 'google-analyticator') . "</option>\n";
596
 
597
  echo "<option value='http'";
598
  if(get_option(key_ga_specify_http) == 'http')
599
  echo " selected='selected'";
600
+ echo ">" . __('HTTP', 'google-analyticator') . "</option>\n";
601
 
602
  echo "<option value='https'";
603
  if(get_option(key_ga_specify_http) == 'https')
604
  echo " selected='selected'";
605
+ echo ">" . __('HTTPS', 'google-analyticator') . "</option>\n";
606
 
607
  echo "</select>\n";
608
  ?>
609
+ <p style="margin: 5px 10px;" class="setting-description"><?php _e('Explicitly set the type of HTTP connection your website uses. Setting this option instead of relying on the auto detect may resolve the _gat is undefined error message.', 'google-analyticator'); ?></p>
610
  </td>
611
  </tr>
612
  </table>
613
  <p class="submit">
614
  <?php if ( function_exists('settings_fields') ) settings_fields('google-analyticator'); ?>
615
+ <input type="submit" name="info_update" value="<?php _e('Save Changes', 'google-analyticator'); ?>" />
616
  </p>
617
  </div>
618
  </form>
620
  <?php
621
  }
622
 
623
+ /**
624
+ * Checks if the WordPress API is a valid method for selecting an account
625
+ *
626
+ * @return a list of accounts if available, false if none available
627
+ **/
628
+ function ga_get_analytics_accounts()
629
+ {
630
+ $accounts = array();
631
+
632
+ # Get the class for interacting with the Google Analytics
633
+ require_once('class.analytics.stats.php');
634
+
635
+ # Create a new Gdata call
636
+ if ( isset($_GET['token']) )
637
+ $stats = new GoogleAnalyticsStats($_GET['token']);
638
+ else
639
+ $stats = new GoogleAnalyticsStats();
640
+
641
+ # Check if Google sucessfully logged in
642
+ if ( ! $stats->checkLogin() )
643
+ return false;
644
+
645
+ # Get a list of accounts
646
+ $accounts = $stats->getAnalyticsAccounts();
647
+
648
+ # Return the account array if there are accounts
649
+ if ( count($accounts) > 0 )
650
+ return $accounts;
651
+ else
652
+ return false;
653
+ }
654
+
655
  // Add the script
656
  $ga_in_footer = false;
657
  if (get_option(key_ga_footer) == ga_enabled) {
google-analytics-stats-widget.php CHANGED
@@ -9,9 +9,9 @@
9
  class GoogleStatsWidget extends WP_Widget
10
  {
11
  function GoogleStatsWidget() {
12
- $widget_ops = array('classname' => 'widget_google_stats', 'description' => __( "Displays Stat Info From Google Analytics") );
13
  $control_ops = array('width' => 400, 'height' => 400);
14
- $this->WP_Widget('googlestats', __('Google Analytics Stats'), $widget_ops, $control_ops);
15
  }
16
 
17
  function widget($args, $instance) {
@@ -34,7 +34,7 @@ class GoogleStatsWidget extends WP_Widget
34
  echo $before_title . $title . $after_title;
35
 
36
  # Make the stats chicklet
37
- echo '<!--Data gathered from last ' . number_format($timeFrame) . ' days using Google Analyticator -->';
38
  $this->initiateBackground($pageBg, $font);
39
  $this->beginWidget($font, $widgetBg);
40
  $this->widgetInfo($this->getUniqueVisitors($acnt, $timeFrame), $line1, $line2, $innerBg, $font);
@@ -75,49 +75,44 @@ class GoogleStatsWidget extends WP_Widget
75
 
76
  $accounts = array();
77
 
78
- # Check if a username has been set
79
- if ( get_option('google_stats_user') != '' ) {
80
-
81
- # Get the class for interacting with the Google Analytics
82
- require_once('class.analytics.stats.php');
83
-
84
- # Create a new Gdata call
85
- $stats = new GoogleAnalyticsStats(stripslashes(get_option('google_stats_user')), stripslashes(get_option('google_stats_password')), true);
86
-
87
- # Check if Google sucessfully logged in
88
- $login = $stats->checkLogin();
89
 
90
- # Get a list of accounts
91
- $accounts = $stats->getAnalyticsAccounts();
92
-
93
- }
 
94
 
95
  # Output the options
96
- echo '<p style="text-align:right;"><label for="' . $this->get_field_name('title') . '">' . __('Title:') . ' <input style="width: 250px;" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $title . '" /></label></p>';
97
  # The list of accounts
98
- echo '<p style="text-align:right;"><label for="' . $this->get_field_name('account') . '">' . __('Analytics account: ');
99
  echo '<select name="' . $this->get_field_name('account') . '" id="' . $this->get_field_id('account') . '" style="margin-top: -3px; margin-bottom: 10px;">';
100
  if ( count($accounts) > 0 )
101
  foreach ( $accounts AS $account ) { $select = ( $acnt == $account['id'] ) ? ' selected="selected"' : ''; echo '<option value="' . $account['id'] . '"' . $select . '>' . $account['title'] . '</option>'; }
102
  elseif ( $login == false )
103
- echo '<option value="">Wrong login. Set user/pass in settings.</option>';
104
  else
105
- echo '<option value="">No Analytics accounts available.</option>';
106
  echo '</select></label></p>';
107
  # Time frame
108
- echo '<p style="text-align:right;"><label for="' . $this->get_field_name('timeFrame') . '">' . __('Days of data to get:') . ' <input style="width: 150px;" id="' . $this->get_field_id('timeFrame') . '" name="' . $this->get_field_name('timeFrame') . '" type="text" value="' . $timeFrame . '" /></label></p>';
109
  # Page background
110
- echo '<p style="text-align:right;"><label for="' . $this->get_field_name('pageBg') . '">' . __('Page background:') . ' <input style="width: 150px;" id="' . $this->get_field_id('pageBg') . '" name="' . $this->get_field_name('pageBg') . '" type="text" value="' . $pageBg . '" /></label></p>';
111
  # Widget background
112
- echo '<p style="text-align:right;"><label for="' . $this->get_field_name('widgetBg') . '">' . __('Widget background:') . ' <input style="width: 150px;" id="' . $this->get_field_id('widgetBg') . '" name="' . $this->get_field_name('widgetBg') . '" type="text" value="' . $widgetBg . '" /></label></p>';
113
  # Inner background
114
- echo '<p style="text-align:right;"><label for="' . $this->get_field_name('innerBg') . '">' . __('Inner background:') . ' <input style="width: 150px;" id="' . $this->get_field_id('innerBg') . '" name="' . $this->get_field_name('innerBg') . '" type="text" value="' . $innerBg . '" /></label></p>';
115
  # Font color
116
- echo '<p style="text-align:right;"><label for="' . $this->get_field_name('font') . '">' . __('Font color:') . ' <input style="width: 150px;" id="' . $this->get_field_id('font') . '" name="' . $this->get_field_name('font') . '" type="text" value="' . $font . '" /></label></p>';
117
  # Text line 1
118
- echo '<p style="text-align:right;"><label for="' . $this->get_field_name('line1') . '">' . __('Line 1 text:') . ' <input style="width: 200px;" id="' . $this->get_field_id('line1') . '" name="' . $this->get_field_name('line1') . '" type="text" value="' . $line1 . '" /></label></p>';
119
  # Text line 2
120
- echo '<p style="text-align:right;"><label for="' . $this->get_field_name('line2') . '">' . __('Line 2 text:') . ' <input style="width: 200px;" id="' . $this->get_field_id('line2') . '" name="' . $this->get_field_name('line2') . '" type="text" value="' . $line2 . '" /></label></p>';
121
  }
122
 
123
  /**
@@ -214,7 +209,7 @@ class GoogleStatsWidget extends WP_Widget
214
  require_once('class.analytics.stats.php');
215
 
216
  # Create a new Gdata call
217
- $stats = new GoogleAnalyticsStats(stripslashes(get_option('google_stats_user')), stripslashes(get_option('google_stats_password')), true);
218
 
219
  # Set the account to the one requested
220
  $stats->setAccount($account);
9
  class GoogleStatsWidget extends WP_Widget
10
  {
11
  function GoogleStatsWidget() {
12
+ $widget_ops = array('classname' => 'widget_google_stats', 'description' => __("Displays Stat Info From Google Analytics", 'google-analyticator') );
13
  $control_ops = array('width' => 400, 'height' => 400);
14
+ $this->WP_Widget('googlestats', __('Google Analytics Stats', 'google-analyticator'), $widget_ops, $control_ops);
15
  }
16
 
17
  function widget($args, $instance) {
34
  echo $before_title . $title . $after_title;
35
 
36
  # Make the stats chicklet
37
+ echo '<!-- Data gathered from last ' . number_format($timeFrame) . ' days using Google Analyticator -->';
38
  $this->initiateBackground($pageBg, $font);
39
  $this->beginWidget($font, $widgetBg);
40
  $this->widgetInfo($this->getUniqueVisitors($acnt, $timeFrame), $line1, $line2, $innerBg, $font);
75
 
76
  $accounts = array();
77
 
78
+ # Get the class for interacting with the Google Analytics
79
+ require_once('class.analytics.stats.php');
80
+
81
+ # Create a new Gdata call
82
+ $stats = new GoogleAnalyticsStats();
 
 
 
 
 
 
83
 
84
+ # Check if Google sucessfully logged in
85
+ $login = $stats->checkLogin();
86
+
87
+ # Get a list of accounts
88
+ $accounts = $stats->getAnalyticsAccounts();
89
 
90
  # Output the options
91
+ echo '<p style="text-align:right;"><label for="' . $this->get_field_name('title') . '">' . __('Title', 'google-analyticator') . ': <input style="width: 250px;" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $title . '" /></label></p>';
92
  # The list of accounts
93
+ echo '<p style="text-align:right;"><label for="' . $this->get_field_name('account') . '">' . __('Analytics account', 'google-analyticator') . ': ';
94
  echo '<select name="' . $this->get_field_name('account') . '" id="' . $this->get_field_id('account') . '" style="margin-top: -3px; margin-bottom: 10px;">';
95
  if ( count($accounts) > 0 )
96
  foreach ( $accounts AS $account ) { $select = ( $acnt == $account['id'] ) ? ' selected="selected"' : ''; echo '<option value="' . $account['id'] . '"' . $select . '>' . $account['title'] . '</option>'; }
97
  elseif ( $login == false )
98
+ echo '<option value="">' . __('Authenticate on settings page.', 'google-analyticator') . '</option>';
99
  else
100
+ echo '<option value="">' . __('No Analytics accounts available.', 'google-analyticator') . '</option>';
101
  echo '</select></label></p>';
102
  # Time frame
103
+ echo '<p style="text-align:right;"><label for="' . $this->get_field_name('timeFrame') . '">' . __('Days of data to get', 'google-analyticator') . ': <input style="width: 150px;" id="' . $this->get_field_id('timeFrame') . '" name="' . $this->get_field_name('timeFrame') . '" type="text" value="' . $timeFrame . '" /></label></p>';
104
  # Page background
105
+ echo '<p style="text-align:right;"><label for="' . $this->get_field_name('pageBg') . '">' . __('Page background', 'google-analyticator') . ': <input style="width: 150px;" id="' . $this->get_field_id('pageBg') . '" name="' . $this->get_field_name('pageBg') . '" type="text" value="' . $pageBg . '" /></label></p>';
106
  # Widget background
107
+ echo '<p style="text-align:right;"><label for="' . $this->get_field_name('widgetBg') . '">' . __('Widget background', 'google-analyticator') . ': <input style="width: 150px;" id="' . $this->get_field_id('widgetBg') . '" name="' . $this->get_field_name('widgetBg') . '" type="text" value="' . $widgetBg . '" /></label></p>';
108
  # Inner background
109
+ echo '<p style="text-align:right;"><label for="' . $this->get_field_name('innerBg') . '">' . __('Inner background', 'google-analyticator') . ': <input style="width: 150px;" id="' . $this->get_field_id('innerBg') . '" name="' . $this->get_field_name('innerBg') . '" type="text" value="' . $innerBg . '" /></label></p>';
110
  # Font color
111
+ echo '<p style="text-align:right;"><label for="' . $this->get_field_name('font') . '">' . __('Font color', 'google-analyticator') . ': <input style="width: 150px;" id="' . $this->get_field_id('font') . '" name="' . $this->get_field_name('font') . '" type="text" value="' . $font . '" /></label></p>';
112
  # Text line 1
113
+ echo '<p style="text-align:right;"><label for="' . $this->get_field_name('line1') . '">' . __('Line 1 text', 'google-analyticator') . ': <input style="width: 200px;" id="' . $this->get_field_id('line1') . '" name="' . $this->get_field_name('line1') . '" type="text" value="' . $line1 . '" /></label></p>';
114
  # Text line 2
115
+ echo '<p style="text-align:right;"><label for="' . $this->get_field_name('line2') . '">' . __('Line 2 text', 'google-analyticator') . ': <input style="width: 200px;" id="' . $this->get_field_id('line2') . '" name="' . $this->get_field_name('line2') . '" type="text" value="' . $line2 . '" /></label></p>';
116
  }
117
 
118
  /**
209
  require_once('class.analytics.stats.php');
210
 
211
  # Create a new Gdata call
212
+ $stats = new GoogleAnalyticsStats();
213
 
214
  # Set the account to the one requested
215
  $stats->setAccount($account);
google-analytics-stats.php CHANGED
@@ -42,7 +42,7 @@ class GoogleStatsWidget
42
  echo $before_title . $options['title'] . $after_title;
43
 
44
  # Make the stats chicklet
45
- echo '<!--Data gathered from last ' . number_format($options['timeFrame']) . ' days using Google Analyticator -->';
46
  $this->initiateBackground($options['pageBg'], $options['font']);
47
  $this->beginWidget($options['font'], $options['widgetBg']);
48
  $this->widgetInfo($this->getUniqueVisitors($options['account'], $options['timeFrame']), $options['line1'], $options['line2'], $options['innerBg'], $options['font']);
@@ -111,24 +111,19 @@ class GoogleStatsWidget
111
 
112
  $accounts = array();
113
 
114
- # Check if a username has been set
115
- if ( get_option('google_stats_user') != '' ) {
116
-
117
- # Get the class for interacting with the Google Analytics
118
- require_once('class.analytics.stats.php');
119
-
120
- # Create a new Gdata call
121
- $stats = new GoogleAnalyticsStats(stripslashes(get_option('google_stats_user')), stripslashes(get_option('google_stats_password')), true);
122
-
123
- # Get a list of accounts
124
- $accounts = $stats->getAnalyticsAccounts();
125
-
126
- }
127
-
128
  # Output the options
129
- echo '<p style="text-align:right;"><label for="google_stats_title">' . __('Title:') . ' <input style="width: 250px;" id="google_stats_title" name="google_stats_title" type="text" value="' . $title . '" /></label></p>';
130
  # The list of accounts
131
- echo '<p style="text-align:right;"><label for="google_stats_account">' . __('Analytics account: ');
132
  echo '<select name="google_stats_account" style="margin-top: -3px; margin-bottom: 10px;">';
133
  if ( count($accounts) > 0 )
134
  foreach ( $accounts AS $account ) { $select = ( $acnt == $account['id'] ) ? ' selected="selected"' : ''; echo '<option value="' . $account['id'] . '"' . $select . '>' . $account['title'] . '</option>'; }
@@ -136,19 +131,19 @@ class GoogleStatsWidget
136
  echo '<option value="">No accounts. Set user/pass in settings.</option>';
137
  echo '</select>';
138
  # Time frame
139
- echo '<p style="text-align:right;"><label for="google_stats_timeFrame">' . __('Days of data to get:') . ' <input style="width: 150px;" id="google_stats_timeFrame" name="google_stats_timeFrame" type="text" value="' . $timeFrame . '" /></label></p>';
140
  # Page background
141
- echo '<p style="text-align:right;"><label for="google_stats_pageBg">' . __('Page background:') . ' <input style="width: 150px;" id="google_stats_pageBg" name="google_stats_pageBg" type="text" value="' . $pageBg . '" /></label></p>';
142
  # Widget background
143
- echo '<p style="text-align:right;"><label for="google_stats_widgetBg">' . __('Widget background:') . ' <input style="width: 150px;" id="google_stats_widgetBg" name="google_stats_widgetBg" type="text" value="' . $widgetBg . '" /></label></p>';
144
  # Inner background
145
- echo '<p style="text-align:right;"><label for="google_stats_innerBg">' . __('Inner background:') . ' <input style="width: 150px;" id="google_stats_innerBg" name="google_stats_innerBg" type="text" value="' . $innerBg . '" /></label></p>';
146
  # Font color
147
- echo '<p style="text-align:right;"><label for="google_stats_font">' . __('Font color:') . ' <input style="width: 150px;" id="google_stats_font" name="google_stats_font" type="text" value="' . $font . '" /></label></p>';
148
  # Text line 1
149
- echo '<p style="text-align:right;"><label for="google_stats_line1">' . __('Line 1 text:') . ' <input style="width: 200px;" id="google_stats_line1" name="google_stats_line1" type="text" value="' . $line1 . '" /></label></p>';
150
  # Text line 2
151
- echo '<p style="text-align:right;"><label for="google_stats_line2">' . __('Line 2 text:') . ' <input style="width: 200px;" id="google_stats_line2" name="google_stats_line2" type="text" value="' . $line2 . '" /></label></p>';
152
  # Mark the form as updated
153
  echo '<input type="hidden" id="google-stats-submit" name="google-stats-submit" value="1" />';
154
  }
@@ -247,7 +242,7 @@ class GoogleStatsWidget
247
  require_once('class.analytics.stats.php');
248
 
249
  # Create a new Gdata call
250
- $stats = new GoogleAnalyticsStats(stripslashes(get_option('google_stats_user')), stripslashes(get_option('google_stats_password')), true);
251
 
252
  # Set the account to the one requested
253
  $stats->setAccount($account);
42
  echo $before_title . $options['title'] . $after_title;
43
 
44
  # Make the stats chicklet
45
+ echo '<!-- Data gathered from last ' . number_format($options['timeFrame']) . ' days using Google Analyticator -->';
46
  $this->initiateBackground($options['pageBg'], $options['font']);
47
  $this->beginWidget($options['font'], $options['widgetBg']);
48
  $this->widgetInfo($this->getUniqueVisitors($options['account'], $options['timeFrame']), $options['line1'], $options['line2'], $options['innerBg'], $options['font']);
111
 
112
  $accounts = array();
113
 
114
+ # Get the class for interacting with the Google Analytics
115
+ require_once('class.analytics.stats.php');
116
+
117
+ # Create a new Gdata call
118
+ $stats = new GoogleAnalyticsStats();
119
+
120
+ # Get a list of accounts
121
+ $accounts = $stats->getAnalyticsAccounts();
122
+
 
 
 
 
 
123
  # Output the options
124
+ echo '<p style="text-align:right;"><label for="google_stats_title">' . __('Title', 'google-analyticator') . ': <input style="width: 250px;" id="google_stats_title" name="google_stats_title" type="text" value="' . $title . '" /></label></p>';
125
  # The list of accounts
126
+ echo '<p style="text-align:right;"><label for="google_stats_account">' . __('Analytics account', 'google-analyticator') . ': ';
127
  echo '<select name="google_stats_account" style="margin-top: -3px; margin-bottom: 10px;">';
128
  if ( count($accounts) > 0 )
129
  foreach ( $accounts AS $account ) { $select = ( $acnt == $account['id'] ) ? ' selected="selected"' : ''; echo '<option value="' . $account['id'] . '"' . $select . '>' . $account['title'] . '</option>'; }
131
  echo '<option value="">No accounts. Set user/pass in settings.</option>';
132
  echo '</select>';
133
  # Time frame
134
+ echo '<p style="text-align:right;"><label for="google_stats_timeFrame">' . __('Days of data to get', 'google-analyticator') . ': <input style="width: 150px;" id="google_stats_timeFrame" name="google_stats_timeFrame" type="text" value="' . $timeFrame . '" /></label></p>';
135
  # Page background
136
+ echo '<p style="text-align:right;"><label for="google_stats_pageBg">' . __('Page background', 'google-analyticator') . ': <input style="width: 150px;" id="google_stats_pageBg" name="google_stats_pageBg" type="text" value="' . $pageBg . '" /></label></p>';
137
  # Widget background
138
+ echo '<p style="text-align:right;"><label for="google_stats_widgetBg">' . __('Widget background', 'google-analyticator') . ': <input style="width: 150px;" id="google_stats_widgetBg" name="google_stats_widgetBg" type="text" value="' . $widgetBg . '" /></label></p>';
139
  # Inner background
140
+ echo '<p style="text-align:right;"><label for="google_stats_innerBg">' . __('Inner background', 'google-analyticator') . ': <input style="width: 150px;" id="google_stats_innerBg" name="google_stats_innerBg" type="text" value="' . $innerBg . '" /></label></p>';
141
  # Font color
142
+ echo '<p style="text-align:right;"><label for="google_stats_font">' . __('Font color', 'google-analyticator') . ': <input style="width: 150px;" id="google_stats_font" name="google_stats_font" type="text" value="' . $font . '" /></label></p>';
143
  # Text line 1
144
+ echo '<p style="text-align:right;"><label for="google_stats_line1">' . __('Line 1 text', 'google-analyticator') . ': <input style="width: 200px;" id="google_stats_line1" name="google_stats_line1" type="text" value="' . $line1 . '" /></label></p>';
145
  # Text line 2
146
+ echo '<p style="text-align:right;"><label for="google_stats_line2">' . __('Line 2 text', 'google-analyticator') . ': <input style="width: 200px;" id="google_stats_line2" name="google_stats_line2" type="text" value="' . $line2 . '" /></label></p>';
147
  # Mark the form as updated
148
  echo '<input type="hidden" id="google-stats-submit" name="google-stats-submit" value="1" />';
149
  }
242
  require_once('class.analytics.stats.php');
243
 
244
  # Create a new Gdata call
245
+ $stats = new GoogleAnalyticsStats();
246
 
247
  # Set the account to the one requested
248
  $stats->setAccount($account);
google-analytics-summary-widget.php ADDED
@@ -0,0 +1,457 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Creates a summary widget for Google Analytics stats
5
+ *
6
+ * @author Spiral Web Consulting
7
+ **/
8
+ class GoogleAnalyticsSummary
9
+ {
10
+ var $api = false;
11
+ var $id = false;
12
+
13
+ /**
14
+ * Start the process of including the widget
15
+ **/
16
+ function GoogleAnalyticsSummary()
17
+ {
18
+ add_action('wp_dashboard_setup', array($this, 'addDashboardWidget'));
19
+ add_action('admin_print_scripts-index.php', array($this, 'addJavascript'));
20
+ add_action('admin_head-index.php', array($this, 'addTopJs'));
21
+ }
22
+
23
+ /**
24
+ * Add the widget to the dashboard
25
+ **/
26
+ function addDashboardWidget()
27
+ {
28
+ # Attempt to login and get the current account
29
+ $this->id = $this->getAnalyticsAccount();
30
+ $this->api->setAccount($this->id);
31
+
32
+ wp_add_dashboard_widget('google-analytics-summary', 'Google Analytics Summary', array($this, 'widget'));
33
+ }
34
+
35
+ /**
36
+ * Add the scripts to the admin
37
+ **/
38
+ function addJavascript()
39
+ {
40
+ # Include the Sparklines graphing library
41
+ wp_enqueue_script('jquery-sparklines', plugins_url('/google-analyticator/jquery.sparkline.min.js'), array('jquery'), '1.4.2');
42
+ }
43
+
44
+ /**
45
+ * Add the Javascript to the top
46
+ **/
47
+ function addTopJs()
48
+ {
49
+ ?>
50
+ <script type="text/javascript">
51
+
52
+ jQuery(document).ready(function(){
53
+
54
+ if ( navigator.appName != 'Microsoft Internet Explorer' ) {
55
+
56
+ jQuery('.ga_visits').sparkline(ga_visits, { type:'line', width:'100%', height:'75px', lineColor:'#aaa', fillColor:'#f0f0f0', spotColor:false, minSpotColor:false, maxSpotColor:false, chartRangeMin:0 });
57
+
58
+ } else {
59
+
60
+ // Hide the widget graph
61
+ jQuery('.ga_visits_title').remove();
62
+ jQuery('.ga_visits').remove();
63
+
64
+ }
65
+
66
+ });
67
+
68
+ </script>
69
+ <?php
70
+ }
71
+
72
+ /**
73
+ * The widget display
74
+ **/
75
+ function widget()
76
+ {
77
+ # Check that we can display the widget before continuing
78
+ if ( $this->id == false ) {
79
+ # Output error message
80
+ echo '<p>' . __('No Analytics account selected. Double check you are authenticated with Google on Google Analyticator\'s settings page and make sure an account is selected.', 'google-analyticator') . '</p>';
81
+
82
+ # Add Javascript variable to prevent breaking the Javascript
83
+ echo '<script type="text/javascript">var ga_visits = [];</script>';
84
+
85
+ return false;
86
+ }
87
+
88
+ # Add the header information for the visits graph
89
+ echo '<p class="ga_visits_title" style="font-style: italic; font-family: Georgia, \'Times New Roman\', \'Bitstream Charter\', Times, serif; margin-top: -5px; color: #777; font-size: 13px;">' . __('Visits Over the Past 30 Days', 'google-analyticator') . '</p>';
90
+
91
+ # Add the sparkline for the past 30 days
92
+ $this->getVisitsGraph();
93
+
94
+ # Add the summary header
95
+ echo '<p style="font-style: italic; font-family: Georgia, \'Times New Roman\', \'Bitstream Charter\', Times, serif; color: #777; font-size: 13px;">' . __('Site Usage', 'google-analyticator') . '</p>';
96
+
97
+ # Add the visitor summary
98
+ $this->getSiteUsage();
99
+
100
+ # Add the top 5 posts header
101
+ echo '<p style="font-style: italic; font-family: Georgia, \'Times New Roman\', \'Bitstream Charter\', Times, serif; color: #777; font-size: 13px;">' . __('Top Pages', 'google-analyticator') . '</p>';
102
+
103
+ # Add the top 5 posts
104
+ $this->getTopPages();
105
+
106
+ # Add the tab information
107
+ echo '<table width="100%"><tr><td width="50%" valign="top">';
108
+
109
+ # Add the top 5 referrers header
110
+ echo '<p style="font-style: italic; font-family: Georgia, \'Times New Roman\', \'Bitstream Charter\', Times, serif; color: #777; font-size: 13px;">' . __('Top Referrers', 'google-analyticator') . '</p>';
111
+
112
+ # Add the referrer information
113
+ $this->getTopReferrers();
114
+
115
+ # Add the second column
116
+ echo '</td><td valign="top">';
117
+
118
+ # Add the top 5 search header
119
+ echo '<p style="font-style: italic; font-family: Georgia, \'Times New Roman\', \'Bitstream Charter\', Times, serif; color: #777; font-size: 13px;">' . __('Top Searches', 'google-analyticator') . '</p>';
120
+
121
+ # Add the search information
122
+ $this->getTopSearches();
123
+
124
+ # Close the table
125
+ echo '</td></tr></table>';
126
+ }
127
+
128
+ /**
129
+ * Get the current analytics account
130
+ *
131
+ * @return the analytics account
132
+ **/
133
+ function getAnalyticsAccount()
134
+ {
135
+ $accounts = array();
136
+
137
+ # Get the class for interacting with the Google Analytics
138
+ require_once('class.analytics.stats.php');
139
+
140
+ # Create a new Gdata call
141
+ $this->api = new GoogleAnalyticsStats();
142
+
143
+ # Check if Google sucessfully logged in
144
+ if ( ! $this->api->checkLogin() )
145
+ return false;
146
+
147
+ # Get a list of accounts
148
+ $accounts = $this->api->getAnalyticsAccounts();
149
+
150
+ # Check if we have a list of accounts
151
+ if ( count($accounts) <= 0 )
152
+ return false;
153
+
154
+ # Loop throught the account and return the current account
155
+ foreach ( $accounts AS $account ) {
156
+
157
+ # Check if the UID matches the selected UID
158
+ if ( $account['ga:webPropertyId'] == get_option('ga_uid') )
159
+ return $account['id'];
160
+
161
+ }
162
+
163
+ return false;
164
+ }
165
+
166
+ /**
167
+ * Get the visitors graph
168
+ **/
169
+ function getVisitsGraph()
170
+ {
171
+ # Get the value from the database
172
+ $cached = unserialize(get_option('google_stats_visitsGraph_' . $this->id));
173
+ $updated = false;
174
+
175
+ # Check if the call has been made before
176
+ if ( is_array($cached) ) {
177
+
178
+ # Check if the last time called was within two hours, if so, mark to not retrieve and grab the stats array
179
+ if ( $cached['lastcalled'] > ( time() - 7200 ) ) {
180
+ $updated = true;
181
+ $stats = $cached['stats'];
182
+ }
183
+
184
+ }
185
+
186
+ # If the stats need to be updated
187
+ if ( ! $updated ) {
188
+
189
+ # Get the metrics needed to build the visits graph
190
+ $before = date('Y-m-d', strtotime('-31 days'));
191
+ $yesterday = date('Y-m-d', strtotime('-1 day'));
192
+ $stats = $this->api->getMetrics('ga:visits', $before, $yesterday, 'ga:date', 'ga:date');
193
+
194
+ # Store the serialized stats in the database
195
+ $newStats = serialize(array('stats'=>$stats, 'lastcalled'=>time()));
196
+ update_option('google_stats_visitsGraph_' . $this->id, $newStats);
197
+
198
+ }
199
+
200
+ # Create a list of the data points for graphing
201
+ $data = '';
202
+ $max = 0;
203
+ foreach ( $stats AS $stat ) {
204
+ $data .= $stat['ga:visits'] . ',';
205
+
206
+ # Update the max value if greater
207
+ if ( $max < $stat['ga:visits'] )
208
+ $max = $stat['ga:visits'];
209
+ }
210
+
211
+ # Shorten the string to remove the last comma
212
+ $data = substr($data, 0, -1);
213
+
214
+ # Output the graph
215
+ echo '<script type="text/javascript">var ga_visits = [' . $data . '];</script>';
216
+ echo '<span class="ga_visits" title="' . sprintf(__('The most visits on a single day was %d. Yesterday there were %d visits.', 'google-analyticator'), $max, $stat['ga:visits']) . '"></span>';
217
+ }
218
+
219
+ /**
220
+ * Get the site usage
221
+ **/
222
+ function getSiteUsage()
223
+ {
224
+ # Get the value from the database
225
+ $cached = unserialize(get_option('google_stats_siteUsage_' . $this->id));
226
+ $updated = false;
227
+
228
+ # Check if the call has been made before
229
+ if ( is_array($cached) ) {
230
+
231
+ # Check if the last time called was within two hours, if so, mark to not retrieve and grab the stats array
232
+ if ( $cached['lastcalled'] > ( time() - 7200 ) ) {
233
+ $updated = true;
234
+ $stats = $cached['stats'];
235
+ }
236
+
237
+ }
238
+
239
+ # If the stats need to be updated
240
+ if ( ! $updated ) {
241
+
242
+ # Get the metrics needed to build the usage table
243
+ $before = date('Y-m-d', strtotime('-31 days'));
244
+ $yesterday = date('Y-m-d', strtotime('-1 day'));
245
+ $stats = $this->api->getMetrics('ga:visits,ga:bounces,ga:entrances,ga:pageviews,ga:timeOnSite,ga:newVisits', $before, $yesterday);
246
+
247
+ # Store the serialized stats in the database
248
+ $newStats = serialize(array('stats'=>$stats, 'lastcalled'=>time()));
249
+ update_option('google_stats_siteUsage_' . $this->id, $newStats);
250
+
251
+ }
252
+
253
+ # Create the site usage table
254
+ ?>
255
+ <table width="100%">
256
+ <tr>
257
+ <td width=""><strong><?php echo number_format($stats[0]['ga:visits']); ?></strong></td>
258
+ <td width=""><?php _e('Visits', 'google-analyticator'); ?></td>
259
+ <td width="20%"><strong><?php echo number_format(round(($stats[0]['ga:bounces']/$stats[0]['ga:entrances'])*100, 2), 2); ?>%</strong></td>
260
+ <td width="30%"><?php _e('Bounce Rate', 'google-analyticator'); ?></td>
261
+ </tr>
262
+ <tr>
263
+ <td><strong><?php echo number_format($stats[0]['ga:pageviews']); ?></strong></td>
264
+ <td><?php _e('Pageviews', 'google-analyticator'); ?></td>
265
+ <td><strong><?php echo $this->sec2Time($stats[0]['ga:timeOnSite']/$stats[0]['ga:visits']); ?></strong></td>
266
+ <td><?php _e('Avg. Time on Site', 'google-analyticator'); ?></td>
267
+ </tr>
268
+ <tr>
269
+ <td><strong><?php echo number_format(round($stats[0]['ga:pageviews']/$stats[0]['ga:visits'], 2), 2); ?></strong></td>
270
+ <td><?php _e('Pages/Visit', 'google-analyticator'); ?></td>
271
+ <td><strong><?php echo number_format(round(($stats[0]['ga:newVisits']/$stats[0]['ga:visits'])*100, 2), 2); ?>%</strong></td>
272
+ <td><?php _e('% New Visits', 'google-analyticator'); ?></td>
273
+ </tr>
274
+ </table>
275
+ <?php
276
+ }
277
+
278
+ /**
279
+ * Get the top pages
280
+ **/
281
+ function getTopPages()
282
+ {
283
+ # Get the value from the database
284
+ $cached = unserialize(get_option('google_stats_topPages_' . $this->id));
285
+ $updated = false;
286
+
287
+ # Check if the call has been made before
288
+ if ( is_array($cached) ) {
289
+
290
+ # Check if the last time called was within two hours, if so, mark to not retrieve and grab the stats array
291
+ if ( $cached['lastcalled'] > ( time() - 7200 ) ) {
292
+ $updated = true;
293
+ $stats = $cached['stats'];
294
+ }
295
+
296
+ }
297
+
298
+ # If the stats need to be updated
299
+ if ( ! $updated ) {
300
+
301
+ # Get the metrics needed to build the top pages
302
+ $before = date('Y-m-d', strtotime('-31 days'));
303
+ $yesterday = date('Y-m-d', strtotime('-1 day'));
304
+ $stats = $this->api->getMetrics('ga:pageviews', $before, $yesterday, 'ga:pageTitle,ga:pagePath', '-ga:pageviews', 'ga:pagePath!%3D%2F', '5');
305
+
306
+ # Store the serialized stats in the database
307
+ $newStats = serialize(array('stats'=>$stats, 'lastcalled'=>time()));
308
+ update_option('google_stats_topPages_' . $this->id, $newStats);
309
+
310
+ }
311
+
312
+ # Build the top pages list
313
+ echo '<ol>';
314
+
315
+ # Loop through each stat
316
+ foreach ( $stats AS $stat ) {
317
+ echo '<li><a href="' . $stat['ga:pagePath'] . '">' . $stat['ga:pageTitle'] . '</a> - ' . number_format($stat['ga:pageviews']) . ' ' . __('Views', 'google-analyticator') . '</li>';
318
+ }
319
+
320
+ # Finish the list
321
+ echo '</ol>';
322
+ }
323
+
324
+ /**
325
+ * Get the top referrers
326
+ **/
327
+ function getTopReferrers()
328
+ {
329
+ # Get the value from the database
330
+ $cached = unserialize(get_option('google_stats_topReferrers_' . $this->id));
331
+ $updated = false;
332
+
333
+ # Check if the call has been made before
334
+ if ( is_array($cached) ) {
335
+
336
+ # Check if the last time called was within two hours, if so, mark to not retrieve and grab the stats array
337
+ if ( $cached['lastcalled'] > ( time() - 7200 ) ) {
338
+ $updated = true;
339
+ $stats = $cached['stats'];
340
+ }
341
+
342
+ }
343
+
344
+ # If the stats need to be updated
345
+ if ( ! $updated ) {
346
+
347
+ # Get the metrics needed to build the top referrers
348
+ $before = date('Y-m-d', strtotime('-31 days'));
349
+ $yesterday = date('Y-m-d', strtotime('-1 day'));
350
+ $stats = $this->api->getMetrics('ga:visits', $before, $yesterday, 'ga:source,ga:medium', '-ga:visits', 'ga:medium%3D%3Dreferral', '5');
351
+
352
+ # Store the serialized stats in the database
353
+ $newStats = serialize(array('stats'=>$stats, 'lastcalled'=>time()));
354
+ update_option('google_stats_topReferrers_' . $this->id, $newStats);
355
+
356
+ }
357
+
358
+ # Build the top pages list
359
+ echo '<ol>';
360
+
361
+ # Loop through each stat
362
+ foreach ( $stats AS $stat ) {
363
+ echo '<li><strong>' . $stat['ga:source'] . '</strong> - ' . number_format($stat['ga:visits']) . ' ' . __('Visits', 'google-analyticator') . '</li>';
364
+ }
365
+
366
+ # Finish the list
367
+ echo '</ol>';
368
+ }
369
+
370
+ /**
371
+ * Get the top searches
372
+ **/
373
+ function getTopSearches()
374
+ {
375
+ # Get the value from the database
376
+ $cached = unserialize(get_option('google_stats_topSearches_' . $this->id));
377
+ $updated = false;
378
+
379
+ # Check if the call has been made before
380
+ if ( is_array($cached) ) {
381
+
382
+ # Check if the last time called was within two hours, if so, mark to not retrieve and grab the stats array
383
+ if ( $cached['lastcalled'] > ( time() - 7200 ) ) {
384
+ $updated = true;
385
+ $stats = $cached['stats'];
386
+ }
387
+
388
+ }
389
+
390
+ # If the stats need to be updated
391
+ if ( ! $updated ) {
392
+
393
+ # Get the metrics needed to build the top searches
394
+ $before = date('Y-m-d', strtotime('-31 days'));
395
+ $yesterday = date('Y-m-d', strtotime('-1 day'));
396
+ $stats = $this->api->getMetrics('ga:visits', $before, $yesterday, 'ga:keyword', '-ga:visits', 'ga:keyword!%3D(not%20set)', '5');
397
+
398
+ # Store the serialized stats in the database
399
+ $newStats = serialize(array('stats'=>$stats, 'lastcalled'=>time()));
400
+ update_option('google_stats_topSearches_' . $this->id, $newStats);
401
+
402
+ }
403
+
404
+ # Build the top pages list
405
+ echo '<ol>';
406
+
407
+ # Loop through each stat
408
+ foreach ( $stats AS $stat ) {
409
+ echo '<li><strong>' . $stat['ga:keyword'] . '</strong> - ' . number_format($stat['ga:visits']) . ' ' . __('Visits', 'google-analyticator') . '</li>';
410
+ }
411
+
412
+ # Finish the list
413
+ echo '</ol>';
414
+ }
415
+
416
+ /**
417
+ * Convert second to a time format
418
+ **/
419
+ function sec2Time($time)
420
+ {
421
+ # Check if numeric
422
+ if ( is_numeric($time) ) {
423
+ $value = array(
424
+ "years" => '00',
425
+ "days" => '00',
426
+ "hours" => '00',
427
+ "minutes" => '00',
428
+ "seconds" => '00'
429
+ );
430
+ if ( $time >= 31556926 ) {
431
+ $value["years"] = floor($time/31556926);
432
+ $time = ($time%31556926);
433
+ }
434
+ if ( $time >= 86400 ) {
435
+ $value["days"] = floor($time/86400);
436
+ $time = ($time%86400);
437
+ }
438
+ if ( $time >= 3600 ) {
439
+ $value["hours"] = str_pad(floor($time/3600), 2, 0, STR_PAD_LEFT);
440
+ $time = ($time%3600);
441
+ }
442
+ if ( $time >= 60 ) {
443
+ $value["minutes"] = str_pad(floor($time/60), 2, 0, STR_PAD_LEFT);
444
+ $time = ($time%60);
445
+ }
446
+ $value["seconds"] = str_pad(floor($time), 2, 0, STR_PAD_LEFT);
447
+
448
+ # Get the hour:minute:second version
449
+ return $value['hours'] . ':' . $value['minutes'] . ':' . $value['seconds'];
450
+ } else {
451
+ return false;
452
+ }
453
+ }
454
+
455
+ } // END class
456
+
457
+ ?>
jquery.sparkline.min.js ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* jquery.sparkline 1.4.2 - http://omnipotent.net/jquery.sparkline/ */
2
+
3
+ (function($){$.fn.simpledraw=function(width,height,use_existing){if(use_existing&&this[0].vcanvas)return this[0].vcanvas;if(width==undefined)width=$(this).innerWidth();if(height==undefined)height=$(this).innerHeight();if($.browser.hasCanvas){return new vcanvas_canvas(width,height,this);}else if($.browser.msie){return new vcanvas_vml(width,height,this);}else{return false;}};var pending=[];$.fn.sparkline=function(uservalues,options){var options=$.extend({type:'line',lineColor:'#00f',fillColor:'#cdf',defaultPixelsPerValue:3,width:'auto',height:'auto',composite:false},options?options:{});return this.each(function(){var render=function(){var values=(uservalues=='html'||uservalues==undefined)?$(this).text().split(','):uservalues;var width=options.width=='auto'?values.length*options.defaultPixelsPerValue:options.width;if(options.height=='auto'){if(!options.composite||!this.vcanvas){var tmp=document.createElement('span');tmp.innerHTML='a';$(this).html(tmp);height=$(tmp).innerHeight();$(tmp).remove();}}else{height=options.height;}
4
+ $.fn.sparkline[options.type].call(this,values,options,width,height);}
5
+ if(($(this).html()&&$(this).is(':hidden'))||($.fn.jquery<"1.3.0"&&$(this).parents().is(':hidden'))){pending.push([this,render]);}else{render.call(this);}});};$.sparkline_display_visible=function(){for(var i=pending.length-1;i>=0;i--){var el=pending[i][0];if($(el).is(':visible')&&!$(el).parents().is(':hidden')){pending[i][1].call(el);pending.splice(i,1);}}};$.fn.sparkline.line=function(values,options,width,height){var options=$.extend({spotColor:'#f80',spotRadius:1.5,minSpotColor:'#f80',maxSpotColor:'#f80',normalRangeMin:undefined,normalRangeMax:undefined,normalRangeColor:'#ccc',chartRangeMin:undefined,chartRangeMax:undefined},options?options:{});var xvalues=[],yvalues=[];for(i=0;i<values.length;i++){var isstr=typeof(values[i])=='string';var isarray=typeof(values[i])=='object'&&values[i]instanceof Array;var sp=isstr&&values[i].split(':');if(isstr&&sp.length==2){xvalues.push(Number(sp[0]));yvalues.push(Number(sp[1]));}else if(isarray){xvalues.push(values[i][0]);yvalues.push(values[i][1]);}else{xvalues.push(i);yvalues.push(Number(values[i]));}}
6
+ if(options.xvalues){xvalues=options.xvalues;}
7
+ var maxy=Math.max.apply(Math,yvalues);var maxyval=maxy;var miny=Math.min.apply(Math,yvalues);var minyval=miny;var maxx=Math.max.apply(Math,xvalues);var maxxval=maxx;var minx=Math.min.apply(Math,xvalues);var minxval=minx;if(options.normalRangeMin!=undefined){if(options.normalRangeMin<miny)
8
+ miny=options.normalRangeMin;if(options.normalRangeMax>maxy)
9
+ maxy=options.normalRangeMax;}
10
+ if(options.chartRangeMin!=undefined&&options.chartRangeMin<miny){miny=options.chartRangeMin;}
11
+ if(options.chartRangeMax!=undefined&&options.chartRangeMax>maxy){maxy=options.chartRangeMax;}
12
+ var rangex=maxx-minx==0?1:maxx-minx;var rangey=maxy-miny==0?1:maxy-miny;var vl=yvalues.length-1;if(vl<1){this.innerHTML='';return;}
13
+ var target=$(this).simpledraw(width,height,options.composite);if(target){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;var canvas_top=0;var canvas_left=0;if(options.spotRadius&&(canvas_width<(options.spotRadius*4)||canvas_height<(options.spotRadius*4))){options.spotRadius=0;}
14
+ if(options.spotRadius){if(options.minSpotColor||(options.spotColor&&yvalues[vl]==miny))
15
+ canvas_height-=Math.ceil(options.spotRadius);if(options.maxSpotColor||(options.spotColor&&yvalues[vl]==maxy)){canvas_height-=Math.ceil(options.spotRadius);canvas_top+=Math.ceil(options.spotRadius);}
16
+ if(options.minSpotColor||options.maxSpotColor&&(yvalues[0]==miny||yvalues[0]==maxy)){canvas_left+=Math.ceil(options.spotRadius);canvas_width-=Math.ceil(options.spotRadius);}
17
+ if(options.spotColor||(options.minSpotColor||options.maxSpotColor&&(yvalues[vl]==miny||yvalues[vl]==maxy)))
18
+ canvas_width-=Math.ceil(options.spotRadius);}
19
+ canvas_height--;if(options.normalRangeMin!=undefined){var ytop=canvas_top+Math.round(canvas_height-(canvas_height*((options.normalRangeMax-miny)/rangey)));var height=Math.round((canvas_height*(options.normalRangeMax-options.normalRangeMin))/rangey);target.drawRect(canvas_left,ytop,canvas_width,height,undefined,options.normalRangeColor);}
20
+ var path=[[canvas_left,canvas_top+canvas_height]];for(var i=0;i<yvalues.length;i++){var x=xvalues[i],y=yvalues[i];path.push([canvas_left+Math.round((x-minx)*(canvas_width/rangex)),canvas_top+Math.round(canvas_height-(canvas_height*((y-miny)/rangey)))]);}
21
+ if(options.fillColor){path.push([canvas_left+canvas_width,canvas_top+canvas_height-1]);target.drawShape(path,undefined,options.fillColor);path.pop();}
22
+ path[0]=[canvas_left,canvas_top+Math.round(canvas_height-(canvas_height*((yvalues[0]-miny)/rangey)))];target.drawShape(path,options.lineColor);if(options.spotRadius&&options.spotColor){target.drawCircle(canvas_left+canvas_width,canvas_top+Math.round(canvas_height-(canvas_height*((yvalues[vl]-miny)/rangey))),options.spotRadius,undefined,options.spotColor);}
23
+ if(maxy!=minyval){if(options.spotRadius&&options.minSpotColor){var x=xvalues[yvalues.indexOf(minyval)];target.drawCircle(canvas_left+Math.round((x-minx)*(canvas_width/rangex)),canvas_top+Math.round(canvas_height-(canvas_height*((minyval-miny)/rangey))),options.spotRadius,undefined,options.minSpotColor);}
24
+ if(options.spotRadius&&options.maxSpotColor){var x=xvalues[yvalues.indexOf(maxyval)];target.drawCircle(canvas_left+Math.round((x-minx)*(canvas_width/rangex)),canvas_top+Math.round(canvas_height-(canvas_height*((maxyval-miny)/rangey))),options.spotRadius,undefined,options.maxSpotColor);}}}else{this.innerHTML='';}};$.fn.sparkline.bar=function(values,options,width,height){values=$.map(values,Number);var options=$.extend({type:'bar',barColor:'#00f',negBarColor:'#f44',zeroColor:undefined,zeroAxis:undefined,barWidth:4,barSpacing:1,chartRangeMax:undefined,chartRangeMin:undefined},options?options:{});var width=(values.length*options.barWidth)+((values.length-1)*options.barSpacing);var max=Math.max.apply(Math,values);var min=Math.min.apply(Math,values);if(options.chartRangeMin!=undefined&&options.chartRangeMin<min){min=options.chartRangeMin;}
25
+ if(options.chartRangeMax!=undefined&&options.chartRangeMax>max){max=options.chartRangeMax;}
26
+ if(options.zeroAxis==undefined)options.zeroAxis=min<0;var range=max-min==0?1:max-min;var target=$(this).simpledraw(width,height);if(target){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;var yzero=min<0&&options.zeroAxis?canvas_height-Math.round(canvas_height*(Math.abs(min)/range))-1:canvas_height-1;for(var i=0;i<values.length;i++){var x=i*(options.barWidth+options.barSpacing);var val=values[i];var color=(val<0)?options.negBarColor:options.barColor;if(options.zeroAxis&&min<0){var height=Math.round(canvas_height*((Math.abs(val)/range)))+1;var y=(val<0)?yzero:yzero-height;}else{var height=Math.round(canvas_height*((val-min)/range))+1;var y=canvas_height-height;}
27
+ if(val==0&&options.zeroColor!=undefined){color=options.zeroColor;}
28
+ target.drawRect(x,y,options.barWidth-1,height-1,color,color);}}else{this.innerHTML='';}};$.fn.sparkline.tristate=function(values,options,width,height){values=$.map(values,Number);var options=$.extend({barWidth:4,barSpacing:1,posBarColor:'#6f6',negBarColor:'#f44',zeroBarColor:'#999',colorMap:{}},options);var width=(values.length*options.barWidth)+((values.length-1)*options.barSpacing);var target=$(this).simpledraw(width,height);if(target){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;var half_height=Math.round(canvas_height/2);for(var i=0;i<values.length;i++){var x=i*(options.barWidth+options.barSpacing);if(values[i]<0){var y=half_height;var height=half_height-1;var color=options.negBarColor;}else if(values[i]>0){var y=0;var height=half_height-1;var color=options.posBarColor;}else{var y=half_height-1;var height=2;var color=options.zeroBarColor;}
29
+ if(options.colorMap[values[i]]){color=options.colorMap[values[i]];}
30
+ target.drawRect(x,y,options.barWidth-1,height-1,color,color);}}else{this.innerHTML='';}};$.fn.sparkline.discrete=function(values,options,width,height){values=$.map(values,Number);var options=$.extend({lineHeight:'auto',thresholdColor:undefined,thresholdValue:0,chartRangeMax:undefined,chartRangeMin:undefined},options);width=options.width=='auto'?values.length*2:width;var interval=Math.floor(width/values.length);var target=$(this).simpledraw(width,height);if(target){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;var line_height=options.lineHeight=='auto'?Math.round(canvas_height*0.3):options.lineHeight;var pheight=canvas_height-line_height;var min=Math.min.apply(Math,values);var max=Math.max.apply(Math,values);if(options.chartRangeMin!=undefined&&options.chartRangeMin<min){min=options.chartRangeMin;}
31
+ if(options.chartRangeMax!=undefined&&options.chartRangeMax>max){max=options.chartRangeMax;}
32
+ var range=max-min;for(var i=0;i<values.length;i++){var val=values[i];var x=(i*interval);var ytop=Math.round(pheight-pheight*((val-min)/range));target.drawLine(x,ytop,x,ytop+line_height,(options.thresholdColor&&val<options.thresholdValue)?options.thresholdColor:options.lineColor);}}else{this.innerHTML='';}};$.fn.sparkline.bullet=function(values,options,width,height){values=$.map(values,Number);var options=$.extend({targetColor:'red',targetWidth:3,performanceColor:'blue',rangeColors:['#D3DAFE','#A8B6FF','#7F94FF'],base:undefined},options);width=options.width=='auto'?'4.0em':width;var target=$(this).simpledraw(width,height);if(target&&values.length>1){var canvas_width=target.pixel_width-Math.ceil(options.targetWidth/2);var canvas_height=target.pixel_height;var min=Math.min.apply(Math,values);var max=Math.max.apply(Math,values);if(options.base==undefined){var min=min<0?min:0;}else{min=options.base;}
33
+ var range=max-min;for(i=2;i<values.length;i++){var rangeval=parseInt(values[i]);var rangewidth=Math.round(canvas_width*((rangeval-min)/range));target.drawRect(0,0,rangewidth-1,canvas_height-1,options.rangeColors[i-2],options.rangeColors[i-2]);}
34
+ var perfval=parseInt(values[1]);var perfwidth=Math.round(canvas_width*((perfval-min)/range));target.drawRect(0,Math.round(canvas_height*0.3),perfwidth-1,Math.round(canvas_height*0.4)-1,options.performanceColor,options.performanceColor);var targetval=parseInt(values[0]);var x=Math.round(canvas_width*((targetval-min)/range)-(options.targetWidth/2));var targettop=Math.round(canvas_height*0.10);var targetheight=canvas_height-(targettop*2);target.drawRect(x,targettop,options.targetWidth-1,targetheight-1,options.targetColor,options.targetColor);}else{this.innerHTML='';}};$.fn.sparkline.pie=function(values,options,width,height){values=$.map(values,Number);var options=$.extend({sliceColors:['#f00','#0f0','#00f']},options);width=options.width=='auto'?height:width;var target=$(this).simpledraw(width,height);if(target&&values.length>1){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;var radius=Math.floor(Math.min(canvas_width,canvas_height)/2);var total=0;for(var i=0;i<values.length;i++)
35
+ total+=values[i];var next=0;if(options.offset){next+=(2*Math.PI)*(options.offset/360);}
36
+ var circle=2*Math.PI;for(var i=0;i<values.length;i++){var start=next;var end=next;if(total>0){end=next+(circle*(values[i]/total));}
37
+ target.drawPieSlice(radius,radius,radius,start,end,undefined,options.sliceColors[i%options.sliceColors.length]);next=end;}}};function quartile(values,q){if(q==2){var vl2=Math.floor(values.length/2);return values.length%2?values[vl2]:(values[vl2]+values[vl2+1])/2;}else{var vl4=Math.floor(values.length/4);return values.length%2?(values[vl4*q]+values[vl4*q+1])/2:values[vl4*q];}};$.fn.sparkline.box=function(values,options,width,height){values=$.map(values,Number);var options=$.extend({raw:false,boxLineColor:'black',boxFillColor:'#cdf',whiskerColor:'black',outlierLineColor:'#333',outlierFillColor:'white',medianColor:'red',showOutliers:true,outlierIQR:1.5,spotRadius:1.5,target:undefined,targetColor:'#4a2',chartRangeMax:undefined,chartRangeMin:undefined},options);width=options.width=='auto'?'4.0em':width;minvalue=options.chartRangeMin==undefined?Math.min.apply(Math,values):options.chartRangeMin;maxvalue=options.chartRangeMax==undefined?Math.max.apply(Math,values):options.chartRangeMax;var target=$(this).simpledraw(width,height);if(target&&values.length>1){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;if(options.raw){if(options.showOutliers&&values.length>5){var loutlier=values[0],lwhisker=values[1],q1=values[2],q2=values[3],q3=values[4],rwhisker=values[5],routlier=values[6];}else{var lwhisker=values[0],q1=values[1],q2=values[2],q3=values[3],rwhisker=values[4];}}else{values.sort(function(a,b){return a-b;});var q1=quartile(values,1);var q2=quartile(values,2);var q3=quartile(values,3);var iqr=q3-q1;if(options.showOutliers){var lwhisker=undefined,rwhisker=undefined;for(var i=0;i<values.length;i++){if(lwhisker==undefined&&values[i]>q1-(iqr*options.outlierIQR))
38
+ lwhisker=values[i];if(values[i]<q3+(iqr*options.outlierIQR))
39
+ rwhisker=values[i];}
40
+ var loutlier=values[0];var routlier=values[values.length-1];}else{var lwhisker=values[0];var rwhisker=values[values.length-1];}}
41
+ var unitsize=canvas_width/(maxvalue-minvalue+1);var canvas_left=0;if(options.showOutliers){canvas_left=Math.ceil(options.spotRadius);canvas_width-=2*Math.ceil(options.spotRadius);var unitsize=canvas_width/(maxvalue-minvalue+1);if(loutlier<lwhisker)
42
+ target.drawCircle((loutlier-minvalue)*unitsize+canvas_left,canvas_height/2,options.spotRadius,options.outlierLineColor,options.outlierFillColor);if(routlier>rwhisker)
43
+ target.drawCircle((routlier-minvalue)*unitsize+canvas_left,canvas_height/2,options.spotRadius,options.outlierLineColor,options.outlierFillColor);}
44
+ target.drawRect(Math.round((q1-minvalue)*unitsize+canvas_left),Math.round(canvas_height*0.1),Math.round((q3-q1)*unitsize),Math.round(canvas_height*0.8),options.boxLineColor,options.boxFillColor);target.drawLine(Math.round((lwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height/2),Math.round((q1-minvalue)*unitsize+canvas_left),Math.round(canvas_height/2),options.lineColor);target.drawLine(Math.round((lwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height/4),Math.round((lwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height-canvas_height/4),options.whiskerColor);target.drawLine(Math.round((rwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height/2),Math.round((q3-minvalue)*unitsize+canvas_left),Math.round(canvas_height/2),options.lineColor);target.drawLine(Math.round((rwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height/4),Math.round((rwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height-canvas_height/4),options.whiskerColor);target.drawLine(Math.round((q2-minvalue)*unitsize+canvas_left),Math.round(canvas_height*0.1),Math.round((q2-minvalue)*unitsize+canvas_left),Math.round(canvas_height*0.9),options.medianColor);if(options.target){var size=Math.ceil(options.spotRadius);target.drawLine(Math.round((options.target-minvalue)*unitsize+canvas_left),Math.round((canvas_height/2)-size),Math.round((options.target-minvalue)*unitsize+canvas_left),Math.round((canvas_height/2)+size),options.targetColor);target.drawLine(Math.round((options.target-minvalue)*unitsize+canvas_left-size),Math.round(canvas_height/2),Math.round((options.target-minvalue)*unitsize+canvas_left+size),Math.round(canvas_height/2),options.targetColor);}}else{this.innerHTML='';}};if(!Array.prototype.indexOf){Array.prototype.indexOf=function(entry){for(var i=0;i<this.length;i++){if(this[i]==entry)
45
+ return i;}
46
+ return-1;}}
47
+ if($.browser.msie&&!document.namespaces['v']){document.namespaces.add('v','urn:schemas-microsoft-com:vml','#default#VML');}
48
+ if($.browser.hasCanvas==undefined){var t=document.createElement('canvas');$.browser.hasCanvas=t.getContext!=undefined;}
49
+ var vcanvas_base=function(width,height,target){};vcanvas_base.prototype={init:function(width,height,target){this.width=width;this.height=height;this.target=target;if(target[0])target=target[0];target.vcanvas=this;},drawShape:function(path,lineColor,fillColor){alert('drawShape not implemented');},drawLine:function(x1,y1,x2,y2,lineColor){return this.drawShape([[x1,y1],[x2,y2]],lineColor);},drawCircle:function(x,y,radius,lineColor,fillColor){alert('drawCircle not implemented');},drawPieSlice:function(x,y,radius,startAngle,endAngle,lineColor,fillColor){alert('drawPieSlice not implemented');},drawRect:function(x,y,width,height,lineColor,fillColor){alert('drawRect not implemented');},getElement:function(){return this.canvas;},_insert:function(el,target){$(target).html(el);}};var vcanvas_canvas=function(width,height,target){return this.init(width,height,target);};vcanvas_canvas.prototype=$.extend(new vcanvas_base,{_super:vcanvas_base.prototype,init:function(width,height,target){this._super.init(width,height,target);this.canvas=document.createElement('canvas');if(target[0])target=target[0];target.vcanvas=this;$(this.canvas).css({display:'inline-block',width:width,height:height,verticalAlign:'top'});this._insert(this.canvas,target);this.pixel_height=$(this.canvas).height();this.pixel_width=$(this.canvas).width();this.canvas.width=this.pixel_width;this.canvas.height=this.pixel_height;$(this.canvas).css({width:this.pixel_width,height:this.pixel_height});},_getContext:function(lineColor,fillColor){var context=this.canvas.getContext('2d');if(lineColor!=undefined)
50
+ context.strokeStyle=lineColor;context.lineWidth=1;if(fillColor!=undefined)
51
+ context.fillStyle=fillColor;return context;},drawShape:function(path,lineColor,fillColor){var context=this._getContext(lineColor,fillColor);context.beginPath();context.moveTo(path[0][0]+0.5,path[0][1]+0.5);for(var i=1;i<path.length;i++){context.lineTo(path[i][0]+0.5,path[i][1]+0.5);}
52
+ if(lineColor!=undefined){context.stroke();}
53
+ if(fillColor!=undefined){context.fill();}},drawCircle:function(x,y,radius,lineColor,fillColor){var context=this._getContext(lineColor,fillColor);context.beginPath();context.arc(x,y,radius,0,2*Math.PI,false);if(lineColor!=undefined){context.stroke();}
54
+ if(fillColor!=undefined){context.fill();}},drawPieSlice:function(x,y,radius,startAngle,endAngle,lineColor,fillColor){var context=this._getContext(lineColor,fillColor);context.beginPath();context.moveTo(x,y);context.arc(x,y,radius,startAngle,endAngle,false);context.lineTo(x,y);context.closePath();if(lineColor!=undefined){context.stroke();}
55
+ if(fillColor){context.fill();}},drawRect:function(x,y,width,height,lineColor,fillColor){return this.drawShape([[x,y],[x+width,y],[x+width,y+height],[x,y+height],[x,y]],lineColor,fillColor);}});var vcanvas_vml=function(width,height,target){return this.init(width,height,target);};vcanvas_vml.prototype=$.extend(new vcanvas_base,{_super:vcanvas_base.prototype,init:function(width,height,target){this._super.init(width,height,target);if(target[0])target=target[0];target.vcanvas=this;this.canvas=document.createElement('span');$(this.canvas).css({display:'inline-block',position:'relative',overflow:'hidden',width:width,height:height,margin:'0px',padding:'0px',verticalAlign:'top'});this._insert(this.canvas,target);this.pixel_height=$(this.canvas).height();this.pixel_width=$(this.canvas).width();this.canvas.width=this.pixel_width;this.canvas.height=this.pixel_height;;var groupel='<v:group coordorigin="0 0" coordsize="'+this.pixel_width+' '+this.pixel_height+'"'
56
+ +' style="position:absolute;top:0;left:0;width:'+this.pixel_width+'px;height='+this.pixel_height+'px;"></v:group>';this.canvas.insertAdjacentHTML('beforeEnd',groupel);this.group=$(this.canvas).children()[0];},drawShape:function(path,lineColor,fillColor){var vpath=[];for(var i=0;i<path.length;i++){vpath[i]=''+(path[i][0])+','+(path[i][1]);}
57
+ var initial=vpath.splice(0,1);var stroke=lineColor==undefined?' stroked="false" ':' strokeWeight="1" strokeColor="'+lineColor+'" ';var fill=fillColor==undefined?' filled="false"':' fillColor="'+fillColor+'" filled="true" ';var closed=vpath[0]==vpath[vpath.length-1]?'x ':'';var vel='<v:shape coordorigin="0 0" coordsize="'+this.pixel_width+' '+this.pixel_height+'" '
58
+ +stroke
59
+ +fill
60
+ +' style="position:absolute;left:0px;top:0px;height:'+this.pixel_height+'px;width:'+this.pixel_width+'px;padding:0px;margin:0px;" '
61
+ +' path="m '+initial+' l '+vpath.join(', ')+' '+closed+'e">'
62
+ +' </v:shape>';this.group.insertAdjacentHTML('beforeEnd',vel);},drawCircle:function(x,y,radius,lineColor,fillColor){x-=radius+1;y-=radius+1;var stroke=lineColor==undefined?' stroked="false" ':' strokeWeight="1" strokeColor="'+lineColor+'" ';var fill=fillColor==undefined?' filled="false"':' fillColor="'+fillColor+'" filled="true" ';var vel='<v:oval '
63
+ +stroke
64
+ +fill
65
+ +' style="position:absolute;top:'+y+'px; left:'+x+'px; width:'+(radius*2)+'px; height:'+(radius*2)+'px"></v:oval>';this.group.insertAdjacentHTML('beforeEnd',vel);},drawPieSlice:function(x,y,radius,startAngle,endAngle,lineColor,fillColor){if(startAngle==endAngle){return;}
66
+ if((endAngle-startAngle)==(2*Math.PI)){startAngle=0.0;endAngle=(2*Math.PI);}
67
+ var startx=x+Math.round(Math.cos(startAngle)*radius);var starty=y+Math.round(Math.sin(startAngle)*radius);var endx=x+Math.round(Math.cos(endAngle)*radius);var endy=y+Math.round(Math.sin(endAngle)*radius);var vpath=[x-radius,y-radius,x+radius,y+radius,startx,starty,endx,endy];var stroke=lineColor==undefined?' stroked="false" ':' strokeWeight="1" strokeColor="'+lineColor+'" ';var fill=fillColor==undefined?' filled="false"':' fillColor="'+fillColor+'" filled="true" ';var vel='<v:shape coordorigin="0 0" coordsize="'+this.pixel_width+' '+this.pixel_height+'" '
68
+ +stroke
69
+ +fill
70
+ +' style="position:absolute;left:0px;top:0px;height:'+this.pixel_height+'px;width:'+this.pixel_width+'px;padding:0px;margin:0px;" '
71
+ +' path="m '+x+','+y+' wa '+vpath.join(', ')+' x e">'
72
+ +' </v:shape>';this.group.insertAdjacentHTML('beforeEnd',vel);},drawRect:function(x,y,width,height,lineColor,fillColor){return this.drawShape([[x,y],[x,y+height],[x+width,y+height],[x+width,y],[x,y]],lineColor,fillColor);}});})(jQuery);
readme.txt CHANGED
@@ -4,13 +4,13 @@ Donate link: http://plugins.spiralwebconsulting.com/analyticator.html#donate
4
  Tags: stats, statistics, google, analytics, google analytics, tracking, widget
5
  Requires at least: 2.7
6
  Tested up to: 2.8.1
7
- Stable tag: 4.3.4
8
 
9
- Adds the necessary JavaScript code to enable Google Analytics.
10
 
11
  == Description ==
12
 
13
- Google Analyticator adds the necessary JavaScript code to enable Google Analytics logging on any WordPress blog. This eliminates the need to edit your template code to begin logging.
14
 
15
  *Google Analyticator is brought to you for free by [Spiral Web Consulting](http://spiralwebconsulting.com/). Spiral Web Consulting is a small web development firm specializing in PHP development. Visit our website to learn more, and don't hesitate to ask us to develop your next big WordPress plugin idea.*
16
 
@@ -18,16 +18,18 @@ Google Analyticator adds the necessary JavaScript code to enable Google Analytic
18
 
19
  Google Analyticator Has the Following Features:
20
 
21
- - Standard Google Analytics tracking support
22
- - Provides a widget that can be used to display visitor stat information on the front-end
23
- - External link tracking of all links on the page, including links not managed by WordPress
24
- - Download link tracking
25
- - **NEW!** Support for event tracking with outbound links / downloads instead of the old pageview tracking method
26
- - Support for hiding Administrator visits without affecting Google Analytics' site overlay feature
27
- - Support for any advanced tracking code Google provides
28
- - Easily installable only requiring the user knows their UID
29
- - Allows code to be placed in the footer to ensure faster load times
30
- - Complete control over options; disable any feature if needed
 
 
31
 
32
  For more information, visit the [Google Analyticator plugin page](http://plugins.spiralwebconsulting.com/analyticator.html).
33
 
@@ -41,10 +43,23 @@ Please visit [Spiral Web Consulting's forum](http://plugins.spiralwebconsulting.
41
 
42
  == Screenshots ==
43
 
44
- Please visit the [Google Analyticator plugin page](http://plugins.spiralwebconsulting.com/analyticator.html#screenshots) for the latest screenshots.
 
 
 
 
 
45
 
46
  == Changelog ==
47
 
 
 
 
 
 
 
 
 
48
  = 4.3.4 =
49
  * Fixes a bug that was breaking the save button on the settings page in IE.
50
  * Prevents the widget from grabbing Analytics data earlier January 1, 2005.
4
  Tags: stats, statistics, google, analytics, google analytics, tracking, widget
5
  Requires at least: 2.7
6
  Tested up to: 2.8.1
7
+ Stable tag: 5.0
8
 
9
+ Adds the necessary JavaScript code to enable Google Analytics. Includes widgets for Analytics data display.
10
 
11
  == Description ==
12
 
13
+ Google Analyticator adds the necessary JavaScript code to enable Google Analytics logging on any WordPress blog. This eliminates the need to edit your template code to begin logging. Google Analyticator also includes several widgets for displaying Analytics data in the admin and on your blog.
14
 
15
  *Google Analyticator is brought to you for free by [Spiral Web Consulting](http://spiralwebconsulting.com/). Spiral Web Consulting is a small web development firm specializing in PHP development. Visit our website to learn more, and don't hesitate to ask us to develop your next big WordPress plugin idea.*
16
 
18
 
19
  Google Analyticator Has the Following Features:
20
 
21
+ - Supports standard Google Analytics tracking
22
+ - **NEW!** Includes an admin dashboard widget that displays a graph of the last 30 days of visitors, a summary of site usage, the top pages, the top referrers, and the top searches
23
+ - Includes a widget that can be used to display visitor stat information on the front-end
24
+ - Supports outbound link tracking of all links on the page, including links not managed by WordPress
25
+ - Supports download link tracking
26
+ - Supports event tracking with outbound links / downloads instead of the old pageview tracking method
27
+ - Allows hiding of Administrator visits without affecting Google Analytics' site overlay feature
28
+ - Supports any advanced tracking code Google provides
29
+ - Installs easily - unlike other plugins, the user doesn't even have to know their Analytics UID
30
+ - Allows tracking code to be placed in the footer to ensure faster load times
31
+ - Provides complete control over options; disable any feature if needed
32
+ - **NEW!** Supports localization - get the settings page in your language of choice
33
 
34
  For more information, visit the [Google Analyticator plugin page](http://plugins.spiralwebconsulting.com/analyticator.html).
35
 
43
 
44
  == Screenshots ==
45
 
46
+ 1. An example of the admin dashboard widget displaying stats pulled from Google Analytics.
47
+ 2. The top half of the settings page.
48
+ 3. The configuration options for the front-end widget.
49
+ 4. An example of a front-end widget configuration.
50
+ 5. An example of a front-end widget configuration.
51
+ 6. An example of a front-end widget configuration.
52
 
53
  == Changelog ==
54
 
55
+ = 5.0 =
56
+ * Adds a new admin dashboard widget that displays a graph of the last 30 days of visitors, a summary of site usage, the top pages, the top referrers, and the top searches.
57
+ * Changes the Google authentication method to AuthSub. This removes the Google username / password requirement. **Users who had previously entered their username / password in the settings page will need to revisit the settings page and authenticate for the widget to continue to function.**
58
+ * Adds support for automatically retrieving an Analytics account's UID if Google Analyticator is authenticated with Google.
59
+ * Updates the Google Analytics API class to use the WordPress HTTP API, thus removing cURL as a core requirement for the widget.
60
+ * Updates the UID setting help to remove old urchin.js references and provide additional help for finding a UID.
61
+ * Prepares all strings for localization. If you would like to translate Google Analyticator, [visit our forums](http://plugins.spiralwebconsulting.com/forums/viewforum.php?f=16).
62
+
63
  = 4.3.4 =
64
  * Fixes a bug that was breaking the save button on the settings page in IE.
65
  * Prevents the widget from grabbing Analytics data earlier January 1, 2005.
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
screenshot-4.png ADDED
Binary file
screenshot-5.png ADDED
Binary file
screenshot-6.png ADDED
Binary file