Rotating Tweets (Twitter widget and shortcode) - Version 0.490

Version Description

Download this release

Release Info

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

Code changes from version 0.486 to 0.490

js/jquery.cycle.lite.js DELETED
@@ -1,232 +0,0 @@
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.js CHANGED
@@ -11,4 +11,7 @@ jQuery(document).ready(function() {
11
  fx: 'scrollUp'
12
  });
13
  });
14
- });
 
 
 
11
  fx: 'scrollUp'
12
  });
13
  });
14
+ });
15
+ /* And call the Twitter script while we're at it! */
16
+ /* Standard script to call Twitter */
17
+ !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
js/rotating_tweet_zee.js CHANGED
@@ -8,9 +8,12 @@ jQuery(document).ready(function() {
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
- });
 
 
 
8
  var timeoutdelay = rotate_id.split('_');
9
  jQuery(rotate_id).cycle({
10
  pause: 1,
11
+ height: '7em',
12
  timeout: timeoutdelay[1],
13
  fx: 'scrollUp'
14
  });
15
  });
16
+ });
17
+ /* And call the Twitter script while we're at it! */
18
+ /* Standard script to call Twitter */
19
+ !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Rotating Tweets widget and shortcode ===
2
  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
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
 
@@ -15,6 +15,7 @@ Widget and/or shortcode to show your latest tweets one at a time an animated rot
15
  * 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.
16
  * Reliable - keeps showing your latest Tweets even if the Twitter website is down.
17
  * 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.
 
18
  * Replaces [t.co](http://t.co) links with the original link
19
  * Caches the most recent data from Twitter to avoid problems with rate limiting
20
  * Uses [jQuery](http://jquery.com/) and [jQuery.Cycle](http://jquery.malsup.com/cycle/) to produce a nice smooth result.
@@ -42,16 +43,21 @@ Possible variables for the shortcode include:
42
  * `tweet_count` = number of tweets to show - optional - default is `5`
43
  * `show_follow` = `'0'` or `'1'` - show follow button - optional - default is `'0'`
44
  * `timeout` = time that each tweet is shown in milliseconds - optional - default is `'4000'` (i.e. 4 seconds)
 
 
45
 
46
  == Frequently Asked Questions ==
47
  = How often does the plug-in call Twitter =
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.
1
  === Rotating Tweets widget and shortcode ===
2
  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
5
  Requires at least: 2.6
6
  Tested up to: 3.4
7
+ Stable tag: 0.490
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
15
  * 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.
16
  * Reliable - keeps showing your latest Tweets even if the Twitter website is down.
17
  * 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.
18
+ * Gives you the option to show a fully customisable Twitter 'follow' button
19
  * Replaces [t.co](http://t.co) links with the original link
20
  * Caches the most recent data from Twitter to avoid problems with rate limiting
21
  * Uses [jQuery](http://jquery.com/) and [jQuery.Cycle](http://jquery.malsup.com/cycle/) to produce a nice smooth result.
43
  * `tweet_count` = number of tweets to show - optional - default is `5`
44
  * `show_follow` = `'0'` or `'1'` - show follow button - optional - default is `'0'`
45
  * `timeout` = time that each tweet is shown in milliseconds - optional - default is `'4000'` (i.e. 4 seconds)
46
+ * `no_show_count` = `'0'` or `'1'` - remove the follower count from the Twitter follow button - optional - default is `'0'`
47
+ * `no_show_screen_name` = `'0'` or `'1'` - remove the screen name from the Twitter follow button - optional - default is `'0'`
48
 
49
  == Frequently Asked Questions ==
50
  = How often does the plug-in call Twitter =
51
  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.
52
 
53
  == Upgrade notice ==
54
+ = 0.49 =
55
+ Lets you customise the Twitter 'follow' button. Fixes problem with media links. Sorts problem of overlong links reshaping widgets.
56
 
57
  == Changelog ==
58
+ = 0.49 =
59
+ Lets you customise the Twitter 'follow' button
60
+
61
  = 0.48 =
62
  More detailed error messages for Wordpress installations unable to access Twitter.
63
  Fixes problem on the zeeBizzCard template and sets up fix for other templates that use their own install of the `jquery-cycle` javascript.
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.486
6
  Author: Martin Tod
7
  Author URI: http://www.martintod.org.uk
8
  License: GPL2
@@ -64,13 +64,32 @@ class rotatingtweets_Widget extends WP_Widget {
64
  $tw_tweet_count = $instance['tw_tweet_count'];
65
  $tw_show_follow = $instance['tw_show_follow'];
66
  $tw_timeout = $instance['tw_timeout'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  if(empty($tw_timeout)) $tw_timeout = 4000;
68
  $tweets = rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_replies,$tw_tweet_count);
69
  ?>
70
  <?php echo $before_widget;
71
  if ( $title )
72
  echo $before_title . $title . $after_title;
73
- rotating_tweets_display($tweets,$tw_tweet_count,$tw_show_follow,$tw_timeout);
74
  echo $after_widget; ?>
75
  <?php
76
  }
@@ -101,36 +120,57 @@ class rotatingtweets_Widget extends WP_Widget {
101
  if(empty($tw_timeout)) $tw_timeout = 4000;
102
  if(empty($tw_tweet_count)) $tw_tweet_count = 5;
103
  ?>
104
- <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <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>
105
- <p><label for="<?php echo $this->get_field_id('tw_screen_name'); ?>"><?php _e('Twitter name:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('tw_screen_name'); ?>" name="<?php echo $this->get_field_name('tw_screen_name'); ?>" value="<?php echo $tw_screen_name; ?>" /></label></p>
106
- <p><label for="<?php echo $this->get_field_id('tw_include_rts'); ?>"><?php _e('Include retweets?'); ?> <input id="<?php echo $this->get_field_id('tw_include_rts'); ?>" name="<?php echo $this->get_field_name('tw_include_rts'); ?>" type="checkbox" value="1" <?php if($tw_include_rts==1): ?>checked="checked" <?php endif; ?>/></label></p>
107
- <p><label for="<?php echo $this->get_field_id('tw_exclude_replies'); ?>"><?php _e('Exclude replies?'); ?> <input id="<?php echo $this->get_field_id('tw_exclude_replies'); ?>" name="<?php echo $this->get_field_name('tw_exclude_replies'); ?>" type="checkbox" value="1" <?php if($tw_exclude_replies==1): ?>checked="checked" <?php endif; ?>/></label></p>
108
- <p><label for="<?php echo $this->get_field_id('tw_show_follow'); ?>"><?php _e('Show follow button?'); ?> <input id="<?php echo $this->get_field_id('tw_show_follow'); ?>" name="<?php echo $this->get_field_name('tw_show_follow'); ?>" type="checkbox" value="1" <?php if($tw_show_follow==1): ?>checked="checked" <?php endif; ?>/></label></p>
109
- <p><label for="<?php echo $this->get_field_id('tw_tweet_count'); ?>"><?php _e('How many tweets?'); ?> <select id="<?php echo $this->get_field_id('tw_tweet_count'); ?>" name="<?php echo $this->get_field_name('tw_tweet_count');?>">
110
- <?php
111
- for ($i=1; $i<20; $i++) {
112
- echo "\n\t<option value='$i' ";
113
- if($tw_tweet_count==$i): ?>selected="selected" <?php endif;
114
- echo ">$i</option>";
115
- }
116
- ?></select></label></p>
117
- <p><label for="<?php echo $this->get_field_id('tw_timeout'); ?>"><?php _e('Speed'); ?> <select id="<?php echo $this->get_field_id('tw_timeout'); ?>" name="<?php echo $this->get_field_name('tw_timeout');?>">
118
- <?php
119
- $timeoutoptions = array (
120
- "3000" => "Faster (3 seconds)",
121
- "4000" => "Normal (4 seconds)",
122
- "5000" => "Slower (5 seconds)",
123
- "6000" => "Slowest (6 seconds)"
124
- );
125
- foreach ($timeoutoptions as $val => $words) {
126
- echo "\n\t<option value='$val' ";
127
- if($tw_timeout==$val): ?>selected="selected" <?php endif;
128
- echo ">$words</option>";
129
- }
130
- ?></select></label></p>
131
- <?php
132
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
 
 
 
 
 
 
134
  } // class rotatingtweets_Widget
135
 
136
  // register rotatingtweets_Widget widget
@@ -168,6 +208,8 @@ function rotatingtweets_display( $atts, $content=null, $code="" ) {
168
  $exclude_replies :: [boolean] exclude replies - optional
169
  $tweet_count :: [integer] number of tweets to show - optional - default 5
170
  $show_follow :: [boolean] show follow button
 
 
171
  */
172
  extract( shortcode_atts( array(
173
  'screen_name' => 'twitter',
@@ -175,10 +217,12 @@ function rotatingtweets_display( $atts, $content=null, $code="" ) {
175
  'exclude_replies' => FALSE,
176
  'tweet_count' => 5,
177
  'show_follow' => FALSE,
178
- 'timeout' => 4000
 
 
179
  ), $atts ) );
180
  $tweets = rotatingtweets_get_tweets($screen_name,$include_rts,$exclude_replies,$tweet_count);
181
- $returnstring = rotating_tweets_display($tweets,$tweet_count,$show_follow,$timeout,FALSE);
182
  return $returnstring;
183
  }
184
  add_shortcode( 'rotatingtweets', 'rotatingtweets_display' );
@@ -255,7 +299,7 @@ function rotatingtweets_trigger_rate_limiting() {
255
  }
256
 
257
  # Displays the tweets
258
- function rotating_tweets_display($json,$tweet_count=5,$show_follow=FALSE,$timeout=4000,$print=TRUE) {
259
  unset($result);
260
  $tweet_count = max(1,intval($tweet_count));
261
  $timeout = max(intval($timeout),0);
@@ -323,14 +367,18 @@ function rotating_tweets_display($json,$tweet_count=5,$show_follow=FALSE,$timeou
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;
330
  if(!empty($media)):
331
  foreach($media as $medium):
332
  $before[] = "*".$medium->url."*";
333
- $after[] = "<a href='".$medium->expanded_url."'>".$medium->display_url."</a>";
 
 
334
  endforeach;
335
  endif;
336
  $before[]="%#(\w+)%";
@@ -338,7 +386,8 @@ function rotating_tweets_display($json,$tweet_count=5,$show_follow=FALSE,$timeou
338
  $main_text = preg_replace($before,$after,$main_text);
339
  $result .= "\n\t\t<p class='rtw_main'>$main_text</p>";
340
  $result .= "\n\t\t<p class='rtw_meta'><a href='http://twitter.com/".$user->screen_name."/status/".$twitter_object->id_str."'>".ucfirst(rotatingtweets_contextualtime(strtotime($twitter_object->created_at)))."</a> from <a target='_BLANK' href='http://twitter.com/".$user->screen_name."' title=\"".$user->name."\">".$user->name."'s Twitter</a> via ".$twitter_object->source;
341
- # $result .= '<br /><a href="http://twitter.com/intent/tweet?in_reply_to='.$twitter_object->id_str.'" title="Reply"><img src="'.plugins_url('images/reply.png', __FILE__).'" width="16" height="16" alt="Reply" /></a> <a href="http://twitter.com/intent/retweet?tweet_id='.$twitter_object->id_str.'" title="Retweet" ><img src="'.plugins_url('images/retweet.png', __FILE__).'" width="16" height="16" alt="Retweet" /></a> <a href="http://twitter.com/intent/favorite?tweet_id='.$twitter_object->id_str.'" title="Favourite"><img src="'.plugins_url('images/favorite.png', __FILE__).'" alt="Favorite" width="16" height="16" /></a></p>';
 
342
  else:
343
  $result .= "\n\t\t<p class='rtw_main'>Problem retrieving data from Twitter.</p></div>";
344
  $result .= "<!-- rotatingtweets plugin was unable to parse this data: ".print_r($json,TRUE)." -->";
@@ -349,10 +398,11 @@ function rotating_tweets_display($json,$tweet_count=5,$show_follow=FALSE,$timeou
349
  endforeach;
350
  endif;
351
  $result .= "\n</div>";
352
- if($show_follow==TRUE && !empty($user->screen_name)):
353
- $result .= "\n<div class='follow-button'><a href='http://twitter.com/".$user->screen_name."' class='twitter-follow-button' title='Follow @".$user->screen_name."'>@".$user->screen_name."</a></div>";
354
- $script = 'http://platform.twitter.com/widgets.js';
355
- wp_enqueue_script( 'twitter-wjs', $script, FALSE, FALSE, TRUE );
 
356
  endif;
357
  wp_enqueue_script( 'jquery' );
358
  wp_enqueue_script( 'jquery-cycle', plugins_url('js/jquery.cycle.all.js', __FILE__),array('jquery'),FALSE,FALSE );
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.490
6
  Author: Martin Tod
7
  Author URI: http://www.martintod.org.uk
8
  License: GPL2
64
  $tw_tweet_count = $instance['tw_tweet_count'];
65
  $tw_show_follow = $instance['tw_show_follow'];
66
  $tw_timeout = $instance['tw_timeout'];
67
+ switch($tw_show_follow) {
68
+ case 2:
69
+ $tw_no_show_count = TRUE;
70
+ $tw_no_show_screen_name = FALSE;
71
+ break;
72
+ case 3:
73
+ $tw_no_show_count = FALSE;
74
+ $tw_no_show_screen_name = TRUE;
75
+ break;
76
+ case 4:
77
+ $tw_no_show_count = TRUE;
78
+ $tw_no_show_screen_name = TRUE;
79
+ break;
80
+ default:
81
+ $tw_no_show_count = FALSE;
82
+ $tw_no_show_screen_name = FALSE;
83
+ break;
84
+ }
85
+
86
  if(empty($tw_timeout)) $tw_timeout = 4000;
87
  $tweets = rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_replies,$tw_tweet_count);
88
  ?>
89
  <?php echo $before_widget;
90
  if ( $title )
91
  echo $before_title . $title . $after_title;
92
+ rotating_tweets_display($tweets,$tw_tweet_count,$tw_show_follow,$tw_timeout,TRUE,$tw_no_show_count,$tw_no_show_screen_name);
93
  echo $after_widget; ?>
94
  <?php
95
  }
120
  if(empty($tw_timeout)) $tw_timeout = 4000;
121
  if(empty($tw_tweet_count)) $tw_tweet_count = 5;
122
  ?>
123
+ <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <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>
124
+ <p><label for="<?php echo $this->get_field_id('tw_screen_name'); ?>"><?php _e('Twitter name:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('tw_screen_name'); ?>" name="<?php echo $this->get_field_name('tw_screen_name'); ?>" value="<?php echo $tw_screen_name; ?>" /></label></p>
125
+ <p><label for="<?php echo $this->get_field_id('tw_include_rts'); ?>"><?php _e('Include retweets?'); ?> <input id="<?php echo $this->get_field_id('tw_include_rts'); ?>" name="<?php echo $this->get_field_name('tw_include_rts'); ?>" type="checkbox" value="1" <?php if($tw_include_rts==1): ?>checked="checked" <?php endif; ?>/></label></p>
126
+ <p><label for="<?php echo $this->get_field_id('tw_exclude_replies'); ?>"><?php _e('Exclude replies?'); ?> <input id="<?php echo $this->get_field_id('tw_exclude_replies'); ?>" name="<?php echo $this->get_field_name('tw_exclude_replies'); ?>" type="checkbox" value="1" <?php if($tw_exclude_replies==1): ?>checked="checked" <?php endif; ?>/></label></p>
127
+ <p><label for="<?php echo $this->get_field_id('tw_tweet_count'); ?>"><?php _e('How many tweets?'); ?> <select id="<?php echo $this->get_field_id('tw_tweet_count'); ?>" name="<?php echo $this->get_field_name('tw_tweet_count');?>">
128
+ <?php
129
+ for ($i=1; $i<20; $i++) {
130
+ echo "\n\t<option value='$i' ";
131
+ if($tw_tweet_count==$i): ?>selected="selected" <?php endif;
132
+ echo ">$i</option>";
133
+ }
134
+ ?></select></label></p>
135
+ <p><label for="<?php echo $this->get_field_id('tw_timeout'); ?>"><?php _e('Speed'); ?> <select id="<?php echo $this->get_field_id('tw_timeout'); ?>" name="<?php echo $this->get_field_name('tw_timeout');?>">
136
+ <?php
137
+ $timeoutoptions = array (
138
+ "3000" => "Faster (3 seconds)",
139
+ "4000" => "Normal (4 seconds)",
140
+ "5000" => "Slower (5 seconds)",
141
+ "6000" => "Slowest (6 seconds)"
142
+ );
143
+ foreach ($timeoutoptions as $val => $words) {
144
+ echo "\n\t<option value='$val' ";
145
+ if($tw_timeout==$val): ?>selected="selected" <?php endif;
146
+ echo ">$words</option>";
147
+ }
148
+ ?></select></label></p>
149
+ <p><?php _e('Show follow button?'); ?></p>
150
+ <?php
151
+ /*
152
+ $plugindir = plugin_dir_url(__FILE__);
153
+ $showfollowoptions = array (
154
+ 0 => 'None',
155
+ 1 => "Show name and number of followers<br /><img src='".$plugindir."images/follow-full.png' height='20' width='206' align='top' alt='Twitter Follow Button showing screen name and follower count' />",
156
+ 2 => "Show name only<br /><img src='".$plugindir."images/follow-full-no-count.png' height='20' align='top' width='117' alt='Twitter Follow Button showing only screen name and no follower count' />",
157
+ 3 => "Show button only<br /><img src='".$plugindir."images/follow-short.png' height='20' width='60' align='top' alt='Twitter Follow Button without screen name or follow count' />"
158
+ );
159
+ */
160
+ $showfollowoptions = array (
161
+ 0 => 'None',
162
+ 1 => "Show name and number of followers",
163
+ 2 => "Show name only",
164
+ 3 => "Show followers only",
165
+ 4 => "Show button only"
166
+ );
167
 
168
+ foreach ($showfollowoptions as $val => $html) {
169
+ echo "<input type='radio' value='$val' id='".$this->get_field_id('tw_tweet_count_'.$val)."' name= '".$this->get_field_name('tw_show_follow')."'";
170
+ if($tw_show_follow==$val): ?> checked="checked" <?php endif;
171
+ echo "><label for '".$this->get_field_id('tw_tweet_count_'.$val)."'> $html</label><br />";
172
+ }
173
+ }
174
  } // class rotatingtweets_Widget
175
 
176
  // register rotatingtweets_Widget widget
208
  $exclude_replies :: [boolean] exclude replies - optional
209
  $tweet_count :: [integer] number of tweets to show - optional - default 5
210
  $show_follow :: [boolean] show follow button
211
+ $no_show_count :: [boolean] remove count from follow button
212
+ $no_show_screen_name :: [boolean] remove screen name from follow button
213
  */
214
  extract( shortcode_atts( array(
215
  'screen_name' => 'twitter',
217
  'exclude_replies' => FALSE,
218
  'tweet_count' => 5,
219
  'show_follow' => FALSE,
220
+ 'timeout' => 4000,
221
+ 'no_show_count' => FALSE,
222
+ 'no_show_screen_name' => FALSE
223
  ), $atts ) );
224
  $tweets = rotatingtweets_get_tweets($screen_name,$include_rts,$exclude_replies,$tweet_count);
225
+ $returnstring = rotating_tweets_display($tweets,$tweet_count,$show_follow,$timeout,FALSE,$no_show_count,$no_show_screen_name);
226
  return $returnstring;
227
  }
228
  add_shortcode( 'rotatingtweets', 'rotatingtweets_display' );
299
  }
300
 
301
  # Displays the tweets
302
+ function rotating_tweets_display($json,$tweet_count=5,$show_follow=FALSE,$timeout=4000,$print=TRUE,$no_show_count=FALSE,$no_show_screen_name=FALSE) {
303
  unset($result);
304
  $tweet_count = max(1,intval($tweet_count));
305
  $timeout = max(intval($timeout),0);
367
  if(!empty($urls)):
368
  foreach($urls as $url):
369
  $before[] = "*".$url->url."*";
370
+ $displayurl = $url->display_url;
371
+ if(strlen($displayurl)>29) $displayurl = substr($displayurl,0,29)."&hellip;";
372
+ $after[] = "<a href='".$url->url."' title='".$url->expanded_url."'>".esc_html($displayurl)."</a>";
373
  endforeach;
374
  endif;
375
  $media = $entities->media;
376
  if(!empty($media)):
377
  foreach($media as $medium):
378
  $before[] = "*".$medium->url."*";
379
+ $displayurl = $medium->display_url;
380
+ if(strlen($displayurl)>30) $displayurl = substr($displayurl,0,30)."&hellip;";
381
+ $after[] = "<a href='".$medium->url."' title='".$medium->expanded_url."'>".esc_html($displayurl)."</a>";
382
  endforeach;
383
  endif;
384
  $before[]="%#(\w+)%";
386
  $main_text = preg_replace($before,$after,$main_text);
387
  $result .= "\n\t\t<p class='rtw_main'>$main_text</p>";
388
  $result .= "\n\t\t<p class='rtw_meta'><a href='http://twitter.com/".$user->screen_name."/status/".$twitter_object->id_str."'>".ucfirst(rotatingtweets_contextualtime(strtotime($twitter_object->created_at)))."</a> from <a target='_BLANK' href='http://twitter.com/".$user->screen_name."' title=\"".$user->name."\">".$user->name."'s Twitter</a> via ".$twitter_object->source;
389
+ # $result .= ' <a href="http://twitter.com/intent/tweet?in_reply_to='.$twitter_object->id_str.'" title="Reply"><img src="'.plugins_url('images/reply.png', __FILE__).'" width="16" height="16" alt="Reply" /></a> <a href="http://twitter.com/intent/retweet?tweet_id='.$twitter_object->id_str.'" title="Retweet" ><img src="'.plugins_url('images/retweet.png', __FILE__).'" width="16" height="16" alt="Retweet" /></a> <a href="http://twitter.com/intent/favorite?tweet_id='.$twitter_object->id_str.'" title="Favourite"><img src="'.plugins_url('images/favorite.png', __FILE__).'" alt="Favorite" width="16" height="16" /></a></p>';
390
+ # $result .= ' &middot; <a href="http://twitter.com/intent/tweet?in_reply_to='.$twitter_object->id_str.'">reply</a> &middot; <a href="http://twitter.com/intent/retweet?tweet_id='.$twitter_object->id_str.'">retweet</a> &middot; <a href="http://twitter.com/intent/favorite?tweet_id='.$twitter_object->id_str.'">favorite</a></p>';
391
  else:
392
  $result .= "\n\t\t<p class='rtw_main'>Problem retrieving data from Twitter.</p></div>";
393
  $result .= "<!-- rotatingtweets plugin was unable to parse this data: ".print_r($json,TRUE)." -->";
398
  endforeach;
399
  endif;
400
  $result .= "\n</div>";
401
+ if($show_follow && !empty($user->screen_name)):
402
+ unset($shortenvariables);
403
+ if($no_show_count) $shortenvariables = ' data-show-count="false"';
404
+ if($no_show_screen_name) $shortenvariables .= ' data-show-screen-name="false"';
405
+ $result .= "\n<div class='follow-button'><a href='http://twitter.com/".$user->screen_name."' class='twitter-follow-button'{$shortenvariables} title='Follow @".$user->screen_name."'>Follow @".$user->screen_name."</a></div>";
406
  endif;
407
  wp_enqueue_script( 'jquery' );
408
  wp_enqueue_script( 'jquery-cycle', plugins_url('js/jquery.cycle.all.js', __FILE__),array('jquery'),FALSE,FALSE );