Rotating Tweets (Twitter widget and shortcode) - Version 1.8.3

Version Description

  • Fixed 'Invalid argument' bug when combining tweets from different accounts

=

Download this release

Release Info

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

Code changes from version 1.8.2 to 1.8.3

Files changed (2) hide show
  1. readme.txt +8 -3
  2. rotatingtweets.php +22 -14
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,page builder
5
  Requires at least: 3.2
6
  Tested up to: 4.4.1
7
- Stable tag: 1.8.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -183,10 +183,15 @@ into your CSS - changing `123px;` to the width you're aiming at - either via put
183
  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.
184
 
185
  == Upgrade notice ==
186
- = 1.8.2 =
187
- * Fixed 'Undefined variable' bug in line 648
188
 
189
  == Changelog ==
 
 
 
 
 
190
  = 1.8.2 =
191
  * Fixed 'Undefined variable' bug in line 648
192
 
4
  Tags: shortcode,widget,twitter,rotating,rotate,rotator,tweet,tweets,animation,jquery,jquery cycle,cycle,multilingual,responsive,page builder
5
  Requires at least: 3.2
6
  Tested up to: 4.4.1
7
+ Stable tag: 1.8.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
183
  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.
184
 
185
  == Upgrade notice ==
186
+ = 1.8.3 =
187
+ * Fixed 'Invalid argument' bug when combining tweets from different accounts
188
 
189
  == Changelog ==
190
+ = 1.8.3 =
191
+ * Fixed 'Invalid argument' bug when combining tweets from different accounts
192
+ * Allow up to 60 tweets
193
+ * Deletion of Italian `.mo` file - since now available as a [Wordpress-hosted translation pack](https://translate.wordpress.org/projects/wp-plugins/rotatingtweets)
194
+
195
  = 1.8.2 =
196
  * Fixed 'Undefined variable' bug in line 648
197
 
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.8.2
6
  Text Domain: rotatingtweets
7
  Domain Path: /languages
8
  Author: Martin Tod
@@ -276,7 +276,7 @@ class rotatingtweets_Widget extends WP_Widget {
276
  <p><input id="<?php echo $this->get_field_id('tw_links_in_new_window'); ?>" name="<?php echo $this->get_field_name('tw_links_in_new_window'); ?>" type="checkbox" value="1" <?php if($tw_links_in_new_window==1): ?>checked="checked" <?php endif; ?>/><label for="<?php echo $this->get_field_id('tw_links_in_new_window'); ?>"> <?php _e('Open all links in new window or tab?','rotatingtweets'); ?></label></p>
277
  <p><label for="<?php echo $this->get_field_id('tw_tweet_count'); ?>"><?php _e('How many tweets?','rotatingtweets'); ?> <select id="<?php echo $this->get_field_id('tw_tweet_count'); ?>" name="<?php echo $this->get_field_name('tw_tweet_count');?>">
278
  <?php
279
- for ($i=1; $i<31; $i++) {
280
  echo "\n\t<option value='$i' ";
281
  if($tw_tweet_count==$i): ?>selected="selected" <?php endif;
282
  echo ">$i</option>";
@@ -1160,7 +1160,7 @@ function rotatingtweets_get_tweets_sf($tw_screen_name,$tw_include_rts,$tw_exclud
1160
  endif;
1161
  # Checks if it is time to call Twitter directly yet or if it should use the cache
1162
  if($timegap > $cache_delay):
1163
- $apioptions = array('screen_name'=>$tw_screen_name,'include_entities'=>1,'count'=>40,'include_rts'=>$tw_include_rts,'exclude_replies'=>$tw_exclude_replies);
1164
  $twitterusers = FALSE;
1165
  if($tw_search) {
1166
  $apioptions['q']=$tw_search;
@@ -1238,7 +1238,7 @@ function rotatingtweets_get_tweets_sf($tw_screen_name,$tw_include_rts,$tw_exclud
1238
  if(!empty($firstentry['text']) ):
1239
  $number_returned_tweets = count($twitterjson);
1240
  if(WP_DEBUG) echo "<!-- ".$number_returned_tweets." tweets returned -->";
1241
- if( $tw_search && $tw_merge && $number_returned_tweets < 40 && isset($latest_json) && is_array($latest_json) && count($latest_json)>0 ):
1242
  if(WP_DEBUG) echo "<!-- ".count($latest_json)." tweets in cache -->";
1243
  $twitterjson = rotatingtweet_combine_jsons($twitterjson,$latest_json);
1244
  if(WP_DEBUG) echo "<!-- ".count($twitterjson)." tweets in merged json -->";
@@ -1290,16 +1290,24 @@ function rotatingtweets_transform_collection_data($twittertweets,$twitterusers)
1290
  return $return;
1291
  }
1292
  function rotatingtweet_combine_jsons($a,$b) {
1293
- $tweet_keys = array();
1294
- foreach($a as $item) {
1295
- $tweet_keys[] = $item['id_str'];
1296
- }
1297
- foreach($b as $item) {
1298
- if( !empty($item['id_str']) && !in_array($item['id_str'],$tweet_keys) ):
1299
- $a[]=$item;
1300
- endif;
1301
- }
1302
- return rotatingtweets_sort_json($a);
 
 
 
 
 
 
 
 
1303
  }
1304
  function rotatingtweets_sort_json($a) {
1305
  $sort_json = array();
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.8.3
6
  Text Domain: rotatingtweets
7
  Domain Path: /languages
8
  Author: Martin Tod
276
  <p><input id="<?php echo $this->get_field_id('tw_links_in_new_window'); ?>" name="<?php echo $this->get_field_name('tw_links_in_new_window'); ?>" type="checkbox" value="1" <?php if($tw_links_in_new_window==1): ?>checked="checked" <?php endif; ?>/><label for="<?php echo $this->get_field_id('tw_links_in_new_window'); ?>"> <?php _e('Open all links in new window or tab?','rotatingtweets'); ?></label></p>
277
  <p><label for="<?php echo $this->get_field_id('tw_tweet_count'); ?>"><?php _e('How many tweets?','rotatingtweets'); ?> <select id="<?php echo $this->get_field_id('tw_tweet_count'); ?>" name="<?php echo $this->get_field_name('tw_tweet_count');?>">
278
  <?php
279
+ for ($i=1; $i<61; $i++) {
280
  echo "\n\t<option value='$i' ";
281
  if($tw_tweet_count==$i): ?>selected="selected" <?php endif;
282
  echo ">$i</option>";
1160
  endif;
1161
  # Checks if it is time to call Twitter directly yet or if it should use the cache
1162
  if($timegap > $cache_delay):
1163
+ $apioptions = array('screen_name'=>$tw_screen_name,'include_entities'=>1,'count'=>60,'include_rts'=>$tw_include_rts,'exclude_replies'=>$tw_exclude_replies);
1164
  $twitterusers = FALSE;
1165
  if($tw_search) {
1166
  $apioptions['q']=$tw_search;
1238
  if(!empty($firstentry['text']) ):
1239
  $number_returned_tweets = count($twitterjson);
1240
  if(WP_DEBUG) echo "<!-- ".$number_returned_tweets." tweets returned -->";
1241
+ if( $tw_search && $tw_merge && $number_returned_tweets < 60 && isset($latest_json) && is_array($latest_json) && count($latest_json)>0 ):
1242
  if(WP_DEBUG) echo "<!-- ".count($latest_json)." tweets in cache -->";
1243
  $twitterjson = rotatingtweet_combine_jsons($twitterjson,$latest_json);
1244
  if(WP_DEBUG) echo "<!-- ".count($twitterjson)." tweets in merged json -->";
1290
  return $return;
1291
  }
1292
  function rotatingtweet_combine_jsons($a,$b) {
1293
+ if(is_array($a) && count($a) && is_array($b) && count($b)):
1294
+ $tweet_keys = array();
1295
+ foreach($a as $item) {
1296
+ $tweet_keys[] = $item['id_str'];
1297
+ }
1298
+ foreach($b as $item) {
1299
+ if( !empty($item['id_str']) && !in_array($item['id_str'],$tweet_keys) ):
1300
+ $a[]=$item;
1301
+ endif;
1302
+ }
1303
+ return rotatingtweets_sort_json($a);
1304
+ elseif(is_array($a) && count($a)):
1305
+ return($a);
1306
+ elseif(is_array($b) && count($b)):
1307
+ return($b);
1308
+ else:
1309
+ return null;
1310
+ endif;
1311
  }
1312
  function rotatingtweets_sort_json($a) {
1313
  $sort_json = array();