Twitter Widget Pro - Version 2.1.1

Version Description

  • Added an option to open links in new windows
Download this release

Release Info

Developer aaroncampbell
Plugin Icon wp plugin Twitter Widget Pro
Version 2.1.1
Comparing to
See all releases

Code changes from version 2.1.0 to 2.1.1

languages/twitter-widget-pro.pot CHANGED
@@ -7,7 +7,7 @@ msgid ""
7
  msgstr ""
8
  "Project-Id-Version: PACKAGE VERSION\n"
9
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/twitter-widget-pro\n"
10
- "POT-Creation-Date: 2009-11-11 22:34+0000\n"
11
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -24,174 +24,179 @@ msgstr ""
24
  msgid "Twitter Widget Pro"
25
  msgstr ""
26
 
27
- #: wp-twitter-widget.php:71
28
  msgid "Twitter username:"
29
  msgstr ""
30
 
31
- #: wp-twitter-widget.php:72
32
  msgid "username"
33
  msgstr ""
34
 
35
- #: wp-twitter-widget.php:75
36
  msgid "Give the feed a title (optional):"
37
  msgstr ""
38
 
39
- #: wp-twitter-widget.php:76
40
  msgid "title"
41
  msgstr ""
42
 
43
- #: wp-twitter-widget.php:79
44
  msgid "How many items would you like to display?"
45
  msgstr ""
46
 
47
- #: wp-twitter-widget.php:90
48
  msgid "Hide @replies"
49
  msgstr ""
50
 
51
- #: wp-twitter-widget.php:93
52
  msgid "What to display when Twitter is down (optional):"
53
  msgstr ""
54
 
55
- #: wp-twitter-widget.php:94
56
  msgid "errmsg"
57
  msgstr ""
58
 
59
- #: wp-twitter-widget.php:97
60
  msgid "Number of seconds to wait for a response from Twitter (default 2):"
61
  msgstr ""
62
 
63
- #: wp-twitter-widget.php:98
64
  msgid "fetchTimeOut"
65
  msgstr ""
66
 
67
- #: wp-twitter-widget.php:101
68
  msgid "Show date/time of Tweet (rather than 2 ____ ago):"
69
  msgstr ""
70
 
71
- #: wp-twitter-widget.php:103
72
  msgid "Always"
73
  msgstr ""
74
 
75
- #: wp-twitter-widget.php:104
76
  msgid "If over an hour old"
77
  msgstr ""
78
 
79
- #: wp-twitter-widget.php:105
80
  msgid "If over a day old"
81
  msgstr ""
82
 
83
- #: wp-twitter-widget.php:106
84
  msgid "If over a week old"
85
  msgstr ""
86
 
87
- #: wp-twitter-widget.php:107
88
  msgid "If over a month old"
89
  msgstr ""
90
 
91
- #: wp-twitter-widget.php:108
92
  msgid "If over a year old"
93
  msgstr ""
94
 
95
- #: wp-twitter-widget.php:109
96
  msgid "Never"
97
  msgstr ""
98
 
99
- #: wp-twitter-widget.php:114
100
  msgid "Hide RSS Icon and Link"
101
  msgstr ""
102
 
103
- #: wp-twitter-widget.php:118
 
 
 
 
104
  msgid "Show Profile Image"
105
  msgstr ""
106
 
107
- #: wp-twitter-widget.php:122
108
  msgid "Show Link to Twitter Widget Pro"
109
  msgstr ""
110
 
111
- #: wp-twitter-widget.php:241
112
  msgid "Manage Widgets"
113
  msgstr ""
114
 
115
- #: wp-twitter-widget.php:343
116
  msgid "Syndicate this content"
117
  msgstr ""
118
 
119
- #: wp-twitter-widget.php:361
120
  msgid "No Tweets Available"
121
  msgstr ""
122
 
123
- #: wp-twitter-widget.php:369
124
  #, php-format
125
  msgid "from %s"
126
  msgstr ""
127
 
128
- #: wp-twitter-widget.php:384
129
  #, php-format
130
  msgid "in reply to %s"
131
  msgstr ""
132
 
133
- #: wp-twitter-widget.php:406
134
- #, php-format
135
- msgid ""
136
- "Powered by <a href=\"%s\" title=\"Get Twitter Widget for your WordPress site"
137
- "\">WordPress Twitter Widget Pro</a>"
138
  msgstr ""
139
 
140
- #: wp-twitter-widget.php:467
 
 
 
 
141
  msgid "Invalid Twitter Response."
142
  msgstr ""
143
 
144
- #: wp-twitter-widget.php:481
145
  msgid "Could not connect to Twitter"
146
  msgstr ""
147
 
148
- #: wp-twitter-widget.php:533
149
  msgid "h:i:s A F d, Y"
150
  msgstr ""
151
 
152
- #: wp-twitter-widget.php:544
153
  #, php-format
154
  msgid "about %s year ago"
155
  msgid_plural "about %s years ago"
156
  msgstr[0] ""
157
  msgstr[1] ""
158
 
159
- #: wp-twitter-widget.php:545
160
  #, php-format
161
  msgid "about %s month ago"
162
  msgid_plural "about %s months ago"
163
  msgstr[0] ""
164
  msgstr[1] ""
165
 
166
- #: wp-twitter-widget.php:546
167
  #, php-format
168
  msgid "about %s week ago"
169
  msgid_plural "about %s weeks ago"
170
  msgstr[0] ""
171
  msgstr[1] ""
172
 
173
- #: wp-twitter-widget.php:547
174
  #, php-format
175
  msgid "about %s day ago"
176
  msgid_plural "about %s days ago"
177
  msgstr[0] ""
178
  msgstr[1] ""
179
 
180
- #: wp-twitter-widget.php:548
181
  #, php-format
182
  msgid "about %s hour ago"
183
  msgid_plural "about %s hours ago"
184
  msgstr[0] ""
185
  msgstr[1] ""
186
 
187
- #: wp-twitter-widget.php:549
188
  #, php-format
189
  msgid "about %s minute ago"
190
  msgid_plural "about %s minutes ago"
191
  msgstr[0] ""
192
  msgstr[1] ""
193
 
194
- #: wp-twitter-widget.php:550
195
  #, php-format
196
  msgid "about %s second ago"
197
  msgid_plural "about %s seconds ago"
7
  msgstr ""
8
  "Project-Id-Version: PACKAGE VERSION\n"
9
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/twitter-widget-pro\n"
10
+ "POT-Creation-Date: 2009-11-13 21:31+0000\n"
11
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
24
  msgid "Twitter Widget Pro"
25
  msgstr ""
26
 
27
+ #: wp-twitter-widget.php:72
28
  msgid "Twitter username:"
29
  msgstr ""
30
 
31
+ #: wp-twitter-widget.php:73
32
  msgid "username"
33
  msgstr ""
34
 
35
+ #: wp-twitter-widget.php:76
36
  msgid "Give the feed a title (optional):"
37
  msgstr ""
38
 
39
+ #: wp-twitter-widget.php:77
40
  msgid "title"
41
  msgstr ""
42
 
43
+ #: wp-twitter-widget.php:80
44
  msgid "How many items would you like to display?"
45
  msgstr ""
46
 
47
+ #: wp-twitter-widget.php:91
48
  msgid "Hide @replies"
49
  msgstr ""
50
 
51
+ #: wp-twitter-widget.php:94
52
  msgid "What to display when Twitter is down (optional):"
53
  msgstr ""
54
 
55
+ #: wp-twitter-widget.php:95
56
  msgid "errmsg"
57
  msgstr ""
58
 
59
+ #: wp-twitter-widget.php:98
60
  msgid "Number of seconds to wait for a response from Twitter (default 2):"
61
  msgstr ""
62
 
63
+ #: wp-twitter-widget.php:99
64
  msgid "fetchTimeOut"
65
  msgstr ""
66
 
67
+ #: wp-twitter-widget.php:102
68
  msgid "Show date/time of Tweet (rather than 2 ____ ago):"
69
  msgstr ""
70
 
71
+ #: wp-twitter-widget.php:104
72
  msgid "Always"
73
  msgstr ""
74
 
75
+ #: wp-twitter-widget.php:105
76
  msgid "If over an hour old"
77
  msgstr ""
78
 
79
+ #: wp-twitter-widget.php:106
80
  msgid "If over a day old"
81
  msgstr ""
82
 
83
+ #: wp-twitter-widget.php:107
84
  msgid "If over a week old"
85
  msgstr ""
86
 
87
+ #: wp-twitter-widget.php:108
88
  msgid "If over a month old"
89
  msgstr ""
90
 
91
+ #: wp-twitter-widget.php:109
92
  msgid "If over a year old"
93
  msgstr ""
94
 
95
+ #: wp-twitter-widget.php:110
96
  msgid "Never"
97
  msgstr ""
98
 
99
+ #: wp-twitter-widget.php:115
100
  msgid "Hide RSS Icon and Link"
101
  msgstr ""
102
 
103
+ #: wp-twitter-widget.php:119
104
+ msgid "Open links in a new window"
105
+ msgstr ""
106
+
107
+ #: wp-twitter-widget.php:123
108
  msgid "Show Profile Image"
109
  msgstr ""
110
 
111
+ #: wp-twitter-widget.php:127
112
  msgid "Show Link to Twitter Widget Pro"
113
  msgstr ""
114
 
115
+ #: wp-twitter-widget.php:249
116
  msgid "Manage Widgets"
117
  msgstr ""
118
 
119
+ #: wp-twitter-widget.php:402
120
  msgid "Syndicate this content"
121
  msgstr ""
122
 
123
+ #: wp-twitter-widget.php:430
124
  msgid "No Tweets Available"
125
  msgstr ""
126
 
127
+ #: wp-twitter-widget.php:438
128
  #, php-format
129
  msgid "from %s"
130
  msgstr ""
131
 
132
+ #: wp-twitter-widget.php:450
133
  #, php-format
134
  msgid "in reply to %s"
135
  msgstr ""
136
 
137
+ #: wp-twitter-widget.php:472
138
+ msgid "Get Twitter Widget for your WordPress site"
 
 
 
139
  msgstr ""
140
 
141
+ #: wp-twitter-widget.php:474
142
+ msgid "Powered by"
143
+ msgstr ""
144
+
145
+ #: wp-twitter-widget.php:530
146
  msgid "Invalid Twitter Response."
147
  msgstr ""
148
 
149
+ #: wp-twitter-widget.php:544
150
  msgid "Could not connect to Twitter"
151
  msgstr ""
152
 
153
+ #: wp-twitter-widget.php:596
154
  msgid "h:i:s A F d, Y"
155
  msgstr ""
156
 
157
+ #: wp-twitter-widget.php:607
158
  #, php-format
159
  msgid "about %s year ago"
160
  msgid_plural "about %s years ago"
161
  msgstr[0] ""
162
  msgstr[1] ""
163
 
164
+ #: wp-twitter-widget.php:608
165
  #, php-format
166
  msgid "about %s month ago"
167
  msgid_plural "about %s months ago"
168
  msgstr[0] ""
169
  msgstr[1] ""
170
 
171
+ #: wp-twitter-widget.php:609
172
  #, php-format
173
  msgid "about %s week ago"
174
  msgid_plural "about %s weeks ago"
175
  msgstr[0] ""
176
  msgstr[1] ""
177
 
178
+ #: wp-twitter-widget.php:610
179
  #, php-format
180
  msgid "about %s day ago"
181
  msgid_plural "about %s days ago"
182
  msgstr[0] ""
183
  msgstr[1] ""
184
 
185
+ #: wp-twitter-widget.php:611
186
  #, php-format
187
  msgid "about %s hour ago"
188
  msgid_plural "about %s hours ago"
189
  msgstr[0] ""
190
  msgstr[1] ""
191
 
192
+ #: wp-twitter-widget.php:612
193
  #, php-format
194
  msgid "about %s minute ago"
195
  msgid_plural "about %s minutes ago"
196
  msgstr[0] ""
197
  msgstr[1] ""
198
 
199
+ #: wp-twitter-widget.php:613
200
  #, php-format
201
  msgid "about %s second ago"
202
  msgid_plural "about %s seconds ago"
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal%4
4
  Tags: twitter, widget, feed
5
  Requires at least: 2.8
6
  Tested up to: 2.9
7
- Stable tag: 2.1.0
8
 
9
  A widget that properly handles twitter feeds, including parsing @username, #hashtags, and URLs into links. Requires PHP5.
10
 
@@ -15,13 +15,12 @@ link parsing. It supports displaying profiles images, and even lets you control
15
  whether to display the time and date of a tweet or how log ago it happened
16
  (about 5 hours ago, etc). Requires PHP5.
17
 
18
- You may also be interested in WordPress tips and tricks at <a href="http://wpinformer.com">WordPress Informer</a> or gerneral <a href="http://webdevnews.net">Web Developer News</a>
19
-
20
  == Installation ==
21
 
22
  1. Verify that you have PHP5, which is required for this plugin.
23
  1. Upload the whole `twitter-widget-pro` directory to the `/wp-content/plugins/` directory
24
  1. Activate the plugin through the 'Plugins' menu in WordPress
 
25
 
26
  == Frequently Asked Questions ==
27
 
@@ -54,6 +53,7 @@ However, there are more things you can control.
54
  * hiderss - set to true to hide the RSS icon (defaults to false)
55
  * hidereplies - set to true to hide @replies that are sent from the account (defaults to false)
56
  * avatar - set to true to display the avatar from the Twitter account (defaults to false)
 
57
  * showXavisysLink - set to true to display a link to the Twitter Widget Pro page. We greatly appreciate your support in linking to this page so others can find this useful plugin too! (defaults to false)
58
  * items - The number of items to display (defaults to 10)
59
  * showts - Number of seconds old a tweet has to be to show ___ ago rather than a date/time (defaults to 86400 seconds which is 24 hours)
@@ -61,8 +61,8 @@ However, there are more things you can control.
61
 
62
  You can see these put into action by trying something like:
63
 
64
- * `[twitter-widget username="wpinformer" before_widget="<div class='half-box'>" after_widget="</div>" before_title="<h1>" after_title="</h1>" errmsg="Uh oh!" hiderss="true" hidereplies="true" avatar="1" showXavisysLink="1" items="3" showts="60"]Your Title[/twitter-widget]`
65
- * `[twitter-widget username="wpinformer" before_widget="<div class='half-box'>" after_widget="</div>" before_title="<h1>" after_title="</h1>" errmsg="Uh oh!" hiderss="true" hidereplies="true" avatar="1" showXavisysLink="1" items="3" showts="60" title="Your Title"]`
66
  * `[twitter-widget username="wpinformer"]`
67
 
68
  = Why can't I display a friends feed anymore? =
@@ -78,6 +78,9 @@ Aparently the database queries required to display the friends feed was causing
78
 
79
  == Changelog ==
80
 
 
 
 
81
  = 2.1.0 =
82
  * Added a shortcode to allow you to embed a widget in any post or page
83
 
4
  Tags: twitter, widget, feed
5
  Requires at least: 2.8
6
  Tested up to: 2.9
7
+ Stable tag: 2.1.1
8
 
9
  A widget that properly handles twitter feeds, including parsing @username, #hashtags, and URLs into links. Requires PHP5.
10
 
15
  whether to display the time and date of a tweet or how log ago it happened
16
  (about 5 hours ago, etc). Requires PHP5.
17
 
 
 
18
  == Installation ==
19
 
20
  1. Verify that you have PHP5, which is required for this plugin.
21
  1. Upload the whole `twitter-widget-pro` directory to the `/wp-content/plugins/` directory
22
  1. Activate the plugin through the 'Plugins' menu in WordPress
23
+ 1. In WordPress admin go to 'Appearance' -> 'Widgets' and add "Twitter Widget Pro" to one of your widget-ready areas of your site
24
 
25
  == Frequently Asked Questions ==
26
 
53
  * hiderss - set to true to hide the RSS icon (defaults to false)
54
  * hidereplies - set to true to hide @replies that are sent from the account (defaults to false)
55
  * avatar - set to true to display the avatar from the Twitter account (defaults to false)
56
+ * targetBlank - set to true to have all links open in a new window (defaults to false)
57
  * showXavisysLink - set to true to display a link to the Twitter Widget Pro page. We greatly appreciate your support in linking to this page so others can find this useful plugin too! (defaults to false)
58
  * items - The number of items to display (defaults to 10)
59
  * showts - Number of seconds old a tweet has to be to show ___ ago rather than a date/time (defaults to 86400 seconds which is 24 hours)
61
 
62
  You can see these put into action by trying something like:
63
 
64
+ * `[twitter-widget username="wpinformer" before_widget="<div class='half-box'>" after_widget="</div>" before_title="<h1>" after_title="</h1>" errmsg="Uh oh!" hiderss="true" hidereplies="true" targetBlank="true" avatar="1" showXavisysLink="1" items="3" showts="60"]Your Title[/twitter-widget]`
65
+ * `[twitter-widget username="wpinformer" before_widget="<div class='half-box'>" after_widget="</div>" before_title="<h1>" after_title="</h1>" errmsg="Uh oh!" hiderss="true" hidereplies="true" targetBlank="true" avatar="1" showXavisysLink="1" items="3" showts="60" title="Your Title"]`
66
  * `[twitter-widget username="wpinformer"]`
67
 
68
  = Why can't I display a friends feed anymore? =
78
 
79
  == Changelog ==
80
 
81
+ = 2.1.1 =
82
+ * Added an option to open links in new windows
83
+
84
  = 2.1.0 =
85
  * Added a shortcode to allow you to embed a widget in any post or page
86
 
wp-twitter-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Twitter Widget Pro
4
  * Plugin URI: http://xavisys.com/wordpress-plugins/wordpress-twitter-widget/
5
  * Description: A widget that properly handles twitter feeds, including @username, #hashtag, and link parsing. It can even display profile images for the users. Requires PHP5.
6
- * Version: 2.1.0
7
  * Author: Aaron D. Campbell
8
  * Author URI: http://xavisys.com/
9
  * Text Domain: twitter-widget-pro
@@ -57,6 +57,7 @@ class WP_Widget_Twitter_Pro extends WP_Widget {
57
  'hidereplies' => false,
58
  'avatar' => false,
59
  'showXavisysLink' => false,
 
60
  'items' => 10,
61
  'showts' => 60 * 60 * 24,
62
  );
@@ -113,6 +114,10 @@ class WP_Widget_Twitter_Pro extends WP_Widget {
113
  <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id('hiderss'); ?>" name="<?php echo $this->get_field_name('hiderss'); ?>"<?php checked($instance['hiderss'], 'true'); ?> />
114
  <label for="<?php echo $this->get_field_id('hiderss'); ?>"><?php _e('Hide RSS Icon and Link', 'twitter-widget-pro'); ?></label>
115
  </p>
 
 
 
 
116
  <p>
117
  <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id('avatar'); ?>" name="<?php echo $this->get_field_name('avatar'); ?>"<?php checked($instance['avatar'], 'true'); ?> />
118
  <label for="<?php echo $this->get_field_id('avatar'); ?>"><?php _e('Show Profile Image', 'twitter-widget-pro'); ?></label>
@@ -231,11 +236,11 @@ class wpTwitterWidget
231
  * @return string - Username as link (XHTML)
232
  */
233
  private function _getUserName($user) {
234
- return <<<profileImage
235
- <strong>
236
- <a title="{$user->name}" href="http://twitter.com/{$user->screen_name}">{$user->screen_name}</a>
237
- </strong>
238
- profileImage;
239
  }
240
 
241
  public function addWidgetLink( $links, $file ){
@@ -254,10 +259,18 @@ profileImage;
254
  * @return string - Tweet text with @replies linked
255
  */
256
  public function linkTwitterUsers($text) {
257
- $text = preg_replace('/(^|\s)@(\w*)/i', '$1<a href="http://twitter.com/$2" class="twitter-user">@$2</a>', $text);
258
  return $text;
259
  }
260
 
 
 
 
 
 
 
 
 
261
  /**
262
  * Replace #hashtag with a link to search.twitter.com for that hashtag
263
  *
@@ -276,9 +289,11 @@ profileImage;
276
  * @return string - Tweet text with #hashtags linked
277
  */
278
  private function _hashtagLink($matches) {
279
- return "{$matches[1]}<a href='http://search.twitter.com/search?q="
280
- . urlencode($matches[2])
281
- . "' class='twitter-hashtag'>{$matches[2]}</a>";
 
 
282
  }
283
 
284
  /**
@@ -296,7 +311,7 @@ profileImage;
296
  * $4 is the URL without the protocol://
297
  * $5 is the URL parameters
298
  */
299
- $text = preg_replace("/(^|\s)(([a-zA-Z]+:\/\/)([a-z][a-z0-9_\..-]*[a-z]{2,6})([a-zA-Z0-9~\/*-?&%]*))/i", "$1<a href=\"$2\">$2</a>", $text);
300
 
301
  /**
302
  * match www.something.domain/path/file.extension?some=variable&another=asf%
@@ -306,18 +321,57 @@ profileImage;
306
  * $4 is the URL matched without the www.
307
  * $5 is the URL parameters
308
  */
309
- $text = preg_replace("/(^|\s)(www\.([a-z][a-z0-9_\..-]*[a-z]{2,6})([a-zA-Z0-9~\/*-?&%]*))/i", "$1<a href=\"http://$2\">$2</a>", $text);
310
 
311
  return $text;
312
  }
313
 
314
- function register() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  register_widget('WP_Widget_Twitter_Pro');
316
  }
317
 
 
 
 
 
 
318
  public function display( $args ) {
319
  $args = wp_parse_args( $args );
320
 
 
 
 
 
321
  // Validate our options
322
  $args['items'] = (int) $args['items'];
323
  if ( $args['items'] < 1 || 20 < $args['items'] ) {
@@ -343,14 +397,26 @@ profileImage;
343
  $icon = get_option('siteurl').'/wp-includes/images/rss.png';
344
  }
345
  $feedUrl = $this->_getFeedUrl($args, 'rss', false);
346
- $args['before_title'] .= "<a class='twitterwidget twitterwidget-rss' href='{$feedUrl}' title='" . attribute_escape(__('Syndicate this content', 'twitter-widget-pro')) ."'><img style='background:orange;color:white;border:none;' width='14' height='14' src='{$icon}' alt='RSS' /></a> ";
 
 
 
 
 
 
347
  }
348
  $twitterLink = 'http://twitter.com/' . $args['username'];
349
- $args['before_title'] .= "<a class='twitterwidget twitterwidget-title' href='{$twitterLink}' title='" . attribute_escape("Twitter: {$args['username']}") . "'>";
350
  $args['after_title'] = '</a>' . $args['after_title'];
351
  if (empty($args['title'])) {
352
  $args['title'] = "Twitter: {$args['username']}";
353
  }
 
 
 
 
 
 
354
  $widgetContent .= $args['before_title'] . $args['title'] . $args['after_title'];
355
  if (!is_a($tweets, 'wpTwitterWidgetException') && !empty($tweets[0]) && $args['avatar'] == 'true') {
356
  $widgetContent .= '<div class="twitter-avatar">';
@@ -370,33 +436,27 @@ profileImage;
370
  $tweet->ago = $this->_timeSince(strtotime($tweet->created_at), $args['showts']);
371
  $entryContent = apply_filters( 'widget_twitter_content', $tweet->text );
372
  $from = sprintf(__('from %s', 'twitter-widget-pro'), str_replace('&', '&amp;', $tweet->source));
373
- $widgetContent .= <<<WIDGET_START
374
- <li>
375
- <span class="entry-content">{$entryContent}</span>
376
- <span class="entry-meta">
377
- <span class="time-meta">
378
- <a href="http://twitter.com/{$tweet->user->screen_name}/statuses/{$tweet->id}">
379
- {$tweet->ago}
380
- </a>
381
- </span>
382
- <span class="from-meta">
383
- {$from}
384
- </span>
385
- WIDGET_START;
386
- if (!empty($tweet->in_reply_to_screen_name)) {
387
- $rtLinkText = sprintf( __('in reply to %s', 'twitter-widget-pro'), $tweet->in_reply_to_screen_name );
388
- $widgetContent .= <<<replyTo
389
- <span class="in-reply-to-meta">
390
- <a href="http://twitter.com/{$tweet->in_reply_to_screen_name}/statuses/{$tweet->in_reply_to_status_id}" class="reply-to">
391
- {$rtLinkText}
392
- </a>
393
- </span>
394
- replyTo;
395
- }
396
- $widgetContent .= <<<WIDGET_ENTRY_END
397
- </span>
398
- </li>
399
- WIDGET_ENTRY_END;
400
 
401
  if (++$count >= $args['items']) {
402
  break;
@@ -406,14 +466,14 @@ WIDGET_ENTRY_END;
406
  }
407
 
408
  if ( $args['showXavisysLink'] == 'true' ) {
409
- $xavisysLink = sprintf(__('Powered by <a href="%s" title="Get Twitter Widget for your WordPress site">WordPress Twitter Widget Pro</a>', 'twitter-widget-pro'), 'http://xavisys.com/wordpress-plugins/wordpress-twitter-widget/' );
410
- $widgetContent .= <<<XAVISYS_LINK
411
- <li class="xavisys-link">
412
- <span class="xavisys-link-text">
413
- {$xavisysLink}
414
- </span>
415
- </li>
416
- XAVISYS_LINK;
417
  }
418
  $widgetContent .= '</ul></div>' . $args['after_widget'];
419
  return $widgetContent;
@@ -563,11 +623,11 @@ XAVISYS_LINK;
563
  * @return string - Linked image (XHTML)
564
  */
565
  private function _getProfileImage($user) {
566
- return <<<profileImage
567
- <a title="{$user->name}" href="http://twitter.com/{$user->screen_name}">
568
- <img alt="{$user->name}" src="{$user->profile_image_url}" />
569
- </a>
570
- profileImage;
571
  }
572
 
573
  /**
@@ -591,6 +651,7 @@ profileImage;
591
  'hidereplies' => false,
592
  'avatar' => false,
593
  'showXavisysLink' => false,
 
594
  'items' => 10,
595
  'showts' => 60 * 60 * 24,
596
  );
@@ -612,6 +673,9 @@ profileImage;
612
  if ( $attr['showXavisysLink'] && $attr['showXavisysLink'] != 'false' && $attr['showXavisysLink'] != '0' ) {
613
  $attr['showXavisysLink'] == true;
614
  }
 
 
 
615
 
616
  return $this->display($attr);
617
  }
3
  * Plugin Name: Twitter Widget Pro
4
  * Plugin URI: http://xavisys.com/wordpress-plugins/wordpress-twitter-widget/
5
  * Description: A widget that properly handles twitter feeds, including @username, #hashtag, and link parsing. It can even display profile images for the users. Requires PHP5.
6
+ * Version: 2.1.1
7
  * Author: Aaron D. Campbell
8
  * Author URI: http://xavisys.com/
9
  * Text Domain: twitter-widget-pro
57
  'hidereplies' => false,
58
  'avatar' => false,
59
  'showXavisysLink' => false,
60
+ 'targetBlank' => false,
61
  'items' => 10,
62
  'showts' => 60 * 60 * 24,
63
  );
114
  <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id('hiderss'); ?>" name="<?php echo $this->get_field_name('hiderss'); ?>"<?php checked($instance['hiderss'], 'true'); ?> />
115
  <label for="<?php echo $this->get_field_id('hiderss'); ?>"><?php _e('Hide RSS Icon and Link', 'twitter-widget-pro'); ?></label>
116
  </p>
117
+ <p>
118
+ <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id('targetBlank'); ?>" name="<?php echo $this->get_field_name('targetBlank'); ?>"<?php checked($instance['targetBlank'], 'true'); ?> />
119
+ <label for="<?php echo $this->get_field_id('targetBlank'); ?>"><?php _e('Open links in a new window', 'twitter-widget-pro'); ?></label>
120
+ </p>
121
  <p>
122
  <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id('avatar'); ?>" name="<?php echo $this->get_field_name('avatar'); ?>"<?php checked($instance['avatar'], 'true'); ?> />
123
  <label for="<?php echo $this->get_field_id('avatar'); ?>"><?php _e('Show Profile Image', 'twitter-widget-pro'); ?></label>
236
  * @return string - Username as link (XHTML)
237
  */
238
  private function _getUserName($user) {
239
+ $attrs = array(
240
+ 'href' => "http://twitter.com/{$user->screen_name}",
241
+ 'title' => $user->name
242
+ );
243
+ return '<strong>' . $this->_buildLink($user->screen_name, $attrs) . '</strong>';
244
  }
245
 
246
  public function addWidgetLink( $links, $file ){
259
  * @return string - Tweet text with @replies linked
260
  */
261
  public function linkTwitterUsers($text) {
262
+ $text = preg_replace_callback('/(^|\s)@(\w*)/i', array($this, '_linkTwitterUsersCallback'), $text);
263
  return $text;
264
  }
265
 
266
+ private function _linkTwitterUsersCallback($matches) {
267
+ $linkAttrs = array(
268
+ 'href' => 'http://twitter.com/' . urlencode($matches[2]),
269
+ 'class' => 'twitter-user'
270
+ );
271
+ return $matches[1] . $this->_buildLink('@'.$matches[2], $linkAttrs);
272
+ }
273
+
274
  /**
275
  * Replace #hashtag with a link to search.twitter.com for that hashtag
276
  *
289
  * @return string - Tweet text with #hashtags linked
290
  */
291
  private function _hashtagLink($matches) {
292
+ $linkAttrs = array(
293
+ 'href' => 'http://search.twitter.com/search?q=' . urlencode($matches[2]),
294
+ 'class' => 'twitter-hashtag'
295
+ );
296
+ return $matches[1] . $this->_buildLink($matches[2], $linkAttrs);
297
  }
298
 
299
  /**
311
  * $4 is the URL without the protocol://
312
  * $5 is the URL parameters
313
  */
314
+ $text = preg_replace_callback("/(^|\s)(([a-zA-Z]+:\/\/)([a-z][a-z0-9_\..-]*[a-z]{2,6})([a-zA-Z0-9~\/*-?&%]*))/i", array($this, '_linkUrlsCallback'), $text);
315
 
316
  /**
317
  * match www.something.domain/path/file.extension?some=variable&another=asf%
321
  * $4 is the URL matched without the www.
322
  * $5 is the URL parameters
323
  */
324
+ $text = preg_replace_callback("/(^|\s)(www\.([a-z][a-z0-9_\..-]*[a-z]{2,6})([a-zA-Z0-9~\/*-?&%]*))/i", array($this, '_linkUrlsCallback'), $text);
325
 
326
  return $text;
327
  }
328
 
329
+ private function _linkUrlsCallback ($matches) {
330
+ $linkAttrs = array(
331
+ 'href' => $matches[2]
332
+ );
333
+ return $matches[1] . $this->_buildLink($matches[2], $linkAttrs);
334
+ }
335
+
336
+ private function _notEmpty( $v ) {
337
+ return !(empty($v));
338
+ }
339
+
340
+ private function _buildLink( $text, $attributes = array(), $noFilter = false ) {
341
+ $attributes = array_filter( wp_parse_args( $attributes ), array($this, '_notEmpty' ) );
342
+ $attributes = apply_filters( 'widget_twitter_link_attributes', $attributes );
343
+ $attributes = wp_parse_args( $attributes );
344
+ $text = apply_filters( 'widget_twitter_link_text', $text );
345
+ $link = '<a';
346
+ foreach ( $attributes as $name => $value ) {
347
+ $link .= ' ' . esc_attr($name) . '="' . esc_attr($value) . '"';
348
+ }
349
+ $link .= '>';
350
+ if ( $no_filter ) {
351
+ $link .= esc_html($text);
352
+ } else {
353
+ $link .= $text;
354
+ }
355
+ $link .= '</a>';
356
+ return $link;
357
+ }
358
+
359
+ public function register() {
360
  register_widget('WP_Widget_Twitter_Pro');
361
  }
362
 
363
+ public function targetBlank($attributes) {
364
+ $attributes['target'] = '_blank';
365
+ return $attributes;
366
+ }
367
+
368
  public function display( $args ) {
369
  $args = wp_parse_args( $args );
370
 
371
+ if ( $args['targetBlank'] ) {
372
+ add_filter('widget_twitter_link_attributes', array($this, 'targetBlank'));
373
+ }
374
+
375
  // Validate our options
376
  $args['items'] = (int) $args['items'];
377
  if ( $args['items'] < 1 || 20 < $args['items'] ) {
397
  $icon = get_option('siteurl').'/wp-includes/images/rss.png';
398
  }
399
  $feedUrl = $this->_getFeedUrl($args, 'rss', false);
400
+ $linkAttrs = array(
401
+ 'class' => 'twitterwidget twitterwidget-rss',
402
+ 'title' => __('Syndicate this content', 'twitter-widget-pro'),
403
+ 'href' => $feedUrl
404
+ );
405
+
406
+ $args['before_title'] .= $this->_buildLink("<img style='background:orange;color:white;border:none;' width='14' height='14' src='{$icon}' alt='RSS' />", $linkAttrs, true);
407
  }
408
  $twitterLink = 'http://twitter.com/' . $args['username'];
409
+
410
  $args['after_title'] = '</a>' . $args['after_title'];
411
  if (empty($args['title'])) {
412
  $args['title'] = "Twitter: {$args['username']}";
413
  }
414
+ $linkAttrs = array(
415
+ 'class' => 'twitterwidget twitterwidget-title',
416
+ 'title' => "Twitter: {$args['username']}",
417
+ 'href' => $twitterLink
418
+ );
419
+ $args['title'] = $this->_buildLink($args['title'], $linkAttrs, current_user_can('unfiltered_html'));
420
  $widgetContent .= $args['before_title'] . $args['title'] . $args['after_title'];
421
  if (!is_a($tweets, 'wpTwitterWidgetException') && !empty($tweets[0]) && $args['avatar'] == 'true') {
422
  $widgetContent .= '<div class="twitter-avatar">';
436
  $tweet->ago = $this->_timeSince(strtotime($tweet->created_at), $args['showts']);
437
  $entryContent = apply_filters( 'widget_twitter_content', $tweet->text );
438
  $from = sprintf(__('from %s', 'twitter-widget-pro'), str_replace('&', '&amp;', $tweet->source));
439
+ $widgetContent .= '<li>';
440
+ $widgetContent .= "<span class='entry-content'>{$entryContent}</span>";
441
+ $widgetContent .= "<span class='entry-meta'>";
442
+ $widgetContent .= "<span class='time-meta'>";
443
+ $linkAttrs = array(
444
+ 'href' => "http://twitter.com/{$tweet->user->screen_name}/statuses/{$tweet->id}"
445
+ );
446
+ $widgetContent .= $this->_buildLink($tweet->ago, $linkAttrs);
447
+ $widgetContent .= '</span>';
448
+ $widgetContent .= "<span class='from-meta'>{$from}</span>";
449
+ if ( !empty($tweet->in_reply_to_screen_name) ) {
450
+ $rtLinkText = sprintf( __('in reply to %s', 'twitter-widget-pro'), $tweet->in_reply_to_screen_name );
451
+ $widgetContent .= '<span class="in-reply-to-meta">';
452
+ $linkAttrs = array(
453
+ 'href' => "http://twitter.com/{$tweet->in_reply_to_screen_name}/statuses/{$tweet->in_reply_to_status_id}",
454
+ 'class' => 'reply-to'
455
+ );
456
+ $widgetContent .= $this->_buildLink($rtLinkText, $linkAttrs);
457
+ $widgetContent .= '</span>';
458
+ }
459
+ $widgetContent .= '</span></li>';
 
 
 
 
 
 
460
 
461
  if (++$count >= $args['items']) {
462
  break;
466
  }
467
 
468
  if ( $args['showXavisysLink'] == 'true' ) {
469
+ $widgetContent .= '<li class="xavisys-link"><span class="xavisys-link-text">';
470
+ $linkAttrs = array(
471
+ 'href' => 'http://xavisys.com/wordpress-plugins/wordpress-twitter-widget/',
472
+ 'title' => __('Get Twitter Widget for your WordPress site', 'twitter-widget-pro')
473
+ );
474
+ $widgetContent .= __('Powered by', 'twitter-widget-pro');
475
+ $widgetContent .= $this->_buildLink('WordPress Twitter Widget Pro', $linkAttrs);
476
+ $widgetContent .= '</span></li>';
477
  }
478
  $widgetContent .= '</ul></div>' . $args['after_widget'];
479
  return $widgetContent;
623
  * @return string - Linked image (XHTML)
624
  */
625
  private function _getProfileImage($user) {
626
+ $linkAttrs = array(
627
+ 'href' => "http://twitter.com/{$user->screen_name}",
628
+ 'title' => $user->name
629
+ );
630
+ return $this->_buildLink("<img alt='{$user->name}' src='{$user->profile_image_url}' />", $linkAttrs, true);
631
  }
632
 
633
  /**
651
  'hidereplies' => false,
652
  'avatar' => false,
653
  'showXavisysLink' => false,
654
+ 'targetBlank' => false,
655
  'items' => 10,
656
  'showts' => 60 * 60 * 24,
657
  );
673
  if ( $attr['showXavisysLink'] && $attr['showXavisysLink'] != 'false' && $attr['showXavisysLink'] != '0' ) {
674
  $attr['showXavisysLink'] == true;
675
  }
676
+ if ( $attr['targetBlank'] && $attr['targetBlank'] != 'false' && $attr['targetBlank'] != '0' ) {
677
+ $attr['targetBlank'] == true;
678
+ }
679
 
680
  return $this->display($attr);
681
  }