Google Analytics for WordPress by MonsterInsights - Version 3.0

Version Description

  • Major backend overhaul, using new Yoast backend class.
  • Added ability to automatically redirect non hashtagged campaign URLs to hashtagged campaign URL's when setAllowAnchor is set to true (if you don't get it, forget about it, you might need it but don't need to worry)
Download this release

Release Info

Developer joostdevalk
Plugin Icon 128x128 Google Analytics for WordPress by MonsterInsights
Version 3.0
Comparing to
See all releases

Code changes from version 2.9.5 to 3.0

googleanalytics.php CHANGED
@@ -4,8 +4,8 @@ Plugin Name: Google Analytics for WordPress
4
  Plugin URI: http://yoast.com/wordpress/analytics/
5
  Description: This plugin makes it simple to add Google Analytics with extra search engines and automatic clickout and download tracking to your WordPress blog.
6
  Author: Joost de Valk
7
- Version: 2.9.5
8
- Requires at least: 2.6
9
  Author URI: http://yoast.com/
10
  License: GPL
11
 
@@ -20,37 +20,33 @@ $gapppluginpath = plugins_url('', __FILE__).'/';
20
 
21
  if ( ! class_exists( 'GA_Admin' ) ) {
22
 
23
- class GA_Admin {
24
-
25
- function add_config_page() {
26
- $plugin_page = add_submenu_page('plugins.php', 'Google Analytics for WordPress Configuration', 'Google Analytics', 9, basename(__FILE__), array('GA_Admin','config_page'));
27
- add_action( 'admin_head-'. $plugin_page, array('GA_Admin','config_page_head') );
28
- add_filter( 'plugin_action_links', array( 'GA_Admin', 'filter_plugin_actions'), 10, 2 );
29
- add_filter( 'ozh_adminmenu_icon', array( 'GA_Admin', 'add_ozh_adminmenu_icon' ) );
30
- } // end add_GA_config_page()
31
-
32
- function add_ozh_adminmenu_icon( $hook ) {
33
- static $gawpicon;
34
- if (!$gawpicon) {
35
- $gawpicon = WP_CONTENT_URL . '/plugins/' . plugin_basename(dirname(__FILE__)). '/chart_curve.png';
36
- }
37
- if ($hook == 'googleanalytics.php') return $gawpicon;
38
- return $hook;
39
- }
40
-
41
- function filter_plugin_actions( $links, $file ){
42
- //Static so we don't call plugin_basename on every plugin row.
43
- static $this_plugin;
44
- if ( ! $this_plugin ) $this_plugin = plugin_basename(__FILE__);
45
 
46
- if ( $file == $this_plugin ){
47
- $settings_link = '<a href="plugins.php?page=googleanalytics.php">' . __('Settings') . '</a>';
48
- array_unshift( $links, $settings_link ); // before other links
49
- }
50
- return $links;
 
 
 
 
 
51
  }
52
 
53
  function config_page_head() {
 
54
  wp_enqueue_script('jquery');
55
  ?>
56
  <script type="text/javascript" charset="utf-8">
@@ -58,30 +54,32 @@ if ( ! class_exists( 'GA_Admin' ) ) {
58
  jQuery('#explanation td').css("display","none");
59
  jQuery('#advancedsettings').change(function(){
60
  if ((jQuery('#advancedsettings').attr('checked')) == true) {
61
- jQuery('#advancedsettingstr').css("border-bottom","1px solid #333");
62
- jQuery('.advanced th, .advanced td').css("display","table-cell");
63
  } else {
64
- jQuery('#advancedsettingstr').css("border-bottom","none");
65
- jQuery('.advanced th, .advanced td').css("display","none");
66
  }
67
  }).change();
68
  jQuery('#explain').click(function(){
69
- if ((jQuery('#explanation td').css("display")) == "table-cell") {
70
- jQuery('#explanation td').css("display","none");
71
  } else {
72
- jQuery('#explanation td').css("display","table-cell");
73
  }
74
  });
75
  });
76
  </script>
77
- <style type="text/css" media="screen">
78
- .pluginmenu li {
79
- list-style-type: square;
80
- margin-left: 20px;
81
- padding-left: 5px;
82
- }
83
- </style>
84
  <?php
 
 
 
 
 
 
 
 
 
 
 
85
  }
86
 
87
  function config_page() {
@@ -115,7 +113,7 @@ if ( ! class_exists( 'GA_Admin' ) ) {
115
  }
116
  }
117
 
118
- foreach (array('extrase', 'imagese', 'trackoutbound', 'trackloggedin', 'admintracking', 'trackadsense', 'userv2', 'allowanchor', 'rsslinktagging') as $option_name) {
119
  if (isset($_POST[$option_name])) {
120
  $options[$option_name] = true;
121
  } else {
@@ -128,217 +126,167 @@ if ( ! class_exists( 'GA_Admin' ) ) {
128
  }
129
 
130
  update_option('GoogleAnalyticsPP', $options);
131
- echo "<div id=\"message\" class=\"updated\"><p>Google Analytics settings updated.</p></div>\n";
 
 
132
  }
133
 
134
  $options = get_option('GoogleAnalyticsPP');
135
  ?>
136
  <div class="wrap">
137
- <?php screen_icon('tools'); ?>
138
  <h2>Google Analytics for WordPress Configuration</h2>
139
- <div style="width: 250px; float:right;">
140
- <h3>The latest news on Yoast</h3>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  <?php
142
- yst_db_widget('small', 2, 150, false);
 
 
143
  ?>
144
  </div>
145
- <form action="" method="post" id="analytics-conf">
146
- <table class="form-table" style="clear:none;">
147
- <?php wp_nonce_field('analyticspp-config'); ?>
148
- <tr>
149
- <th scope="row" style="width:250px;" valign="top">
150
- <label for="uastring">Analytics Account ID</label> &nbsp; &nbsp; &nbsp; <small><a href="#" id="explain">What's this?</a></small>
151
- </th>
152
- <td>
153
- <input id="uastring" name="uastring" type="text" size="20" maxlength="40" value="<?php echo $options['uastring']; ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /><br/>
154
- </td>
155
- </tr>
156
- <tr id="explanation">
157
- <td colspan="2">
158
- <div style="background: #fff; border: 1px solid #ccc; width: 60%; padding: 5px;">
159
- <strong>Explanation</strong><br/>
160
- Find the Account ID, starting with UA- in your account overview, as marked below:<br/>
161
- <br/>
162
- <img src="<?php echo $gapppluginpath ?>/account-id.png" alt="Account ID"/><br/>
163
- <br/>
164
- Once you have entered your Account ID in the box above your pages will be trackable by Google Analytics.<br/>
165
- Still can't find it? Watch <a href="http://yoast.com/wordpress/google-analytics/#accountid">this video</a>!
166
- </div>
167
- </td>
168
- </tr>
169
- <tr>
170
- <th scope="row" valign="top">
171
- <label for="position">Where should the tracking script be placed?</label>
172
- </th>
173
- <td>
174
- <select name="position" id="position" style="width:200px;">
175
- <option value="footer"<?php if ($options['position'] == 'footer' || $options['position'] == "") { echo ' selected="selected"';} ?>>In the footer (default)</option>
176
- <option value="header"<?php if ($options['position'] == 'header') { echo ' selected="selected"';} ?>>In the header</option>
177
- </select>
178
- </td>
179
- </tr>
180
- <tr>
181
- <th scope="row" valign="top">
182
- <label for="trackoutbound">Track outbound clicks<br/>
183
- &amp; downloads</label>
184
- </th>
185
- <td>
186
- <input type="checkbox" id="trackoutbound" name="trackoutbound" <?php if ($options['trackoutbound']) echo ' checked="checked" '; ?>/>
187
- </td>
188
- </tr>
189
- <tr>
190
- <th scope="row" valign="top">
191
- <label for="advancedsettings">Show advanced settings</label><br/>
192
- <small>Only adviced for advanced users who know their way around Google Analytics</small>
193
- </th>
194
- <td>
195
- <input type="checkbox" id="advancedsettings" name="advancedsettings" <?php if ($options['advancedsettings']) echo ' checked="checked" '; ?>/>
196
- </td>
197
- </tr>
198
- <tr class="advanced">
199
- <th scope="row" valign="top">
200
- <label for="admintracking">Track the administrator too</label><br/>
201
- <small>(default is true)</small>
202
- </th>
203
- <td>
204
- <input type="checkbox" id="admintracking" name="admintracking" <?php if ($options['admintracking']) echo ' checked="checked" '; ?>/>
205
- </td>
206
- </tr>
207
- <tr class="advanced">
208
- <th scope="row" valign="top">
209
- <label for="trackloggedin">Segment logged in users</label><br/>
210
- </th>
211
- <td>
212
- <input type="checkbox" id="trackloggedin" name="trackloggedin" <?php if ($options['trackloggedin']) echo ' checked="checked" '; ?>/>
213
- </td>
214
- </tr>
215
- <tr class="advanced">
216
- <th scope="row" valign="top">
217
- <label for="dlextensions">Extensions of files to track as downloads</label><br/>
218
- <small>(If the extension is only two chars, prefix it with a dot, like '.js')</small>
219
- </th>
220
- <td>
221
- <input type="text" name="dlextensions" size="30" value="<?php echo $options['dlextensions']; ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;"/>
222
- </td>
223
- </tr>
224
- <tr class="advanced">
225
- <th scope="row" valign="top">
226
- <label for="dlprefix">Prefix for tracked downloads</label>
227
- </th>
228
- <td>
229
- <input type="text" id="dlprefix" name="dlprefix" size="30" value="<?php echo $options['dlprefix']; ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;"/>
230
- </td>
231
- </tr>
232
- <tr class="advanced">
233
- <th scope="row" valign="top">
234
- <label for="artprefix">Prefix for outbound clicks from articles</label>
235
- </th>
236
- <td>
237
- <input type="text" id="artprefix" name="artprefix" size="30" value="<?php echo $options['artprefix']; ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;"/>
238
- </td>
239
- </tr>
240
- <tr class="advanced">
241
- <th scope="row" valign="top">
242
- <label for="comprefix">Prefix for outbound clicks from within comments</label>
243
- </th>
244
- <td>
245
- <input type="text" id="comprefix" name="comprefix" size="30" value="<?php echo $options['comprefix']; ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;"/>
246
- </td>
247
- </tr>
248
- <tr class="advanced">
249
- <th scope="row" valign="top">
250
- <label for="comautprefix">Prefix for outbound clicks from comment author links</label>
251
- </th>
252
- <td>
253
- <input type="text" id="comautprefix" name="comautprefix" size="30" value="<?php echo $options['comautprefix']; ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;"/>
254
- </td>
255
- </tr>
256
- <tr class="advanced">
257
- <th scope="row" valign="top">
258
- <label for="blogrollprefix">Prefix for outbound clicks from blogroll links</label>
259
- </th>
260
- <td>
261
- <input type="text" id="blogrollprefix" name="blogrollprefix" size="30" value="<?php echo $options['blogrollprefix']; ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;"/>
262
- </td>
263
- </tr>
264
- <tr class="advanced">
265
- <th scope="row" valign="top">
266
- <label for="domainorurl">Track full URL of outbound clicks or just the domain?</label>
267
- </th>
268
- <td>
269
- <select name="domainorurl" id="domainorurl" style="width:200px;">
270
- <option value="domain"<?php if ($options['domainorurl'] == 'domain') { echo ' selected="selected"';} ?>>Just the domain</option>
271
- <option value="url"<?php if ($options['domainorurl'] == 'url') { echo ' selected="selected"';} ?>>Track the complete URL</option>
272
- </select>
273
- </td>
274
- </tr>
275
- <tr class="advanced">
276
- <th scope="row" valign="top">
277
- <label for="domain">Domain Tracking</label><br/>
278
- <small>This allows you to set the domain that's set by <a href="http://code.google.com/apis/analytics/docs/gaJSApiDomainDirectory.html#_gat.GA_Tracker_._setDomainName"><code>setDomainName</code></a> for tracking subdomains, if empty this will not be set.</small>
279
- </th>
280
- <td>
281
- <input type="text" id="domain" name="domain" size="30" value="<?php echo $options['domain']; ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;"/>
282
- </td>
283
- </tr>
284
- <tr class="advanced">
285
- <th scope="row" valign="top">
286
- <label for="trackadsense">Track AdSense</label><br/>
287
- <small>This requires integration of your Analytics and AdSense account, for help, <a href="https://www.google.com/adsense/support/bin/topic.py?topic=15007">look here</a>.</small>
288
- </th>
289
- <td>
290
- <input type="checkbox" id="trackadsense" name="trackadsense" <?php if ($options['trackadsense']) echo ' checked="checked" '; ?>/>
291
- </td>
292
- </tr>
293
- <tr class="advanced">
294
- <th scope="row" valign="top">
295
- <label for="extrase">Track extra Search Engines</label>
296
- </th>
297
- <td>
298
- <input type="checkbox" id="extrase" name="extrase" <?php if ($options['extrase']) echo ' checked="checked" '; ?>/>
299
- </td>
300
- </tr>
301
- <tr class="advanced">
302
- <th scope="row" valign="top">
303
- <label for="userv2">I use Urchin too.</label>
304
- </th>
305
- <td>
306
- <input type="checkbox" id="userv2" name="userv2" <?php if ($options['userv2']) echo ' checked="checked" '; ?>/>
307
- </td>
308
- </tr>
309
- <tr class="advanced">
310
- <th scope="row" valign="top">
311
- <label for="rsslinktagging">Tag the links in your RSS feed with campaign variables.</label>
312
- </th>
313
- <td>
314
- <input type="checkbox" id="rsslinktagging" name="rsslinktagging" <?php if ($options['rsslinktagging']) echo ' checked="checked" '; ?>/>
315
- </td>
316
- </tr>
317
- <tr class="advanced">
318
- <th scope="row" valign="top">
319
- <label for="allowanchor">Use # instead of ? for Campaign tracking?</label><br/>
320
- <small>This adds a <a href="http://code.google.com/apis/analytics/docs/gaJSApiCampaignTracking.html#_gat.GA_Tracker_._setAllowAnchor">setAllowAnchor</a> call to your tracking script, and makes RSS link tagging use a # as well.</small>
321
- </th>
322
- <td>
323
- <input type="checkbox" id="allowanchor" name="allowanchor" <?php if ($options['allowanchor']) echo ' checked="checked" '; ?>/>
324
- </td>
325
- </tr>
326
- </table>
327
- <p style="border:0;" class="submit"><input type="submit" name="submit" value="Update Settings &raquo;" /></p>
328
- </form>
329
- <form action="" method="post">
330
- <input type="hidden" name="reset" value="true"/>
331
- <p style="border:0;" class="submit"><input type="submit" value="Reset Settings &raquo;" /></p>
332
- </form>
333
- <br/><br/>
334
- <h3>Like this plugin?</h3>
335
- <p>Why not do any of the following:</p>
336
- <ul class="pluginmenu">
337
- <li>Link to it so other folks can find out about it.</li>
338
- <li><a href="http://wordpress.org/extend/plugins/google-analytics-for-wordpress/">Give it a good rating</a> on WordPress.org, so others will find it more easily too!</li>
339
- <li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2017947">Donate a token of your appreciation</a>.</li>
340
- </ul>
341
  </div>
 
 
342
  <?php
343
  if (isset($options['uastring'])) {
344
  if ($options['uastring'] == "") {
@@ -377,6 +325,7 @@ if ( ! class_exists( 'GA_Admin' ) ) {
377
 
378
  } // end class GA_Admin
379
 
 
380
  } //endif
381
 
382
 
@@ -594,6 +543,34 @@ if (strpos($_SERVER['HTTP_REFERER'],"images.google") && strpos($_SERVER['HTTP_RE
594
  } // class GA_Filter
595
  } // endif
596
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
597
  $gaf = new GA_Filter();
598
  $origin = $gaf->ga_get_domain($_SERVER["HTTP_HOST"]);
599
 
@@ -641,57 +618,4 @@ if ($options['position'] == 'footer' || $options['position'] == "") {
641
  if ($options['rsslinktagging']) {
642
  add_filter ( 'the_permalink_rss', array('GA_Filter','rsslinktagger'), 99 );
643
  }
644
-
645
- if (!function_exists('yst_db_widget')) {
646
- function yst_text_limit( $text, $limit, $finish = ' [&hellip;]') {
647
- if( strlen( $text ) > $limit ) {
648
- $text = substr( $text, 0, $limit );
649
- $text = substr( $text, 0, - ( strlen( strrchr( $text,' ') ) ) );
650
- $text .= $finish;
651
- }
652
- return $text;
653
- }
654
-
655
- function yst_db_widget($image = 'normal', $num = 3, $excerptsize = 250, $showdate = true) {
656
- require_once(ABSPATH.WPINC.'/rss.php');
657
- if ( $rss = fetch_rss( 'http://feeds2.feedburner.com/joostdevalk' ) ) {
658
- echo '<div class="rss-widget">';
659
- if ($image != 'small') {
660
- echo '<a href="http://yoast.com/" title="Go to Yoast.com"><img src="http://cdn.yoast.com/yoast-logo-rss.png" class="alignright" alt="Yoast"/></a>';
661
- } else {
662
- echo '<a href="http://yoast.com/" title="Go to Yoast.com"><img width="80" src="http://cdn.yoast.com/yoast-logo-rss.png" class="alignright" alt="Yoast"/></a>';
663
- }
664
- echo '<ul>';
665
- if (!is_numeric($num)) {
666
- $num = 3;
667
- }
668
- $rss->items = array_slice( $rss->items, 0, $num );
669
- foreach ( (array) $rss->items as $item ) {
670
- echo '<li>';
671
- echo '<a class="rsswidget" href="'.clean_url( $item['link'], $protocolls=null, 'display' ).'">'. htmlentities($item['title']) .'</a> ';
672
- if ($showdate)
673
- echo '<span class="rss-date">'. date('F j, Y', strtotime($item['pubdate'])) .'</span>';
674
- echo '<div class="rssSummary">'. yst_text_limit($item['summary'],$excerptsize) .'</div>';
675
- echo '</li>';
676
- }
677
- echo '</ul>';
678
- echo '<div style="border-top: 1px solid #ddd; padding-top: 10px; text-align:center;">';
679
- echo '<a href="http://feeds2.feedburner.com/joostdevalk"><img src="'.get_bloginfo('wpurl').'/wp-includes/images/rss.png" alt=""/> Subscribe with RSS</a>';
680
- if ($image != 'small') {
681
- echo ' &nbsp; &nbsp; &nbsp; ';
682
- } else {
683
- echo '<br/>';
684
- }
685
- echo '<a href="http://yoast.com/email-blog-updates/"><img src="http://cdn.yoast.com/email_sub.png" alt=""/> Subscribe by email</a>';
686
- echo '</div>';
687
- echo '</div>';
688
- }
689
- }
690
-
691
- function yst_widget_setup() {
692
- wp_add_dashboard_widget( 'yst_db_widget' , 'The Latest news from Yoast' , 'yst_db_widget');
693
- }
694
-
695
- add_action('wp_dashboard_setup', 'yst_widget_setup');
696
- }
697
- ?>
4
  Plugin URI: http://yoast.com/wordpress/analytics/
5
  Description: This plugin makes it simple to add Google Analytics with extra search engines and automatic clickout and download tracking to your WordPress blog.
6
  Author: Joost de Valk
7
+ Version: 3.0
8
+ Requires at least: 2.7
9
  Author URI: http://yoast.com/
10
  License: GPL
11
 
20
 
21
  if ( ! class_exists( 'GA_Admin' ) ) {
22
 
23
+ require_once('yst_plugin_tools.php');
24
+
25
+ class GA_Admin extends Yoast_Plugin_Admin {
26
+
27
+ var $hook = 'google-analytics';
28
+ var $filename = 'google-analytics-for-wordpress/googleanalytics.php';
29
+ var $longname = 'Google Analytics Configuration';
30
+ var $shortname = 'Google Analytics';
31
+ var $ozhicon = 'chart_curve.png';
32
+ var $optionname = 'GoogleAnalyticsPP';
33
+ var $homepage = 'http://yoast.com/wordpress/analytics/';
34
+
 
 
 
 
 
 
 
 
 
 
35
 
36
+ function GA_Admin() {
37
+ add_action( 'admin_menu', array(&$this, 'register_settings_page') );
38
+ add_filter( 'plugin_action_links', array(&$this, 'add_action_link'), 10, 2 );
39
+ add_filter( 'ozh_adminmenu_icon', array(&$this, 'add_ozh_adminmenu_icon' ) );
40
+
41
+ add_action('admin_print_scripts', array(&$this,'config_page_scripts'));
42
+ add_action('admin_print_styles', array(&$this,'config_page_styles'));
43
+
44
+ add_action('wp_dashboard_setup', array(&$this,'widget_setup'));
45
+ add_action('admin_head', array(&$this,'config_page_head'));
46
  }
47
 
48
  function config_page_head() {
49
+ if ($_GET['page'] == $this->hook) {
50
  wp_enqueue_script('jquery');
51
  ?>
52
  <script type="text/javascript" charset="utf-8">
54
  jQuery('#explanation td').css("display","none");
55
  jQuery('#advancedsettings').change(function(){
56
  if ((jQuery('#advancedsettings').attr('checked')) == true) {
57
+ jQuery('#advancedgasettings').css("display","block");
 
58
  } else {
59
+ jQuery('#advancedgasettings').css("display","none");
 
60
  }
61
  }).change();
62
  jQuery('#explain').click(function(){
63
+ if ((jQuery('#explanation').css("display")) == "block") {
64
+ jQuery('#explanation').css("display","none");
65
  } else {
66
+ jQuery('#explanation').css("display","block");
67
  }
68
  });
69
  });
70
  </script>
 
 
 
 
 
 
 
71
  <?php
72
+ }
73
+ }
74
+
75
+ function checkbox($id) {
76
+ $options = get_option($this->optionname);
77
+ return '<input type="checkbox" id="'.$id.'" name="'.$id.'"'. checked($options[$id],true,false).'/>';
78
+ }
79
+
80
+ function textinput($id) {
81
+ $options = get_option($this->optionname);
82
+ return '<input type="text" id="'.$id.'" name="'.$id.'" size="30" value="'.$options[$id].'"/>';
83
  }
84
 
85
  function config_page() {
113
  }
114
  }
115
 
116
+ foreach (array('extrase', 'imagese', 'trackoutbound', 'trackloggedin', 'admintracking', 'trackadsense', 'userv2', 'allowanchor', 'rsslinktagging', 'advancedsettings') as $option_name) {
117
  if (isset($_POST[$option_name])) {
118
  $options[$option_name] = true;
119
  } else {
126
  }
127
 
128
  update_option('GoogleAnalyticsPP', $options);
129
+ echo "<div id=\"updatemessage\" class=\"updated fade\"><p>Google Analytics settings updated.</p></div>\n";
130
+ echo "<script type=\"text/javascript\">setTimeout(function(){jQuery('#updatemessage').hide('slow');}, 3000);</script>";
131
+
132
  }
133
 
134
  $options = get_option('GoogleAnalyticsPP');
135
  ?>
136
  <div class="wrap">
137
+ <a href="http://yoast.com/"><div id="yoast-icon" style="background: url(http://cdn.yoast.com/theme/yoast-32x32.png) no-repeat;" class="icon32"><br /></div></a>
138
  <h2>Google Analytics for WordPress Configuration</h2>
139
+ <div class="postbox-container" style="width:70%;">
140
+ <div class="metabox-holder">
141
+ <div class="meta-box-sortables">
142
+ <form action="" method="post" id="analytics-conf">
143
+ <?php
144
+ wp_nonce_field('analyticspp-config');
145
+ $rows = array();
146
+ $rows[] = array(
147
+ 'id' => 'uastring',
148
+ 'label' => 'Analytics Account ID',
149
+ 'desc' => '<a href="#" id="explain">What\'s this?</a>',
150
+ 'content' => '<input id="uastring" name="uastring" type="text" size="20" maxlength="40" value="'.$options['uastring'].'"/><br/><div id="explanation" style="background: #fff; border: 1px solid #ccc; padding: 5px; display:none;">
151
+ <strong>Explanation</strong><br/>
152
+ Find the Account ID, starting with UA- in your account overview, as marked below:<br/>
153
+ <br/>
154
+ <img src="'.$gapppluginpath.'/account-id.png" alt="Account ID"/><br/>
155
+ <br/>
156
+ Once you have entered your Account ID in the box above your pages will be trackable by Google Analytics.<br/>
157
+ Still can\'t find it? Watch <a href="http://yoast.com/wordpress/google-analytics/#accountid">this video</a>!
158
+ </div>'
159
+ );
160
+ $rows[] = array(
161
+ 'id' => 'position',
162
+ 'label' => 'Where should the tracking script be placed?',
163
+ 'content' => '<select name="position" id="position">
164
+ <option value="footer" '.checked($options['position'],true,false).'>In the footer (default)</option>
165
+ <option value="header" '.checked($options['position'],true,false).'>In the header</option>
166
+ </select>'
167
+ );
168
+ $rows[] = array(
169
+ 'id' => 'trackoutbound',
170
+ 'label' => 'Track outbound clicks &amp; downloads',
171
+ 'desc' => '',
172
+ 'content' => $this->checkbox('trackoutbound'),
173
+ );
174
+ $rows[] = array(
175
+ 'id' => 'advancedsettings',
176
+ 'label' => 'Show advanced settings',
177
+ 'desc' => 'Only adviced for advanced users who know their way around Google Analytics',
178
+ 'content' => $this->checkbox('advancedsettings'),
179
+ );
180
+ $this->postbox('gasettings','Google Analytics Settings',$this->form_table($rows));
181
+
182
+ $rows = array();
183
+ $rows[] = array(
184
+ 'id' => 'admintracking',
185
+ 'label' => 'Track the administrator too',
186
+ 'desc' => 'Not recommended, as this would schew your statistics.',
187
+ 'content' => $this->checkbox('admintracking'),
188
+ );
189
+ $rows[] = array(
190
+ 'id' => 'trackloggedin',
191
+ 'label' => 'Segment logged in users',
192
+ 'content' => $this->checkbox('trackloggedin'),
193
+ );
194
+ $rows[] = array(
195
+ 'id' => 'dlextensions',
196
+ 'label' => 'Extensions of files to track as downloads',
197
+ 'content' => $this->textinput('dlextensions'),
198
+ );
199
+ $rows[] = array(
200
+ 'id' => 'dlprefix',
201
+ 'label' => 'Prefix for tracked downloads',
202
+ 'content' => $this->textinput('dlprefix'),
203
+ );
204
+ $rows[] = array(
205
+ 'id' => 'artprefix',
206
+ 'label' => 'Prefix for outbound clicks from articles',
207
+ 'content' => $this->textinput('artprefix'),
208
+ );
209
+ $rows[] = array(
210
+ 'id' => 'comprefix',
211
+ 'label' => 'Prefix for outbound clicks from links in comments',
212
+ 'content' => $this->textinput('comprefix'),
213
+ );
214
+ $rows[] = array(
215
+ 'id' => 'comautprefix',
216
+ 'label' => 'Prefix for outbound clicks from comment author links',
217
+ 'content' => $this->textinput('comautprefix'),
218
+ );
219
+ $rows[] = array(
220
+ 'id' => 'blogrollprefix',
221
+ 'label' => 'Prefix for outbound clicks from blogroll links',
222
+ 'content' => $this->textinput('blogrollprefix'),
223
+ );
224
+ $rows[] = array(
225
+ 'id' => 'domainorurl',
226
+ 'label' => 'Track full URL of outbound clicks or just the domain',
227
+ 'content' => '<select name="domainorurl" id="domainorurl">
228
+ <option value="domain"'.selected($options['domainorurl'],'domain',false).'>Just the domain</option>
229
+ <option value="url"'.selected($options['domainorurl'],'url',false).'>Track the complete URL</option>
230
+ </select>',
231
+ );
232
+ $rows[] = array(
233
+ 'id' => 'domain',
234
+ 'label' => 'Domain Tracking',
235
+ 'desc' => 'This allows you to set the domain that\'s set by <a href="http://code.google.com/apis/analytics/docs/gaJSApiDomainDirectory.html#_gat.GA_Tracker_._setDomainName"><code>setDomainName</code></a> for tracking subdomains, if empty this will not be set.',
236
+ 'content' => $this->textinput('domain'),
237
+ );
238
+ $rows[] = array(
239
+ 'id' => 'trackadsense',
240
+ 'label' => 'Track AdSense',
241
+ 'desc' => 'This requires integration of your Analytics and AdSense account, for help, <a href="https://www.google.com/adsense/support/bin/topic.py?topic=15007">look here</a>.',
242
+ 'content' => $this->checkbox('trackadsense'),
243
+ );
244
+ $rows[] = array(
245
+ 'id' => 'extrase',
246
+ 'label' => 'Track extra Search Engines',
247
+ 'content' => $this->checkbox('extrase'),
248
+ );
249
+ $rows[] = array(
250
+ 'id' => 'userv2',
251
+ 'label' => 'I use Urchin',
252
+ 'content' => $this->checkbox('userv2'),
253
+ );
254
+ $rows[] = array(
255
+ 'id' => 'rsslinktagging',
256
+ 'label' => 'Tag the links in your RSS feed with campaign variables.',
257
+ 'content' => $this->checkbox('rsslinktagging'),
258
+ );
259
+ $rows[] = array(
260
+ 'id' => 'allowanchor',
261
+ 'label' => 'Use # instead of ? for Campaign tracking?',
262
+ 'desc' => 'This adds a <a href="http://code.google.com/apis/analytics/docs/gaJSApiCampaignTracking.html#_gat.GA_Tracker_._setAllowAnchor">setAllowAnchor</a> call to your tracking script, and makes RSS link tagging use a # as well.',
263
+ 'content' => $this->checkbox('allowanchor'),
264
+ );
265
+ $this->postbox('advancedgasettings','Advanced Settings',$this->form_table($rows));
266
+
267
+ ?>
268
+ <div class="submit"><input type="submit" class="button-primary" name="submit" value="Update Google Analytics Settings &raquo;" /></div>
269
+ </form>
270
+ <form action="" method="post">
271
+ <input type="hidden" name="reset" value="true"/>
272
+ <div class="submit"><input type="submit" value="Reset Settings &raquo;" /></div>
273
+ </form>
274
+ </div>
275
+ </div>
276
+ </div>
277
+ <div class="postbox-container" style="width:20%;">
278
+ <div class="metabox-holder">
279
+ <div class="meta-box-sortables">
280
  <?php
281
+ $this->plugin_like('blog-icons');
282
+ $this->plugin_support('blog-icons');
283
+ $this->news();
284
  ?>
285
  </div>
286
+ <br/><br/><br/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
287
  </div>
288
+ </div>
289
+ </div>
290
  <?php
291
  if (isset($options['uastring'])) {
292
  if ($options['uastring'] == "") {
325
 
326
  } // end class GA_Admin
327
 
328
+ $ga_admin = new GA_Admin();
329
  } //endif
330
 
331
 
543
  } // class GA_Filter
544
  } // endif
545
 
546
+ /**
547
+ * If setAllowAnchor is set to true, GA ignores all links tagged "normally", so we redirect all "normally" tagged URL's
548
+ * to one tagged with a hash. Needs some work as it also needs to do that when the first utm_ var is actually not the
549
+ * first GET variable in the URL.
550
+ */
551
+ if ( $options['allowanchor'] ) {
552
+ function ga_utm_hastag_redirect() {
553
+ if (isset($_SERVER['REQUEST_URI'])) {
554
+ if (strpos($_SERVER['REQUEST_URI'], "utm_") !== false) {
555
+ $url = 'http://';
556
+ if ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "") {
557
+ $url = 'https://';
558
+ }
559
+ $url .= $_SERVER['SERVER_NAME'];
560
+ if ( strpos($_SERVER['REQUEST_URI'], "?utm_") !== false ) {
561
+ $url .= str_replace("?utm_","#utm_",$_SERVER['REQUEST_URI']);
562
+ }
563
+ else if ( strpos($_SERVER['REQUEST_URI'], "&utm_") !== false ) {
564
+ $url .= substr_replace($_SERVER['REQUEST_URI'], "#utm_", strpos($_SERVER['REQUEST_URI'], "&utm_"), 5);
565
+ }
566
+ wp_redirect($url, 301);
567
+ exit;
568
+ }
569
+ }
570
+ }
571
+ add_action('init','ga_utm_hastag_redirect',1);
572
+ }
573
+
574
  $gaf = new GA_Filter();
575
  $origin = $gaf->ga_get_domain($_SERVER["HTTP_HOST"]);
576
 
618
  if ($options['rsslinktagging']) {
619
  add_filter ( 'the_permalink_rss', array('GA_Filter','rsslinktagger'), 99 );
620
  }
621
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: joostdevalk
3
  Donate link: http://yoast.com/donate/
4
  Tags: analytics, google analytics, statistics
5
- Requires at least: 2.2
6
- Tested up to: 2.8.1
7
- Stable tag: 2.9.5
8
 
9
  The Google Analytics for WordPress plugin automatically tracks and segments all outbound links from within posts, comment author links, links within comments, blogroll links and downloads. It also allows you to track AdSense clicks, add extra search engines, track image search queries and it will even work together with Urchin.
10
 
@@ -22,13 +22,17 @@ In the options panel for the plugin, you can determine the prefixes to use for t
22
 
23
  This section describes how to install the plugin and get it working.
24
 
25
- 1. Delete any existing `gapp` folder from the `/wp-content/plugins/` directory
26
- 1. Upload `gapp` folder to the `/wp-content/plugins/` directory
27
  1. Activate the plugin through the 'Plugins' menu in WordPress
28
- 1. Go to the options panel under the 'Plugins' menu and add your Analytics account number and set the settings you want.
29
 
30
  == Changelog ==
31
 
 
 
 
 
32
  = 2.9.5 =
33
  * Fixed a bug with the included RSS, which came up when multiple Yoast plugins were installed.
34
 
2
  Contributors: joostdevalk
3
  Donate link: http://yoast.com/donate/
4
  Tags: analytics, google analytics, statistics
5
+ Requires at least: 2.7
6
+ Tested up to: 2.8.2
7
+ Stable tag: 3.0
8
 
9
  The Google Analytics for WordPress plugin automatically tracks and segments all outbound links from within posts, comment author links, links within comments, blogroll links and downloads. It also allows you to track AdSense clicks, add extra search engines, track image search queries and it will even work together with Urchin.
10
 
22
 
23
  This section describes how to install the plugin and get it working.
24
 
25
+ 1. Delete any existing `gapp` or `google-analytics-for-wordpress` folder from the `/wp-content/plugins/` directory
26
+ 1. Upload `google-analytics-for-wordpress` folder to the `/wp-content/plugins/` directory
27
  1. Activate the plugin through the 'Plugins' menu in WordPress
28
+ 1. Go to the options panel under the 'Settings' menu and add your Analytics account number and set the settings you want.
29
 
30
  == Changelog ==
31
 
32
+ = 3.0 =
33
+ * Major backend overhaul, using new Yoast backend class.
34
+ * Added ability to automatically redirect non hashtagged campaign URLs to hashtagged campaign URL's when setAllowAnchor is set to true (if you don't get it, forget about it, you might need it but don't need to worry)
35
+
36
  = 2.9.5 =
37
  * Fixed a bug with the included RSS, which came up when multiple Yoast plugins were installed.
38
 
screenshot-1.jpg ADDED
Binary file
screenshot-1.png DELETED
Binary file
yst_plugin_tools.css ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ small {
2
+ font-weight:normal;
3
+ color:#777;
4
+ }
5
+
6
+ div.inside ul {
7
+ margin-left: 20px;
8
+ }
9
+
10
+ div.inside ul li {
11
+ list-style: square;
12
+ line-height:16px;
13
+ }
14
+
15
+ div.inside ul li.rss {
16
+ list-style-image: url(/wp-includes/images/rss.png);
17
+ }
18
+
19
+ div.inside ul li.email {
20
+ list-style-image: url(http://cdn.yoast.com/email_sub.png);
21
+ }
22
+
23
+ div.inside ul li.yoast {
24
+ list-style-image: url(http://cdn.yoast.com/theme/yoast-16x16.png);
25
+ }
26
+
27
+ .text {
28
+ width: 250px;
29
+ }
yst_plugin_tools.php ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Backend Class for use in all Yoast plugins
5
+ * Version 0.2
6
+ */
7
+
8
+ if (!class_exists('Yoast_Plugin_Admin')) {
9
+ class Yoast_Plugin_Admin {
10
+
11
+ var $hook = '';
12
+ var $filename = '';
13
+ var $longname = '';
14
+ var $shortname = '';
15
+ var $ozhicon = '';
16
+ var $optionname = '';
17
+ var $homepage = '';
18
+ var $accesslvl = 'manage_options';
19
+
20
+ function Yoast_Plugin_Admin() {
21
+ add_action( 'admin_menu', array(&$this, 'register_settings_page') );
22
+ add_filter( 'plugin_action_links', array(&$this, 'add_action_link'), 10, 2 );
23
+ add_filter( 'ozh_adminmenu_icon', array(&$this, 'add_ozh_adminmenu_icon' ) );
24
+
25
+ add_action('admin_print_scripts', array(&$this,'config_page_scripts'));
26
+ add_action('admin_print_styles', array(&$this,'config_page_styles'));
27
+
28
+ add_action('wp_dashboard_setup', array(&$this,'widget_setup'));
29
+ }
30
+
31
+ function add_ozh_adminmenu_icon( $hook ) {
32
+ if ($hook == $this->hook)
33
+ return WP_CONTENT_URL . '/plugins/' . plugin_basename(dirname($filename)). '/'.$this->ozhicon;
34
+ return $hook;
35
+ }
36
+
37
+ function config_page_styles() {
38
+ if (isset($_GET['page']) && $_GET['page'] == $this->hook) {
39
+ wp_enqueue_style('dashboard');
40
+ wp_enqueue_style('thickbox');
41
+ wp_enqueue_style('global');
42
+ wp_enqueue_style('wp-admin');
43
+ wp_enqueue_style('blogicons-admin-css', WP_CONTENT_URL . '/plugins/' . plugin_basename(dirname(__FILE__)). '/yst_plugin_tools.css');
44
+ }
45
+ }
46
+
47
+ function register_settings_page() {
48
+ add_options_page($this->longname, $this->shortname, $this->accesslvl, $this->hook, array(&$this,'config_page'));
49
+ }
50
+
51
+ function plugin_options_url() {
52
+ return admin_url( 'options-general.php?page='.$this->hook );
53
+ }
54
+
55
+ /**
56
+ * Add a link to the settings page to the plugins list
57
+ */
58
+ function add_action_link( $links, $file ) {
59
+ static $this_plugin;
60
+ if( empty($this_plugin) ) $this_plugin = $this->filename;
61
+ if ( $file == $this_plugin ) {
62
+ $settings_link = '<a href="' . $this->plugin_options_url() . '">' . __('Settings') . '</a>';
63
+ array_unshift( $links, $settings_link );
64
+ }
65
+ return $links;
66
+ }
67
+
68
+ function config_page() {
69
+
70
+ }
71
+
72
+ function config_page_scripts() {
73
+ if (isset($_GET['page']) && $_GET['page'] == $this->hook) {
74
+ wp_enqueue_script('postbox');
75
+ wp_enqueue_script('dashboard');
76
+ wp_enqueue_script('thickbox');
77
+ wp_enqueue_script('media-upload');
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Create a Checkbox input field
83
+ */
84
+ function checkbox($id, $label) {
85
+ $options = get_option($this->optionname);
86
+ return '<input type="checkbox" id="'.$id.'" name="'.$id.'"'. checked($options[$id],true,false).'/> <label for="'.$id.'">'.$label.'</label><br/>';
87
+ }
88
+
89
+ /**
90
+ * Create a Text input field
91
+ */
92
+ function textinput($id, $label) {
93
+ $options = get_option($this->optionname);
94
+ return '<label for="'.$id.'">'.$label.':</label><br/><input size="45" type="text" id="'.$id.'" name="'.$id.'" value="'.$options[$id].'"/><br/><br/>';
95
+ }
96
+
97
+ /**
98
+ * Create a potbox widget
99
+ */
100
+ function postbox($id, $title, $content) {
101
+ ?>
102
+ <div id="<?php echo $id; ?>" class="postbox">
103
+ <div class="handlediv" title="Click to toggle"><br /></div>
104
+ <h3 class="hndle"><span><?php echo $title; ?></span></h3>
105
+ <div class="inside">
106
+ <?php echo $content; ?>
107
+ </div>
108
+ </div>
109
+ <?php
110
+ }
111
+
112
+
113
+ /**
114
+ * Create a form table from an array of rows
115
+ */
116
+ function form_table($rows) {
117
+ $content = '<table class="form-table">';
118
+ foreach ($rows as $row) {
119
+ $content .= '<tr><th valign="top" scrope="row">';
120
+ if (isset($row['id']) && $row['id'] != '')
121
+ $content .= '<label for="'.$row['id'].'">'.$row['label'].':</label>';
122
+ else
123
+ $content .= $row['label'];
124
+ if (isset($row['desc']) && $row['desc'] != '')
125
+ $content .= '<br/><small>'.$row['desc'].'</small>';
126
+ $content .= '</th><td valign="top">';
127
+ $content .= $row['content'];
128
+ $content .= '</td></tr>';
129
+ }
130
+ $content .= '</table>';
131
+ return $content;
132
+ }
133
+
134
+ /**
135
+ * Create a "plugin like" box.
136
+ */
137
+ function plugin_like() {
138
+ $content = '<p>'.__('Why not do any or all of the following:','ystplugin').'</p>';
139
+ $content .= '<ul>';
140
+ $content .= '<li><a href="'.$this->homepage.'">'.__('Link to it so other folks can find out about it.','ystplugin').'</a></li>';
141
+ $content .= '<li><a href="http://wordpress.org/extend/plugins/'.$this->hook.'/">'.__('Give it a good rating on WordPress.org.','ystplugin').'</a></li>';
142
+ $content .= '<li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2017947">'.__('Donate a token of your appreciation.','ystplugin').'</a></li>';
143
+ $content .= '</ul>';
144
+ $this->postbox($this->hook.'like', 'Like this plugin?', $content);
145
+ }
146
+
147
+ /**
148
+ * Info box with link to the support forums.
149
+ */
150
+ function plugin_support() {
151
+ $content = '<p>'.__('If you have any problems with this plugin or good ideas for improvements or new features, please talk about them in the','ystplugin').' <a href="http://wordpress.org/tags/'.$this->hook.'">'.__("Support forums",'ystplugin').'</a>.</p>';
152
+ $this->postbox($this->hook.'support', 'Need support?', $content);
153
+ }
154
+
155
+ /**
156
+ * Box with latest news from Yoast.com
157
+ */
158
+ function news() {
159
+ require_once(ABSPATH.WPINC.'/rss.php');
160
+ if ( $rss = fetch_rss( 'http://feeds2.feedburner.com/joostdevalk' ) ) {
161
+ $content = '<ul>';
162
+ $rss->items = array_slice( $rss->items, 0, 3 );
163
+ foreach ( (array) $rss->items as $item ) {
164
+ $content .= '<li class="yoast">';
165
+ $content .= '<a class="rsswidget" href="'.clean_url( $item['link'], $protocolls=null, 'display' ).'">'. htmlentities($item['title']) .'</a> ';
166
+ $content .= '</li>';
167
+ }
168
+ $content .= '<li class="rss"><a href="http://yoast.com/feed/">Subscribe with RSS</a></li>';
169
+ $content .= '<li class="email"><a href="http://yoast.com/email-blog-updates/">Subscribe by email</a></li>';
170
+ $this->postbox('yoastlatest', 'Latest news from Yoast', $content);
171
+ } else {
172
+ $this->postbox('yoastlatest', 'Latest news from Yoast', 'Nothing to say...');
173
+ }
174
+ }
175
+
176
+ function text_limit( $text, $limit, $finish = ' [&hellip;]') {
177
+ if( strlen( $text ) > $limit ) {
178
+ $text = substr( $text, 0, $limit );
179
+ $text = substr( $text, 0, - ( strlen( strrchr( $text,' ') ) ) );
180
+ $text .= $finish;
181
+ }
182
+ return $text;
183
+ }
184
+
185
+ function db_widget() {
186
+ $options = get_option('yoastdbwidget');
187
+ if (isset($_POST['yoast_removedbwidget'])) {
188
+ $options['removedbwidget'] = true;
189
+ update_option('yoastdbwidget',$options);
190
+ }
191
+ if ($options['removedbwidget']) {
192
+ echo "If you reload, this widget will be gone and never appear again, unless you decide to delete the database option 'yoastdbwidget'.";
193
+ return;
194
+ }
195
+ require_once(ABSPATH.WPINC.'/rss.php');
196
+ if ( $rss = fetch_rss( 'http://yoast.com/feed/' ) ) {
197
+ echo '<div class="rss-widget">';
198
+ echo '<a href="http://yoast.com/" title="Go to Yoast.com"><img src="http://netdna.yoast.com/yoast-logo-rss.png" class="alignright" alt="Yoast"/></a>';
199
+ echo '<ul>';
200
+ $rss->items = array_slice( $rss->items, 0, 3 );
201
+ foreach ( (array) $rss->items as $item ) {
202
+ echo '<li>';
203
+ echo '<a class="rsswidget" href="'.clean_url( $item['link'], $protocolls=null, 'display' ).'">'. htmlentities($item['title']) .'</a> ';
204
+ echo '<span class="rss-date">'. date('F j, Y', strtotime($item['pubdate'])) .'</span>';
205
+ echo '<div class="rssSummary">'. $this->text_limit($item['summary'],250) .'</div>';
206
+ echo '</li>';
207
+ }
208
+ echo '</ul>';
209
+ echo '<div style="border-top: 1px solid #ddd; padding-top: 10px; text-align:center;">';
210
+ echo '<a href="http://feeds2.feedburner.com/joostdevalk"><img src="'.get_bloginfo('wpurl').'/wp-includes/images/rss.png" alt=""/> Subscribe with RSS</a>';
211
+ echo ' &nbsp; &nbsp; &nbsp; ';
212
+ echo '<a href="http://yoast.com/email-blog-updates/"><img src="http://netdna.yoast.com/email_sub.png" alt=""/> Subscribe by email</a>';
213
+ echo '<form class="alignright" method="post"><input type="hidden" name="yoast_removedbwidget" value="true"/><input title="Remove this widget from all users dashboards" type="submit" value="X"/></form>';
214
+ echo '</div>';
215
+ echo '</div>';
216
+ }
217
+ }
218
+
219
+ function widget_setup() {
220
+ $options = get_option('yoastdbwidget');
221
+ if (!$options['removedbwidget'])
222
+ wp_add_dashboard_widget( 'yoast_db_widget' , 'The Latest news from Yoast' , array(&$this, 'db_widget'));
223
+ }
224
+ }
225
+ }
226
+
227
+ ?>