Rotating Tweets (Twitter widget and shortcode) - Version 1.8.5

Version Description

  • Add shortcode for a large Twitter 'follow' button. Support for PHP7. Support for 'Selective Refresh'.

=

Download this release

Release Info

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

Code changes from version 1.8.4 to 1.8.5

js/jquery.cycle2.renamed.js CHANGED
@@ -308,7 +308,13 @@ $.fn.cycle2.API = {
308
  var opts = this.opts();
309
  var after, curr, next, slideOpts, tx;
310
 
311
- if ( opts.slideCount < 2 ) {
 
 
 
 
 
 
312
  opts.timeoutId = 0;
313
  return;
314
  }
308
  var opts = this.opts();
309
  var after, curr, next, slideOpts, tx;
310
 
311
+ // Addition of check for undefined to cope with widget updating
312
+ if( !opts || !("slideCount" in opts) ) {
313
+ return; // borrowed from https://github.com/malsup/cycle2/issues/240
314
+ }
315
+ // End of addition
316
+
317
+ if ( opts.slideCount < 2 ) {
318
  opts.timeoutId = 0;
319
  return;
320
  }
js/rotatingtweets_v2.js CHANGED
@@ -67,15 +67,15 @@ $.fn.cycle2.transitions.scrollLeftGap = {
67
  };
68
 
69
  })(jQuery);
70
- /*
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$/,
77
  srcReplacePattern = /.png$/;
78
- jQuery('.rtw_intents a').hover(function() {
79
  rtw_src = jQuery(this).find('img').attr('src');
80
  jQuery(this).find('img').attr('src',rtw_src.replace(clearOutHovers,".png"));
81
  rtw_src = jQuery(this).find('img').attr('src');
@@ -84,13 +84,34 @@ jQuery(document).ready(function() {
84
  rtw_src = jQuery(this).find('img').attr('src');
85
  jQuery(this).find('img').attr('src',rtw_src.replace(clearOutHovers,".png"));
86
  });
87
- jQuery('.rotatingtweets').children().not('.cycle-carousel-wrap').has('.rtw_wide').find('.rtw_wide .rtw_intents').hide();
88
- jQuery('.rotatingtweets').children().not('.cycle-carousel-wrap').has('.rtw_wide').find('.rtw_expand').show();
89
- jQuery('.rotatingtweets').children().not('.cycle-carousel-wrap').has('.rtw_wide').hover(function() {
90
  jQuery(this).find('.rtw_intents').show();
91
  },function() {
92
  jQuery(this).find('.rtw_intents').hide();
93
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  });
95
  /* And call the Twitter script while we're at it! */
96
  /* Standard script to call Twitter */
67
  };
68
 
69
  })(jQuery);
70
+ /*
71
+ Function for basic functionality
72
  */
73
+ function rotatingtweetsInteraction( targetid ) {
74
  // Script to show mouseover effects when going over the Twitter intents
75
  var rtw_src,
76
  clearOutHovers = /_hover.png$/,
77
  srcReplacePattern = /.png$/;
78
+ jQuery( targetid ).find('.rtw_intents a').hover(function() {
79
  rtw_src = jQuery(this).find('img').attr('src');
80
  jQuery(this).find('img').attr('src',rtw_src.replace(clearOutHovers,".png"));
81
  rtw_src = jQuery(this).find('img').attr('src');
84
  rtw_src = jQuery(this).find('img').attr('src');
85
  jQuery(this).find('img').attr('src',rtw_src.replace(clearOutHovers,".png"));
86
  });
87
+ jQuery( targetid ).children().not('.cycle-carousel-wrap').has('.rtw_wide').find('.rtw_wide .rtw_intents').hide();
88
+ jQuery( targetid ).children().not('.cycle-carousel-wrap').has('.rtw_wide').find('.rtw_expand').show();
89
+ jQuery( targetid ).children().not('.cycle-carousel-wrap').has('.rtw_wide').hover(function() {
90
  jQuery(this).find('.rtw_intents').show();
91
  },function() {
92
  jQuery(this).find('.rtw_intents').hide();
93
  });
94
+ }
95
+
96
+ /*
97
+ Script to cycle the rotating tweets
98
+ */
99
+ jQuery(document).ready(function() {
100
+ rotatingtweetsInteraction('.rotatingtweets');
101
+
102
+ if ( 'undefined' === typeof wp || ! wp.customize || ! wp.customize.selectiveRefresh ) {
103
+ return;
104
+ };
105
+ // Re-load Twitter widgets when a partial is rendered.
106
+ wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function( placement ) {
107
+ console.log(placement);
108
+ var newid = '#' + placement.container[0].id;
109
+ rotatingtweetsInteraction(newid + " > .rotatingtweets" );
110
+ jQuery( newid + " > .rotatingtweets" ).cycle2();
111
+ twttr.widgets.load(
112
+ document.getElementById(newid)
113
+ );
114
+ } );
115
  });
116
  /* And call the Twitter script while we're at it! */
117
  /* Standard script to call Twitter */
js/rotatingtweets_v2_cyclone.js CHANGED
@@ -66,17 +66,15 @@ $.fn.cycle.transitions.scrollLeftGap = {
66
  };
67
 
68
  })(jQuery);
69
- /*
70
- Script to cycle the rotating tweets
71
  */
72
- jQuery(document).ready(function() {
73
- // Needed because - unlike the RT version of jQuery Cycle2 - the auto-selector hasn't been renamed
74
- jQuery('.rotatingtweets').cycle();
75
  // Script to show mouseover effects when going over the Twitter intents
76
  var rtw_src,
77
  clearOutHovers = /_hover.png$/,
78
  srcReplacePattern = /.png$/;
79
- jQuery('.rtw_intents a').hover(function() {
80
  rtw_src = jQuery(this).find('img').attr('src');
81
  jQuery(this).find('img').attr('src',rtw_src.replace(clearOutHovers,".png"));
82
  rtw_src = jQuery(this).find('img').attr('src');
@@ -85,13 +83,36 @@ jQuery(document).ready(function() {
85
  rtw_src = jQuery(this).find('img').attr('src');
86
  jQuery(this).find('img').attr('src',rtw_src.replace(clearOutHovers,".png"));
87
  });
88
- jQuery('.rotatingtweets').children().not('.cycle-carousel-wrap').has('.rtw_wide').find('.rtw_wide .rtw_intents').hide();
89
- jQuery('.rotatingtweets').children().not('.cycle-carousel-wrap').has('.rtw_wide').find('.rtw_expand').show();
90
- jQuery('.rotatingtweets').children().not('.cycle-carousel-wrap').has('.rtw_wide').hover(function() {
91
  jQuery(this).find('.rtw_intents').show();
92
  },function() {
93
  jQuery(this).find('.rtw_intents').hide();
94
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  });
96
  /* And call the Twitter script while we're at it! */
97
  /* Standard script to call Twitter */
66
  };
67
 
68
  })(jQuery);
69
+ /*
70
+ Function for basic functionality
71
  */
72
+ function rotatingtweetsInteraction( targetid ) {
 
 
73
  // Script to show mouseover effects when going over the Twitter intents
74
  var rtw_src,
75
  clearOutHovers = /_hover.png$/,
76
  srcReplacePattern = /.png$/;
77
+ jQuery( targetid ).find('.rtw_intents a').hover(function() {
78
  rtw_src = jQuery(this).find('img').attr('src');
79
  jQuery(this).find('img').attr('src',rtw_src.replace(clearOutHovers,".png"));
80
  rtw_src = jQuery(this).find('img').attr('src');
83
  rtw_src = jQuery(this).find('img').attr('src');
84
  jQuery(this).find('img').attr('src',rtw_src.replace(clearOutHovers,".png"));
85
  });
86
+ jQuery( targetid ).children().not('.cycle-carousel-wrap').has('.rtw_wide').find('.rtw_wide .rtw_intents').hide();
87
+ jQuery( targetid ).children().not('.cycle-carousel-wrap').has('.rtw_wide').find('.rtw_expand').show();
88
+ jQuery( targetid ).children().not('.cycle-carousel-wrap').has('.rtw_wide').hover(function() {
89
  jQuery(this).find('.rtw_intents').show();
90
  },function() {
91
  jQuery(this).find('.rtw_intents').hide();
92
  });
93
+ }
94
+
95
+
96
+ /*
97
+ Script to cycle the rotating tweets
98
+ */
99
+ jQuery(document).ready(function() {
100
+ jQuery('.rotatingtweets').cycle();
101
+ rotatingtweetsInteraction('.rotatingtweets');
102
+
103
+ if ( 'undefined' === typeof wp || ! wp.customize || ! wp.customize.selectiveRefresh ) {
104
+ return;
105
+ };
106
+ // Re-load Twitter widgets when a partial is rendered.
107
+ wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function( placement ) {
108
+ console.log( placement );
109
+ var newid = '#' + placement.container[0].id;
110
+ rotatingtweetsInteraction(newid + " > .rotatingtweets" );
111
+ jQuery( newid + " > .rotatingtweets" ).cycle();
112
+ twttr.widgets.load(
113
+ document.getElementById(newid)
114
+ );
115
+ } );
116
  });
117
  /* And call the Twitter script while we're at it! */
118
  /* Standard script to call Twitter */
languages/rotatingtweets-de_DE.mo CHANGED
Binary file
readme.txt CHANGED
@@ -3,8 +3,8 @@ 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.5
7
- Stable tag: 1.8.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -98,6 +98,7 @@ Possible variables for the shortcode include:
98
  * `show_follow` = `'0'` or `'1'` - show follow button - default is `'0'`
99
  * `no_show_count` = `'0'` or `'1'` - remove the follower count from the Twitter follow button - default is `'0'`
100
  * `no_show_screen_name` = `'0'` or `'1'` - remove the screen name from the Twitter follow button - default is `'0'`
 
101
 
102
  == Credits ==
103
  Most of this is my own work, but special thanks are owed to:
@@ -183,10 +184,16 @@ into your CSS - changing `123px;` to the width you're aiming at - either via put
183
  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.
184
 
185
  == Upgrade notice ==
186
- = 1.8.4 =
187
- * Updated JavaScript for plug-ins and themes with their own JQuery Cycle2 installations
188
 
189
  == Changelog ==
 
 
 
 
 
 
190
  = 1.8.4 =
191
  * Updated JavaScript for plug-ins and themes with their own [JQuery Cycle2](http://jquery.malsup.com/cycle2/) installations
192
 
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.6.1
7
+ Stable tag: 1.8.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
98
  * `show_follow` = `'0'` or `'1'` - show follow button - default is `'0'`
99
  * `no_show_count` = `'0'` or `'1'` - remove the follower count from the Twitter follow button - default is `'0'`
100
  * `no_show_screen_name` = `'0'` or `'1'` - remove the screen name from the Twitter follow button - default is `'0'`
101
+ * `large_follow_button` = `'0'` or `'1'` - show a large Twitter follow button - default is `'0'`
102
 
103
  == Credits ==
104
  Most of this is my own work, but special thanks are owed to:
184
  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.
185
 
186
  == Upgrade notice ==
187
+ = 1.8.5 =
188
+ * Add shortcode for a large Twitter 'follow' button. Support for PHP7. Support for 'Selective Refresh'.
189
 
190
  == Changelog ==
191
+ = 1.8.5 =
192
+ * Add shortcode for a large Twitter 'follow' button
193
+ * Support for PHP7
194
+ * Support for 'Selective Refresh'
195
+ * Ensuring `show_media` display links respects `links_in_new_window` variable.
196
+
197
  = 1.8.4 =
198
  * Updated JavaScript for plug-ins and themes with their own [JQuery Cycle2](http://jquery.malsup.com/cycle2/) installations
199
 
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.8.4
6
  Text Domain: rotatingtweets
7
  Domain Path: /languages
8
  Author: Martin Tod
@@ -39,12 +39,18 @@ require_once('lib/wp_twitteroauth.php');
39
  class rotatingtweets_Widget extends WP_Widget {
40
  /** constructor */
41
  public function __construct() {
 
 
 
42
  parent::__construct(
43
  'rotatingtweets_widget', // Base ID
44
  __( 'Rotating Tweets', 'rotatingtweets' ), // Name
45
- array( 'description' => __('A widget to show tweets for a particular user in rotation.', 'rotatingtweets'), ) // Args
 
 
 
46
  );
47
- if ( is_active_widget( false, false, $this->id_base, true ) ) {
48
  rotatingtweets_enqueue_scripts();
49
  }
50
  }
@@ -210,29 +216,29 @@ class rotatingtweets_Widget extends WP_Widget {
210
  if(isset($instance[$var])):
211
  switch($val[2]):
212
  case "string":
213
- $$val[0] = esc_attr(trim($instance[$var]));
214
  break;
215
  case "format":
216
  if($instance[$var]==='custom'):
217
- $$val[0] = 'custom';
218
  else:
219
- $$val[0] = absint($instance[$var]);
220
  endif;
221
  break;
222
  case "number":
223
  case "boolean":
224
- $$val[0] = absint($instance[$var]);
225
  break;
226
  case "notboolean":
227
- $$val[0] = !$instance[$var];
228
  break;
229
  endswitch;
230
  else:
231
- $$val[0] = $val[1];
232
  endif;
233
  if(isset($val[3])):
234
- $metaoption[$val[0]]=$$val[0];
235
- unset($$val[0]);
236
  endif;
237
  }
238
  ?>
@@ -579,6 +585,7 @@ function rotatingtweets_display_shortcode( $atts, $content=null, $code="", $prin
579
  'timeout' => 4000,
580
  'no_show_count' => FALSE,
581
  'no_show_screen_name' => FALSE,
 
582
  'show_meta_timestamp' => TRUE,
583
  'show_meta_screen_name' => TRUE,
584
  'show_meta_via' => TRUE,
@@ -631,6 +638,19 @@ function rotatingtweets_display_shortcode( $atts, $content=null, $code="", $prin
631
  endif;
632
  if($only_rts) $include_rts=true;
633
  $args['w3tc_render_to']=str_replace('widget','shortcode',$args['w3tc_render_to']);
 
 
 
 
 
 
 
 
 
 
 
 
 
634
  if(!$args['text_cache_id']) $args['text_cache_id'] = "rt-sc-".md5(serialize($args));
635
  $args['displaytype']='shortcode';
636
  if(empty($screen_name)) $screen_name = 'twitter';
@@ -1799,7 +1819,7 @@ function rotating_tweets_display($json,$args,$print=FALSE) {
1799
  $alt = esc_html(trim(str_replace($media_data['url'],'',strip_tags($main_text))));
1800
  $before[] = "*".$media_data['url']."*";
1801
  $after[] = "";
1802
- $show_media = "<a href='{$media_data['url']}' title='{$alt}'><img src='{$media_data['media_url_https']}' alt='{$alt}' class='rtw_media_image' /></a>";
1803
  endif;
1804
  else:
1805
  unset($media);
@@ -2150,6 +2170,7 @@ function rotating_tweets_display($json,$args,$print=FALSE) {
2150
  $shortenvariables = '';
2151
  if($args['no_show_count']) $shortenvariables = ' data-show-count="false"';
2152
  if($args['no_show_screen_name']) $shortenvariables .= ' data-show-screen-name="false"';
 
2153
  $followUserText = sprintf(__('Follow @%s','rotatingtweets'),remove_accents(str_replace('@','',$args['screen_name'])));
2154
  $result .= "\n<div class='rtw_follow follow-button'><a href='http://twitter.com/".$args['screen_name']."' class='twitter-follow-button'{$shortenvariables} title='".$followUserText."' data-lang='{$twitterlocale}'>".$followUserText."</a></div>";
2155
  endif;
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.8.5
6
  Text Domain: rotatingtweets
7
  Domain Path: /languages
8
  Author: Martin Tod
39
  class rotatingtweets_Widget extends WP_Widget {
40
  /** constructor */
41
  public function __construct() {
42
+ // Does the JavaScript support selective refresh?
43
+
44
+
45
  parent::__construct(
46
  'rotatingtweets_widget', // Base ID
47
  __( 'Rotating Tweets', 'rotatingtweets' ), // Name
48
+ array(
49
+ 'description' => __('A widget to show tweets for a particular user in rotation.', 'rotatingtweets'),
50
+ 'customize_selective_refresh' => true,
51
+ ) // Args
52
  );
53
+ if ( is_active_widget( false, false, $this->id_base, true ) || is_customize_preview() ) {
54
  rotatingtweets_enqueue_scripts();
55
  }
56
  }
216
  if(isset($instance[$var])):
217
  switch($val[2]):
218
  case "string":
219
+ ${$val[0]} = esc_attr(trim($instance[$var]));
220
  break;
221
  case "format":
222
  if($instance[$var]==='custom'):
223
+ ${$val[0]} = 'custom';
224
  else:
225
+ ${$val[0]} = absint($instance[$var]);
226
  endif;
227
  break;
228
  case "number":
229
  case "boolean":
230
+ ${$val[0]} = absint($instance[$var]);
231
  break;
232
  case "notboolean":
233
+ ${$val[0]} = !$instance[$var];
234
  break;
235
  endswitch;
236
  else:
237
+ ${$val[0]} = $val[1];
238
  endif;
239
  if(isset($val[3])):
240
+ $metaoption[$val[0]]=${$val[0]};
241
+ unset(${$val[0]});
242
  endif;
243
  }
244
  ?>
585
  'timeout' => 4000,
586
  'no_show_count' => FALSE,
587
  'no_show_screen_name' => FALSE,
588
+ 'large_follow_button' => FALSE,
589
  'show_meta_timestamp' => TRUE,
590
  'show_meta_screen_name' => TRUE,
591
  'show_meta_via' => TRUE,
638
  endif;
639
  if($only_rts) $include_rts=true;
640
  $args['w3tc_render_to']=str_replace('widget','shortcode',$args['w3tc_render_to']);
641
+ /* Test to clear broken transients */
642
+ if($args['no_cache']) {
643
+ $clearargs = $args;
644
+ $clearargs['no_cache'] = FALSE;
645
+ if(WP_DEBUG) echo "<!-- Clearing cache: stored cache = ".$args['text_cache_id']." ; calculcated cache = rt-sc-".md5(serialize($clearargs))." -->";
646
+ if($args['text_cache_id']):
647
+ $clear_cache_id = $args['text_cache_id'];
648
+ else:
649
+ $clear_cache_id = "rt-sc-".md5(serialize($clearargs));
650
+ endif;
651
+ if(WP_DEBUG) echo "<!-- Clearing cache {$clear_cache_id} -->";
652
+ delete_transient($clear_cache_id);
653
+ }
654
  if(!$args['text_cache_id']) $args['text_cache_id'] = "rt-sc-".md5(serialize($args));
655
  $args['displaytype']='shortcode';
656
  if(empty($screen_name)) $screen_name = 'twitter';
1819
  $alt = esc_html(trim(str_replace($media_data['url'],'',strip_tags($main_text))));
1820
  $before[] = "*".$media_data['url']."*";
1821
  $after[] = "";
1822
+ $show_media = "<a href='{$media_data['url']}' title='{$alt}'{$targetvalue}><img src='{$media_data['media_url_https']}' alt='{$alt}' class='rtw_media_image' /></a>";
1823
  endif;
1824
  else:
1825
  unset($media);
2170
  $shortenvariables = '';
2171
  if($args['no_show_count']) $shortenvariables = ' data-show-count="false"';
2172
  if($args['no_show_screen_name']) $shortenvariables .= ' data-show-screen-name="false"';
2173
+ if(isset($args['large_follow_button']) && $args['large_follow_button']) $shortenvariables .= ' data-size="large"';
2174
  $followUserText = sprintf(__('Follow @%s','rotatingtweets'),remove_accents(str_replace('@','',$args['screen_name'])));
2175
  $result .= "\n<div class='rtw_follow follow-button'><a href='http://twitter.com/".$args['screen_name']."' class='twitter-follow-button'{$shortenvariables} title='".$followUserText."' data-lang='{$twitterlocale}'>".$followUserText."</a></div>";
2176
  endif;