Twitter Widget Pro - Version 2.5.1

Version Description

Fix potential conflict with other oAuth plugins

Download this release

Release Info

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

Code changes from version 2.5.0 to 2.5.1

lib/oauth-util.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
- class OAuthUtil {
3
  public static function urlencode_rfc3986( $input ) {
4
  if ( is_array( $input ) )
5
- return array_map( array( 'OAuthUtil', 'urlencode_rfc3986' ), $input );
6
  else if ( is_scalar( $input ) )
7
  return str_replace( '+', ' ', str_replace( '%7E', '~', rawurlencode( $input ) ) );
8
  else
@@ -28,7 +28,7 @@ class OAuthUtil {
28
  $header_name = $matches[2][0];
29
  $header_content = ( isset( $matches[5] ) ) ? $matches[5][0] : $matches[4][0];
30
  if ( preg_match( '/^oauth_/', $header_name ) || ! $only_allow_oauth_parameters )
31
- $params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
32
 
33
  $offset = $match[1] + strlen($match[0]);
34
  }
@@ -87,8 +87,8 @@ class OAuthUtil {
87
  $parsed_parameters = array();
88
  foreach ( $pairs as $pair ) {
89
  $split = explode( '=', $pair, 2 );
90
- $parameter = OAuthUtil::urldecode_rfc3986( $split[0] );
91
- $value = isset( $split[1] ) ? OAuthUtil::urldecode_rfc3986( $split[1] ) : '';
92
 
93
  if ( isset( $parsed_parameters[$parameter] ) ) {
94
  // We have already recieved parameter(s) with this name, so add to the
@@ -112,8 +112,8 @@ class OAuthUtil {
112
  return '';
113
 
114
  // Urlencode both keys and values
115
- $keys = OAuthUtil::urlencode_rfc3986( array_keys( $params ) );
116
- $values = OAuthUtil::urlencode_rfc3986( array_values( $params ) );
117
  $params = array_combine( $keys, $values );
118
 
119
  // Parameters are sorted by name, using lexicographical byte value ordering.
1
  <?php
2
+ class twpOAuthUtil {
3
  public static function urlencode_rfc3986( $input ) {
4
  if ( is_array( $input ) )
5
+ return array_map( array( 'twpOAuthUtil', 'urlencode_rfc3986' ), $input );
6
  else if ( is_scalar( $input ) )
7
  return str_replace( '+', ' ', str_replace( '%7E', '~', rawurlencode( $input ) ) );
8
  else
28
  $header_name = $matches[2][0];
29
  $header_content = ( isset( $matches[5] ) ) ? $matches[5][0] : $matches[4][0];
30
  if ( preg_match( '/^oauth_/', $header_name ) || ! $only_allow_oauth_parameters )
31
+ $params[$header_name] = twpOAuthUtil::urldecode_rfc3986($header_content);
32
 
33
  $offset = $match[1] + strlen($match[0]);
34
  }
87
  $parsed_parameters = array();
88
  foreach ( $pairs as $pair ) {
89
  $split = explode( '=', $pair, 2 );
90
+ $parameter = twpOAuthUtil::urldecode_rfc3986( $split[0] );
91
+ $value = isset( $split[1] ) ? twpOAuthUtil::urldecode_rfc3986( $split[1] ) : '';
92
 
93
  if ( isset( $parsed_parameters[$parameter] ) ) {
94
  // We have already recieved parameter(s) with this name, so add to the
112
  return '';
113
 
114
  // Urlencode both keys and values
115
+ $keys = twpOAuthUtil::urlencode_rfc3986( array_keys( $params ) );
116
+ $values = twpOAuthUtil::urlencode_rfc3986( array_values( $params ) );
117
  $params = array_combine( $keys, $values );
118
 
119
  // Parameters are sorted by name, using lexicographical byte value ordering.
lib/wp-twitter.php CHANGED
@@ -102,22 +102,21 @@ class wpTwitter {
102
  $this->sign_request( $parameters, $request_url );
103
  switch ($method) {
104
  case 'GET':
105
- $request_url = $this->get_normalized_http_url( $request_url ) . '?' . OAuthUtil::build_http_query( $parameters );
106
  $resp = wp_remote_get($request_url);
107
  break;
108
  default:
109
  $resp = wp_remote_request($request_url, array( 'method'=>$method, 'body'=>$parameters));
110
  }
111
 
112
- if ( 'account/verify_credentials' == $method )
113
- dump( $resp, '$resp' );
114
-
115
  if ( !is_wp_error( $resp ) && $resp['response']['code'] >= 200 && $resp['response']['code'] < 300 ) {
116
  $decoded_response = json_decode( $resp['body'] );
117
  if ( empty( $decoded_response ) && ! empty( $resp['body'] ) )
118
  $decoded_response = wp_parse_args( $resp['body'] );
119
  return $decoded_response;
120
  } else {
 
 
121
  return new WP_Error( $resp['response']['code'], 'Could not recognize the response from Twitter' );
122
  }
123
  }
@@ -155,7 +154,7 @@ class wpTwitter {
155
  if ( isset( $parameters['oauth_signature'] ) )
156
  unset( $parameters['oauth_signature'] );
157
 
158
- return OAuthUtil::build_http_query( $parameters );
159
  }
160
 
161
  public function build_signature( $parameters, $request_url, $method = 'GET' ) {
@@ -165,7 +164,7 @@ class wpTwitter {
165
  $this->get_signable_parameters( $parameters )
166
  );
167
 
168
- $parts = OAuthUtil::urlencode_rfc3986($parts);
169
 
170
  $base_string = implode('&', $parts);
171
  $token_secret = '';
@@ -178,7 +177,7 @@ class wpTwitter {
178
  $token_secret,
179
  );
180
 
181
- $key_parts = OAuthUtil::urlencode_rfc3986( $key_parts );
182
  $key = implode( '&', $key_parts );
183
 
184
  return base64_encode( hash_hmac( 'sha1', $base_string, $key, true ) );
102
  $this->sign_request( $parameters, $request_url );
103
  switch ($method) {
104
  case 'GET':
105
+ $request_url = $this->get_normalized_http_url( $request_url ) . '?' . twpOAuthUtil::build_http_query( $parameters );
106
  $resp = wp_remote_get($request_url);
107
  break;
108
  default:
109
  $resp = wp_remote_request($request_url, array( 'method'=>$method, 'body'=>$parameters));
110
  }
111
 
 
 
 
112
  if ( !is_wp_error( $resp ) && $resp['response']['code'] >= 200 && $resp['response']['code'] < 300 ) {
113
  $decoded_response = json_decode( $resp['body'] );
114
  if ( empty( $decoded_response ) && ! empty( $resp['body'] ) )
115
  $decoded_response = wp_parse_args( $resp['body'] );
116
  return $decoded_response;
117
  } else {
118
+ if ( is_wp_error( $resp ) )
119
+ return $resp;
120
  return new WP_Error( $resp['response']['code'], 'Could not recognize the response from Twitter' );
121
  }
122
  }
154
  if ( isset( $parameters['oauth_signature'] ) )
155
  unset( $parameters['oauth_signature'] );
156
 
157
+ return twpOAuthUtil::build_http_query( $parameters );
158
  }
159
 
160
  public function build_signature( $parameters, $request_url, $method = 'GET' ) {
164
  $this->get_signable_parameters( $parameters )
165
  );
166
 
167
+ $parts = twpOAuthUtil::urlencode_rfc3986($parts);
168
 
169
  $base_string = implode('&', $parts);
170
  $token_secret = '';
177
  $token_secret,
178
  );
179
 
180
+ $key_parts = twpOAuthUtil::urlencode_rfc3986( $key_parts );
181
  $key = implode( '&', $key_parts );
182
 
183
  return base64_encode( hash_hmac( 'sha1', $base_string, $key, true ) );
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: twitter, widget, feed
5
  Requires at least: 3.0
6
  Tested up to: 3.5
7
- Stable tag: 2.5.0
8
 
9
  A widget that properly handles twitter feeds, including parsing @username, #hashtags, and URLs into links.
10
 
@@ -130,6 +130,9 @@ Aparently the database queries required to display the friends feed was causing
130
 
131
  == Upgrade Notice ==
132
 
 
 
 
133
  = 2.5.0 =
134
  Upgrade to the new Twitter API and add support for lists
135
 
@@ -177,6 +180,10 @@ Fewer "could not connect to Twitter" messages, new links (reply, retweet, favori
177
 
178
  == Changelog ==
179
 
 
 
 
 
180
  = 2.5.0 =
181
  * Use the new Twitter API with oAuth
182
  * Adds support for lists
4
  Tags: twitter, widget, feed
5
  Requires at least: 3.0
6
  Tested up to: 3.5
7
+ Stable tag: 2.5.1
8
 
9
  A widget that properly handles twitter feeds, including parsing @username, #hashtags, and URLs into links.
10
 
130
 
131
  == Upgrade Notice ==
132
 
133
+ = 2.5.1 =
134
+ Fix potential conflict with other oAuth plugins
135
+
136
  = 2.5.0 =
137
  Upgrade to the new Twitter API and add support for lists
138
 
180
 
181
  == Changelog ==
182
 
183
+ = 2.5.1 =
184
+ * Rename OAuthUtil class to twpOAuthUtil
185
+ * Don't use 'account/verify_credentials' as it has a very low limit
186
+
187
  = 2.5.0 =
188
  * Use the new Twitter API with oAuth
189
  * Adds support for lists
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.0
7
  * Author: Aaron D. Campbell
8
  * Author URI: http://ran.ge/
9
  * License: GPLv2 or later
@@ -30,7 +30,7 @@
30
 
31
  require_once( 'tlc-transients.php' );
32
  require_once( 'range-plugin-framework.php' );
33
- define( 'TWP_VERSION', '2.5.0' );
34
 
35
  /**
36
  * WP_Widget_Twitter_Pro is the class that handles the main widget.
@@ -404,9 +404,9 @@ class wpTwitterWidget extends RangePlugin {
404
  <?php
405
  foreach ( $this->_settings['twp-authed-users'] as $u ) {
406
  $this->_wp_twitter_oauth->set_token( $u );
407
- $user_info = $this->_wp_twitter_oauth->send_authed_request( 'account/verify_credentials', 'GET' );
408
  $style = $auth_link = '';
409
- if ( is_wp_error( $user_info ) ) {
410
  $query_args = array(
411
  'action' => 'authorize',
412
  'screen_name' => $u['screen_name'],
@@ -421,7 +421,6 @@ class wpTwitterWidget extends RangePlugin {
421
  <strong>@<?php echo esc_html( $u['screen_name'] ) . $auth_link; ?></strong>
422
  </th>
423
  <?php
424
- $rates = $this->_wp_twitter_oauth->send_authed_request( 'application/rate_limit_status', 'GET', array( 'resources' => 'statuses,lists' ) );
425
  if ( ! is_wp_error( $rates ) ) {
426
  $display_rates = array(
427
  __( 'Lists', $this->_slug ) => $rates->resources->lists->{'/lists/statuses'},
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.1
7
  * Author: Aaron D. Campbell
8
  * Author URI: http://ran.ge/
9
  * License: GPLv2 or later
30
 
31
  require_once( 'tlc-transients.php' );
32
  require_once( 'range-plugin-framework.php' );
33
+ define( 'TWP_VERSION', '2.5.1' );
34
 
35
  /**
36
  * WP_Widget_Twitter_Pro is the class that handles the main widget.
404
  <?php
405
  foreach ( $this->_settings['twp-authed-users'] as $u ) {
406
  $this->_wp_twitter_oauth->set_token( $u );
407
+ $rates = $this->_wp_twitter_oauth->send_authed_request( 'application/rate_limit_status', 'GET', array( 'resources' => 'statuses,lists' ) );
408
  $style = $auth_link = '';
409
+ if ( is_wp_error( $rates ) ) {
410
  $query_args = array(
411
  'action' => 'authorize',
412
  'screen_name' => $u['screen_name'],
421
  <strong>@<?php echo esc_html( $u['screen_name'] ) . $auth_link; ?></strong>
422
  </th>
423
  <?php
 
424
  if ( ! is_wp_error( $rates ) ) {
425
  $display_rates = array(
426
  __( 'Lists', $this->_slug ) => $rates->resources->lists->{'/lists/statuses'},