Version Description
Includes an important upgrade needed for Rotating Tweets to keep working after March 2013. Fixed problem with hashtags.
=
Download this release
Release Info
Developer | mpntod |
Plugin | Rotating Tweets (Twitter widget and shortcode) |
Version | 1.3.14 |
Comparing to | |
See all releases |
Code changes from version 1.3.13 to 1.3.14
- readme.txt +8 -4
- rotatingtweets.php +33 -7
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,animation,jquery,jquery cycle,cycle,multilingual
|
5 |
Requires at least: 2.6
|
6 |
Tested up to: 3.5
|
7 |
-
Stable tag: 1.3.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -73,8 +73,9 @@ Possible variables for the shortcode include:
|
|
73 |
* `get_favorites` = `'0'` or `'1'` - show someone's favorites rather than their timeline - default is `'0'`
|
74 |
* `url_length` = sets the length that the URL should be trimmed to...
|
75 |
* `url` = Twitter user URL. If `screen_name` is empty and this link is valid, `screen_name` will be set to the user name included in `url`
|
|
|
76 |
|
77 |
-
although the only one you *have* to have is `screen_name`.
|
78 |
|
79 |
== Credits ==
|
80 |
Most of this is my own work, but special thanks are owed to:
|
@@ -117,10 +118,13 @@ If there is only one copy of `jquery` and of `jquery.cycle` on your page, the be
|
|
117 |
1. Read the diagnostics and look for any problems that relate to JavaScript. This will normally tell you which JavaScript (if any) is having problems.
|
118 |
|
119 |
== Upgrade notice ==
|
120 |
-
= 1.3.
|
121 |
-
Includes an important upgrade needed for Rotating Tweets to keep working after March 2013.
|
122 |
|
123 |
== Changelog ==
|
|
|
|
|
|
|
124 |
= 1.3.13 =
|
125 |
Strips `@` from screen names to avoid API problems.
|
126 |
|
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: 1.3.14
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
73 |
* `get_favorites` = `'0'` or `'1'` - show someone's favorites rather than their timeline - default is `'0'`
|
74 |
* `url_length` = sets the length that the URL should be trimmed to...
|
75 |
* `url` = Twitter user URL. If `screen_name` is empty and this link is valid, `screen_name` will be set to the user name included in `url`
|
76 |
+
* `search` = a term to search for
|
77 |
|
78 |
+
although, unless you are using `search`, the only one you *have* to have is `screen_name`.
|
79 |
|
80 |
== Credits ==
|
81 |
Most of this is my own work, but special thanks are owed to:
|
118 |
1. Read the diagnostics and look for any problems that relate to JavaScript. This will normally tell you which JavaScript (if any) is having problems.
|
119 |
|
120 |
== Upgrade notice ==
|
121 |
+
= 1.3.14 =
|
122 |
+
Includes an important upgrade needed for Rotating Tweets to keep working after March 2013. Fixed problem with hashtags.
|
123 |
|
124 |
== Changelog ==
|
125 |
+
= 1.3.14 =
|
126 |
+
Fixes accents in hashtags (hopefully). Adds beta of search to the API. Adds new format of Tweet display.
|
127 |
+
|
128 |
= 1.3.13 =
|
129 |
Strips `@` from screen names to avoid API problems.
|
130 |
|
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.3.
|
6 |
Text Domain: rotatingtweets
|
7 |
Author: Martin Tod
|
8 |
Author URI: http://www.martintod.org.uk
|
@@ -375,6 +375,7 @@ function rotatingtweets_display_shortcode( $atts, $content=null, $code="", $prin
|
|
375 |
'official_format' => FALSE,
|
376 |
'links_in_new_window' => FALSE,
|
377 |
'url_length' => 29,
|
|
|
378 |
'get_favorites' => FALSE,
|
379 |
'ratelimit' => FALSE
|
380 |
), $atts ) ;
|
@@ -389,7 +390,7 @@ function rotatingtweets_display_shortcode( $atts, $content=null, $code="", $prin
|
|
389 |
if(empty($screen_name)) $screen_name = 'twitter';
|
390 |
# Makes sure the scripts are listed
|
391 |
rotatingtweets_enqueue_scripts();
|
392 |
-
$tweets = rotatingtweets_get_tweets($screen_name,$include_rts,$exclude_replies,$get_favorites);
|
393 |
$returnstring = rotating_tweets_display($tweets,$args,$print);
|
394 |
return $returnstring;
|
395 |
}
|
@@ -545,7 +546,11 @@ function rotatingtweets_call_twitter_API($command,$options = NULL,$api = NULL )
|
|
545 |
$string[] = $name . "=" . urlencode($val);
|
546 |
}
|
547 |
endif;
|
548 |
-
$
|
|
|
|
|
|
|
|
|
549 |
if(!empty($string)) $apicall .= "?".implode('&',$string);
|
550 |
if(WP_DEBUG) echo "<!-- Using version 1 of API - calling string ".esc_attr($apicall)." -->";
|
551 |
$result = wp_remote_request($apicall);
|
@@ -567,15 +572,20 @@ function rotatingtweets_call_twitter_API($command,$options = NULL,$api = NULL )
|
|
567 |
}
|
568 |
|
569 |
# Get the latest data from Twitter (or from a cache if it's been less than 2 minutes since the last load)
|
570 |
-
function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_replies,$tw_get_favorites = FALSE) {
|
571 |
# Clear up variables
|
572 |
$tw_screen_name = urlencode(trim(remove_accents(str_replace('@','',$tw_screen_name))));
|
|
|
|
|
|
|
573 |
$cache_delay = 120;
|
574 |
if($tw_include_rts != 1) $tw_include_rts = 0;
|
575 |
if($tw_exclude_replies != 1) $tw_exclude_replies = 0;
|
576 |
|
577 |
# Get the option strong
|
578 |
-
if($
|
|
|
|
|
579 |
$stringname = $tw_screen_name.$tw_include_rts.$tw_exclude_replies.'favorites';
|
580 |
} else {
|
581 |
$stringname = $tw_screen_name.$tw_include_rts.$tw_exclude_replies;
|
@@ -609,7 +619,10 @@ function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_r
|
|
609 |
# Checks if it is time to call Twitter directly yet or if it should use the cache
|
610 |
if($timegap > $cache_delay):
|
611 |
$apioptions = array('screen_name'=>$tw_screen_name,'include_entities'=>1,'count'=>70,'include_rts'=>$tw_include_rts,'exclude_replies'=>$tw_exclude_replies);
|
612 |
-
if($
|
|
|
|
|
|
|
613 |
$twitterdata = rotatingtweets_call_twitter_API('favorites/list',$apioptions);
|
614 |
} else {
|
615 |
$twitterdata = rotatingtweets_call_twitter_API('statuses/user_timeline',$apioptions);
|
@@ -642,6 +655,9 @@ function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_r
|
|
642 |
elseif(!empty($twitterjson)):
|
643 |
# If there's regular data, then update the cache and return the data
|
644 |
unset($firstentry);
|
|
|
|
|
|
|
645 |
if(is_array($twitterjson)) $firstentry = $twitterjson[0];
|
646 |
if(!empty($firstentry['text'])):
|
647 |
if(WP_DEBUG):
|
@@ -907,7 +923,8 @@ function rotating_tweets_display($json,$args,$print=TRUE) {
|
|
907 |
$after[] = "<a href='".$medium['url']."' title='".$medium['expanded_url']."'".$targetvalue.">".esc_html($displayurl)."</a>";
|
908 |
endforeach;
|
909 |
endif;
|
910 |
-
$before[]="%#([0-9]*[\p{L}a-zA-Z_]+\w*)%";
|
|
|
911 |
$after[]='<a href="http://twitter.com/search?q=%23$1&src=hash" title="#$1"'.$targetvalue.'>#$1</a>';
|
912 |
$main_text = preg_replace($before,$after,$main_text);
|
913 |
|
@@ -974,6 +991,15 @@ function rotating_tweets_display($json,$args,$print=TRUE) {
|
|
974 |
$result .= '— '.$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>';
|
975 |
$result .= '</blockquote>';
|
976 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
977 |
}
|
978 |
else:
|
979 |
$result .= "\n\t\t<p class='rtw_main'>".__("Problem retrieving data from Twitter.",'rotatingtweets')."</p></div>";
|
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.3.14
|
6 |
Text Domain: rotatingtweets
|
7 |
Author: Martin Tod
|
8 |
Author URI: http://www.martintod.org.uk
|
375 |
'official_format' => FALSE,
|
376 |
'links_in_new_window' => FALSE,
|
377 |
'url_length' => 29,
|
378 |
+
'search' => FALSE,
|
379 |
'get_favorites' => FALSE,
|
380 |
'ratelimit' => FALSE
|
381 |
), $atts ) ;
|
390 |
if(empty($screen_name)) $screen_name = 'twitter';
|
391 |
# Makes sure the scripts are listed
|
392 |
rotatingtweets_enqueue_scripts();
|
393 |
+
$tweets = rotatingtweets_get_tweets($screen_name,$include_rts,$exclude_replies,$get_favorites,$search);
|
394 |
$returnstring = rotating_tweets_display($tweets,$args,$print);
|
395 |
return $returnstring;
|
396 |
}
|
546 |
$string[] = $name . "=" . urlencode($val);
|
547 |
}
|
548 |
endif;
|
549 |
+
if($command != 'search/tweets'):
|
550 |
+
$apicall = "http://api.twitter.com/1/".$command.".json";
|
551 |
+
else:
|
552 |
+
$apicall = "http://search.twitter.com/search.json";
|
553 |
+
endif;
|
554 |
if(!empty($string)) $apicall .= "?".implode('&',$string);
|
555 |
if(WP_DEBUG) echo "<!-- Using version 1 of API - calling string ".esc_attr($apicall)." -->";
|
556 |
$result = wp_remote_request($apicall);
|
572 |
}
|
573 |
|
574 |
# Get the latest data from Twitter (or from a cache if it's been less than 2 minutes since the last load)
|
575 |
+
function rotatingtweets_get_tweets($tw_screen_name,$tw_include_rts,$tw_exclude_replies,$tw_get_favorites = FALSE,$tw_search = FALSE ) {
|
576 |
# Clear up variables
|
577 |
$tw_screen_name = urlencode(trim(remove_accents(str_replace('@','',$tw_screen_name))));
|
578 |
+
if($tw_search) {
|
579 |
+
$tw_search = urlencode(trim($tw_search));
|
580 |
+
}
|
581 |
$cache_delay = 120;
|
582 |
if($tw_include_rts != 1) $tw_include_rts = 0;
|
583 |
if($tw_exclude_replies != 1) $tw_exclude_replies = 0;
|
584 |
|
585 |
# Get the option strong
|
586 |
+
if($tw_search) {
|
587 |
+
$stringname = 'search-'.$tw_include_rts.$tw_exclude_replies.$tw_search;
|
588 |
+
}elseif($tw_get_favorites) {
|
589 |
$stringname = $tw_screen_name.$tw_include_rts.$tw_exclude_replies.'favorites';
|
590 |
} else {
|
591 |
$stringname = $tw_screen_name.$tw_include_rts.$tw_exclude_replies;
|
619 |
# Checks if it is time to call Twitter directly yet or if it should use the cache
|
620 |
if($timegap > $cache_delay):
|
621 |
$apioptions = array('screen_name'=>$tw_screen_name,'include_entities'=>1,'count'=>70,'include_rts'=>$tw_include_rts,'exclude_replies'=>$tw_exclude_replies);
|
622 |
+
if($tw_search) {
|
623 |
+
$apioptions['q']=$tw_search;
|
624 |
+
$twitterdata = rotatingtweets_call_twitter_API('search/tweets',$apioptions);
|
625 |
+
} elseif($tw_get_favorites) {
|
626 |
$twitterdata = rotatingtweets_call_twitter_API('favorites/list',$apioptions);
|
627 |
} else {
|
628 |
$twitterdata = rotatingtweets_call_twitter_API('statuses/user_timeline',$apioptions);
|
655 |
elseif(!empty($twitterjson)):
|
656 |
# If there's regular data, then update the cache and return the data
|
657 |
unset($firstentry);
|
658 |
+
if(isset($twitterjson['statuses'])):
|
659 |
+
$twitterjson = $twitterjson['statuses'];
|
660 |
+
endif;
|
661 |
if(is_array($twitterjson)) $firstentry = $twitterjson[0];
|
662 |
if(!empty($firstentry['text'])):
|
663 |
if(WP_DEBUG):
|
923 |
$after[] = "<a href='".$medium['url']."' title='".$medium['expanded_url']."'".$targetvalue.">".esc_html($displayurl)."</a>";
|
924 |
endforeach;
|
925 |
endif;
|
926 |
+
// $before[]="%#([0-9]*[\p{L}a-zA-Z_]+\w*)%";
|
927 |
+
$before[]="%#(\d*[^\d\s[:punct:]]+[^\s[:punct:]]+)%";
|
928 |
$after[]='<a href="http://twitter.com/search?q=%23$1&src=hash" title="#$1"'.$targetvalue.'>#$1</a>';
|
929 |
$main_text = preg_replace($before,$after,$main_text);
|
930 |
|
991 |
$result .= '— '.$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>';
|
992 |
$result .= '</blockquote>';
|
993 |
break;
|
994 |
+
case 4:
|
995 |
+
$result .= "\n\t\t<p class='rtw_main'>$main_text</p>";
|
996 |
+
$result .= "\n\t<div class='rtw_meta rtw_info'><div class='rtw_intents'>".rotatingtweets_intents($twitter_object,$twitterlocale, 1,$targetvalue).'</div>';
|
997 |
+
if($args['show_meta_screen_name']):
|
998 |
+
$result .= sprintf(__('from <a href=\'%1$s\' title=\'%2$s\'>%2$s\'s Twitter</a>','rotatingtweets'),'https://twitter.com/intent/user?user_id='.$user['id'],$user['name']).' · ';
|
999 |
+
endif;
|
1000 |
+
$result .= rotatingtweets_timestamp_link($twitter_object,'long',$targetvalue);
|
1001 |
+
$result .= "\n</div>";
|
1002 |
+
break;
|
1003 |
}
|
1004 |
else:
|
1005 |
$result .= "\n\t\t<p class='rtw_main'>".__("Problem retrieving data from Twitter.",'rotatingtweets')."</p></div>";
|