Rotating Tweets (Twitter widget and shortcode) - Version 1.6.10

Version Description

  • New code to shrink size of cache by about 70%

=

Download this release

Release Info

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

Code changes from version 1.6.9 to 1.6.10

Files changed (2) hide show
  1. readme.txt +7 -4
  2. rotatingtweets.php +57 -5
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: mpntod
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9XCNM4QSVHYT8
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.8
7
- Stable tag: 1.6.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -163,10 +163,13 @@ into your CSS - changing `123px;` to the width you're aiming at - either via put
163
  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.
164
 
165
  == Upgrade notice ==
166
- = 1.6.9 =
167
- * Bug fix for error introduced in 1.6.8.
168
 
169
  == Changelog ==
 
 
 
170
  = 1.6.9 =
171
  * Bug fix.
172
 
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9XCNM4QSVHYT8
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.8.1
7
+ Stable tag: 1.6.10
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
163
  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.
164
 
165
  == Upgrade notice ==
166
+ = 1.6.10 =
167
+ * New code to shrink size of cache by about 70%
168
 
169
  == Changelog ==
170
+ = 1.6.10 =
171
+ * New code to shrink size of cache by about 70%
172
+
173
  = 1.6.9 =
174
  * Bug fix.
175
 
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.6.9
6
  Text Domain: rotatingtweets
7
  Author: Martin Tod
8
  Author URI: http://www.martintod.org.uk
@@ -1050,12 +1050,12 @@ function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_r
1050
  endif;
1051
  if(is_array($twitterjson) && isset($twitterjson[0] )) $firstentry = $twitterjson[0];
1052
  if(!empty($firstentry['text'])):
 
 
 
1053
  if(WP_DEBUG):
1054
  echo "<!-- Storing cache entry for $stringname in $optionname -->";
1055
  endif;
1056
- $latest_json = $twitterjson;
1057
- $option[$stringname]['json']=$latest_json;
1058
- $option[$stringname]['datetime']=time();
1059
  update_option($optionname,$option);
1060
  endif;
1061
  endif;
@@ -1065,6 +1065,58 @@ function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_r
1065
  return;
1066
  endif;
1067
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1068
 
1069
  # Gets the rate limiting data to see how long it will be before we can tweet again
1070
  function rotatingtweets_get_rate_data() {
@@ -1339,7 +1391,7 @@ function rotating_tweets_display($json,$args,$print=TRUE) {
1339
  endif;
1340
  if(!empty($rt_data)):
1341
  $rt_user = $rt_data['user'];
1342
- // These versions remove RT and use the original text
1343
  $rt_replace_array = array(1,2,3);
1344
  if(in_array($args['official_format'],$rt_replace_array)):
1345
  $main_text = $rt_data['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.6.10
6
  Text Domain: rotatingtweets
7
  Author: Martin Tod
8
  Author URI: http://www.martintod.org.uk
1050
  endif;
1051
  if(is_array($twitterjson) && isset($twitterjson[0] )) $firstentry = $twitterjson[0];
1052
  if(!empty($firstentry['text'])):
1053
+ $latest_json = rotatingtweets_shrink_json($twitterjson);
1054
+ $option[$stringname]['json']=$latest_json;
1055
+ $option[$stringname]['datetime']=time();
1056
  if(WP_DEBUG):
1057
  echo "<!-- Storing cache entry for $stringname in $optionname -->";
1058
  endif;
 
 
 
1059
  update_option($optionname,$option);
1060
  endif;
1061
  endif;
1065
  return;
1066
  endif;
1067
  }
1068
+ function rotatingtweets_shrink_json($json) {
1069
+ $return = array();
1070
+ foreach($json as $item):
1071
+ $return[]=rotatingtweets_shrink_element($item);
1072
+ endforeach;
1073
+ if(WP_DEBUG):
1074
+ $startsize = strlen(json_encode($json));
1075
+ $endsize = strlen(json_encode($return));
1076
+ $shrink = (1-$endsize/$startsize)*100;
1077
+ echo "<!-- Cachesize shrunk by ".number_format($shrink)."% -->";
1078
+ endif;
1079
+ return($return);
1080
+ }
1081
+ function rotatingtweets_shrink_element($json) {
1082
+ $rt_top_elements = array('text','retweeted_status','user','entities','source','id_str','created_at');
1083
+ $return = array();
1084
+ foreach($rt_top_elements as $rt_element):
1085
+ if(isset($json[$rt_element])):
1086
+ switch($rt_element) {
1087
+ case "user":
1088
+ $return[$rt_element]=rotatingtweets_shrink_user($json[$rt_element]);
1089
+ break;
1090
+ case "entities":
1091
+ $return[$rt_element]=rotatingtweets_shrink_entities($json[$rt_element]);
1092
+ break;
1093
+ case "retweeted_status":
1094
+ $return[$rt_element]=rotatingtweets_shrink_element($json[$rt_element]);
1095
+ break;
1096
+ default:
1097
+ $return[$rt_element]=$json[$rt_element];
1098
+ break;
1099
+ };
1100
+ endif;
1101
+ endforeach;
1102
+ return($return);
1103
+ }
1104
+ function rotatingtweets_shrink_user($user) {
1105
+ $rt_user_elements = array('screen_name','id','name','profile_image_url_https','profile_image_url');
1106
+ $return = array();
1107
+ foreach($rt_user_elements as $rt_element):
1108
+ if(isset($user[$rt_element])) $return[$rt_element]=$user[$rt_element];
1109
+ endforeach;
1110
+ return($return);
1111
+ }
1112
+ function rotatingtweets_shrink_entities($json) {
1113
+ $rt_entity_elements = array('urls','media');
1114
+ $return = array();
1115
+ foreach($rt_entity_elements as $rt_element):
1116
+ if(isset($json[$rt_element])) $return[$rt_element]=$json[$rt_element];
1117
+ endforeach;
1118
+ return($return);
1119
+ }
1120
 
1121
  # Gets the rate limiting data to see how long it will be before we can tweet again
1122
  function rotatingtweets_get_rate_data() {
1391
  endif;
1392
  if(!empty($rt_data)):
1393
  $rt_user = $rt_data['user'];
1394
+ // The version numbers in this array remove RT and use the original text
1395
  $rt_replace_array = array(1,2,3);
1396
  if(in_array($args['official_format'],$rt_replace_array)):
1397
  $main_text = $rt_data['text'];