Rotating Tweets (Twitter widget and shortcode) - Version 0.42

Version Description

Fixed major bug causing crashes when Twitter goes down

=

Download this release

Release Info

Developer mpntod
Plugin Icon wp plugin Rotating Tweets (Twitter widget and shortcode)
Version 0.42
Comparing to
See all releases

Code changes from version 0.40 to 0.42

Files changed (2) hide show
  1. readme.txt +7 -4
  2. rotatingtweets.php +7 -5
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: shortcode,widget,twitter,rotating,rotate,rotator,tweet,tweets
5
  Requires at least: 2.6
6
  Tested up to: 3.4
7
- Stable tag: 0.40
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -13,7 +13,7 @@ Replaces a shortcode such as [rotatingtweets screen_name='your_twitter_name'], o
13
  == Description ==
14
  * Replaces a [shortcode](http://codex.wordpress.org/Shortcode) such as `[rotatingtweets screen_name='your_twitter_name']`, or a [widget](http://codex.wordpress.org/WordPress_Widgets), with a rotating display of your most recent tweets
15
  * Space efficient - instead of showing all your tweets at once, shows one at a time and then smoothly replaces it with the next one. After showing all your tweets, loops back to the beginning again.
16
- * Customisable - you decide whose tweets to show, how many to show, whether to include retweets and replies, and whether to show a follow button
17
  * Replaces [t.co](http://t.co) links with the original link
18
  * Caches the most recent data from Twitter to avoid problems with rate limiting
19
  * Uses [jQuery](http://jquery.com/) and [jQuery.Cycle](http://jquery.malsup.com/cycle/) to produce a nice smooth result.
@@ -40,10 +40,13 @@ But you may just decide to use the 'Rotating Tweets' widget!
40
  In most cases, each use (or "instance") of this plug-in gets data from Twitter every 2 minutes. The exception is when two or more instances share the same settings (screen name etc.), in which case they share the same data rather than each calling it separately.
41
 
42
  == Upgrade notice ==
43
- = 0.40 =
44
- Added ability to alter speed of rotation
45
 
46
  == Changelog ==
 
 
 
47
  = 0.40 =
48
  Added ability to alter speed of rotation
49
 
4
  Tags: shortcode,widget,twitter,rotating,rotate,rotator,tweet,tweets
5
  Requires at least: 2.6
6
  Tested up to: 3.4
7
+ Stable tag: 0.42
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
13
  == Description ==
14
  * Replaces a [shortcode](http://codex.wordpress.org/Shortcode) such as `[rotatingtweets screen_name='your_twitter_name']`, or a [widget](http://codex.wordpress.org/WordPress_Widgets), with a rotating display of your most recent tweets
15
  * Space efficient - instead of showing all your tweets at once, shows one at a time and then smoothly replaces it with the next one. After showing all your tweets, loops back to the beginning again.
16
+ * Customisable - you decide whose tweets to show, how many to show, whether to include retweets and replies, and whether to show a follow button. You can also decide how quickly the tweets rotate.
17
  * Replaces [t.co](http://t.co) links with the original link
18
  * Caches the most recent data from Twitter to avoid problems with rate limiting
19
  * Uses [jQuery](http://jquery.com/) and [jQuery.Cycle](http://jquery.malsup.com/cycle/) to produce a nice smooth result.
40
  In most cases, each use (or "instance") of this plug-in gets data from Twitter every 2 minutes. The exception is when two or more instances share the same settings (screen name etc.), in which case they share the same data rather than each calling it separately.
41
 
42
  == Upgrade notice ==
43
+ = 0.42 =
44
+ Fixed major bug causing crashes when Twitter goes down
45
 
46
  == Changelog ==
47
+ = 0.42 =
48
+ Fixed major bug causing crashes when Twitter goes down
49
+
50
  = 0.40 =
51
  Added ability to alter speed of rotation
52
 
rotatingtweets.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Rotating Tweets widget & shortcode
4
  Description: Replaces a shortcode such as [rotatingtweets userid='your_twitter_name'], or a widget, with a rotating tweets display
5
- Version: 0.40
6
  Author: Martin Tod
7
  Author URI: http://www.martintod.org.uk
8
  License: GPL2
@@ -70,7 +70,7 @@ class rotatingtweets_Widget extends WP_Widget {
70
  function update($new_instance, $old_instance) {
71
  $instance = $old_instance;
72
  $instance['title'] = strip_tags($new_instance['title']);
73
- $instance['tw_screen_name'] = strip_tags($new_instance['tw_screen_name']);
74
  $instance['tw_include_rts'] = absint($new_instance['tw_include_rts']);
75
  $instance['tw_exclude_replies'] = absint($new_instance['tw_exclude_replies']);
76
  $instance['tw_tweet_count'] = max(1,intval($new_instance['tw_tweet_count']));
@@ -82,7 +82,7 @@ class rotatingtweets_Widget extends WP_Widget {
82
  /** @see WP_Widget::form */
83
  function form($instance) {
84
  $title = esc_attr($instance['title']);
85
- $tw_screen_name = esc_attr($instance['tw_screen_name']);
86
  $tw_include_rts = absint($instance['tw_include_rts']);
87
  $tw_exclude_replies = absint($instance['tw_exclude_replies']);
88
  $tw_tweet_count = intval($instance['tw_tweet_count']);
@@ -177,7 +177,7 @@ add_shortcode( 'rotatingtweets', 'rotatingtweets_display' );
177
  # Get the latest data from Twitter (or from a cache if it's been less than 2 minutes since the last load)
178
  function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_replies,$tw_tweet_count) {
179
  # Clear up variables
180
- $check_regex = "%^[A-Za-z0-9_]+$%";
181
  $cache_delay = 120;
182
  if($tw_include_rts != 1) $tw_include_rts = 0;
183
  if($tw_exclude_replies != 1) $tw_exclude_replies = 0;
@@ -192,7 +192,9 @@ function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_r
192
  if($timegap > $cache_delay):
193
  $callstring = "http://api.twitter.com/1/statuses/user_timeline.json?screen_name=".$tw_screen_name."&include_entities=1&count=20&include_rts=".$tw_include_rts."&exclude_replies=".$tw_exclude_replies;
194
  $twitterdata = wp_remote_request($callstring);
195
- $twitterjson = json_decode($twitterdata['body']);
 
 
196
  endif;
197
  if(!empty($twitterjson) && empty($twitterjson->errors)):
198
  $latest_json = $twitterjson;
2
  /*
3
  Plugin Name: Rotating Tweets widget & shortcode
4
  Description: Replaces a shortcode such as [rotatingtweets userid='your_twitter_name'], or a widget, with a rotating tweets display
5
+ Version: 0.42
6
  Author: Martin Tod
7
  Author URI: http://www.martintod.org.uk
8
  License: GPL2
70
  function update($new_instance, $old_instance) {
71
  $instance = $old_instance;
72
  $instance['title'] = strip_tags($new_instance['title']);
73
+ $instance['tw_screen_name'] = strip_tags(trim($new_instance['tw_screen_name']));
74
  $instance['tw_include_rts'] = absint($new_instance['tw_include_rts']);
75
  $instance['tw_exclude_replies'] = absint($new_instance['tw_exclude_replies']);
76
  $instance['tw_tweet_count'] = max(1,intval($new_instance['tw_tweet_count']));
82
  /** @see WP_Widget::form */
83
  function form($instance) {
84
  $title = esc_attr($instance['title']);
85
+ $tw_screen_name = esc_attr(trim($instance['tw_screen_name']));
86
  $tw_include_rts = absint($instance['tw_include_rts']);
87
  $tw_exclude_replies = absint($instance['tw_exclude_replies']);
88
  $tw_tweet_count = intval($instance['tw_tweet_count']);
177
  # Get the latest data from Twitter (or from a cache if it's been less than 2 minutes since the last load)
178
  function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_replies,$tw_tweet_count) {
179
  # Clear up variables
180
+ # $check_regex = "%^[A-Za-z0-9_]+$%";
181
  $cache_delay = 120;
182
  if($tw_include_rts != 1) $tw_include_rts = 0;
183
  if($tw_exclude_replies != 1) $tw_exclude_replies = 0;
192
  if($timegap > $cache_delay):
193
  $callstring = "http://api.twitter.com/1/statuses/user_timeline.json?screen_name=".$tw_screen_name."&include_entities=1&count=20&include_rts=".$tw_include_rts."&exclude_replies=".$tw_exclude_replies;
194
  $twitterdata = wp_remote_request($callstring);
195
+ if(!is_wp_error($twitterdata)):
196
+ $twitterjson = json_decode($twitterdata['body']);
197
+ endif;
198
  endif;
199
  if(!empty($twitterjson) && empty($twitterjson->errors)):
200
  $latest_json = $twitterjson;