Version Description
- Added shortcode support
- Fixed bug rendering url fragments as hashtags
Download this release
Release Info
Developer | timwhitlock |
Plugin | Latest Tweets Widget |
Version | 1.0.10 |
Comparing to | |
See all releases |
Code changes from version 1.0.9 to 1.0.10
- latest-tweets.php +30 -1
- lib/twitter-api-utils.php +7 -5
- readme.txt +18 -3
latest-tweets.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Latest Tweets
|
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/latest-tweets-widget/
|
5 |
Description: Provides a sidebar widget showing latest tweets - compatible with the new Twitter API 1.1
|
6 |
Author: Tim Whitlock
|
7 |
-
Version: 1.0.
|
8 |
Author URI: http://timwhitlock.info/
|
9 |
*/
|
10 |
|
@@ -80,6 +80,24 @@ function latest_tweets_render( $screen_name, $count, $rts, $ats ){
|
|
80 |
}
|
81 |
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
|
85 |
/**
|
@@ -191,6 +209,17 @@ function latest_tweets_register_widget(){
|
|
191 |
add_action( 'widgets_init', 'latest_tweets_register_widget' );
|
192 |
|
193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
if( is_admin() ){
|
195 |
if( ! function_exists('twitter_api_get') ){
|
196 |
require_once dirname(__FILE__).'/lib/twitter-api.php';
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/latest-tweets-widget/
|
5 |
Description: Provides a sidebar widget showing latest tweets - compatible with the new Twitter API 1.1
|
6 |
Author: Tim Whitlock
|
7 |
+
Version: 1.0.10
|
8 |
Author URI: http://timwhitlock.info/
|
9 |
*/
|
10 |
|
80 |
}
|
81 |
|
82 |
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Render tweets as HTML anywhere
|
86 |
+
*/
|
87 |
+
function latest_tweets_render_html( $screen_name = '', $num = 5, $rts = true, $ats = true ){
|
88 |
+
$items = latest_tweets_render( $screen_name, $num, $rts, $ats );
|
89 |
+
$list = apply_filters('latest_tweets_render_list', $items );
|
90 |
+
if( is_array($list) ){
|
91 |
+
$list = '<ul><li>'.implode('</li><li>',$items).'</li></ul>';
|
92 |
+
}
|
93 |
+
return
|
94 |
+
'<div class="latest-tweets">'.
|
95 |
+
apply_filters( 'latest_tweets_render_before', '' ).
|
96 |
+
$list.
|
97 |
+
apply_filters( 'latest_tweets_render_after', '' ).
|
98 |
+
'</div>';
|
99 |
+
}
|
100 |
+
|
101 |
|
102 |
|
103 |
/**
|
209 |
add_action( 'widgets_init', 'latest_tweets_register_widget' );
|
210 |
|
211 |
|
212 |
+
|
213 |
+
function lastest_tweets_shortcode( $atts ){
|
214 |
+
$screen_name = isset($atts['user']) ? trim($atts['user'],' @') : '';
|
215 |
+
$num = isset($atts['max']) ? (int) $atts['max'] : 5;
|
216 |
+
return latest_tweets_render_html( $screen_name, $num, true, false );
|
217 |
+
}
|
218 |
+
|
219 |
+
add_shortcode( 'tweets', 'lastest_tweets_shortcode' );
|
220 |
+
|
221 |
+
|
222 |
+
|
223 |
if( is_admin() ){
|
224 |
if( ! function_exists('twitter_api_get') ){
|
225 |
require_once dirname(__FILE__).'/lib/twitter-api.php';
|
lib/twitter-api-utils.php
CHANGED
@@ -19,7 +19,7 @@ function twitter_api_html( $src, $target = '_blank', $alreadyhtml = false ){
|
|
19 |
$src = esc_html( $src );
|
20 |
}
|
21 |
// linkify URLs (restricting to 30 chars as per twitter.com)
|
22 |
-
$src = preg_replace_callback('!https?://(\S+)!', 'twitter_api_html_linkify_callback', $src );
|
23 |
if( '_blank' !== $target ){
|
24 |
$src = str_replace( '"_blank"', '"'.$target.'"', $src );
|
25 |
}
|
@@ -36,11 +36,13 @@ function twitter_api_html( $src, $target = '_blank', $alreadyhtml = false ){
|
|
36 |
* @internal
|
37 |
*/
|
38 |
function twitter_api_html_linkify_callback( array $r ){
|
39 |
-
list( $
|
40 |
-
|
41 |
-
|
|
|
|
|
42 |
}
|
43 |
-
return '<a href="'.$href.'" target="_blank">'.$
|
44 |
}
|
45 |
|
46 |
|
19 |
$src = esc_html( $src );
|
20 |
}
|
21 |
// linkify URLs (restricting to 30 chars as per twitter.com)
|
22 |
+
$src = preg_replace_callback('!(https?://)(\S+)!', 'twitter_api_html_linkify_callback', $src );
|
23 |
if( '_blank' !== $target ){
|
24 |
$src = str_replace( '"_blank"', '"'.$target.'"', $src );
|
25 |
}
|
36 |
* @internal
|
37 |
*/
|
38 |
function twitter_api_html_linkify_callback( array $r ){
|
39 |
+
list( , $proto, $label ) = $r;
|
40 |
+
$label = str_replace( '#', '#', $label );
|
41 |
+
$href = $proto.$label;
|
42 |
+
if( isset($label{30}) ){
|
43 |
+
$label = substr_replace( $label, '…', 30 );
|
44 |
}
|
45 |
+
return '<a href="'.$href.'" target="_blank">'.$label.'</a>';
|
46 |
}
|
47 |
|
48 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://timwhitlock.info/donate-to-a-project/
|
|
4 |
Tags: twitter, tweets, oauth, api, rest, api, widget, sidebar
|
5 |
Requires at least: 3.5.1
|
6 |
Tested up to: 3.5.1
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -75,6 +75,10 @@ Do so at your own risk.
|
|
75 |
|
76 |
== Changelog ==
|
77 |
|
|
|
|
|
|
|
|
|
78 |
= 1.0.9 =
|
79 |
* Fixed pluralisation bug in date printing
|
80 |
* Now expanding t.co links unless render_text filter is used
|
@@ -109,8 +113,19 @@ Do so at your own risk.
|
|
109 |
|
110 |
== Upgrade Notice ==
|
111 |
|
112 |
-
= 1.0.
|
113 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
|
116 |
== Theming ==
|
4 |
Tags: twitter, tweets, oauth, api, rest, api, widget, sidebar
|
5 |
Requires at least: 3.5.1
|
6 |
Tested up to: 3.5.1
|
7 |
+
Stable tag: 1.0.10
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
75 |
|
76 |
== Changelog ==
|
77 |
|
78 |
+
= 1.0.10 =
|
79 |
+
* Added shortcode support
|
80 |
+
* Fixed bug rendering url fragments as hashtags
|
81 |
+
|
82 |
= 1.0.9 =
|
83 |
* Fixed pluralisation bug in date printing
|
84 |
* Now expanding t.co links unless render_text filter is used
|
113 |
|
114 |
== Upgrade Notice ==
|
115 |
|
116 |
+
= 1.0.10 =
|
117 |
+
* Important bug fixes, upgrade highly recommended
|
118 |
+
|
119 |
+
|
120 |
+
== Shortcodes ==
|
121 |
+
|
122 |
+
You can embed tweets in the body of your posts using a Wordpress the shortcode `[tweets]`.
|
123 |
+
|
124 |
+
To specify a different user's timeline add the `user` attribute.
|
125 |
+
To override the default number of 5 tweets add the `max` attribute, e.g:
|
126 |
+
|
127 |
+
[tweets max=10 user=timwhitlock]
|
128 |
+
|
129 |
|
130 |
|
131 |
== Theming ==
|