Twitter Widget Pro - Version 2.5.3

Version Description

Another SSL verification fix and add Twitter List support to shortcodes

Download this release

Release Info

Developer aaroncampbell
Plugin Icon wp plugin Twitter Widget Pro
Version 2.5.3
Comparing to
See all releases

Code changes from version 2.5.2 to 2.5.3

Files changed (3) hide show
  1. lib/wp-twitter.php +18 -13
  2. readme.txt +14 -3
  3. wp-twitter-widget.php +11 -3
lib/wp-twitter.php CHANGED
@@ -61,15 +61,17 @@ class wpTwitter {
61
 
62
  private function _get_request_defaults() {
63
  $params = array(
64
- 'sslverify' => apply_filters( 'twp_sslverify', false ),
65
- 'oauth_version' => '1.0',
66
- 'oauth_nonce' => md5( microtime() . mt_rand() ),
67
- 'oauth_timestamp' => time(),
68
- 'oauth_consumer_key' => $this->_consumer_key
 
 
69
  );
70
 
71
  if ( ! empty( $this->_token['oauth_token'] ) )
72
- $params['oauth_token'] = $this->_token['oauth_token'];
73
 
74
  return $params;
75
  }
@@ -96,18 +98,21 @@ class wpTwitter {
96
  /**
97
  * Format and sign an OAuth / API request
98
  */
99
- public function send_authed_request( $request_url, $method, $parameters = array() ) {
100
- $parameters = wp_parse_args( $parameters, $this->_get_request_defaults() );
 
101
  if ( ! filter_var( $request_url , FILTER_VALIDATE_URL ) )
102
  $request_url = self::get_api_endpoint( $request_url );
103
  $this->sign_request( $parameters, $request_url );
104
  switch ($method) {
105
  case 'GET':
106
- $request_url = $this->get_normalized_http_url( $request_url ) . '?' . twpOAuthUtil::build_http_query( $parameters );
107
- $resp = wp_remote_get($request_url);
 
108
  break;
109
  default:
110
- $resp = wp_remote_request($request_url, array( 'method'=>$method, 'body'=>$parameters));
 
111
  }
112
 
113
  if ( !is_wp_error( $resp ) && $resp['response']['code'] >= 200 && $resp['response']['code'] < 300 ) {
@@ -141,8 +146,8 @@ class wpTwitter {
141
  }
142
 
143
  public function sign_request( &$parameters, $request_url, $method = 'GET' ) {
144
- $parameters['oauth_signature_method'] = 'HMAC-SHA1';
145
- $parameters['oauth_signature'] = $this->build_signature( $parameters, $request_url, $method );
146
  }
147
 
148
  /**
61
 
62
  private function _get_request_defaults() {
63
  $params = array(
64
+ 'sslverify' => apply_filters( 'twp_sslverify', false ),
65
+ 'body' => array(
66
+ 'oauth_version' => '1.0',
67
+ 'oauth_nonce' => md5( microtime() . mt_rand() ),
68
+ 'oauth_timestamp' => time(),
69
+ 'oauth_consumer_key' => $this->_consumer_key,
70
+ ),
71
  );
72
 
73
  if ( ! empty( $this->_token['oauth_token'] ) )
74
+ $params['body']['oauth_token'] = $this->_token['oauth_token'];
75
 
76
  return $params;
77
  }
98
  /**
99
  * Format and sign an OAuth / API request
100
  */
101
+ public function send_authed_request( $request_url, $method, $body_parameters = array() ) {
102
+ $parameters = $this->_get_request_defaults();
103
+ $parameters['body'] = wp_parse_args( $body_parameters, $parameters['body'] );
104
  if ( ! filter_var( $request_url , FILTER_VALIDATE_URL ) )
105
  $request_url = self::get_api_endpoint( $request_url );
106
  $this->sign_request( $parameters, $request_url );
107
  switch ($method) {
108
  case 'GET':
109
+ $request_url = $this->get_normalized_http_url( $request_url ) . '?' . twpOAuthUtil::build_http_query( $parameters['body'] );
110
+ unset( $parameters['body'] );
111
+ $resp = wp_remote_get( $request_url, $parameters );
112
  break;
113
  default:
114
+ $parameters['method'] = $method;
115
+ $resp = wp_remote_request( $request_url, $parameters );
116
  }
117
 
118
  if ( !is_wp_error( $resp ) && $resp['response']['code'] >= 200 && $resp['response']['code'] < 300 ) {
146
  }
147
 
148
  public function sign_request( &$parameters, $request_url, $method = 'GET' ) {
149
+ $parameters['body']['oauth_signature_method'] = 'HMAC-SHA1';
150
+ $parameters['body']['oauth_signature'] = $this->build_signature( $parameters['body'], $request_url, $method );
151
  }
152
 
153
  /**
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: aaroncampbell, PeteMall, range, saracannon
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9993090
4
  Tags: twitter, widget, feed
5
  Requires at least: 3.0
6
- Tested up to: 3.5
7
- Stable tag: 2.5.2
8
 
9
  A widget that properly handles twitter feeds, including parsing @username, #hashtags, and URLs into links.
10
 
@@ -20,7 +20,9 @@ Brought to you by <a href="http://ran.ge/" title="WordPress Development">Ran.ge<
20
 
21
  == Installation ==
22
 
23
- 1. Use automatic installer.
 
 
24
  1. In WordPress admin go to 'Appearance' -> 'Widgets' and add "Twitter Widget Pro" to one of your widget-ready areas of your site
25
 
26
  == Frequently Asked Questions ==
@@ -42,6 +44,8 @@ page. The simplest form of this would be `[twitter-widget username="yourTwitter
42
  The simplest form of this would be `[twitter-widget username="yourTwitterUsername"]`
43
  However, there are more things you can control.
44
 
 
 
45
  * before_widget - This is inserted before the widget.
46
  * after_widget - This is inserted after the widget, and is often used to close tags opened in before_widget
47
  * before_title - This is inserted before the title and defults to <h2>
@@ -130,6 +134,9 @@ Aparently the database queries required to display the friends feed was causing
130
 
131
  == Upgrade Notice ==
132
 
 
 
 
133
  = 2.5.2 =
134
  Fixes hashtag links, ignoring of retweets, and SSL verification
135
 
@@ -183,6 +190,10 @@ Fewer "could not connect to Twitter" messages, new links (reply, retweet, favori
183
 
184
  == Changelog ==
185
 
 
 
 
 
186
  = 2.5.2 =
187
  * Don't force verification of Twitter's SSL certificate
188
  * Fix empty admin notice
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9993090
4
  Tags: twitter, widget, feed
5
  Requires at least: 3.0
6
+ Tested up to: 3.6
7
+ Stable tag: 2.5.3
8
 
9
  A widget that properly handles twitter feeds, including parsing @username, #hashtags, and URLs into links.
10
 
20
 
21
  == Installation ==
22
 
23
+ 1. Use automatic installer to install and active the plugin.
24
+ 1. You should see a notice appear in your admin that links you to the settings page.
25
+ 1. Follow the instructions to setup your Twitter app and authenticate your account (an unfortunate step made necessary by Twitter's API changes).
26
  1. In WordPress admin go to 'Appearance' -> 'Widgets' and add "Twitter Widget Pro" to one of your widget-ready areas of your site
27
 
28
  == Frequently Asked Questions ==
44
  The simplest form of this would be `[twitter-widget username="yourTwitterUsername"]`
45
  However, there are more things you can control.
46
 
47
+ * username - A Twitter username to pull a feed of Tweets from. The user needs to be authenticated.
48
+ * list - A Twitter list id owned by one of the users you've authenticated.
49
  * before_widget - This is inserted before the widget.
50
  * after_widget - This is inserted after the widget, and is often used to close tags opened in before_widget
51
  * before_title - This is inserted before the title and defults to <h2>
134
 
135
  == Upgrade Notice ==
136
 
137
+ = 2.5.3 =
138
+ Another SSL verification fix and add Twitter List support to shortcodes
139
+
140
  = 2.5.2 =
141
  Fixes hashtag links, ignoring of retweets, and SSL verification
142
 
190
 
191
  == Changelog ==
192
 
193
+ = 2.5.3 =
194
+ * Don't force verification of Twitter's SSL certificate
195
+ * Add support for Twitter Lists in shortcodes
196
+
197
  = 2.5.2 =
198
  * Don't force verification of Twitter's SSL certificate
199
  * Fix empty admin notice
wp-twitter-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Twitter Widget Pro
4
  * Plugin URI: http://bluedogwebservices.com/wordpress-plugin/twitter-widget-pro/
5
  * Description: A widget that properly handles twitter feeds, including @username, #hashtag, and link parsing. It can even display profile images for the users. Requires PHP5.
6
- * Version: 2.5.2
7
  * Author: Aaron D. Campbell
8
  * Author URI: http://ran.ge/
9
  * License: GPLv2 or later
@@ -318,8 +318,10 @@ class wpTwitterWidget extends RangePlugin {
318
  check_admin_referer( 'authorize' );
319
  $auth_redirect = add_query_arg( array( 'action' => 'authorized' ), $this->get_options_url() );
320
  $token = $this->_wp_twitter_oauth->getRequestToken( $auth_redirect );
321
- if ( is_wp_error( $token ) )
 
322
  return;
 
323
  update_option( '_twp_request_token_'.$token['nonce'], $token );
324
  $screen_name = empty( $_GET['screen_name'] )? '':$_GET['screen_name'];
325
  wp_redirect( $this->_wp_twitter_oauth->get_authorize_url( $screen_name ) );
@@ -363,6 +365,11 @@ class wpTwitterWidget extends RangePlugin {
363
  echo "<div class='updated'><p>" . esc_html( $msg ) . '</p></div>';
364
  }
365
 
 
 
 
 
 
366
  if ( empty( $this->_settings['twp']['consumer-key'] ) || empty( $this->_settings['twp']['consumer-secret'] ) ) {
367
  $msg = sprintf( __( 'You need to <a href="%s">set up your Twitter app keys</a>.', $this->_slug ), $this->get_options_url() );
368
  echo '<div class="error"><p>' . $msg . '</p></div>';
@@ -864,7 +871,7 @@ class wpTwitterWidget extends RangePlugin {
864
  $args['title'] = apply_filters( 'twitter-widget-title', $args['title'], $args );
865
  $args['title'] = "<span class='twitterwidget twitterwidget-title'>{$args['title']}</span>";
866
  $widgetContent .= $args['before_title'] . $args['title'] . $args['after_title'];
867
- if ( !empty( $tweets[0] ) && !empty( $args['avatar'] ) ) {
868
  $widgetContent .= '<div class="twitter-avatar">';
869
  $widgetContent .= $this->_getProfileImage( $tweets[0]->user, $args );
870
  $widgetContent .= '</div>';
@@ -1171,6 +1178,7 @@ class wpTwitterWidget extends RangePlugin {
1171
  'title' => '',
1172
  'errmsg' => '',
1173
  'username' => '',
 
1174
  'hidereplies' => 'false',
1175
  'showretweets' => 'true',
1176
  'hidefrom' => 'false',
3
  * Plugin Name: Twitter Widget Pro
4
  * Plugin URI: http://bluedogwebservices.com/wordpress-plugin/twitter-widget-pro/
5
  * Description: A widget that properly handles twitter feeds, including @username, #hashtag, and link parsing. It can even display profile images for the users. Requires PHP5.
6
+ * Version: 2.5.3
7
  * Author: Aaron D. Campbell
8
  * Author URI: http://ran.ge/
9
  * License: GPLv2 or later
318
  check_admin_referer( 'authorize' );
319
  $auth_redirect = add_query_arg( array( 'action' => 'authorized' ), $this->get_options_url() );
320
  $token = $this->_wp_twitter_oauth->getRequestToken( $auth_redirect );
321
+ if ( is_wp_error( $token ) ) {
322
+ $this->_error = $token;
323
  return;
324
+ }
325
  update_option( '_twp_request_token_'.$token['nonce'], $token );
326
  $screen_name = empty( $_GET['screen_name'] )? '':$_GET['screen_name'];
327
  wp_redirect( $this->_wp_twitter_oauth->get_authorize_url( $screen_name ) );
365
  echo "<div class='updated'><p>" . esc_html( $msg ) . '</p></div>';
366
  }
367
 
368
+ if ( ! empty( $this->_error ) && is_wp_error( $this->_error ) ) {
369
+ $msg = '<p>' . implode( '</p><p>', $this->_error->get_error_messages() ) . '</p>';
370
+ echo '<div class="error">' . $msg . '</div>';
371
+ }
372
+
373
  if ( empty( $this->_settings['twp']['consumer-key'] ) || empty( $this->_settings['twp']['consumer-secret'] ) ) {
374
  $msg = sprintf( __( 'You need to <a href="%s">set up your Twitter app keys</a>.', $this->_slug ), $this->get_options_url() );
375
  echo '<div class="error"><p>' . $msg . '</p></div>';
871
  $args['title'] = apply_filters( 'twitter-widget-title', $args['title'], $args );
872
  $args['title'] = "<span class='twitterwidget twitterwidget-title'>{$args['title']}</span>";
873
  $widgetContent .= $args['before_title'] . $args['title'] . $args['after_title'];
874
+ if ( !empty( $tweets[0] ) && is_object( $tweets[0] ) && !empty( $args['avatar'] ) ) {
875
  $widgetContent .= '<div class="twitter-avatar">';
876
  $widgetContent .= $this->_getProfileImage( $tweets[0]->user, $args );
877
  $widgetContent .= '</div>';
1178
  'title' => '',
1179
  'errmsg' => '',
1180
  'username' => '',
1181
+ 'list' => '',
1182
  'hidereplies' => 'false',
1183
  'showretweets' => 'true',
1184
  'hidefrom' => 'false',