Rotating Tweets (Twitter widget and shortcode) - Version 0.486

Version Description

Download this release

Release Info

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

Code changes from version 0.471 to 0.486

images/bird_16_black.png ADDED
Binary file
images/bird_16_blue.png ADDED
Binary file
images/bird_16_gray.png ADDED
Binary file
images/bird_black_32_0.png ADDED
Binary file
images/bird_black_48_0.png ADDED
Binary file
images/bird_blue_32.png ADDED
Binary file
images/bird_blue_48.png ADDED
Binary file
images/bird_gray_32.png ADDED
Binary file
images/bird_gray_48.png ADDED
Binary file
images/favorite.png ADDED
Binary file
images/favorite_hover.png ADDED
Binary file
images/favorite_on.png ADDED
Binary file
images/reply.png ADDED
Binary file
images/reply_hover.png ADDED
Binary file
images/retweet.png ADDED
Binary file
images/retweet_hover.png ADDED
Binary file
images/retweet_on.png ADDED
Binary file
images/twitter-bird-dark-bgs.png ADDED
Binary file
images/twitter-bird-light-bgs.png ADDED
Binary file
js/jquery.cycle.lite.js ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * jQuery Cycle Lite Plugin
3
+ * http://malsup.com/jquery/cycle/lite/
4
+ * Copyright (c) 2008-2012 M. Alsup
5
+ * Version: 1.6 (02-MAY-2012)
6
+ * Dual licensed under the MIT and GPL licenses:
7
+ * http://www.opensource.org/licenses/mit-license.php
8
+ * http://www.gnu.org/licenses/gpl.html
9
+ * Requires: jQuery v1.3.2 or later
10
+ */
11
+ ;(function($) {
12
+ "use strict";
13
+
14
+ var ver = 'Lite-1.6';
15
+
16
+ $.fn.cycle = function(options) {
17
+ return this.each(function() {
18
+ options = options || {};
19
+
20
+ if (this.cycleTimeout) clearTimeout(this.cycleTimeout);
21
+
22
+ this.cycleTimeout = 0;
23
+ this.cyclePause = 0;
24
+
25
+ var $cont = $(this);
26
+ var $slides = options.slideExpr ? $(options.slideExpr, this) : $cont.children();
27
+ var els = $slides.get();
28
+ if (els.length < 2) {
29
+ if (window.console)
30
+ console.log('terminating; too few slides: ' + els.length);
31
+ return; // don't bother
32
+ }
33
+
34
+ // support metadata plugin (v1.0 and v2.0)
35
+ var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {});
36
+ var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null;
37
+ if (meta)
38
+ opts = $.extend(opts, meta);
39
+
40
+ opts.before = opts.before ? [opts.before] : [];
41
+ opts.after = opts.after ? [opts.after] : [];
42
+ opts.after.unshift(function(){ opts.busy=0; });
43
+
44
+ // allow shorthand overrides of width, height and timeout
45
+ var cls = this.className;
46
+ opts.width = parseInt((cls.match(/w:(\d+)/)||[])[1], 10) || opts.width;
47
+ opts.height = parseInt((cls.match(/h:(\d+)/)||[])[1], 10) || opts.height;
48
+ opts.timeout = parseInt((cls.match(/t:(\d+)/)||[])[1], 10) || opts.timeout;
49
+
50
+ if ($cont.css('position') == 'static')
51
+ $cont.css('position', 'relative');
52
+ if (opts.width)
53
+ $cont.width(opts.width);
54
+ if (opts.height && opts.height != 'auto')
55
+ $cont.height(opts.height);
56
+
57
+ var first = 0;
58
+ $slides.css({position: 'absolute', top:0}).each(function(i) {
59
+ $(this).css('z-index', els.length-i);
60
+ });
61
+
62
+ $(els[first]).css('opacity',1).show(); // opacity bit needed to handle reinit case
63
+ if ($.browser.msie) els[first].style.removeAttribute('filter');
64
+
65
+ if (opts.fit && opts.width)
66
+ $slides.width(opts.width);
67
+ if (opts.fit && opts.height && opts.height != 'auto')
68
+ $slides.height(opts.height);
69
+ if (opts.pause)
70
+ $cont.hover(function(){this.cyclePause=1;}, function(){this.cyclePause=0;});
71
+
72
+ var txFn = $.fn.cycle.transitions[opts.fx];
73
+ if (txFn)
74
+ txFn($cont, $slides, opts);
75
+
76
+ $slides.each(function() {
77
+ var $el = $(this);
78
+ this.cycleH = (opts.fit && opts.height) ? opts.height : $el.height();
79
+ this.cycleW = (opts.fit && opts.width) ? opts.width : $el.width();
80
+ });
81
+
82
+ if (opts.cssFirst)
83
+ $($slides[first]).css(opts.cssFirst);
84
+
85
+ if (opts.timeout) {
86
+ // ensure that timeout and speed settings are sane
87
+ if (opts.speed.constructor == String)
88
+ opts.speed = {slow: 600, fast: 200}[opts.speed] || 400;
89
+ if (!opts.sync)
90
+ opts.speed = opts.speed / 2;
91
+ while((opts.timeout - opts.speed) < 250)
92
+ opts.timeout += opts.speed;
93
+ }
94
+ opts.speedIn = opts.speed;
95
+ opts.speedOut = opts.speed;
96
+
97
+ opts.slideCount = els.length;
98
+ opts.currSlide = first;
99
+ opts.nextSlide = 1;
100
+
101
+ // fire artificial events
102
+ var e0 = $slides[first];
103
+ if (opts.before.length)
104
+ opts.before[0].apply(e0, [e0, e0, opts, true]);
105
+ if (opts.after.length > 1)
106
+ opts.after[1].apply(e0, [e0, e0, opts, true]);
107
+
108
+ if (opts.click && !opts.next)
109
+ opts.next = opts.click;
110
+ if (opts.next)
111
+ $(opts.next).unbind('click.cycle').bind('click.cycle', function(){return advance(els,opts,opts.rev?-1:1);});
112
+ if (opts.prev)
113
+ $(opts.prev).unbind('click.cycle').bind('click.cycle', function(){return advance(els,opts,opts.rev?1:-1);});
114
+
115
+ if (opts.timeout)
116
+ this.cycleTimeout = setTimeout(function() {
117
+ go(els,opts,0,!opts.rev);
118
+ }, opts.timeout + (opts.delay||0));
119
+ });
120
+ };
121
+
122
+ function go(els, opts, manual, fwd) {
123
+ if (opts.busy)
124
+ return;
125
+ var p = els[0].parentNode, curr = els[opts.currSlide], next = els[opts.nextSlide];
126
+ if (p.cycleTimeout === 0 && !manual)
127
+ return;
128
+
129
+ if (manual || !p.cyclePause) {
130
+ if (opts.before.length)
131
+ $.each(opts.before, function(i,o) { o.apply(next, [curr, next, opts, fwd]); });
132
+ var after = function() {
133
+ if ($.browser.msie)
134
+ this.style.removeAttribute('filter');
135
+ $.each(opts.after, function(i,o) { o.apply(next, [curr, next, opts, fwd]); });
136
+ queueNext(opts);
137
+ };
138
+
139
+ if (opts.nextSlide != opts.currSlide) {
140
+ opts.busy = 1;
141
+ $.fn.cycle.custom(curr, next, opts, after);
142
+ }
143
+ var roll = (opts.nextSlide + 1) == els.length;
144
+ opts.nextSlide = roll ? 0 : opts.nextSlide+1;
145
+ opts.currSlide = roll ? els.length-1 : opts.nextSlide-1;
146
+ } else {
147
+ queueNext(opts);
148
+ }
149
+
150
+ function queueNext(opts) {
151
+ if (opts.timeout)
152
+ p.cycleTimeout = setTimeout(function() { go(els,opts,0,!opts.rev); }, opts.timeout);
153
+ }
154
+ }
155
+
156
+ // advance slide forward or back
157
+ function advance(els, opts, val) {
158
+ var p = els[0].parentNode, timeout = p.cycleTimeout;
159
+ if (timeout) {
160
+ clearTimeout(timeout);
161
+ p.cycleTimeout = 0;
162
+ }
163
+ opts.nextSlide = opts.currSlide + val;
164
+ if (opts.nextSlide < 0) {
165
+ opts.nextSlide = els.length - 1;
166
+ }
167
+ else if (opts.nextSlide >= els.length) {
168
+ opts.nextSlide = 0;
169
+ }
170
+ go(els, opts, 1, val>=0);
171
+ return false;
172
+ }
173
+
174
+ $.fn.cycle.custom = function(curr, next, opts, cb) {
175
+ var $l = $(curr), $n = $(next);
176
+ $n.css(opts.cssBefore);
177
+ var fn = function() {$n.animate(opts.animIn, opts.speedIn, opts.easeIn, cb);};
178
+ $l.animate(opts.animOut, opts.speedOut, opts.easeOut, function() {
179
+ $l.css(opts.cssAfter);
180
+ if (!opts.sync)
181
+ fn();
182
+ });
183
+ if (opts.sync)
184
+ fn();
185
+ };
186
+
187
+ $.fn.cycle.transitions = {
188
+ fade: function($cont, $slides, opts) {
189
+ $slides.not(':eq(0)').hide();
190
+ opts.cssBefore = { opacity: 0, display: 'block' };
191
+ opts.cssAfter = { display: 'none' };
192
+ opts.animOut = { opacity: 0 };
193
+ opts.animIn = { opacity: 1 };
194
+ },
195
+ fadeout: function($cont, $slides, opts) {
196
+ opts.before.push(function(curr,next,opts,fwd) {
197
+ $(curr).css('zIndex',opts.slideCount + (fwd === true ? 1 : 0));
198
+ $(next).css('zIndex',opts.slideCount + (fwd === true ? 0 : 1));
199
+ });
200
+ $slides.not(':eq(0)').hide();
201
+ opts.cssBefore = { opacity: 1, display: 'block', zIndex: 1 };
202
+ opts.cssAfter = { display: 'none', zIndex: 0 };
203
+ opts.animOut = { opacity: 0 };
204
+ opts.animIn = { opacity: 1 };
205
+ }
206
+ };
207
+
208
+ $.fn.cycle.ver = function() { return ver; };
209
+
210
+ // @see: http://malsup.com/jquery/cycle/lite/
211
+ $.fn.cycle.defaults = {
212
+ animIn: {},
213
+ animOut: {},
214
+ fx: 'fade',
215
+ after: null,
216
+ before: null,
217
+ cssBefore: {},
218
+ cssAfter: {},
219
+ delay: 0,
220
+ fit: 0,
221
+ height: 'auto',
222
+ metaAttr: 'cycle',
223
+ next: null,
224
+ pause: false,
225
+ prev: null,
226
+ speed: 1000,
227
+ slideExpr: null,
228
+ sync: true,
229
+ timeout: 4000
230
+ };
231
+
232
+ })(jQuery);
js/rotating_tweet_zee.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Script to cycle the rotating tweets (adjusted for the zeebizzcard template
3
+ For some reason we need to fix the minimum height of the rotating tweet area - since without it it defaults to zero
4
+ */
5
+ jQuery(document).ready(function() {
6
+ jQuery('.rotatingtweets').each(function() {
7
+ var rotate_id = "#"+this.id
8
+ var timeoutdelay = rotate_id.split('_');
9
+ jQuery(rotate_id).cycle({
10
+ pause: 1,
11
+ height: '6em',
12
+ timeout: timeoutdelay[1],
13
+ fx: 'scrollUp'
14
+ });
15
+ });
16
+ });
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
5
  Requires at least: 2.6
6
  Tested up to: 3.4
7
- Stable tag: 0.471
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -48,10 +48,14 @@ Possible variables for the shortcode include:
48
  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.
49
 
50
  == Upgrade notice ==
51
- = 0.471 =
52
- Includes fix for the major bug causing crashes when Twitter goes down. Also improved error checking if Twitter has returned an empty value or is rate-limited.
53
 
54
  == Changelog ==
 
 
 
 
55
  = 0.471 =
56
  Making sure that cache never gets overwritten unless new, valid twitter data has been downloaded.
57
  Dealing with the problem that someone in a long conversation may not get enough valid tweets to show by asking for only 20 tweets from Twitter.
@@ -101,4 +105,4 @@ First published version
101
  == Screenshots ==
102
  1. This animation shows rotating tweets inserted into a blog-post via a short code. It is slightly faster than the default setting, but gives a sense of what you get.
103
  2. You can add rotating tweets via a Widget:
104
- 3. Or by using a shortcode:
4
  Tags: shortcode,widget,twitter,rotating,rotate,rotator,tweet,tweets,animation,jquery
5
  Requires at least: 2.6
6
  Tested up to: 3.4
7
+ Stable tag: 0.486
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
48
  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.
49
 
50
  == Upgrade notice ==
51
+ = 0.48 =
52
+ Includes fix for the major bug causing crashes when Twitter goes down. More detailed error messages for Wordpress installations unable to access Twitter.
53
 
54
  == Changelog ==
55
+ = 0.48 =
56
+ More detailed error messages for Wordpress installations unable to access Twitter.
57
+ Fixes problem on the zeeBizzCard template and sets up fix for other templates that use their own install of the `jquery-cycle` javascript.
58
+
59
  = 0.471 =
60
  Making sure that cache never gets overwritten unless new, valid twitter data has been downloaded.
61
  Dealing with the problem that someone in a long conversation may not get enough valid tweets to show by asking for only 20 tweets from Twitter.
105
  == Screenshots ==
106
  1. This animation shows rotating tweets inserted into a blog-post via a short code. It is slightly faster than the default setting, but gives a sense of what you get.
107
  2. You can add rotating tweets via a Widget:
108
+ 3. Or by using a shortcode:
rotatingtweets.php CHANGED
@@ -2,7 +2,7 @@
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.471
6
  Author: Martin Tod
7
  Author URI: http://www.martintod.org.uk
8
  License: GPL2
@@ -40,8 +40,17 @@ class rotatingtweets_Widget extends WP_Widget {
40
  parent::WP_Widget(false, $name = 'Rotating Tweets',array('description'=>'A widget to show tweets for a particular user in rotation.'));
41
  if ( is_active_widget( false, false, $this->id_base ) )
42
  wp_enqueue_script( 'jquery' );
43
- wp_enqueue_script( 'jquery-cycle', plugins_url('js/jquery.cycle.all.js', __FILE__),array('jquery'),FALSE,FALSE );
44
- wp_enqueue_script( 'rotating_tweet', plugins_url('js/rotating_tweet.js', __FILE__),array('jquery','jquery-cycle'),FALSE,FALSE );
 
 
 
 
 
 
 
 
 
45
  wp_enqueue_style( 'rotating_tweet', plugins_url('css/style.css', __FILE__));
46
  }
47
 
@@ -193,6 +202,9 @@ function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_r
193
  $twitterdata = wp_remote_request($callstring);
194
  if(!is_wp_error($twitterdata)):
195
  $twitterjson = json_decode($twitterdata['body']);
 
 
 
196
  endif;
197
  endif;
198
  if(!empty($twitterjson->errors)):
@@ -229,6 +241,7 @@ function rotatingtweets_get_rate_data() {
229
  $rate = json_decode($ratedata['body']);
230
  return($rate);
231
  else:
 
232
  return(FALSE);
233
  endif;
234
  }
@@ -259,6 +272,12 @@ function rotating_tweets_display($json,$tweet_count=5,$show_follow=FALSE,$timeou
259
  if($waittimevalue == 0) $waittime = "less than a minute";
260
  $result .= "\n\t<div class = 'rotatingtweet' style='display:none'><p class='rtw_main'>Next attempt to get data will be in {$waittime}.</p></div>";
261
  else:
 
 
 
 
 
 
262
  $result .= "\n\t<div class = 'rotatingtweet' style='display:none'><p class='rtw_main'>Please check the Twitter name used in the settings.</p></div>";
263
  endif;
264
  else:
@@ -304,7 +323,7 @@ function rotating_tweets_display($json,$tweet_count=5,$show_follow=FALSE,$timeou
304
  if(!empty($urls)):
305
  foreach($urls as $url):
306
  $before[] = "*".$url->url."*";
307
- $after[] = "<a href='".$url->expanded_url."'>".$url->display_url."</a>";
308
  endforeach;
309
  endif;
310
  $media = $entities->media;
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.486
6
  Author: Martin Tod
7
  Author URI: http://www.martintod.org.uk
8
  License: GPL2
40
  parent::WP_Widget(false, $name = 'Rotating Tweets',array('description'=>'A widget to show tweets for a particular user in rotation.'));
41
  if ( is_active_widget( false, false, $this->id_base ) )
42
  wp_enqueue_script( 'jquery' );
43
+ # Get Stylesheet
44
+ $style = get_stylesheet();
45
+ switch ($style):
46
+ case 'zeebizzcard':
47
+ wp_enqueue_script( 'rotating_tweet', plugins_url('js/rotating_tweet_zee.js', __FILE__),array('jquery','zee_jquery-cycle'),FALSE,FALSE );
48
+ break;
49
+ default:
50
+ wp_enqueue_script( 'jquery-cycle', plugins_url('js/jquery.cycle.all.js', __FILE__),array('jquery'),FALSE,FALSE );
51
+ wp_enqueue_script( 'rotating_tweet', plugins_url('js/rotating_tweet.js', __FILE__),array('jquery','jquery-cycle'),FALSE,FALSE );
52
+ break;
53
+ endswitch;
54
  wp_enqueue_style( 'rotating_tweet', plugins_url('css/style.css', __FILE__));
55
  }
56
 
202
  $twitterdata = wp_remote_request($callstring);
203
  if(!is_wp_error($twitterdata)):
204
  $twitterjson = json_decode($twitterdata['body']);
205
+ else:
206
+ # echo "<!-- ";print_r($twitterdata);echo " -->";
207
+ set_transient('rotatingtweets_wp_error',$twitterdata->get_error_messages(), 120);
208
  endif;
209
  endif;
210
  if(!empty($twitterjson->errors)):
241
  $rate = json_decode($ratedata['body']);
242
  return($rate);
243
  else:
244
+ set_transient('rotatingtweets_wp_error',$ratedata->get_error_messages(), 120);
245
  return(FALSE);
246
  endif;
247
  }
272
  if($waittimevalue == 0) $waittime = "less than a minute";
273
  $result .= "\n\t<div class = 'rotatingtweet' style='display:none'><p class='rtw_main'>Next attempt to get data will be in {$waittime}.</p></div>";
274
  else:
275
+ $error_messages = get_transient('rotatingtweets_wp_error');
276
+ if($error_messages):
277
+ foreach($error_messages as $error_message):
278
+ $result .= "\n\t<div class = 'rotatingtweet' style='display:none'><p class='rtw_main'>Wordpress error message: ".$error_message.".</p></div>";
279
+ endforeach;
280
+ endif;
281
  $result .= "\n\t<div class = 'rotatingtweet' style='display:none'><p class='rtw_main'>Please check the Twitter name used in the settings.</p></div>";
282
  endif;
283
  else:
323
  if(!empty($urls)):
324
  foreach($urls as $url):
325
  $before[] = "*".$url->url."*";
326
+ $after[] = "<a href='".$url->url."' title='".$url->expanded_url."'>".$url->display_url."</a>";
327
  endforeach;
328
  endif;
329
  $media = $entities->media;