Rotating Tweets (Twitter widget and shortcode) - Version 0.623

Version Description

Option to show links in a new window. Fixed timezone problem. Escaped title tags.

=

Download this release

Release Info

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

Code changes from version 0.611 to 0.623

Files changed (2) hide show
  1. readme.txt +27 -5
  2. rotatingtweets.php +53 -37
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
5
  Requires at least: 2.6
6
- Tested up to: 3.4.1
7
- Stable tag: 0.611
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -19,7 +19,9 @@ Twitter widget and shortcode to show your latest tweets one at a time an animate
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.
22
- * **Multi-lingual** - now set up to be multi-lingual. The Twitter 'follow' button is automatically translated to match your site's language setting [if Twitter has made the appropriate language available](https://dev.twitter.com/docs/api/1/get/help/languages). Also uses [Wordpress's multi-lingual capability](http://codex.wordpress.org/I18n_for_WordPress_Developers) to enable translation of all the other text used by the plug-in via language packs. If you have made the plug-in work in your language, please send the [gettext PO and MO files](http://codex.wordpress.org/I18n_for_WordPress_Developers) to [me](http://www.martintod.org.uk/contact-martin/) and I will then share them with everyone else. You can download [the latest POT file](http://plugins.svn.wordpress.org/rotatingtweets/trunk/languages/rotatingtweets.pot), and [PO files in each language](http://plugins.svn.wordpress.org/rotatingtweets/trunk/languages/) from this site. You may find [Poedit](http://www.poedit.net/) rather useful for translation and creation of PO and MO files.
 
 
23
 
24
  If you'd like to see what the plug-in looks like in action, you can [see the plug-in working here](http://www.martintod.org.uk/2012/05/29/new-twitter-plugin-to-show-tweets-in-rotation/).
25
 
@@ -51,6 +53,7 @@ Possible variables for the shortcode include:
51
  * `show_meta_screen_name` = `'0'` or `'1'` - show who posted each tweet - optional - default is `'1'`
52
  * `show_meta_via` = `'0'` or `'1'` - show how each tweet was posted - optional - default is `'1'`
53
  * `show_meta_reply_retweet_favorite` = `'0'` or `'1'` - show 'reply', 'retweet' and 'favorite' buttons - optional - default is `'0'`
 
54
  * `rotation_type` = any of the options listed on the [jQuery.cycle website](http://jquery.malsup.com/cycle/browser.html) - default is `'scrollUp'`
55
  * `url_length` = sets the length that the URL should be trimmed to...
56
 
@@ -64,10 +67,29 @@ In most cases, each use (or "instance") of this plug-in gets data from Twitter e
64
  You can do this by going to the `rotatingtweets/css` directory and renaming `yourstyle-sample.css` to `yourstyle.css`. This displays a Twitter bird to the left of your tweets. Any CSS you put into `yourstyle.css` won't be overwritten when the plug-in is upgraded to the latest version.
65
 
66
  == Upgrade notice ==
67
- = 0.611 =
68
- Now includes options consistent with Twitter display options and options to allow for different length URLs
69
 
70
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  = 0.611 =
72
  Finally ran with debug and removed all the error messages.
73
 
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
5
  Requires at least: 2.6
6
+ Tested up to: 3.5
7
+ Stable tag: 0.623
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
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.
22
+ * **Multi-lingual** - now set up to be multi-lingual. The Twitter 'follow' button is automatically translated to match your site's language setting [if Twitter has made the appropriate language available](https://dev.twitter.com/docs/api/1/get/help/languages). Also uses [Wordpress's multi-lingual capability](http://codex.wordpress.org/I18n_for_WordPress_Developers) to enable translation of all the other text used by the plug-in via language packs.
23
+
24
+ If you have made the plug-in work in your language, please send the [gettext PO and MO files](http://codex.wordpress.org/I18n_for_WordPress_Developers) to [me](http://www.martintod.org.uk/contact-martin/) and I will then share them with everyone else. You can download [the latest POT file](http://plugins.svn.wordpress.org/rotatingtweets/trunk/languages/rotatingtweets.pot), and [PO files in each language](http://plugins.svn.wordpress.org/rotatingtweets/trunk/languages/) from this site. You may find [Poedit](http://www.poedit.net/) rather useful for translation and creation of PO and MO files.
25
 
26
  If you'd like to see what the plug-in looks like in action, you can [see the plug-in working here](http://www.martintod.org.uk/2012/05/29/new-twitter-plugin-to-show-tweets-in-rotation/).
27
 
53
  * `show_meta_screen_name` = `'0'` or `'1'` - show who posted each tweet - optional - default is `'1'`
54
  * `show_meta_via` = `'0'` or `'1'` - show how each tweet was posted - optional - default is `'1'`
55
  * `show_meta_reply_retweet_favorite` = `'0'` or `'1'` - show 'reply', 'retweet' and 'favorite' buttons - optional - default is `'0'`
56
+ * `links_in_new_window` = `'0'` or `'1'` - show links in a new tab or window - default is `'0'`
57
  * `rotation_type` = any of the options listed on the [jQuery.cycle website](http://jquery.malsup.com/cycle/browser.html) - default is `'scrollUp'`
58
  * `url_length` = sets the length that the URL should be trimmed to...
59
 
67
  You can do this by going to the `rotatingtweets/css` directory and renaming `yourstyle-sample.css` to `yourstyle.css`. This displays a Twitter bird to the left of your tweets. Any CSS you put into `yourstyle.css` won't be overwritten when the plug-in is upgraded to the latest version.
68
 
69
  == Upgrade notice ==
70
+ = 0.623 =
71
+ Option to show links in a new window. Fixed timezone problem. Escaped title tags.
72
 
73
  == Changelog ==
74
+ = 0.623 =
75
+ Fixed a problem where a short name fitted inside a long one - e.g. @rotary and @rotarycrocus
76
+
77
+ = 0.622 =
78
+ Escaped title tags
79
+
80
+ = 0.621 =
81
+ Fixed timezone problem.
82
+
83
+ = 0.620 =
84
+ Added option to show links in a new window
85
+ Fix problem with selection of 20 second rotating speed.
86
+
87
+ = 0.613 =
88
+ Fixed instructions in plug-ins list.
89
+
90
+ = 0.612 =
91
+ Fixed error message caused by last fix causing tweets to repeat.
92
+
93
  = 0.611 =
94
  Finally ran with debug and removed all the error messages.
95
 
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: 0.611
6
  Text Domain: rotatingtweets
7
  Author: Martin Tod
8
  Author URI: http://www.martintod.org.uk
@@ -105,7 +105,7 @@ class rotatingtweets_Widget extends WP_Widget {
105
  $instance['tw_hide_meta_via'] = !$new_instance['tw_show_meta_via'];
106
  $instance['tw_official_format'] = absint($new_instance['tw_official_format']);
107
  $instance['tw_show_meta_reply_retweet_favorite'] = absint($new_instance['tw_show_meta_reply_retweet_favorite']);
108
- $instance['tw_timeout'] = max(min(intval($new_instance['tw_timeout']/1000)*1000,6000),3000);
109
  return $instance;
110
  }
111
 
@@ -266,7 +266,7 @@ function rotatingtweets_contextualtime_short($small_ts, $large_ts=false) {
266
  return date(_x('j M Y','slightly longer date format as per http://uk.php.net/manual/en/function.date.php','rotatingtweets'),$small_ts);
267
  }
268
  # Get reply,retweet,favorite intents - either words-only (option 0) or icons only (option 1) or both (option 2)
269
- function rotatingtweets_intents($twitter_object,$lang, $icons = 1) {
270
  $addstring = array();
271
  $types = array (
272
  array ( 'link'=>'https://twitter.com/intent/tweet?in_reply_to=', 'icon'=>'images/reply.png', 'text' => __('reply', 'rotatingtweets')),
@@ -274,14 +274,14 @@ function rotatingtweets_intents($twitter_object,$lang, $icons = 1) {
274
  array ( 'link'=>'https://twitter.com/intent/favorite?tweet_id=', 'icon'=>'images/favorite.png', 'text' => __('favorite', 'rotatingtweets'))
275
  );
276
  foreach($types as $type) {
277
- $string = "\n\t\t\t<a href='".$type['link'].$twitter_object->id_str."' title='{$type['text']}' lang='{$lang}'>";
278
  switch($icons) {
279
  case 2:
280
- $addstring[] = $string."<img src='".plugins_url($type['icon'],__FILE__)."' width='16' height='16' alt='{$type['text']}' /> {$type['text']}</a>";
281
  $glue = ' ';
282
  break;
283
  case 1:
284
- $addstring[] = $string."<img src='".plugins_url($type['icon'],__FILE__)."' width='16' height='16' alt='{$type['text']}' /></a>";
285
  $glue = '';
286
  break;
287
  case 0:
@@ -295,11 +295,11 @@ function rotatingtweets_intents($twitter_object,$lang, $icons = 1) {
295
  return($string);
296
  }
297
  // Produces a link to someone's name, icon or screen name (or to the text of your choice) using the 'intent' format for linking
298
- function rotatingtweets_user_intent($person,$lang,$linkcontent) {
299
- $return = "<a href='https://twitter.com/intent/user?user_id={$person->id}' title='{$person->name}' lang='{$lang}'>";
300
  switch($linkcontent){
301
  case 'icon':
302
- $return .= "<img src='{$person->profile_image_url}' alt='{$person->name}' /></a>";
303
  break;
304
  case 'name':
305
  $return .= $person->name."</a>";
@@ -314,15 +314,16 @@ function rotatingtweets_user_intent($person,$lang,$linkcontent) {
314
  return ($return);
315
  }
316
  // Produces a linked timestamp for including in the tweet
317
- function rotatingtweets_timestamp_link($twitter_object,$timetype = 'default') {
318
- $string = '<a target="_blank" href="https://twitter.com/twitterapi/status/'.$twitter_object->id_str.'">';
319
- $tweettimestamp = strtotime($twitter_object->created_at);
 
320
  switch($timetype) {
321
  case 'short':
322
  $string .= rotatingtweets_contextualtime_short($tweettimestamp);
323
  break;
324
  case 'long':
325
- $string .= date_i18n(get_option('time_format'),$tweettimestamp)." &middot; ".date_i18n(get_option('date_format') ,$tweettimestamp);
326
  break;
327
  default:
328
  $string .= ucfirst(rotatingtweets_contextualtime($tweettimestamp));
@@ -363,6 +364,7 @@ function rotatingtweets_display_shortcode( $atts, $content=null, $code="", $prin
363
  'show_meta_reply_retweet_favorite' => FALSE,
364
  'rotation_type' => 'scrollUp',
365
  'official_format' => FALSE,
 
366
  'url_length' => 29,
367
  'ratelimit' => FALSE
368
  ), $atts ) ;
@@ -569,6 +571,12 @@ function rotating_tweets_display($json,$args,$print=TRUE) {
569
  $result .= "<!-- Rate limited -- ";
570
  $result .= sprintf(_n('Next attempt to get data will be in %d minute','Next attempt to get data will be in %d minutes',$waittimevalue,'rotatingtweets'),$waittimevalue)." -->";
571
  endif;
 
 
 
 
 
 
572
  foreach($json as $twitter_object):
573
  $tweet_counter++;
574
  if($tweet_counter <= $tweet_count):
@@ -591,6 +599,8 @@ function rotating_tweets_display($json,$args,$print=TRUE) {
591
  # First clean up the retweets
592
  if(isset($twitter_object->retweeted_status)):
593
  $rt_data = $twitter_object->retweeted_status;
 
 
594
  endif;
595
  if(!empty($rt_data)):
596
  $rt_user = $rt_data->user;
@@ -601,18 +611,20 @@ function rotating_tweets_display($json,$args,$print=TRUE) {
601
  else:
602
  $main_text = "RT @".$rt_user->screen_name . " " . $rt_data->text;
603
  endif;
604
- $before[] = "*@".$rt_user->screen_name."*i";
605
- $after[] = rotatingtweets_user_intent($rt_user,$twitterlocale,'screen_name');
606
  $entities = $rt_data->entities;
607
  endif;
608
  # First the user mentions
609
  if(isset($entities->user_mentions)):
610
  $user_mentions = $entities->user_mentions;
 
 
611
  endif;
612
  if(!empty($user_mentions)):
613
  foreach($user_mentions as $user_mention):
614
- $before[] = "*@".$user_mention->screen_name."*i";
615
- $after[] = rotatingtweets_user_intent($user_mention,$twitterlocale,'screen_name');
616
  endforeach;
617
  # Clearing up duplicates to avoid strange result (possibly risky?)
618
  $before = array_unique($before);
@@ -621,6 +633,8 @@ function rotating_tweets_display($json,$args,$print=TRUE) {
621
  # Now the URLs
622
  if(isset($entities->urls)):
623
  $urls = $entities->urls;
 
 
624
  endif;
625
  if(!empty($urls)):
626
  foreach($urls as $url):
@@ -631,22 +645,24 @@ function rotating_tweets_display($json,$args,$print=TRUE) {
631
  $displayurl = str_replace(json_decode('"\u2026"'),"",$displayurl);
632
  $displayurl = substr($displayurl,0,$urllength)."&hellip;";
633
  endif;
634
- $after[] = "<a href='".$url->url."' title='".$url->expanded_url."'>".esc_html($displayurl)."</a>";
635
  endforeach;
636
  endif;
637
  if(isset($entities->media)):
638
  $media = $entities->media;
 
 
639
  endif;
640
  if(!empty($media)):
641
  foreach($media as $medium):
642
  $before[] = "*".$medium->url."*";
643
  $displayurl = $medium->display_url;
644
  if(strlen($displayurl)>30) $displayurl = substr($displayurl,0,30)."&hellip;";
645
- $after[] = "<a href='".$medium->url."' title='".$medium->expanded_url."'>".esc_html($displayurl)."</a>";
646
  endforeach;
647
  endif;
648
- $before[]="%#(\w+)%";
649
- $after[]='<a href="http://search.twitter.com/search?q=%23$1" title="#$1">#$1</a>';
650
  $main_text = preg_replace($before,$after,$main_text);
651
 
652
  # Now for the meta text
@@ -654,9 +670,9 @@ function rotating_tweets_display($json,$args,$print=TRUE) {
654
  case 0:
655
  # This is the original Rotating Tweets display routine
656
  $result .= "\n\t\t<p class='rtw_main'>$main_text</p>";
657
- unset($meta);
658
  if($args['show_meta_timestamp']):
659
- $meta .= rotatingtweets_timestamp_link($twitter_object,'default');
660
  endif;
661
  if($args['show_meta_screen_name']):
662
  if(!empty($meta)) $meta .= ' ';
@@ -668,7 +684,7 @@ function rotating_tweets_display($json,$args,$print=TRUE) {
668
  endif;
669
  if($args['show_meta_reply_retweet_favorite']):
670
  if(!empty($meta)) $meta .= ' &middot; ';
671
- $meta .= rotatingtweets_intents($twitter_object,$twitterlocale, 0);
672
  endif;
673
  if(!empty($meta)) $result .= "\n\t\t<p class='rtw_meta'>".ucfirst($meta)."</p>";
674
  break;
@@ -676,40 +692,40 @@ function rotating_tweets_display($json,$args,$print=TRUE) {
676
  # This is an attempt to replicate the original Tweet
677
  $result .= "\n\t<div class='rtw_info'>";
678
  $result .= "\n\t\t<div class='rtw_twitter_icon'><img src='".plugins_url('images/bird_16_blue.png', __FILE__)."' alt='".__('Twitter','rotatingtweets')."' /></a></div>";
679
- $result .= "\n\t\t<div class='rtw_icon'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'icon')."</div>";
680
- $result .= "\n\t\t<div class='rtw_name'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'name')."</div>";
681
- $result .= "\n\t\t<div class='rtw_id'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'screen_name')."</div>";
682
  $result .= "\n\t</div>";
683
  $result .= "\n\t<p class='rtw_main'>".$main_text."</p>";
684
- $result .= "\n\t<div class='rtw_meta'><div class='rtw_intents'>".rotatingtweets_intents($twitter_object,$twitterlocale, 1).'</div>';
685
- $result .= rotatingtweets_timestamp_link($twitter_object,'long');
686
  if(isset($retweeter)) {
687
- $result .= " &middot; ".rotatingtweets_user_intent($retweeter,$twitterlocale,sprintf(__('Retweeted by %s','rotatingtweets'),$retweeter->name));
688
  }
689
  $result .= "\n</div>";
690
  break;
691
  case 2:
692
  # This is a slightly adjusted version of the original tweet - designed for wide boxes - consistent with Twitter guidelines
693
  $result .= "\n\t\t<div class='rtw_wide'>";
694
- $result .= "\n\t\t<div class='rtw_wide_icon'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'icon')."</div>";
695
  $result .= "\n\t\t<div class='rtw_wide_block'><div class='rtw_info'>";
696
- $result .= "\n\t\t\t<div class='rtw_time_short'>".rotatingtweets_timestamp_link($twitter_object,'short').'</a></div>';
697
- $result .= "\n\t\t\t<div class='rtw_name'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'name')."</div>";
698
- $result .= "\n\t\t\t<div class='rtw_id'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'screen_name')."</div>";
699
  $result .= "\n\t\t</div>";
700
  $result .= "\n\t\t<p class='rtw_main'>".$main_text."</p>";
701
  // $result .= "\n\t\t<div class='rtw_meta'><div class='rtw_intents'>".rotatingtweets_intents($twitter_object,$twitterlocale, 1).'</div>';
702
  if(isset($retweeter)) {
703
- $result .= "\n\t\t<div class='rtw_rt_meta'>".rotatingtweets_user_intent($retweeter,$twitterlocale,"<img src='".plugins_url('images/retweet_on.png',__FILE__)."' width='16' height='16' alt='".sprintf(__('Retweeted by %s','rotatingtweets'),$retweeter->name)."' />".sprintf(__('Retweeted by %s','rotatingtweets'),$retweeter->name))."</div>";
704
  }
705
- $result .= "\n\t\t<div class='rtw_meta'><span class='rtw_expand' style='display:none;'>".__('Expand','rotatingtweets')."</span><span class='rtw_intents'>".rotatingtweets_intents($twitter_object,$twitterlocale, 2).'</span>';
706
  $result .= "</div></div></div>";
707
  break;
708
  case 3:
709
  # This one uses the twitter standard approach for embedding via their javascript API - unfortunately I can't work out how to make it work with the rotating tweet javascript! If anyone can work out how to calculate the height of a oEmbed Twitter tweet, I will be very grateful! :-)
710
  $result .= '<blockquote class="twitter-tweet">';
711
  $result .= "<p>".$main_text."</p>";
712
- $result .= '&mdash; '.$user->name.' (@'.$user->screen_name.') <a href="https://twitter.com/twitterapi/status/'.$twitter_object->id_str.'" data-datetime="'.date('c',strtotime($twitter_object->created_at)).'">'.date_i18n(get_option('date_format') ,strtotime($twitter_object->created_at)).'</a>';
713
  $result .= '</blockquote>';
714
  break;
715
  }
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: 0.623
6
  Text Domain: rotatingtweets
7
  Author: Martin Tod
8
  Author URI: http://www.martintod.org.uk
105
  $instance['tw_hide_meta_via'] = !$new_instance['tw_show_meta_via'];
106
  $instance['tw_official_format'] = absint($new_instance['tw_official_format']);
107
  $instance['tw_show_meta_reply_retweet_favorite'] = absint($new_instance['tw_show_meta_reply_retweet_favorite']);
108
+ $instance['tw_timeout'] = max(min(intval($new_instance['tw_timeout']/1000)*1000,20000),3000);
109
  return $instance;
110
  }
111
 
266
  return date(_x('j M Y','slightly longer date format as per http://uk.php.net/manual/en/function.date.php','rotatingtweets'),$small_ts);
267
  }
268
  # Get reply,retweet,favorite intents - either words-only (option 0) or icons only (option 1) or both (option 2)
269
+ function rotatingtweets_intents($twitter_object,$lang, $icons = 1,$targetvalue='') {
270
  $addstring = array();
271
  $types = array (
272
  array ( 'link'=>'https://twitter.com/intent/tweet?in_reply_to=', 'icon'=>'images/reply.png', 'text' => __('reply', 'rotatingtweets')),
274
  array ( 'link'=>'https://twitter.com/intent/favorite?tweet_id=', 'icon'=>'images/favorite.png', 'text' => __('favorite', 'rotatingtweets'))
275
  );
276
  foreach($types as $type) {
277
+ $string = "\n\t\t\t<a href='".$type['link'].$twitter_object->id_str."' title='".esc_attr($type['text'])."' lang='{$lang}'{$targetvalue}>";
278
  switch($icons) {
279
  case 2:
280
+ $addstring[] = $string."<img src='".plugins_url($type['icon'],__FILE__)."' width='16' height='16' alt='".esc_attr($type['text'])."' /> {$type['text']}</a>";
281
  $glue = ' ';
282
  break;
283
  case 1:
284
+ $addstring[] = $string."<img src='".plugins_url($type['icon'],__FILE__)."' width='16' height='16' alt='".esc_attr($type['text'])."' /></a>";
285
  $glue = '';
286
  break;
287
  case 0:
295
  return($string);
296
  }
297
  // Produces a link to someone's name, icon or screen name (or to the text of your choice) using the 'intent' format for linking
298
+ function rotatingtweets_user_intent($person,$lang,$linkcontent,$targetvalue='') {
299
+ $return = "<a href='https://twitter.com/intent/user?user_id={$person->id}' title='".esc_attr($person->name)."' lang='{$lang}'{$targetvalue}>";
300
  switch($linkcontent){
301
  case 'icon':
302
+ $return .= "<img src='{$person->profile_image_url}' alt='".esc_attr($person->name)."' /></a>";
303
  break;
304
  case 'name':
305
  $return .= $person->name."</a>";
314
  return ($return);
315
  }
316
  // Produces a linked timestamp for including in the tweet
317
+ function rotatingtweets_timestamp_link($twitter_object,$timetype = 'default',$targetvalue='') {
318
+ $string = '<a '.$targetvalue.' href="https://twitter.com/twitterapi/status/'.$twitter_object->id_str.'">';
319
+ $tweettimestamp = strtotime($twitter_object->created_at );
320
+ // echo "<!-- ".$twitter_object->created_at . " | " .get_option('timezone_string') ." | $tweettimestamp -->";
321
  switch($timetype) {
322
  case 'short':
323
  $string .= rotatingtweets_contextualtime_short($tweettimestamp);
324
  break;
325
  case 'long':
326
+ $string .= date_i18n(get_option('time_format'),$tweettimestamp + ( get_option('gmt_offset') * 60 * 60 ) )." &middot; ".date_i18n(get_option('date_format') ,$tweettimestamp + ( get_option('gmt_offset') * 60 * 60 ) );
327
  break;
328
  default:
329
  $string .= ucfirst(rotatingtweets_contextualtime($tweettimestamp));
364
  'show_meta_reply_retweet_favorite' => FALSE,
365
  'rotation_type' => 'scrollUp',
366
  'official_format' => FALSE,
367
+ 'links_in_new_window' => FALSE,
368
  'url_length' => 29,
369
  'ratelimit' => FALSE
370
  ), $atts ) ;
571
  $result .= "<!-- Rate limited -- ";
572
  $result .= sprintf(_n('Next attempt to get data will be in %d minute','Next attempt to get data will be in %d minutes',$waittimevalue,'rotatingtweets'),$waittimevalue)." -->";
573
  endif;
574
+ # Set up the link treatment
575
+ if(isset($arg['links_in_new_window']) && $arg['links_in_new_window'] == TRUE ) {
576
+ $targetvalue = ' target="_blank" ';
577
+ } else {
578
+ $targetvalue = '';
579
+ }
580
  foreach($json as $twitter_object):
581
  $tweet_counter++;
582
  if($tweet_counter <= $tweet_count):
599
  # First clean up the retweets
600
  if(isset($twitter_object->retweeted_status)):
601
  $rt_data = $twitter_object->retweeted_status;
602
+ else:
603
+ unset($rt_data);
604
  endif;
605
  if(!empty($rt_data)):
606
  $rt_user = $rt_data->user;
611
  else:
612
  $main_text = "RT @".$rt_user->screen_name . " " . $rt_data->text;
613
  endif;
614
+ $before[] = "*@".$rt_user->screen_name."\b*i";
615
+ $after[] = rotatingtweets_user_intent($rt_user,$twitterlocale,'screen_name',$targetvalue);
616
  $entities = $rt_data->entities;
617
  endif;
618
  # First the user mentions
619
  if(isset($entities->user_mentions)):
620
  $user_mentions = $entities->user_mentions;
621
+ else:
622
+ unset($user_mentions);
623
  endif;
624
  if(!empty($user_mentions)):
625
  foreach($user_mentions as $user_mention):
626
+ $before[] = "*@".$user_mention->screen_name."\b*i";
627
+ $after[] = rotatingtweets_user_intent($user_mention,$twitterlocale,'screen_name',$targetvalue);
628
  endforeach;
629
  # Clearing up duplicates to avoid strange result (possibly risky?)
630
  $before = array_unique($before);
633
  # Now the URLs
634
  if(isset($entities->urls)):
635
  $urls = $entities->urls;
636
+ else:
637
+ unset($urls);
638
  endif;
639
  if(!empty($urls)):
640
  foreach($urls as $url):
645
  $displayurl = str_replace(json_decode('"\u2026"'),"",$displayurl);
646
  $displayurl = substr($displayurl,0,$urllength)."&hellip;";
647
  endif;
648
+ $after[] = "<a href='".$url->url."' title='".$url->expanded_url."'".$targetvalue.">".esc_html($displayurl)."</a>";
649
  endforeach;
650
  endif;
651
  if(isset($entities->media)):
652
  $media = $entities->media;
653
+ else:
654
+ unset($media);
655
  endif;
656
  if(!empty($media)):
657
  foreach($media as $medium):
658
  $before[] = "*".$medium->url."*";
659
  $displayurl = $medium->display_url;
660
  if(strlen($displayurl)>30) $displayurl = substr($displayurl,0,30)."&hellip;";
661
+ $after[] = "<a href='".$medium->url."' title='".$medium->expanded_url."'".$targetvalue.">".esc_html($displayurl)."</a>";
662
  endforeach;
663
  endif;
664
+ $before[]="%#([0-9]*[a-zA-Z]+\w*)%";
665
+ $after[]='<a href="http://search.twitter.com/search?q=%23$1" title="#$1"'.$targetvalue.'>#$1</a>';
666
  $main_text = preg_replace($before,$after,$main_text);
667
 
668
  # Now for the meta text
670
  case 0:
671
  # This is the original Rotating Tweets display routine
672
  $result .= "\n\t\t<p class='rtw_main'>$main_text</p>";
673
+ $meta = '';
674
  if($args['show_meta_timestamp']):
675
+ $meta .= rotatingtweets_timestamp_link($twitter_object,'default',$targetvalue);
676
  endif;
677
  if($args['show_meta_screen_name']):
678
  if(!empty($meta)) $meta .= ' ';
684
  endif;
685
  if($args['show_meta_reply_retweet_favorite']):
686
  if(!empty($meta)) $meta .= ' &middot; ';
687
+ $meta .= rotatingtweets_intents($twitter_object,$twitterlocale, 0,$targetvalue);
688
  endif;
689
  if(!empty($meta)) $result .= "\n\t\t<p class='rtw_meta'>".ucfirst($meta)."</p>";
690
  break;
692
  # This is an attempt to replicate the original Tweet
693
  $result .= "\n\t<div class='rtw_info'>";
694
  $result .= "\n\t\t<div class='rtw_twitter_icon'><img src='".plugins_url('images/bird_16_blue.png', __FILE__)."' alt='".__('Twitter','rotatingtweets')."' /></a></div>";
695
+ $result .= "\n\t\t<div class='rtw_icon'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'icon',$targetvalue)."</div>";
696
+ $result .= "\n\t\t<div class='rtw_name'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'name',$targetvalue)."</div>";
697
+ $result .= "\n\t\t<div class='rtw_id'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'screen_name',$targetvalue)."</div>";
698
  $result .= "\n\t</div>";
699
  $result .= "\n\t<p class='rtw_main'>".$main_text."</p>";
700
+ $result .= "\n\t<div class='rtw_meta'><div class='rtw_intents'>".rotatingtweets_intents($twitter_object,$twitterlocale, 1,$targetvalue).'</div>';
701
+ $result .= rotatingtweets_timestamp_link($twitter_object,'long',$targetvalue);
702
  if(isset($retweeter)) {
703
+ $result .= " &middot; ".rotatingtweets_user_intent($retweeter,$twitterlocale,sprintf(__('Retweeted by %s','rotatingtweets'),$retweeter->name),$targetvalue);
704
  }
705
  $result .= "\n</div>";
706
  break;
707
  case 2:
708
  # This is a slightly adjusted version of the original tweet - designed for wide boxes - consistent with Twitter guidelines
709
  $result .= "\n\t\t<div class='rtw_wide'>";
710
+ $result .= "\n\t\t<div class='rtw_wide_icon'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'icon',$targetvalue)."</div>";
711
  $result .= "\n\t\t<div class='rtw_wide_block'><div class='rtw_info'>";
712
+ $result .= "\n\t\t\t<div class='rtw_time_short'>".rotatingtweets_timestamp_link($twitter_object,'short',$targetvalue).'</a></div>';
713
+ $result .= "\n\t\t\t<div class='rtw_name'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'name',$targetvalue)."</div>";
714
+ $result .= "\n\t\t\t<div class='rtw_id'>".rotatingtweets_user_intent($tweetuser,$twitterlocale,'screen_name',$targetvalue)."</div>";
715
  $result .= "\n\t\t</div>";
716
  $result .= "\n\t\t<p class='rtw_main'>".$main_text."</p>";
717
  // $result .= "\n\t\t<div class='rtw_meta'><div class='rtw_intents'>".rotatingtweets_intents($twitter_object,$twitterlocale, 1).'</div>';
718
  if(isset($retweeter)) {
719
+ $result .= "\n\t\t<div class='rtw_rt_meta'>".rotatingtweets_user_intent($retweeter,$twitterlocale,"<img src='".plugins_url('images/retweet_on.png',__FILE__)."' width='16' height='16' alt='".sprintf(__('Retweeted by %s','rotatingtweets'),$retweeter->name)."' />".sprintf(__('Retweeted by %s','rotatingtweets'),$retweeter->name),$targetvalue)."</div>";
720
  }
721
+ $result .= "\n\t\t<div class='rtw_meta'><span class='rtw_expand' style='display:none;'>".__('Expand','rotatingtweets')."</span><span class='rtw_intents'>".rotatingtweets_intents($twitter_object,$twitterlocale, 2,$targetvalue).'</span>';
722
  $result .= "</div></div></div>";
723
  break;
724
  case 3:
725
  # This one uses the twitter standard approach for embedding via their javascript API - unfortunately I can't work out how to make it work with the rotating tweet javascript! If anyone can work out how to calculate the height of a oEmbed Twitter tweet, I will be very grateful! :-)
726
  $result .= '<blockquote class="twitter-tweet">';
727
  $result .= "<p>".$main_text."</p>";
728
+ $result .= '&mdash; '.$user->name.' (@'.$user->screen_name.') <a href="https://twitter.com/twitterapi/status/'.$twitter_object->id_str.'" data-datetime="'.date('c',strtotime($twitter_object->created_at)).'"'.$targetvalue.'>'.date_i18n(get_option('date_format') ,strtotime($twitter_object->created_at)).'</a>';
729
  $result .= '</blockquote>';
730
  break;
731
  }