Rotating Tweets (Twitter widget and shortcode) - Version 1.7.14

Version Description

  • Works with Page Builder by SiteOrigin. Adds new shortcode variable.

=

Download this release

Release Info

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

Code changes from version 1.7.13 to 1.7.14

Files changed (3) hide show
  1. js/rotating_tweet_admin.js +13 -10
  2. readme.txt +9 -4
  3. rotatingtweets.php +45 -16
js/rotating_tweet_admin.js CHANGED
@@ -25,27 +25,27 @@ jQuery(document).ready(function() {
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
  }
@@ -54,4 +54,7 @@ jQuery(document).ready(function() {
54
  jQuery(document).on('widget-updated widget-added', function(){
55
  rotatingtweets_runselect();
56
  });
 
 
 
57
  });
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,.panel-dialog').find('.rtw_ad_list_tag').show('fast');
29
  } else {
30
+ jQuery(this).closest('.widget-content,.panel-dialog').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,.panel-dialog').find('.rtw_ad_list_tag').show('fast');
38
  } else {
39
+ jQuery(this).closest('.widget-content,.panel-dialog').find('.rtw_ad_list_tag').hide('fast');
40
  }
41
  if( response == 2) {
42
+ jQuery(this).closest('.widget-content,.panel-dialog').find('.rtw_ad_search').show();
43
+ jQuery(this).closest('.widget-content,.panel-dialog').find('.rtw_ad_not_search').hide();
44
+ // jQuery(this).closest('.widget-content,.panel-dialog').find('.rtw_ad_sf').hide('fast');
45
  } else {
46
+ jQuery(this).closest('.widget-content,.panel-dialog').find('.rtw_ad_search').hide();
47
+ jQuery(this).closest('.widget-content,.panel-dialog').find('.rtw_ad_not_search').show();
48
+ // jQuery(this).closest('.widget-content,.panel-dialog').find('.rtw_ad_sf').show('fast');
49
  }
50
  });
51
  }
54
  jQuery(document).on('widget-updated widget-added', function(){
55
  rotatingtweets_runselect();
56
  });
57
+ jQuery(document).on('panelsopen', function() {
58
+ rotatingtweets_runselect();
59
+ });
60
  });
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Rotating Tweets (Twitter 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,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
 
@@ -66,6 +66,7 @@ Possible variables for the shortcode include:
66
  * `search` = a term to search for. There's a useful guide to using Twitter's search function at https://support.twitter.com/articles/71577-using-advanced-search
67
  * **Twitter options**
68
  * `include_rts` = `'0'` or `'1'` - include retweets - default is `'0'`
 
69
  * `exclude_replies` = `'0'` or `'1'` - exclude replies - default is `'0'`
70
  * `tweet_count` = number of tweets to show - default is `5`
71
  * `get_favorites` = `'0'` or `'1'` - show someone's favorites rather than their timeline - default is `'0'`
@@ -185,10 +186,14 @@ into your CSS - changing `123px;` to the width you're aiming at - either via put
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`
1
  === Rotating Tweets (Twitter 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,multilingual,responsive,page builder
5
  Requires at least: 3.2
6
  Tested up to: 4.1.1
7
+ Stable tag: 1.7.14
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
66
  * `search` = a term to search for. There's a useful guide to using Twitter's search function at https://support.twitter.com/articles/71577-using-advanced-search
67
  * **Twitter options**
68
  * `include_rts` = `'0'` or `'1'` - include retweets - default is `'0'`
69
+ * `only_rts` = `'0'` or `'1'` - only include retweets - default is `'0'`
70
  * `exclude_replies` = `'0'` or `'1'` - exclude replies - default is `'0'`
71
  * `tweet_count` = number of tweets to show - default is `5`
72
  * `get_favorites` = `'0'` or `'1'` - show someone's favorites rather than their timeline - default is `'0'`
186
  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.
187
 
188
  == Upgrade notice ==
189
+ = 1.7.14 =
190
+ * Works with [Page Builder by SiteOrigin](https://wordpress.org/plugins/siteorigin-panels/). Adds new shortcode variable.
191
 
192
  == Changelog ==
193
+ = 1.7.14 =
194
+ * Works with [Page Builder by SiteOrigin](https://wordpress.org/plugins/siteorigin-panels/).
195
+ * Adds new shortcode variable `only_rts`
196
+
197
  = 1.7.13 =
198
  * Adds `profile_image_size`, `shuffle` and `merge_cache` shortcode variables
199
  * Lowers chance of clashes with other installations of cycle2 - by defaulting `autoSelector` to `.rotatingtweets` instead of `.cycle-slideshow`
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.13
6
  Text Domain: rotatingtweets
7
  Author: Martin Tod
8
  Author URI: http://www.martintod.org.uk
@@ -62,7 +62,9 @@ class rotatingtweets_Widget extends WP_Widget {
62
  }
63
  $negative_variables = array('meta_timestamp','meta_screen_name','meta_via');
64
  foreach($negative_variables as $var) {
65
- $newargs['show_'.$var] = !$instance['tw_hide_'.$var];
 
 
66
  }
67
  switch($newargs['show_follow']) {
68
  case 2:
@@ -91,22 +93,39 @@ class rotatingtweets_Widget extends WP_Widget {
91
  endif;
92
  if(empty($rt_tweet_string)):
93
  switch($newargs['show_type']) {
 
94
  case 1:
95
  $tweets = rotatingtweets_get_tweets($newargs['screen_name'],$newargs['include_rts'],$newargs['exclude_replies'],true);
96
  break;
97
- case 2:
 
98
  $tweets = rotatingtweets_get_tweets($newargs['screen_name'],$newargs['include_rts'],$newargs['exclude_replies'],false,$newargs['search']);
99
  // $newargs['screen_name'] = ''; // Originally put in to avoid confusion when people have a 'follow' button and a search tweet
100
  break;
101
- case 3:
 
102
  $tweets = rotatingtweets_get_tweets($newargs['screen_name'],$newargs['include_rts'],$newargs['exclude_replies'],false,false,$newargs['list_tag']);
103
- break;
104
- case 0:
 
 
 
 
 
 
 
 
 
 
 
 
105
  default:
106
  $tweets = rotatingtweets_get_tweets($newargs['screen_name'],$newargs['include_rts'],$newargs['exclude_replies']);
107
  break;
108
  }
109
- $rt_tweet_string = rotating_tweets_display($tweets,$newargs,false);
 
 
110
  elseif(WP_DEBUG):
111
  $rt_tweet_string .= "<!-- Transient ".$newargs['text_cache_id']." loaded -->";
112
  endif;
@@ -213,6 +232,11 @@ class rotatingtweets_Widget extends WP_Widget {
213
  "2" => __("Search",'rotatingtweets'),
214
  "3" => __("List",'rotatingtweets')
215
  );
 
 
 
 
 
216
  foreach ($typeoptions as $val => $html) {
217
  echo "<input type='radio' value='$val' id='".$this->get_field_id('tw_show_type_'.$val)."' name= '".$this->get_field_name('tw_show_type')."'";
218
  if($tw_show_type==$val): ?> checked="checked" <?php endif;
@@ -504,6 +528,7 @@ function rotatingtweets_display_shortcode( $atts, $content=null, $code="", $prin
504
  'screen_name' => '',
505
  'url' => 'http://twitter.com/twitter',
506
  'include_rts' => FALSE,
 
507
  'exclude_replies' => FALSE,
508
  'tweet_count' => 5,
509
  'show_follow' => FALSE,
@@ -558,6 +583,7 @@ function rotatingtweets_display_shortcode( $atts, $content=null, $code="", $prin
558
  echo "<!-- $url => $screen_name -->";
559
  }
560
  endif;
 
561
  $args['w3tc_render_to']=str_replace('widget','shortcode',$args['w3tc_render_to']);
562
  if(!$args['text_cache_id']) $args['text_cache_id'] = "rt-sc-".md5(serialize($args));
563
  $args['displaytype']='shortcode';
@@ -1096,10 +1122,10 @@ function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_r
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 -->";
@@ -1516,7 +1542,7 @@ function rotating_tweets_display($json,$args,$print=FALSE) {
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
1521
  // if (! (!$args['include_rts'] && isset($twitter_object['retweeted_status'])) ) : // This works to exclude retweets
1522
  $tweet_counter++;
@@ -2168,20 +2194,23 @@ function rotatingtweets_enqueue_style() {
2168
  endif;
2169
  endforeach;
2170
  }
2171
- function rotatingtweets_enqueue_admin_scripts($hook) {
2172
  if( 'widgets.php' != $hook ) return;
 
 
 
2173
  wp_enqueue_script( 'jquery' );
2174
  wp_enqueue_script( 'rotating_tweet_admin', plugins_url('js/rotating_tweet_admin.js', __FILE__),array('jquery'),FALSE,FALSE );
2175
  }
2176
- add_action( 'admin_enqueue_scripts', 'rotatingtweets_enqueue_admin_scripts' );
2177
-
2178
  /*
2179
  Forces the inclusion of Rotating Tweets CSS in the header - irrespective of whether the widget or shortcode is in use. I wouldn't normally do this, but CSS needs to be in the header for HTML5 compliance (at least if the intention is not to break other browsers) - and short-code only pages won't do that without some really time-consuming and complicated code up front to check for this
2180
  */
2181
  add_action('wp_enqueue_scripts','rotatingtweets_enqueue_style');
2182
  // add_action('wp_enqueue_scripts','rotatingtweets_enqueue_scripts'); // Use this if you are loading the tweet page via ajax
2183
  $style = strtolower(get_stylesheet());
2184
- if($style == 'gleam'):
2185
  add_action('wp_enqueue_scripts','rotatingtweets_enqueue_scripts');
2186
  endif;
2187
 
@@ -2213,13 +2242,13 @@ function rotatingtweets_block_transport() { return false; }
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
  }
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.14
6
  Text Domain: rotatingtweets
7
  Author: Martin Tod
8
  Author URI: http://www.martintod.org.uk
62
  }
63
  $negative_variables = array('meta_timestamp','meta_screen_name','meta_via');
64
  foreach($negative_variables as $var) {
65
+ if(isset($instance['tw_'.$var])):
66
+ $newargs['show_'.$var] = !$instance['tw_hide_'.$var];
67
+ endif;
68
  }
69
  switch($newargs['show_follow']) {
70
  case 2:
93
  endif;
94
  if(empty($rt_tweet_string)):
95
  switch($newargs['show_type']) {
96
+ // Favourites
97
  case 1:
98
  $tweets = rotatingtweets_get_tweets($newargs['screen_name'],$newargs['include_rts'],$newargs['exclude_replies'],true);
99
  break;
100
+ // Search
101
+ case 2:
102
  $tweets = rotatingtweets_get_tweets($newargs['screen_name'],$newargs['include_rts'],$newargs['exclude_replies'],false,$newargs['search']);
103
  // $newargs['screen_name'] = ''; // Originally put in to avoid confusion when people have a 'follow' button and a search tweet
104
  break;
105
+ // List
106
+ case 3:
107
  $tweets = rotatingtweets_get_tweets($newargs['screen_name'],$newargs['include_rts'],$newargs['exclude_replies'],false,false,$newargs['list_tag']);
108
+ break;
109
+ // Buddypress
110
+ case 4:
111
+ if( function_exists('bp_displayed_user_id')):
112
+ global $bp;
113
+ $rt_buddyid = bp_displayed_user_id();
114
+ $rt_buddyargs = array ('field' => 'Twitter', 'user_id'=> $rt_buddyid );
115
+ print_r($rt_buddyargs);
116
+ $rt_buddytwitter = bp_get_profile_field_data( $rt_buddyargs );
117
+ $tweets = rotatingtweets_get_tweets($rt_buddytwitter,$newargs['include_rts'],$newargs['exclude_replies']);
118
+ break;
119
+ endif;
120
+ // User name
121
+ case 0:
122
  default:
123
  $tweets = rotatingtweets_get_tweets($newargs['screen_name'],$newargs['include_rts'],$newargs['exclude_replies']);
124
  break;
125
  }
126
+ if($tweets):
127
+ $rt_tweet_string = rotating_tweets_display($tweets,$newargs,false);
128
+ endif;
129
  elseif(WP_DEBUG):
130
  $rt_tweet_string .= "<!-- Transient ".$newargs['text_cache_id']." loaded -->";
131
  endif;
232
  "2" => __("Search",'rotatingtweets'),
233
  "3" => __("List",'rotatingtweets')
234
  );
235
+ if (is_plugin_active('buddypress/bp-loader.php')):
236
+ // $typeoptions["4"] = __("User timeline (BuddyPress)",'rotatingtweets');
237
+ elseif($tw_show_type==4):
238
+ $tw_show_type = 0;
239
+ endif;
240
  foreach ($typeoptions as $val => $html) {
241
  echo "<input type='radio' value='$val' id='".$this->get_field_id('tw_show_type_'.$val)."' name= '".$this->get_field_name('tw_show_type')."'";
242
  if($tw_show_type==$val): ?> checked="checked" <?php endif;
528
  'screen_name' => '',
529
  'url' => 'http://twitter.com/twitter',
530
  'include_rts' => FALSE,
531
+ 'only_rts' => FALSE,
532
  'exclude_replies' => FALSE,
533
  'tweet_count' => 5,
534
  'show_follow' => FALSE,
583
  echo "<!-- $url => $screen_name -->";
584
  }
585
  endif;
586
+ if($only_rts) $include_rts=true;
587
  $args['w3tc_render_to']=str_replace('widget','shortcode',$args['w3tc_render_to']);
588
  if(!$args['text_cache_id']) $args['text_cache_id'] = "rt-sc-".md5(serialize($args));
589
  $args['displaytype']='shortcode';
1122
  $twitterjson = $twitterjson['results'];
1123
  endif;
1124
  if(isset($twitterjson) && is_array($twitterjson) && isset($twitterjson[0] )) $firstentry = $twitterjson[0];
1125
+ if(!empty($firstentry['text']) ):
1126
  $number_returned_tweets = count($twitterjson);
1127
  if(WP_DEBUG) echo "<!-- ".$number_returned_tweets." tweets returned -->";
1128
+ if( $tw_search && $tw_merge && $number_returned_tweets < 40 && isset($latest_json) && is_array($latest_json) && count($latest_json)>0 ):
1129
  if(WP_DEBUG) echo "<!-- ".count($latest_json)." tweets in cache -->";
1130
  $twitterjson = rotatingtweet_combine_jsons($twitterjson,$latest_json);
1131
  if(WP_DEBUG) echo "<!-- ".count($twitterjson)." tweets in merged json -->";
1542
  shuffle($json);
1543
  endif;
1544
  foreach($json as $twitter_object):
1545
+ if ((isset($args['only_rts']) && $args['only_rts'] && isset($twitter_object['retweeted_status'] )) || ((!isset($args['only_rts']) || !$args['only_rts']) && ( ! ( ($args['exclude_replies'] && isset($twitter_object['text']) && substr($twitter_object['text'],0,1)=='@') || (!$args['include_rts'] && isset($twitter_object['retweeted_status'])) ) ))):
1546
  // if (! ($args['exclude_replies'] && isset($twitter_object['text']) && substr($twitter_object['text'],0,1)=='@')): // This works to exlude replies
1547
  // if (! (!$args['include_rts'] && isset($twitter_object['retweeted_status'])) ) : // This works to exclude retweets
1548
  $tweet_counter++;
2194
  endif;
2195
  endforeach;
2196
  }
2197
+ function rotatingtweets_enqueue_admin_scripts_widget_page($hook) {
2198
  if( 'widgets.php' != $hook ) return;
2199
+ rotatingtweets_enqueue_admin_scripts($hook);
2200
+ }
2201
+ function rotatingtweets_enqueue_admin_scripts($hook) {
2202
  wp_enqueue_script( 'jquery' );
2203
  wp_enqueue_script( 'rotating_tweet_admin', plugins_url('js/rotating_tweet_admin.js', __FILE__),array('jquery'),FALSE,FALSE );
2204
  }
2205
+ add_action( 'admin_enqueue_scripts', 'rotatingtweets_enqueue_admin_scripts_widget_page' );
2206
+ add_action( 'siteorigin_panel_enqueue_admin_scripts', 'rotatingtweets_enqueue_admin_scripts' );
2207
  /*
2208
  Forces the inclusion of Rotating Tweets CSS in the header - irrespective of whether the widget or shortcode is in use. I wouldn't normally do this, but CSS needs to be in the header for HTML5 compliance (at least if the intention is not to break other browsers) - and short-code only pages won't do that without some really time-consuming and complicated code up front to check for this
2209
  */
2210
  add_action('wp_enqueue_scripts','rotatingtweets_enqueue_style');
2211
  // add_action('wp_enqueue_scripts','rotatingtweets_enqueue_scripts'); // Use this if you are loading the tweet page via ajax
2212
  $style = strtolower(get_stylesheet());
2213
+ if($style == 'gleam' || function_exists('siteorigin_panels_render') ):
2214
  add_action('wp_enqueue_scripts','rotatingtweets_enqueue_scripts');
2215
  endif;
2216
 
2242
 
2243
  /** Support for Buddy Press */
2244
  /*
2245
+ if ( function_exists('bp_is_user_profile') && bp_is_user_profile() ):
2246
  add_action( 'bp_profile_header_meta', 'rotatingtweets_bpdisplay' );
2247
  endif;
2248
 
2249
  function rotatingtweets_bpdisplay() {
2250
  $bbpressTwittername = bp_get_profile_field_data( array('field'=>'Twitter') );
2251
+ if(!empty($bbpressTwittername)) {
2252
  echo do_shortcode("[rotatingtweets screen_name='".$bbpressTwitterName."']");
2253
  }
2254
  }