Rotating Tweets (Twitter widget and shortcode) - Version 0.25

Version Description

Doesn't display empty twitter feeds

Download this release

Release Info

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

Code changes from version 0.21 to 0.25

Files changed (2) hide show
  1. readme.txt +11 -5
  2. rotatingtweets.php +8 -4
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
5
  Requires at least: 2.6
6
  Tested up to: 3.3.2
7
- Stable tag: 0.21
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -14,7 +14,7 @@ Replaces a shortcode such as [rotatingtweets screen_name='your_twitter_name'], o
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 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.
20
 
@@ -27,10 +27,10 @@ If you'd like to see what it looks like in action, you can [see the plug-in work
27
  Possible variables for the shortcode include:
28
 
29
  * `screen_name` = Twitter user name - required
30
- * `include_rts` = `'0'` or `'1'` - include retweets - optional
31
- * `exclude_replies` = `'0'` or `'1'` - exclude replies - optional
32
  * `tweet_count` = number of tweets to show - optional - default is 5
33
- * `show_follow` = `'0'` or `'1'` - show follow button - optional
34
 
35
  But you may just decide to use the 'Rotating Tweets' widget!
36
 
@@ -39,6 +39,9 @@ But you may just decide to use the 'Rotating Tweets' widget!
39
  Not yet. Why not ask one?
40
 
41
  == Upgrade notice ==
 
 
 
42
  = 0.21 =
43
  Fixed a missing `</div>` in the follow-button code
44
 
@@ -46,6 +49,9 @@ Fixed a missing `</div>` in the follow-button code
46
  Fixes a serious problem with cacheing of different feeds
47
 
48
  == Changelog ==
 
 
 
49
  = 0.21 =
50
  Replaced a missing `</div>` in the follow-button code (with thanks to [jacobp](http://wordpress.org/support/profile/jacobp) for spotting it and suggesting a fix)
51
 
4
  Tags: shortcode,widget,twitter,rotating,rotate
5
  Requires at least: 2.6
6
  Tested up to: 3.3.2
7
+ Stable tag: 0.25
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
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.
20
 
27
  Possible variables for the shortcode include:
28
 
29
  * `screen_name` = Twitter user name - required
30
+ * `include_rts` = `'0'` or `'1'` - include retweets - optional - default is '0'
31
+ * `exclude_replies` = `'0'` or `'1'` - exclude replies - optional - default is '0'
32
  * `tweet_count` = number of tweets to show - optional - default is 5
33
+ * `show_follow` = `'0'` or `'1'` - show follow button - optional - default is '0'
34
 
35
  But you may just decide to use the 'Rotating Tweets' widget!
36
 
39
  Not yet. Why not ask one?
40
 
41
  == Upgrade notice ==
42
+ = 0.25 =
43
+ Doesn't display empty twitter feeds
44
+
45
  = 0.21 =
46
  Fixed a missing `</div>` in the follow-button code
47
 
49
  Fixes a serious problem with cacheing of different feeds
50
 
51
  == Changelog ==
52
+ = 0.25 =
53
+ Doesn't display empty twitter feeds
54
+
55
  = 0.21 =
56
  Replaced a missing `</div>` in the follow-button code (with thanks to [jacobp](http://wordpress.org/support/profile/jacobp) for spotting it and suggesting a fix)
57
 
rotatingtweets.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
  /*
3
  Plugin Name: Rotating Tweets widget & shortcode
4
- Description: Replaces a shortcode such as [rotatingtweets userid='mpntod'], or a widget, with a rotating tweets display
5
- Version: 0.21
6
  Author: Martin Tod
7
  Author URI: http://www.martintod.org.uk
8
  License: GPL2
@@ -23,7 +23,7 @@ License: GPL2
23
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
  */
25
  /**
26
- * Replaces a shortcode such as [rotatingtweets userid='mpntod'], or a widget, with a rotating tweets display
27
  *
28
  * @package WordPress
29
  * @since 3.3.2
@@ -181,7 +181,7 @@ function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_r
181
  $twitterdata = wp_remote_request($callstring);
182
  $twitterjson = json_decode($twitterdata['body']);
183
  endif;
184
- if(!empty($twitterjson)):
185
  $latest_json = $twitterjson;
186
  $option[$stringname][json]=$latest_json;
187
  $option[$stringname][datetime]=time();
@@ -193,9 +193,13 @@ function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_r
193
  # Displays the tweets
194
  function rotating_tweets_display($json,$tweet_count=5,$show_follow=FALSE,$print=TRUE) {
195
  unset($result);
 
196
  $tweet_count = max(1,intval($tweet_count));
197
  $result = "<div class='rotatingtweets' id='".uniqid('rotatingtweets_')."'>";
198
  $tweet_counter = 0;
 
 
 
199
  foreach($json as $twitter_object):
200
  $twitter_vars = get_object_vars($twitter_object);
201
  $tweet_counter++;
1
  <?php
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.25
6
  Author: Martin Tod
7
  Author URI: http://www.martintod.org.uk
8
  License: GPL2
23
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
  */
25
  /**
26
+ * Replaces a shortcode such as [rotatingtweets userid='your_twitter_name'], or a widget, with a rotating tweets display
27
  *
28
  * @package WordPress
29
  * @since 3.3.2
181
  $twitterdata = wp_remote_request($callstring);
182
  $twitterjson = json_decode($twitterdata['body']);
183
  endif;
184
+ if(!empty($twitterjson) && empty($twitterjson->errors)):
185
  $latest_json = $twitterjson;
186
  $option[$stringname][json]=$latest_json;
187
  $option[$stringname][datetime]=time();
193
  # Displays the tweets
194
  function rotating_tweets_display($json,$tweet_count=5,$show_follow=FALSE,$print=TRUE) {
195
  unset($result);
196
+ if(!empty($json->errors)) return;
197
  $tweet_count = max(1,intval($tweet_count));
198
  $result = "<div class='rotatingtweets' id='".uniqid('rotatingtweets_')."'>";
199
  $tweet_counter = 0;
200
+ echo "<!--";
201
+ print_r($json);
202
+ echo "-->";
203
  foreach($json as $twitter_object):
204
  $twitter_vars = get_object_vars($twitter_object);
205
  $tweet_counter++;