Rotating Tweets (Twitter widget and shortcode) - Version 0.40

Version Description

Added ability to alter speed of rotation

=

Download this release

Release Info

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

Code changes from version 0.30 to 0.40

Files changed (3) hide show
  1. js/rotating_tweet.js +2 -0
  2. readme.txt +7 -3
  3. rotatingtweets.php +35 -13
js/rotating_tweet.js CHANGED
@@ -4,8 +4,10 @@
4
  jQuery(document).ready(function() {
5
  jQuery('.rotatingtweets').each(function() {
6
  var rotate_id = "#"+this.id
 
7
  jQuery(rotate_id).cycle({
8
  pause: 1,
 
9
  fx: 'scrollUp'
10
  });
11
  });
4
  jQuery(document).ready(function() {
5
  jQuery('.rotatingtweets').each(function() {
6
  var rotate_id = "#"+this.id
7
+ var timeoutdelay = rotate_id.split('_');
8
  jQuery(rotate_id).cycle({
9
  pause: 1,
10
+ timeout: timeoutdelay[1],
11
  fx: 'scrollUp'
12
  });
13
  });
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
5
  Requires at least: 2.6
6
  Tested up to: 3.4
7
- Stable tag: 0.30
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -31,6 +31,7 @@ Possible variables for the shortcode include:
31
  * `exclude_replies` = `'0'` or `'1'` - exclude replies - optional - default is `'0'`
32
  * `tweet_count` = number of tweets to show - optional - default is `5`
33
  * `show_follow` = `'0'` or `'1'` - show follow button - optional - default is `'0'`
 
34
 
35
  But you may just decide to use the 'Rotating Tweets' widget!
36
 
@@ -39,10 +40,13 @@ But you may just decide to use the 'Rotating Tweets' widget!
39
  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.
40
 
41
  == Upgrade notice ==
42
- = 0.30 =
43
- Fixes bug - problem with `get_object_vars()` on line 193
44
 
45
  == Changelog ==
 
 
 
46
  = 0.30 =
47
  Fixes bug - problem with `get_object_vars()` on line 193
48
 
4
  Tags: shortcode,widget,twitter,rotating,rotate,rotator,tweet,tweets
5
  Requires at least: 2.6
6
  Tested up to: 3.4
7
+ Stable tag: 0.40
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
31
  * `exclude_replies` = `'0'` or `'1'` - exclude replies - optional - default is `'0'`
32
  * `tweet_count` = number of tweets to show - optional - default is `5`
33
  * `show_follow` = `'0'` or `'1'` - show follow button - optional - default is `'0'`
34
+ * `timeout` = time that each tweet is shown in milliseconds - optional - default is `'4000'` (i.e. 4 seconds)
35
 
36
  But you may just decide to use the 'Rotating Tweets' widget!
37
 
40
  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.
41
 
42
  == Upgrade notice ==
43
+ = 0.40 =
44
+ Added ability to alter speed of rotation
45
 
46
  == Changelog ==
47
+ = 0.40 =
48
+ Added ability to alter speed of rotation
49
+
50
  = 0.30 =
51
  Fixes bug - problem with `get_object_vars()` on line 193
52
 
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.30
6
  Author: Martin Tod
7
  Author URI: http://www.martintod.org.uk
8
  License: GPL2
@@ -54,26 +54,28 @@ class rotatingtweets_Widget extends WP_Widget {
54
  $tw_exclude_replies = $instance['tw_exclude_replies'];
55
  $tw_tweet_count = $instance['tw_tweet_count'];
56
  $tw_show_follow = $instance['tw_show_follow'];
 
 
57
  $tweets = rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_replies,$tw_tweet_count);
58
-
59
  ?>
60
  <?php echo $before_widget;
61
  if ( $title )
62
  echo $before_title . $title . $after_title;
63
- rotating_tweets_display($tweets,$tw_tweet_count,$tw_show_follow);
64
  echo $after_widget; ?>
65
  <?php
66
  }
67
 
68
  /** @see WP_Widget::update */
69
  function update($new_instance, $old_instance) {
70
- $instance = $old_instance;
71
- $instance['title'] = strip_tags($new_instance['title']);
72
- $instance['tw_screen_name'] = strip_tags($new_instance['tw_screen_name']);
73
- $instance['tw_include_rts'] = absint($new_instance['tw_include_rts']);
74
- $instance['tw_exclude_replies'] = absint($new_instance['tw_exclude_replies']);
75
- $instance['tw_tweet_count'] = max(1,intval($new_instance['tw_tweet_count']));
76
- $instance['tw_show_follow'] = absint($new_instance['tw_show_follow']);;
 
77
  return $instance;
78
  }
79
 
@@ -85,6 +87,10 @@ class rotatingtweets_Widget extends WP_Widget {
85
  $tw_exclude_replies = absint($instance['tw_exclude_replies']);
86
  $tw_tweet_count = intval($instance['tw_tweet_count']);
87
  $tw_show_follow = absint($instance['tw_show_follow']);
 
 
 
 
88
  ?>
89
  <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>
90
  <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>
@@ -99,6 +105,20 @@ class rotatingtweets_Widget extends WP_Widget {
99
  echo ">$i</option>";
100
  }
101
  ?></select></label></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  <?php
103
  }
104
 
@@ -146,9 +166,10 @@ function rotatingtweets_display( $atts, $content=null, $code="" ) {
146
  'exclude_replies' => FALSE,
147
  'tweet_count' => 5,
148
  'show_follow' => FALSE,
 
149
  ), $atts ) );
150
  $tweets = rotatingtweets_get_tweets($screen_name,$include_rts,$exclude_replies,$tweet_count);
151
- $returnstring = rotating_tweets_display($tweets,$tweet_count,$show_follow,FALSE);
152
  return $returnstring;
153
  }
154
  add_shortcode( 'rotatingtweets', 'rotatingtweets_display' );
@@ -183,11 +204,12 @@ function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_r
183
  }
184
 
185
  # Displays the tweets
186
- function rotating_tweets_display($json,$tweet_count=5,$show_follow=FALSE,$print=TRUE) {
187
  unset($result);
188
  if(!empty($json->errors) or empty($json)) return;
189
  $tweet_count = max(1,intval($tweet_count));
190
- $result = "<div class='rotatingtweets' id='".uniqid('rotatingtweets_')."'>";
 
191
  $tweet_counter = 0;
192
  foreach($json as $twitter_object):
193
  $tweet_counter++;
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.40
6
  Author: Martin Tod
7
  Author URI: http://www.martintod.org.uk
8
  License: GPL2
54
  $tw_exclude_replies = $instance['tw_exclude_replies'];
55
  $tw_tweet_count = $instance['tw_tweet_count'];
56
  $tw_show_follow = $instance['tw_show_follow'];
57
+ $tw_timeout = $instance['tw_timeout'];
58
+ if(empty($tw_timeout)) $tw_timeout = 4000;
59
  $tweets = rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_replies,$tw_tweet_count);
 
60
  ?>
61
  <?php echo $before_widget;
62
  if ( $title )
63
  echo $before_title . $title . $after_title;
64
+ rotating_tweets_display($tweets,$tw_tweet_count,$tw_show_follow,$tw_timeout);
65
  echo $after_widget; ?>
66
  <?php
67
  }
68
 
69
  /** @see WP_Widget::update */
70
  function update($new_instance, $old_instance) {
71
+ $instance = $old_instance;
72
+ $instance['title'] = strip_tags($new_instance['title']);
73
+ $instance['tw_screen_name'] = strip_tags($new_instance['tw_screen_name']);
74
+ $instance['tw_include_rts'] = absint($new_instance['tw_include_rts']);
75
+ $instance['tw_exclude_replies'] = absint($new_instance['tw_exclude_replies']);
76
+ $instance['tw_tweet_count'] = max(1,intval($new_instance['tw_tweet_count']));
77
+ $instance['tw_show_follow'] = absint($new_instance['tw_show_follow']);
78
+ $instance['tw_timeout'] = max(min(intval($new_instance['tw_timeout']/1000)*1000,6000),3000);
79
  return $instance;
80
  }
81
 
87
  $tw_exclude_replies = absint($instance['tw_exclude_replies']);
88
  $tw_tweet_count = intval($instance['tw_tweet_count']);
89
  $tw_show_follow = absint($instance['tw_show_follow']);
90
+ $tw_timeout = intval($instance['tw_timeout']);
91
+ # If values not set, set default values
92
+ if(empty($tw_timeout)) $tw_timeout = 4000;
93
+ if(empty($tw_tweet_count)) $tw_tweet_count = 5;
94
  ?>
95
  <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>
96
  <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>
105
  echo ">$i</option>";
106
  }
107
  ?></select></label></p>
108
+ <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');?>">
109
+ <?php
110
+ $timeoutoptions = array (
111
+ "3000" => "Faster (3 seconds)",
112
+ "4000" => "Normal (4 seconds)",
113
+ "5000" => "Slower (5 seconds)",
114
+ "6000" => "Slowest (6 seconds)"
115
+ );
116
+ foreach ($timeoutoptions as $val => $words) {
117
+ echo "\n\t<option value='$val' ";
118
+ if($tw_timeout==$val): ?>selected="selected" <?php endif;
119
+ echo ">$words</option>";
120
+ }
121
+ ?></select></label></p>
122
  <?php
123
  }
124
 
166
  'exclude_replies' => FALSE,
167
  'tweet_count' => 5,
168
  'show_follow' => FALSE,
169
+ 'timeout' => 4000
170
  ), $atts ) );
171
  $tweets = rotatingtweets_get_tweets($screen_name,$include_rts,$exclude_replies,$tweet_count);
172
+ $returnstring = rotating_tweets_display($tweets,$tweet_count,$show_follow,$timeout,FALSE);
173
  return $returnstring;
174
  }
175
  add_shortcode( 'rotatingtweets', 'rotatingtweets_display' );
204
  }
205
 
206
  # Displays the tweets
207
+ function rotating_tweets_display($json,$tweet_count=5,$show_follow=FALSE,$timeout=4000,$print=TRUE) {
208
  unset($result);
209
  if(!empty($json->errors) or empty($json)) return;
210
  $tweet_count = max(1,intval($tweet_count));
211
+ $timeout = max(intval($timeout),0);
212
+ $result = "<div class='rotatingtweets' id='".uniqid('rotatingtweets_'.$timeout.'_')."'>";
213
  $tweet_counter = 0;
214
  foreach($json as $twitter_object):
215
  $tweet_counter++;