Rotating Tweets (Twitter widget and shortcode) - Version 1.4.7

Version Description

  • HTML5 compliance and improved rate-limiting. If you are using a version before 0.700, you will need to upgrade to a more recent version for Rotating Tweets to keep accessing Twitter after May 7, 2013.

=

Download this release

Release Info

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

Code changes from version 1.4.6 to 1.4.7

Files changed (2) hide show
  1. readme.txt +25 -10
  2. rotatingtweets.php +18 -7
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,animation,jquery,jquery cycle,cycle,multilingual,responsive
5
  Requires at least: 2.6
6
  Tested up to: 3.5.1
7
- Stable tag: 1.4.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,7 +12,7 @@ Twitter widget and shortcode to show your latest tweets one at a time an animate
12
 
13
  == Description ==
14
  * **Replaces a [shortcode](http://codex.wordpress.org/Shortcode) such as `[rotatingtweets screen_name='your_twitter']`, or a [widget](http://codex.wordpress.org/WordPress_Widgets), with a rotating display of your most recent tweets**
15
- * **Supports v 1.1 of the Twitter API** - yes! it will keep working after [May 2013](https://dev.twitter.com/calendar)
16
  * **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.
17
  * **Reliable** - keeps showing your latest Tweets even if the Twitter website is down.
18
  * **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 and what type of animation to use.
@@ -103,6 +103,23 @@ Most of this is my own work, but special thanks are owed to:
103
  = What options can I use for the shortcode? =
104
  All the options are listed on the [Rotating Tweets installation page](http://wordpress.org/extend/plugins/rotatingtweets/installation/).
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  = The Rotating Tweets are not rotating. What can I do? =
107
  This normally happens if there is more than one copy of `jQuery` installed on a page - or more than one copy of `jQuery.cycle`.
108
 
@@ -132,9 +149,6 @@ Try installing the [Core Control plug-in](http://wordpress.org/extend/plugins/co
132
 
133
  Thank you to [darkiko](http://wordpress.org/support/profile/darkiko) for sharing their solution to this problem.
134
 
135
- = How can I pull information from two accounts into one widget =
136
- The easiest way is to use a search term like `'from:account1 OR from:account2'`.
137
-
138
  = My widget is too wide! =
139
  Try putting:
140
  `
@@ -144,17 +158,18 @@ div.widget_rotatingtweets_widget, div.rotatingtweet, div.widget_rotatingtweets_w
144
  `
145
  into your CSS - changing `123px;` to the width you're aiming at - either via putting `rotatingtweets.css` into `wp-content/uploads` or by editing your own template files.
146
 
147
- = How often does the plug-in call Twitter =
148
- 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.
149
-
150
  = How can I add a Twitter bird to the left of my tweets? =
151
  You can do this by going to the `rotatingtweets/css` directory and renaming `rotatingtweets-sample.css` to `rotatingtweets.css` and putting it in the `wp-content/uploads/` directory. This displays a Twitter bird to the left of your tweets. Any CSS you put into `rotatingtweets.css` won't be overwritten when the plug-in is upgraded to the latest version.
152
 
153
  == Upgrade notice ==
154
- = 1.4.6 =
155
- * Addition of Brazilian Portuguese and extra display format. If you are using a version before 0.700, you will need to upgrade to a more recent version for Rotating Tweets to keep accessing Twitter after May 7, 2013.
156
 
157
  == Changelog ==
 
 
 
 
158
  = 1.4.6 =
159
  * Addition of Brazilian Portuguese translation
160
  * Addition of new display format 6
4
  Tags: shortcode,widget,twitter,rotating,rotate,rotator,tweet,tweets,animation,jquery,jquery cycle,cycle,multilingual,responsive
5
  Requires at least: 2.6
6
  Tested up to: 3.5.1
7
+ Stable tag: 1.4.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
  * **Replaces a [shortcode](http://codex.wordpress.org/Shortcode) such as `[rotatingtweets screen_name='your_twitter']`, or a [widget](http://codex.wordpress.org/WordPress_Widgets), with a rotating display of your most recent tweets**
15
+ * **Supports v 1.1 of the Twitter API** - yes! it will keep working after [June 11, 2013](https://dev.twitter.com/blog/api-v1-is-retired)
16
  * **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.
17
  * **Reliable** - keeps showing your latest Tweets even if the Twitter website is down.
18
  * **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 and what type of animation to use.
103
  = What options can I use for the shortcode? =
104
  All the options are listed on the [Rotating Tweets installation page](http://wordpress.org/extend/plugins/rotatingtweets/installation/).
105
 
106
+ = How can I include Rotating Tweets in my template? =
107
+ Try something like:
108
+ `<?php echo do_shortcode( "[rotatingtweets screen_name='your_twitter']" ) ?>`
109
+
110
+ = How can I pull information from two accounts into one widget =
111
+ The easiest way is to use a search term like `'from:account1 OR from:account2'`.
112
+
113
+ = How often does the plug-in call Twitter =
114
+ 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.
115
+
116
+ = My Rotating Tweets are not updating. What can I do? =
117
+ This normally happens if there is an SSL problem. Try going to the settings page and switching off SSL validation.
118
+
119
+ If this doesn't solve the problem, check your Twitter API key settings.
120
+
121
+ If neither of these approaches work, Rotating Tweets will normally be reporting the error as a comment in the HTML of your page. This should give you an idea of how to solve the problem.
122
+
123
  = The Rotating Tweets are not rotating. What can I do? =
124
  This normally happens if there is more than one copy of `jQuery` installed on a page - or more than one copy of `jQuery.cycle`.
125
 
149
 
150
  Thank you to [darkiko](http://wordpress.org/support/profile/darkiko) for sharing their solution to this problem.
151
 
 
 
 
152
  = My widget is too wide! =
153
  Try putting:
154
  `
158
  `
159
  into your CSS - changing `123px;` to the width you're aiming at - either via putting `rotatingtweets.css` into `wp-content/uploads` or by editing your own template files.
160
 
 
 
 
161
  = How can I add a Twitter bird to the left of my tweets? =
162
  You can do this by going to the `rotatingtweets/css` directory and renaming `rotatingtweets-sample.css` to `rotatingtweets.css` and putting it in the `wp-content/uploads/` directory. This displays a Twitter bird to the left of your tweets. Any CSS you put into `rotatingtweets.css` won't be overwritten when the plug-in is upgraded to the latest version.
163
 
164
  == Upgrade notice ==
165
+ = 1.4.7 =
166
+ * HTML5 compliance and improved rate-limiting. If you are using a version before 0.700, you will need to upgrade to a more recent version for Rotating Tweets to keep accessing Twitter after May 7, 2013.
167
 
168
  == Changelog ==
169
+ = 1.4.7 =
170
+ * HTML5 compliance
171
+ * Improved rate-limiting
172
+
173
  = 1.4.6 =
174
  * Addition of Brazilian Portuguese translation
175
  * Addition of new display format 6
rotatingtweets.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Rotating Tweets (Twitter widget & shortcode)
4
  Description: Replaces a shortcode such as [rotatingtweets screen_name='your_twitter_name'], or a widget, with a rotating tweets display
5
- Version: 1.4.6
6
  Text Domain: rotatingtweets
7
  Author: Martin Tod
8
  Author URI: http://www.martintod.org.uk
@@ -662,7 +662,7 @@ function rotatingtweets_call_twitter_API($command,$options = NULL,$api = NULL )
662
  $connection = new wp_TwitterOAuth($api['key'], $api['secret'], $api['token'], $api['token_secret'] );
663
  // $result = $connection->get('statuses/user_timeline', $options);
664
  if(WP_DEBUG):
665
- echo "\n<!-- Using OAuth - version 1.1 of API -- ".esc_attr($command)." -->\n";
666
  endif;
667
  if(isset($api['ssl_verify_off']) && $api['ssl_verify_off']):
668
  if(WP_DEBUG):
@@ -732,7 +732,7 @@ function rotatingtweets_shrink_cache() {
732
  if($ageindays < $minageindays) $minageindays = $ageindays;
733
  if(WP_DEBUG):
734
  $cachesize = strlen(json_encode($contents));
735
- echo "\n<!-- $stringname -- $cachesize --".date('d-m-Y',$contents['datetime'])." -- ".number_format($ageindays,1)." days -->";
736
  $totalcachesize = $totalcachesize + $cachesize;
737
  endif;
738
  };
@@ -834,8 +834,19 @@ function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_r
834
  if(!empty($twitterjson['errors'])):
835
  # If there's an error, reset the cache timer to make sure we don't hit Twitter too hard and get rate limited.
836
  // print_r($twitterjson);
837
- $option[$stringname]['datetime']=time();
838
- update_option($optionname,$option);
 
 
 
 
 
 
 
 
 
 
 
839
  elseif(!empty($twitterjson['error'])):
840
  # If Twitter is being rate limited, delays the next load until the reset time
841
  # For some reason the rate limiting error has a different error variable!
@@ -1062,7 +1073,7 @@ function rotating_tweets_display($json,$args,$print=TRUE) {
1062
  # Check if the problem is rate limiting
1063
  if($rate['hourly_limit']>0 && $rate['remaining_hits'] == 0):
1064
  $waittimevalue = intval(($rate['reset_time_in_seconds'] - time())/60);
1065
- $result .= "<!-- Rate limited -- ";
1066
  $result .= sprintf(_n('Next attempt to get data will be in %d minute','Next attempt to get data will be in %d minutes',$waittimevalue,'rotatingtweets'),$waittimevalue)." -->";
1067
  endif;
1068
  */
@@ -1165,7 +1176,7 @@ function rotating_tweets_display($json,$args,$print=TRUE) {
1165
  // $before[]="%#([0-9]*[\p{L}a-zA-Z_]+\w*)%";
1166
  # This is designed to find hashtags and turn them into links...
1167
  $before[]="%#\b(\d*[^\d\s[:punct:]]+[^\s[:punct:]]*)%";
1168
- $after[]='<a href="http://twitter.com/search?q=%23$1&src=hash" title="#$1"'.$targetvalue.'>#$1</a>';
1169
  $main_text = preg_replace($before,$after,$main_text);
1170
 
1171
  # Now for the meta text
2
  /*
3
  Plugin Name: Rotating Tweets (Twitter widget & shortcode)
4
  Description: Replaces a shortcode such as [rotatingtweets screen_name='your_twitter_name'], or a widget, with a rotating tweets display
5
+ Version: 1.4.7
6
  Text Domain: rotatingtweets
7
  Author: Martin Tod
8
  Author URI: http://www.martintod.org.uk
662
  $connection = new wp_TwitterOAuth($api['key'], $api['secret'], $api['token'], $api['token_secret'] );
663
  // $result = $connection->get('statuses/user_timeline', $options);
664
  if(WP_DEBUG):
665
+ echo "\n<!-- Using OAuth - version 1.1 of API - ".esc_attr($command)." -->\n";
666
  endif;
667
  if(isset($api['ssl_verify_off']) && $api['ssl_verify_off']):
668
  if(WP_DEBUG):
732
  if($ageindays < $minageindays) $minageindays = $ageindays;
733
  if(WP_DEBUG):
734
  $cachesize = strlen(json_encode($contents));
735
+ echo "\n<!-- $stringname - $cachesize - ".date('d-m-Y',$contents['datetime'])." - ".number_format($ageindays,1)." days -->";
736
  $totalcachesize = $totalcachesize + $cachesize;
737
  endif;
738
  };
834
  if(!empty($twitterjson['errors'])):
835
  # If there's an error, reset the cache timer to make sure we don't hit Twitter too hard and get rate limited.
836
  // print_r($twitterjson);
837
+ if( $twitterjson['errors'][0]['type'] == 'Twitter' && $twitterjson['errors'][0]['code'] == 88 ):
838
+ $rate = rotatingtweets_get_rate_data();
839
+ if($rate && $rate['remaining_hits'] == 0):
840
+ $option[$stringname]['datetime']= $rate['reset_time_in_seconds'] - $cache_delay + 1;
841
+ update_option($optionname,$option);
842
+ else:
843
+ $option[$stringname]['datetime']=time();
844
+ update_option($optionname,$option);
845
+ endif;
846
+ else:
847
+ $option[$stringname]['datetime']=time();
848
+ update_option($optionname,$option);
849
+ endif;
850
  elseif(!empty($twitterjson['error'])):
851
  # If Twitter is being rate limited, delays the next load until the reset time
852
  # For some reason the rate limiting error has a different error variable!
1073
  # Check if the problem is rate limiting
1074
  if($rate['hourly_limit']>0 && $rate['remaining_hits'] == 0):
1075
  $waittimevalue = intval(($rate['reset_time_in_seconds'] - time())/60);
1076
+ $result .= "<!-- Rate limited - ";
1077
  $result .= sprintf(_n('Next attempt to get data will be in %d minute','Next attempt to get data will be in %d minutes',$waittimevalue,'rotatingtweets'),$waittimevalue)." -->";
1078
  endif;
1079
  */
1176
  // $before[]="%#([0-9]*[\p{L}a-zA-Z_]+\w*)%";
1177
  # This is designed to find hashtags and turn them into links...
1178
  $before[]="%#\b(\d*[^\d\s[:punct:]]+[^\s[:punct:]]*)%";
1179
+ $after[]='<a href="http://twitter.com/search?q=%23$1&amp;src=hash" title="#$1"'.$targetvalue.'>#$1</a>';
1180
  $main_text = preg_replace($before,$after,$main_text);
1181
 
1182
  # Now for the meta text