Rotating Tweets (Twitter widget and shortcode) - Version 1.7.13

Version Description

  • Adds new shortcode variables. Fixes JavaScript & other bugs.

=

Download this release

Release Info

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

Code changes from version 1.7.12 to 1.7.13

js/jquery.cycle2.renamed.js CHANGED
@@ -658,7 +658,7 @@ $.fn.cycle2.transitions = {
658
  // @see: http://jquery.malsup.com/cycle2/api
659
  $.fn.cycle2.defaults = {
660
  allowWrap: true,
661
- autoSelector: '.cycle-slideshow[data-cycle-auto-init!=false]',
662
  delay: 0,
663
  easing: null,
664
  fx: 'fade',
658
  // @see: http://jquery.malsup.com/cycle2/api
659
  $.fn.cycle2.defaults = {
660
  allowWrap: true,
661
+ autoSelector: '.rotatingtweets[data-cycle-auto-init!=false]',
662
  delay: 0,
663
  easing: null,
664
  fx: 'fade',
js/rotating_tweet.js CHANGED
@@ -12,7 +12,14 @@ jQuery(document).ready(function() {
12
  rotate_pager = jQuery(this).data('cycle-pager'),
13
  rotate_pager_template = jQuery(this).data('cycle-pager-template'),
14
  rotate_wp_debug = jQuery(this).hasClass('wp_debug');
15
- if( typeof console == "undefined" || typeof console.log == "undefined" ) {
 
 
 
 
 
 
 
16
  rotate_wp_debug = false;
17
  }
18
  /* If the rotation type has not been set - then set it to scrollUp */
12
  rotate_pager = jQuery(this).data('cycle-pager'),
13
  rotate_pager_template = jQuery(this).data('cycle-pager-template'),
14
  rotate_wp_debug = jQuery(this).hasClass('wp_debug');
15
+ /* Handling old versions of jQuery that handle .data differently */
16
+ if ( rotate_timeout === undefined ) {
17
+ var rotate_id_split = rotate_id.split('_');
18
+ rotate_timeout = rotate_id_split[1];
19
+ rotate_fx = rotate_id_split[2];
20
+ rotate_speed = rotate_id_split[3];
21
+ }
22
+ if( typeof console === "undefined" || typeof console.log === "undefined" ) {
23
  rotate_wp_debug = false;
24
  }
25
  /* If the rotation type has not been set - then set it to scrollUp */
js/rotating_tweet_admin.js CHANGED
@@ -2,49 +2,56 @@
2
  Script to cycle the rotating tweets
3
  */
4
  jQuery(document).ready(function() {
5
- // Script to show or hide display options on start up
6
- jQuery('input.rtw_ad_official:checked').each(function() {
7
- var response = jQuery(this).attr('value');
8
- if( response == 0) {
9
- jQuery(this).parent().find('.rtw_ad_tw_det').show('fast');
10
- } else {
11
- jQuery(this).parent().find('.rtw_ad_tw_det').hide('fast');
12
- }
13
- });
14
- // Script to show or hide display options when box is checked
15
- jQuery('.rtw_ad_official').change(function() {
16
- var response = jQuery(this).attr('value');
17
- if( response == 0) {
18
- jQuery(this).parent().find('.rtw_ad_tw_det').show('fast');
19
- } else {
20
- jQuery(this).parent().find('.rtw_ad_tw_det').hide('fast');
21
- }
22
- });
23
- // Script to show or hide display options on start up
24
- jQuery('input.rtw_ad_type:checked').each(function() {
25
- var response = jQuery(this).attr('value');
26
- if( response == 3) {
27
- jQuery(this).closest('.widget-content').find('.rtw_ad_list_tag').show('fast');
28
- } else {
29
- jQuery(this).closest('.widget-content').find('.rtw_ad_list_tag').hide('fast');
30
- }
31
- });
32
- // Script to show or hide display options when box is checked
33
- jQuery('.rtw_ad_type').change(function() {
34
- var response = jQuery(this).attr('value');
35
- if( response == 3) {
36
- jQuery(this).closest('.widget-content').find('.rtw_ad_list_tag').show('fast');
37
- } else {
38
- jQuery(this).closest('.widget-content').find('.rtw_ad_list_tag').hide('fast');
39
- }
40
- if( response == 2) {
41
- jQuery(this).closest('.widget-content').find('.rtw_ad_search').show();
42
- jQuery(this).closest('.widget-content').find('.rtw_ad_not_search').hide();
43
- // jQuery(this).closest('.widget-content').find('.rtw_ad_sf').hide('fast');
44
- } else {
45
- jQuery(this).closest('.widget-content').find('.rtw_ad_search').hide();
46
- jQuery(this).closest('.widget-content').find('.rtw_ad_not_search').show();
47
- // jQuery(this).closest('.widget-content').find('.rtw_ad_sf').show('fast');
48
- }
 
 
 
 
 
 
 
49
  });
50
  });
2
  Script to cycle the rotating tweets
3
  */
4
  jQuery(document).ready(function() {
5
+ function rotatingtweets_runselect() {
6
+ // Script to show or hide display options on start up
7
+ jQuery('input.rtw_ad_official:checked').each(function() {
8
+ var response = jQuery(this).attr('value');
9
+ if( response == 0) {
10
+ jQuery(this).parent().find('.rtw_ad_tw_det').show('fast');
11
+ } else {
12
+ jQuery(this).parent().find('.rtw_ad_tw_det').hide('fast');
13
+ }
14
+ });
15
+ // Script to show or hide display options when box is checked
16
+ jQuery('.rtw_ad_official').change(function() {
17
+ var response = jQuery(this).attr('value');
18
+ if( response == 0) {
19
+ jQuery(this).parent().find('.rtw_ad_tw_det').show('fast');
20
+ } else {
21
+ jQuery(this).parent().find('.rtw_ad_tw_det').hide('fast');
22
+ }
23
+ });
24
+ // Script to show or hide display options on start up
25
+ jQuery('input.rtw_ad_type:checked').each(function() {
26
+ var response = jQuery(this).attr('value');
27
+ if( response == 3) {
28
+ jQuery(this).closest('.widget-content').find('.rtw_ad_list_tag').show('fast');
29
+ } else {
30
+ jQuery(this).closest('.widget-content').find('.rtw_ad_list_tag').hide('fast');
31
+ }
32
+ });
33
+ // Script to show or hide display options when box is checked
34
+ jQuery('.rtw_ad_type').change(function() {
35
+ var response = jQuery(this).attr('value');
36
+ if( response == 3) {
37
+ jQuery(this).closest('.widget-content').find('.rtw_ad_list_tag').show('fast');
38
+ } else {
39
+ jQuery(this).closest('.widget-content').find('.rtw_ad_list_tag').hide('fast');
40
+ }
41
+ if( response == 2) {
42
+ jQuery(this).closest('.widget-content').find('.rtw_ad_search').show();
43
+ jQuery(this).closest('.widget-content').find('.rtw_ad_not_search').hide();
44
+ // jQuery(this).closest('.widget-content').find('.rtw_ad_sf').hide('fast');
45
+ } else {
46
+ jQuery(this).closest('.widget-content').find('.rtw_ad_search').hide();
47
+ jQuery(this).closest('.widget-content').find('.rtw_ad_not_search').show();
48
+ // jQuery(this).closest('.widget-content').find('.rtw_ad_sf').show('fast');
49
+ }
50
+ });
51
+ }
52
+ rotatingtweets_runselect();
53
+
54
+ jQuery(document).on('widget-updated widget-added', function(){
55
+ rotatingtweets_runselect();
56
  });
57
  });
js/rotatingtweets_v2.js CHANGED
@@ -71,8 +71,6 @@ $.fn.cycle2.transitions.scrollLeftGap = {
71
  Script to cycle the rotating tweets
72
  */
73
  jQuery(document).ready(function() {
74
- // Not at all sure we need this
75
- jQuery('.rotatingtweets').cycle2();
76
  // Script to show mouseover effects when going over the Twitter intents
77
  var rtw_src,
78
  clearOutHovers = /_hover.png$/,
71
  Script to cycle the rotating tweets
72
  */
73
  jQuery(document).ready(function() {
 
 
74
  // Script to show mouseover effects when going over the Twitter intents
75
  var rtw_src,
76
  clearOutHovers = /_hover.png$/,
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: 3.2
6
  Tested up to: 4.1.1
7
- Stable tag: 1.7.12
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -99,6 +99,9 @@ Possible variables for the shortcode include:
99
  * `tweet_length` = maximum number of characters to show in tweet - default is `'0'` which allows whole tweet to be shown
100
  * `no_emoji` = `'0'` or `'1'` - experimental option that removes emoji from the feed - default is `'0'`
101
  * `official_format_override` = `'0'` or `'1'` - enables you to change the settings for `show_meta_reply_retweet_favorite` and `show_meta_timestamp` on the 'official formats'.
 
 
 
102
 
103
  * **Caching**
104
  * `w3tc_render_to` = 'your_choice_of_random_string' - used to support 'fragment caching' by [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/). For this to work, you also need to ensure that `W3TC_DYNAMIC_SECURITY` is defined in your `wp-config.php` file and that you not using 'HTTP Compression' on the W3 Total Cache 'Browser Cache' settings page or 'Enhanced Disk caching' on the W3 Total Cache 'Page Cache' settings page.
@@ -182,10 +185,17 @@ into your CSS - changing `123px;` to the width you're aiming at - either via put
182
  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.
183
 
184
  == Upgrade notice ==
185
- = 1.7.12 =
186
- * Updated version 2 of JavaScript incl. bug fix
187
 
188
  == Changelog ==
 
 
 
 
 
 
 
189
  = 1.7.12 =
190
  * Updated version 2 of JavaScript - updated jQuery.cycle2 and removal of bug
191
  * Fixing height bug
4
  Tags: shortcode,widget,twitter,rotating,rotate,rotator,tweet,tweets,animation,jquery,jquery cycle,cycle,multilingual,responsive
5
  Requires at least: 3.2
6
  Tested up to: 4.1.1
7
+ Stable tag: 1.7.13
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
99
  * `tweet_length` = maximum number of characters to show in tweet - default is `'0'` which allows whole tweet to be shown
100
  * `no_emoji` = `'0'` or `'1'` - experimental option that removes emoji from the feed - default is `'0'`
101
  * `official_format_override` = `'0'` or `'1'` - enables you to change the settings for `show_meta_reply_retweet_favorite` and `show_meta_timestamp` on the 'official formats'.
102
+ * `profile_image_size` = `'normal'`, `'bigger'`, `'mini'` or `'original'` - lets you change the size of profile images - default is `'normal'`
103
+ * `shuffle` = `'0'` or `'1'` - shuffle the order that Tweets display - default is `'0'`
104
+ * `merge_cache` = `'0'` or `'1'` - switches cacheing of searches on or off - default is `'1'` (i.e. on)
105
 
106
  * **Caching**
107
  * `w3tc_render_to` = 'your_choice_of_random_string' - used to support 'fragment caching' by [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/). For this to work, you also need to ensure that `W3TC_DYNAMIC_SECURITY` is defined in your `wp-config.php` file and that you not using 'HTTP Compression' on the W3 Total Cache 'Browser Cache' settings page or 'Enhanced Disk caching' on the W3 Total Cache 'Page Cache' settings page.
185
  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.
186
 
187
  == Upgrade notice ==
188
+ = 1.7.13 =
189
+ * Adds new shortcode variables. Fixes JavaScript & other bugs.
190
 
191
  == Changelog ==
192
+ = 1.7.13 =
193
+ * Adds `profile_image_size`, `shuffle` and `merge_cache` shortcode variables
194
+ * Lowers chance of clashes with other installations of cycle2 - by defaulting `autoSelector` to `.rotatingtweets` instead of `.cycle-slideshow`
195
+ * Handles old versions of jQuery that don't fully support `.data()` better
196
+ * Fixes bug with merge functionality
197
+ * Fixes bug with admin page JavaScript (thanks to this [very helpful article on StackExchange.com](http://wordpress.stackexchange.com/questions/130084/executing-javascript-when-a-widget-is-added-in-the-backend))
198
+
199
  = 1.7.12 =
200
  * Updated version 2 of JavaScript - updated jQuery.cycle2 and removal of bug
201
  * Fixing height bug
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.7.12
6
  Text Domain: rotatingtweets
7
  Author: Martin Tod
8
  Author URI: http://www.martintod.org.uk
@@ -189,27 +189,6 @@ class rotatingtweets_Widget extends WP_Widget {
189
  unset($$val[0]);
190
  endif;
191
  }
192
- /*
193
- if(isset($instance['title'])) $title = esc_attr($instance['title']);
194
- if(isset($instance['tw_screen_name'])) $tw_screen_name = esc_attr(trim($instance['tw_screen_name']));
195
- if(isset($instance['tw_rotation_type'])) $tw_rotation_type = $instance['tw_rotation_type'];
196
- if(isset($instance['tw_include_rts'])) $tw_include_rts = absint($instance['tw_include_rts']);
197
- if(isset($instance['tw_exclude_replies'])) $tw_exclude_replies = absint($instance['tw_exclude_replies']);
198
- if(isset($instance['tw_tweet_count'])) $tw_tweet_count = intval($instance['tw_tweet_count']);
199
- if(isset($instance['tw_show_follow'])) $tw_show_follow = absint($instance['tw_show_follow']);
200
- if(isset($instance['tw_official_format'])) $tw_official_format = absint($instance['tw_official_format']);
201
- if(isset($instance['tw_show_type'])) $tw_show_type = absint($instance['tw_show_type']);
202
- if(isset($instance['tw_links_in_new_window'])) $tw_links_in_new_window = absint($instance['tw_links_in_new_window']);
203
- if(isset($instance['tw_hide_meta_timestamp'])) $metaoption['tw_show_meta_timestamp'] = !$instance['tw_hide_meta_timestamp'];
204
- if(isset($instance['tw_hide_meta_screen_name'])) $metaoption['tw_show_meta_screen_name'] = !$instance['tw_hide_meta_screen_name'];
205
- if(isset($instance['tw_hide_meta_via'])) $metaoption['tw_show_meta_via'] = !$instance['tw_hide_meta_via'];
206
- if(isset($instance['tw_show_meta_reply_retweet_favorite'])) $metaoption['tw_show_meta_reply_retweet_favorite'] = absint($instance['tw_show_meta_reply_retweet_favorite']);
207
- if(isset($instance['tw_timeout'])) $tw_timeout = intval($instance['tw_timeout']);
208
- # If values not set, set default values
209
- if(empty($tw_rotation_type)) $tw_rotation_type = 'scrollUp';
210
- if(empty($tw_timeout)) $tw_timeout = 4000;
211
- if(empty($tw_tweet_count)) $tw_tweet_count = 5;
212
- */
213
  ?>
214
  <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','rotatingtweets'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
215
  <?php
@@ -334,6 +313,8 @@ class rotatingtweets_Widget extends WP_Widget {
334
  }
335
  # This is an appalling hack to deal with the problem that jQuery gets broken when people hit save - as per http://lists.automattic.com/pipermail/wp-hackers/2011-March/037997.html - but it works!
336
  // echo "<script type='text/javascript' src='".plugins_url('js/rotating_tweet_admin.js', __FILE__)."'></script>";
 
 
337
  echo "</div>\n<script type='text/javascript'>\n";
338
  $rtw_admin_script_original = file_get_contents(plugin_dir_path(__FILE__).'js/rotating_tweet_admin.js');
339
  $rtw_admin_script_final = str_replace(
@@ -342,6 +323,7 @@ class rotatingtweets_Widget extends WP_Widget {
342
  $rtw_admin_script_original);
343
  echo $rtw_admin_script_final;
344
  echo "\n</script>";
 
345
  }
346
  } // class rotatingtweets_Widget
347
 
@@ -409,12 +391,30 @@ function rotatingtweets_intents($twitter_object,$lang, $icons = 1,$targetvalue='
409
  return($string);
410
  }
411
  // Produces a link to someone's name, icon or screen name (or to the text of your choice) using the 'intent' format for linking
412
- function rotatingtweets_user_intent($person,$lang,$linkcontent,$targetvalue='') {
413
  if(!is_array($person)) return;
414
  $return = "<a href='https://twitter.com/intent/user?user_id={$person['id']}' title='".esc_attr($person['name'])."' lang='{$lang}'{$targetvalue}>";
415
  switch($linkcontent){
416
  case 'icon':
417
- $return .= "<img src='{$person['profile_image_url_https']}' alt='".esc_attr($person['name'])."' /></a>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
418
  break;
419
  case 'name':
420
  $return .= $person['name']."</a>";
@@ -545,7 +545,10 @@ function rotatingtweets_display_shortcode( $atts, $content=null, $code="", $prin
545
  'w3tc_render_to' => '',
546
  'official_format_override'=>FALSE,
547
  'no_cache'=>FALSE,
548
- 'text_cache_id'=>FALSE
 
 
 
549
  ), $atts ) ;
550
  extract($args);
551
  if(empty($screen_name) && empty($search) && !empty($url)):
@@ -563,7 +566,7 @@ function rotatingtweets_display_shortcode( $atts, $content=null, $code="", $prin
563
  rotatingtweets_enqueue_scripts();
564
  $returnstring = rotatingtweets_get_transient($args['text_cache_id']);
565
  if(strlen($returnstring)==0):
566
- $tweets = rotatingtweets_get_tweets($screen_name,$include_rts,$exclude_replies,$get_favorites,$search,$list);
567
  $returnstring = rotating_tweets_display($tweets,$args,$print);
568
  elseif(WP_DEBUG):
569
  $returnstring .= "<!-- Transient ".$args['text_cache_id']." loaded -->";
@@ -911,7 +914,11 @@ function rotatingtweets_call_twitter_API($command,$options = NULL,$api = NULL )
911
  if(isset($data['errors'])):
912
  $data['errors'][0]['type'] = 'Twitter';
913
  if( empty($api) ) $errorstring[0]['message'] = 'Please enter valid Twitter API Settings on the Rotating Tweets settings page';
914
- if(WP_DEBUG && ! is_admin() ) echo "<!-- Error message from Twitter - {$data['errors']} -->";
 
 
 
 
915
  update_option('rotatingtweets_api_error',$data['errors']);
916
  else:
917
  if(WP_DEBUG && ! is_admin() ) echo "<!-- Successfully read data from Twitter -->";
@@ -938,47 +945,6 @@ function rotatingtweets_call_twitter_API($command,$options = NULL,$api = NULL )
938
  endif;
939
  return($result);
940
  }
941
- /*
942
- # Clear tweets (if too much memory used) // now handled by using separate transients
943
- function rotatingtweets_shrink_cache() {
944
- # Solves a problem that 40+ caches can overload the memory - cuts it to fewer without risking deletion of the tweets on display
945
- $optionname = "rotatingtweets-cache";
946
- $option = get_option($optionname);
947
- $numberidentities = count($option);
948
- if(WP_DEBUG) echo "<!-- There are currently ".$numberidentities." Rotating Tweets identities cached -->";
949
- # If there are fewer than 10 sets of information cached - just return (for speed)
950
- if ( !is_array($option) or $numberidentities == 0 ) return;
951
- # Now make sure that we don't overwrite 'live' tweets
952
- $minageindays = 1000000;
953
- $totalcachesize = 0;
954
- # Get the age and size of tweets remaining
955
- foreach($option as $stringname => $contents) {
956
- $ageindays = (time()-$contents['datetime'])/60/60/24;
957
- if($ageindays < $minageindays) $minageindays = $ageindays;
958
- if(WP_DEBUG):
959
- $cachesize = strlen(json_encode($contents));
960
- echo "\n<!-- $stringname - $cachesize - ".date('d-m-Y',$contents['datetime'])." - ".number_format($ageindays,1)." days -->";
961
- $totalcachesize = $totalcachesize + $cachesize;
962
- endif;
963
- };
964
- if($totalcachesize == 0):
965
- if(WP_DEBUG) echo "<!-- Cache failed to read successfully -->";
966
- return;
967
- endif;
968
- if(WP_DEBUG) echo "\n<!-- The youngest age of any cache is ".number_format($minageindays*24*60,2)." minutes (".number_format($minageindays,8)." days) and total cache size is ".$totalcachesize.". -->";
969
- if($numberidentities < 10) return;
970
- # Set the goal of deleting all the tweets more than 30 days older than the most recent tweets
971
- $targetageindays = $minageindays + 30;
972
- # Now run through and delete
973
- foreach($option as $stringname => $contents) {
974
- $ageindays = (time()-$contents['datetime'])/60/60/24;
975
- if($ageindays > $targetageindays) unset($option[$stringname]);
976
- };
977
- $numberidentities = count($option);
978
- if(WP_DEBUG) echo "<!-- There are now ".$numberidentities." identities cached -->";
979
- update_option($optionname,$option);
980
- }
981
- */
982
  function rotatingtweets_get_cache_delay() {
983
  $cacheoption = get_option('rotatingtweets-api-settings');
984
  if(!isset($cacheoption['cache_delay'])):
@@ -989,7 +955,7 @@ function rotatingtweets_get_cache_delay() {
989
  return($cache_delay);
990
  }
991
  # Get the latest data from Twitter (or from a cache if it's been less than 2 minutes since the last load)
992
- function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_replies,$tw_get_favorites = FALSE,$tw_search = FALSE,$tw_list = FALSE ) {
993
  # Set timer
994
  $rt_starttime = microtime(true);
995
  # Clear up variables
@@ -1129,11 +1095,11 @@ function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_r
1129
  endif;
1130
  $twitterjson = $twitterjson['results'];
1131
  endif;
1132
- if(is_array($twitterjson) && isset($twitterjson[0] )) $firstentry = $twitterjson[0];
1133
  if(!empty($firstentry['text'])):
1134
  $number_returned_tweets = count($twitterjson);
1135
  if(WP_DEBUG) echo "<!-- ".$number_returned_tweets." tweets returned -->";
1136
- if($number_returned_tweets < 40 && is_array($latest_json) && count($latest_json)>0 ):
1137
  if(WP_DEBUG) echo "<!-- ".count($latest_json)." tweets in cache -->";
1138
  $twitterjson = rotatingtweet_combine_jsons($twitterjson,$latest_json);
1139
  if(WP_DEBUG) echo "<!-- ".count($twitterjson)." tweets in merged json -->";
@@ -1217,7 +1183,7 @@ function rotatingtweets_shrink_element($json,$no_emoji=0) {
1217
  $before='/\\p{C}/u'; # Removed all 'other' characters - http://php.net/manual/en/regexp.reference.unicode.php
1218
  $after='';
1219
  $json[$rt_element] = str_replace($before,$after,$json[$rt_element]);
1220
- endif;
1221
  /* Experiment to deal with problem caused by emoji crashing a poorly configured database
1222
  if(function_exists("mb_convert_encoding")):
1223
  $return[$rt_element]=mb_convert_encoding($json[$rt_element], "UTF-8");
@@ -1397,9 +1363,9 @@ function rotating_tweets_display($json,$args,$print=FALSE) {
1397
  foreach($possibleRotations as $possibleRotation):
1398
  if(strtolower($args['rotation_type']) == strtolower($possibleRotation)) $rotation_type = $possibleRotation;
1399
  endforeach;
1400
- # Create an ID that has all the relevant info in - rotation type and speed of rotation
1401
- // $id = uniqid('rotatingtweets_'.$timeout.'_'.$rotation_type.'_'.$speed."_");
1402
- $id = uniqid('rotatingtweets_');
1403
  $result = '';
1404
  $nextprev = '';
1405
  # Put in the 'next / prev' buttons - although not very styled!
@@ -1546,6 +1512,9 @@ function rotating_tweets_display($json,$args,$print=FALSE) {
1546
  array_push($json,$firstelement);
1547
  }
1548
  endif;
 
 
 
1549
  foreach($json as $twitter_object):
1550
  if ( ! ( ($args['exclude_replies'] && isset($twitter_object['text']) && substr($twitter_object['text'],0,1)=='@') || (!$args['include_rts'] && isset($twitter_object['retweeted_status'])) ) ):
1551
  // if (! ($args['exclude_replies'] && isset($twitter_object['text']) && substr($twitter_object['text'],0,1)=='@')): // This works to exlude replies
@@ -1726,6 +1695,12 @@ function rotating_tweets_display($json,$args,$print=FALSE) {
1726
  endif;
1727
  $main_text = $twitter_object['text'];
1728
  endif;
 
 
 
 
 
 
1729
  # Now for the different display options
1730
  switch ($args['official_format']) {
1731
  case 'custom':
@@ -1779,7 +1754,7 @@ function rotating_tweets_display($json,$args,$print=FALSE) {
1779
  # This is an attempt to replicate the original Tweet
1780
  $result .= "\n\t<div class='rtw_info'>";
1781
  $result .= "\n\t\t<div class='rtw_twitter_icon'><img src='".plugins_url('images/twitter-bird-16x16.png', __FILE__)."' width='16' height='16' alt='".__('Twitter','rotatingtweets')."' /></div>";
1782
- $result .= "\n\t\t<div class='rtw_icon'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'icon',$targetvalue)."</div>";
1783
  $result .= "\n\t\t<div class='rtw_name'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'name',$targetvalue)."</div>";
1784
  $result .= "\n\t\t<div class='rtw_id'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'screen_name',$targetvalue)."</div>";
1785
  $result .= "\n\t</div>";
@@ -1807,7 +1782,7 @@ function rotating_tweets_display($json,$args,$print=FALSE) {
1807
  case 2:
1808
  # This is a slightly adjusted version of the original tweet - designed for wide boxes - consistent with Twitter guidelines
1809
  $result .= "\n\t\t<div class='rtw_wide'>";
1810
- $result .= "\n\t\t<div class='rtw_wide_icon'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'icon',$targetvalue)."</div>";
1811
  $result .= "\n\t\t<div class='rtw_wide_block'><div class='rtw_info'>";
1812
  if($args['show_meta_timestamp'] || !isset($args['official_format_override']) || !$args['official_format_override'] ):
1813
  $result .= "\n\t\t\t<div class='rtw_time_short'>".rotatingtweets_timestamp_link($twitter_object,'short',$targetvalue).'</div>';
@@ -2234,4 +2209,19 @@ function rotatingtweets_block_transport() { return false; }
2234
  // add_filter('use_streams_transport', 'rotatingtweets_block_transport');
2235
  // add_filter('use_fopen_transport', 'rotatingtweets_block_transport');
2236
  // add_filter('use_fsockopen_transport', 'rotatingtweets_block_transport');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2237
  ?>
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.7.13
6
  Text Domain: rotatingtweets
7
  Author: Martin Tod
8
  Author URI: http://www.martintod.org.uk
189
  unset($$val[0]);
190
  endif;
191
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  ?>
193
  <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','rotatingtweets'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
194
  <?php
313
  }
314
  # This is an appalling hack to deal with the problem that jQuery gets broken when people hit save - as per http://lists.automattic.com/pipermail/wp-hackers/2011-March/037997.html - but it works!
315
  // echo "<script type='text/javascript' src='".plugins_url('js/rotating_tweet_admin.js', __FILE__)."'></script>";
316
+ echo "</div>\n";
317
+ /*
318
  echo "</div>\n<script type='text/javascript'>\n";
319
  $rtw_admin_script_original = file_get_contents(plugin_dir_path(__FILE__).'js/rotating_tweet_admin.js');
320
  $rtw_admin_script_final = str_replace(
323
  $rtw_admin_script_original);
324
  echo $rtw_admin_script_final;
325
  echo "\n</script>";
326
+ */
327
  }
328
  } // class rotatingtweets_Widget
329
 
391
  return($string);
392
  }
393
  // Produces a link to someone's name, icon or screen name (or to the text of your choice) using the 'intent' format for linking
394
+ function rotatingtweets_user_intent($person,$lang,$linkcontent,$targetvalue='',$iconsize='normal') {
395
  if(!is_array($person)) return;
396
  $return = "<a href='https://twitter.com/intent/user?user_id={$person['id']}' title='".esc_attr($person['name'])."' lang='{$lang}'{$targetvalue}>";
397
  switch($linkcontent){
398
  case 'icon':
399
+ $before = '_normal.';
400
+ $iconlink = $person['profile_image_url_https'];
401
+ switch(strtolower($iconsize)) {
402
+ case 'bigger':
403
+ $after = '_bigger.';
404
+ $iconlink = str_replace($before,$after,$iconlink);
405
+ break;
406
+ case 'mini':
407
+ $after = '_mini.';
408
+ $iconlink = str_replace($before,$after,$iconlink);
409
+ break;
410
+ case 'original':
411
+ $after = '.';
412
+ $iconlink = str_replace($before,$after,$iconlink);
413
+ break;
414
+ default:
415
+ break;
416
+ }
417
+ $return .= "<img src='".esc_url($iconlink)."' alt='".esc_attr($person['name'])."' /></a>";
418
  break;
419
  case 'name':
420
  $return .= $person['name']."</a>";
545
  'w3tc_render_to' => '',
546
  'official_format_override'=>FALSE,
547
  'no_cache'=>FALSE,
548
+ 'text_cache_id'=>FALSE,
549
+ 'profile_image_size'=>'normal',
550
+ 'shuffle'=>0,
551
+ 'merge_cache'=>TRUE
552
  ), $atts ) ;
553
  extract($args);
554
  if(empty($screen_name) && empty($search) && !empty($url)):
566
  rotatingtweets_enqueue_scripts();
567
  $returnstring = rotatingtweets_get_transient($args['text_cache_id']);
568
  if(strlen($returnstring)==0):
569
+ $tweets = rotatingtweets_get_tweets($screen_name,$include_rts,$exclude_replies,$get_favorites,$search,$list,$args['merge_cache']);
570
  $returnstring = rotating_tweets_display($tweets,$args,$print);
571
  elseif(WP_DEBUG):
572
  $returnstring .= "<!-- Transient ".$args['text_cache_id']." loaded -->";
914
  if(isset($data['errors'])):
915
  $data['errors'][0]['type'] = 'Twitter';
916
  if( empty($api) ) $errorstring[0]['message'] = 'Please enter valid Twitter API Settings on the Rotating Tweets settings page';
917
+ if(WP_DEBUG && ! is_admin() ):
918
+ echo "<!-- Error message from Twitter - \n";
919
+ print_r($data['errors']);
920
+ echo "\n-->";
921
+ endif;
922
  update_option('rotatingtweets_api_error',$data['errors']);
923
  else:
924
  if(WP_DEBUG && ! is_admin() ) echo "<!-- Successfully read data from Twitter -->";
945
  endif;
946
  return($result);
947
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
948
  function rotatingtweets_get_cache_delay() {
949
  $cacheoption = get_option('rotatingtweets-api-settings');
950
  if(!isset($cacheoption['cache_delay'])):
955
  return($cache_delay);
956
  }
957
  # Get the latest data from Twitter (or from a cache if it's been less than 2 minutes since the last load)
958
+ function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_replies,$tw_get_favorites = FALSE,$tw_search = FALSE,$tw_list = FALSE, $tw_merge = TRUE ) {
959
  # Set timer
960
  $rt_starttime = microtime(true);
961
  # Clear up variables
1095
  endif;
1096
  $twitterjson = $twitterjson['results'];
1097
  endif;
1098
+ if(isset($twitterjson) && is_array($twitterjson) && isset($twitterjson[0] )) $firstentry = $twitterjson[0];
1099
  if(!empty($firstentry['text'])):
1100
  $number_returned_tweets = count($twitterjson);
1101
  if(WP_DEBUG) echo "<!-- ".$number_returned_tweets." tweets returned -->";
1102
+ if($tw_merge && $number_returned_tweets < 40 && isset($latest_json) && is_array($latest_json) && count($latest_json)>0 ):
1103
  if(WP_DEBUG) echo "<!-- ".count($latest_json)." tweets in cache -->";
1104
  $twitterjson = rotatingtweet_combine_jsons($twitterjson,$latest_json);
1105
  if(WP_DEBUG) echo "<!-- ".count($twitterjson)." tweets in merged json -->";
1183
  $before='/\\p{C}/u'; # Removed all 'other' characters - http://php.net/manual/en/regexp.reference.unicode.php
1184
  $after='';
1185
  $json[$rt_element] = str_replace($before,$after,$json[$rt_element]);
1186
+ endif;
1187
  /* Experiment to deal with problem caused by emoji crashing a poorly configured database
1188
  if(function_exists("mb_convert_encoding")):
1189
  $return[$rt_element]=mb_convert_encoding($json[$rt_element], "UTF-8");
1363
  foreach($possibleRotations as $possibleRotation):
1364
  if(strtolower($args['rotation_type']) == strtolower($possibleRotation)) $rotation_type = $possibleRotation;
1365
  endforeach;
1366
+ # Create an ID that has most of the relevant info in - rotation type and speed of rotation
1367
+ $id = uniqid('rotatingtweets_'.$timeout.'_'.$rotation_type.'_'.$speed."_");
1368
+ // $id = uniqid('rotatingtweets_');
1369
  $result = '';
1370
  $nextprev = '';
1371
  # Put in the 'next / prev' buttons - although not very styled!
1512
  array_push($json,$firstelement);
1513
  }
1514
  endif;
1515
+ if(isset($args['shuffle']) && $args['shuffle']):
1516
+ shuffle($json);
1517
+ endif;
1518
  foreach($json as $twitter_object):
1519
  if ( ! ( ($args['exclude_replies'] && isset($twitter_object['text']) && substr($twitter_object['text'],0,1)=='@') || (!$args['include_rts'] && isset($twitter_object['retweeted_status'])) ) ):
1520
  // if (! ($args['exclude_replies'] && isset($twitter_object['text']) && substr($twitter_object['text'],0,1)=='@')): // This works to exlude replies
1695
  endif;
1696
  $main_text = $twitter_object['text'];
1697
  endif;
1698
+ # Set the iconsize
1699
+ if(isset($args['profile_image_size'])):
1700
+ $iconsize = $args['profile_image_size'];
1701
+ else:
1702
+ $iconsize = 'normal';
1703
+ endif;
1704
  # Now for the different display options
1705
  switch ($args['official_format']) {
1706
  case 'custom':
1754
  # This is an attempt to replicate the original Tweet
1755
  $result .= "\n\t<div class='rtw_info'>";
1756
  $result .= "\n\t\t<div class='rtw_twitter_icon'><img src='".plugins_url('images/twitter-bird-16x16.png', __FILE__)."' width='16' height='16' alt='".__('Twitter','rotatingtweets')."' /></div>";
1757
+ $result .= "\n\t\t<div class='rtw_icon'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'icon',$targetvalue,$iconsize)."</div>";
1758
  $result .= "\n\t\t<div class='rtw_name'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'name',$targetvalue)."</div>";
1759
  $result .= "\n\t\t<div class='rtw_id'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'screen_name',$targetvalue)."</div>";
1760
  $result .= "\n\t</div>";
1782
  case 2:
1783
  # This is a slightly adjusted version of the original tweet - designed for wide boxes - consistent with Twitter guidelines
1784
  $result .= "\n\t\t<div class='rtw_wide'>";
1785
+ $result .= "\n\t\t<div class='rtw_wide_icon'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'icon',$targetvalue,$iconsize)."</div>";
1786
  $result .= "\n\t\t<div class='rtw_wide_block'><div class='rtw_info'>";
1787
  if($args['show_meta_timestamp'] || !isset($args['official_format_override']) || !$args['official_format_override'] ):
1788
  $result .= "\n\t\t\t<div class='rtw_time_short'>".rotatingtweets_timestamp_link($twitter_object,'short',$targetvalue).'</div>';
2209
  // add_filter('use_streams_transport', 'rotatingtweets_block_transport');
2210
  // add_filter('use_fopen_transport', 'rotatingtweets_block_transport');
2211
  // add_filter('use_fsockopen_transport', 'rotatingtweets_block_transport');
2212
+
2213
+
2214
+ /** Support for Buddy Press */
2215
+ /*
2216
+ if (is_plugin_active('buddypress/bp-loader.php') && bp_is_user_profile() ):
2217
+ add_action( 'bp_profile_header_meta', 'rotatingtweets_bpdisplay' );
2218
+ endif;
2219
+
2220
+ function rotatingtweets_bpdisplay() {
2221
+ $bbpressTwittername = bp_get_profile_field_data( array('field'=>'Twitter') );
2222
+ if(!empty($bbpressTwittername) {
2223
+ echo do_shortcode("[rotatingtweets screen_name='".$bbpressTwitterName."']");
2224
+ }
2225
+ }
2226
+ */
2227
  ?>