Version Description
Download this release
Release Info
Developer | aaroncampbell |
Plugin | Twitter Widget Pro |
Version | 1.1.4 |
Comparing to | |
See all releases |
Code changes from version 1.1.3 to 1.1.4
- readme.txt +1 -1
- wp-twitter-widget.php +31 -10
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.5
|
6 |
Tested up to: 2.5.1
|
7 |
-
Stable tag: 1.1.
|
8 |
|
9 |
A widget that properly handles twitter feeds (single user or including friends), including parsing @username and URLs into links. Requires PHP5.
|
10 |
|
4 |
Tags: twitter, widget, feed
|
5 |
Requires at least: 2.5
|
6 |
Tested up to: 2.5.1
|
7 |
+
Stable tag: 1.1.4
|
8 |
|
9 |
A widget that properly handles twitter feeds (single user or including friends), including parsing @username and URLs into links. Requires PHP5.
|
10 |
|
wp-twitter-widget.php
CHANGED
@@ -3,13 +3,17 @@
|
|
3 |
* Plugin Name: Twitter Widget Pro
|
4 |
* Plugin URI: http://xavisys.com/wordpress-twitter-widget/
|
5 |
* Description: A widget that properly handles twitter feeds, including @username and link parsing, feeds that include friends or just one user, and can even display profile images for the users. Requires PHP5.
|
6 |
-
* Version: 1.1.
|
7 |
* Author: Aaron D. Campbell
|
8 |
* Author URI: http://xavisys.com/
|
9 |
*/
|
10 |
|
11 |
/**
|
12 |
* Changelog:
|
|
|
|
|
|
|
|
|
13 |
* 05/08/2008: 1.1.3
|
14 |
* - Fixed validation problems if source is a link containg an &
|
15 |
*
|
@@ -66,6 +70,8 @@
|
|
66 |
* http://codex.wordpress.org/Writing_a_Plugin#Avoiding_Function_Name_Collisions
|
67 |
*/
|
68 |
|
|
|
|
|
69 |
class wpTwitterWidget
|
70 |
{
|
71 |
/**
|
@@ -116,7 +122,7 @@ class wpTwitterWidget
|
|
116 |
}
|
117 |
} else {
|
118 |
// Failed to fetch url;
|
119 |
-
|
120 |
}
|
121 |
}
|
122 |
|
@@ -214,9 +220,13 @@ class wpTwitterWidget
|
|
214 |
$tweets = wp_cache_get($widgetOptions['feed'] . $widgetOptions['username'], 'widget_twitter');
|
215 |
// If there is no cache
|
216 |
if ($tweets == false) {
|
217 |
-
|
218 |
-
|
219 |
-
|
|
|
|
|
|
|
|
|
220 |
}
|
221 |
return $tweets;
|
222 |
}
|
@@ -255,8 +265,13 @@ class wpTwitterWidget
|
|
255 |
$options[$number]['hiderss'] = (isset($options[$number]['hiderss']) && $options[$number]['hiderss']);
|
256 |
$options[$number]['avatar'] = (isset($options[$number]['avatar']) && $options[$number]['avatar']);
|
257 |
|
258 |
-
|
259 |
-
|
|
|
|
|
|
|
|
|
|
|
260 |
|
261 |
echo $before_widget;
|
262 |
|
@@ -277,6 +292,11 @@ class wpTwitterWidget
|
|
277 |
$options[$number]['title'] = "Twitter: {$options[$number]['username']}";
|
278 |
}
|
279 |
echo $before_title . $options[$number]['title'] . $after_title;
|
|
|
|
|
|
|
|
|
|
|
280 |
?>
|
281 |
<ul><?php
|
282 |
if ( $options[$number]['feed'] == 'user' && !empty($tweets) && $options[$number]['avatar']) {
|
@@ -311,8 +331,9 @@ class wpTwitterWidget
|
|
311 |
</li>
|
312 |
<?php
|
313 |
} ?></ul>
|
314 |
-
|
315 |
-
|
|
|
316 |
}
|
317 |
|
318 |
/**
|
@@ -562,4 +583,4 @@ $wpTwitterWidget = new wpTwitterWidget();
|
|
562 |
*/
|
563 |
add_action('widgets_init', array($wpTwitterWidget, 'register'));
|
564 |
add_filter('widget_twitter_content', array($wpTwitterWidget, 'linkTwitterUsers'));
|
565 |
-
add_filter('widget_twitter_content', array($wpTwitterWidget, 'linkUrls'));
|
3 |
* Plugin Name: Twitter Widget Pro
|
4 |
* Plugin URI: http://xavisys.com/wordpress-twitter-widget/
|
5 |
* Description: A widget that properly handles twitter feeds, including @username and link parsing, feeds that include friends or just one user, and can even display profile images for the users. Requires PHP5.
|
6 |
+
* Version: 1.1.4
|
7 |
* Author: Aaron D. Campbell
|
8 |
* Author URI: http://xavisys.com/
|
9 |
*/
|
10 |
|
11 |
/**
|
12 |
* Changelog:
|
13 |
+
* 05/14/2008: 1.1.4
|
14 |
+
* - Added an error if there was a problem connecting to Twitter.
|
15 |
+
* - Added some text if there are no tweets.
|
16 |
+
*
|
17 |
* 05/08/2008: 1.1.3
|
18 |
* - Fixed validation problems if source is a link containg an &
|
19 |
*
|
70 |
* http://codex.wordpress.org/Writing_a_Plugin#Avoiding_Function_Name_Collisions
|
71 |
*/
|
72 |
|
73 |
+
class wpTwitterWidgetException extends Exception {}
|
74 |
+
|
75 |
class wpTwitterWidget
|
76 |
{
|
77 |
/**
|
122 |
}
|
123 |
} else {
|
124 |
// Failed to fetch url;
|
125 |
+
throw new wpTwitterWidgetException(__('Could not connect to Twitter'));
|
126 |
}
|
127 |
}
|
128 |
|
220 |
$tweets = wp_cache_get($widgetOptions['feed'] . $widgetOptions['username'], 'widget_twitter');
|
221 |
// If there is no cache
|
222 |
if ($tweets == false) {
|
223 |
+
try {
|
224 |
+
$tweets = $this->_parseFeed($widgetOptions);
|
225 |
+
// Cache for 60 seconds, Tweets are supposed to be current, so we don't cache for very long
|
226 |
+
wp_cache_set($widgetOptions['feed'] . $widgetOptions['username'], $tweets, 'widget_twitter', 60);
|
227 |
+
} catch (wpTwitterWidgetException $e) {
|
228 |
+
throw $e;
|
229 |
+
}
|
230 |
}
|
231 |
return $tweets;
|
232 |
}
|
265 |
$options[$number]['hiderss'] = (isset($options[$number]['hiderss']) && $options[$number]['hiderss']);
|
266 |
$options[$number]['avatar'] = (isset($options[$number]['avatar']) && $options[$number]['avatar']);
|
267 |
|
268 |
+
|
269 |
+
try {
|
270 |
+
$tweets = $this->_getTweets($options[$number]);
|
271 |
+
$tweets = array_slice($tweets, 0, $options[$number]['items']);
|
272 |
+
} catch (wpTwitterWidgetException $e) {
|
273 |
+
$tweets = $e;
|
274 |
+
}
|
275 |
|
276 |
echo $before_widget;
|
277 |
|
292 |
$options[$number]['title'] = "Twitter: {$options[$number]['username']}";
|
293 |
}
|
294 |
echo $before_title . $options[$number]['title'] . $after_title;
|
295 |
+
if (is_a($tweets, 'wpTwitterWidgetException')) {
|
296 |
+
echo '<ul><li class="wpTwitterWidgetError">' . $tweets->getMessage() . '</li></ul>';
|
297 |
+
} else if (count($tweets) == 0) {
|
298 |
+
echo '<ul><li class="wpTwitterWidgetEmpty">' . __('No Tweets Available') . '</li></ul>';
|
299 |
+
} else {
|
300 |
?>
|
301 |
<ul><?php
|
302 |
if ( $options[$number]['feed'] == 'user' && !empty($tweets) && $options[$number]['avatar']) {
|
331 |
</li>
|
332 |
<?php
|
333 |
} ?></ul>
|
334 |
+
<?php
|
335 |
+
}
|
336 |
+
echo $after_widget;
|
337 |
}
|
338 |
|
339 |
/**
|
583 |
*/
|
584 |
add_action('widgets_init', array($wpTwitterWidget, 'register'));
|
585 |
add_filter('widget_twitter_content', array($wpTwitterWidget, 'linkTwitterUsers'));
|
586 |
+
add_filter('widget_twitter_content', array($wpTwitterWidget, 'linkUrls'));
|