Twitter Widget Pro - Version 1.2.2

Version Description

Download this release

Release Info

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

Code changes from version 1.2.1 to 1.2.2

Files changed (3) hide show
  1. json_decode.php +1 -1
  2. readme.txt +1 -1
  3. wp-twitter-widget.php +25 -14
json_decode.php CHANGED
@@ -318,7 +318,7 @@ class Zend_Json_Decoder
318
  $result .= '\'';
319
  break;
320
  default:
321
- throw new Zend_Json_Exception("Illegal escape "
322
  . "sequence '" . $chr . "'");
323
  }
324
  } elseif ($chr == '"') {
318
  $result .= '\'';
319
  break;
320
  default:
321
+ throw new Exception("Illegal escape "
322
  . "sequence '" . $chr . "'");
323
  }
324
  } elseif ($chr == '"') {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal%4
4
  Tags: twitter, widget, feed
5
  Requires at least: 2.5
6
  Tested up to: 2.5.1
7
- Stable tag: 1.2.1
8
 
9
  A widget that properly handles twitter feeds, including parsing @username and URLs into links. Requires PHP5.
10
 
4
  Tags: twitter, widget, feed
5
  Requires at least: 2.5
6
  Tested up to: 2.5.1
7
+ Stable tag: 1.2.2
8
 
9
  A widget that properly handles twitter feeds, including parsing @username and URLs into links. Requires PHP5.
10
 
wp-twitter-widget.php CHANGED
@@ -3,16 +3,20 @@
3
  * Plugin Name: Twitter Widget Pro
4
  * Plugin URI: http://xavisys.com/wordpress-twitter-widget/
5
  * Description: A widget that properly handles twitter feeds, including @username and link parsing, and can even display profile images for the users. Requires PHP5.
6
- * Version: 1.2.1
7
  * Author: Aaron D. Campbell
8
  * Author URI: http://xavisys.com/
9
  */
10
 
11
- define('TWP_VERSION', '1.2.1');
12
 
13
  /**
14
  * Changelog:
15
- * 06/09/2008: 1.2.0
 
 
 
 
16
  * - Fixed some minor errors in the collection code
17
  * - Added the admin options page (how did that get missed?!?)
18
  *
@@ -163,7 +167,7 @@ class wpTwitterWidget
163
  */
164
  private function _parseFeed($widgetOptions) {
165
  $feedUrl = $this->_getFeedUrl($widgetOptions);
166
- $resp = $this->_fetch_remote_file($feedUrl);
167
  if ( $resp->status >= 200 && $resp->status < 300 ) {
168
  if (function_exists('json_decode')) {
169
  return json_decode($resp->results);
@@ -248,12 +252,13 @@ class wpTwitterWidget
248
  * @param array $headers - Raw headers to pass
249
  * @return Snoopy
250
  */
251
- private function _fetch_remote_file ($url, $headers = "" ) {
 
252
  require_once( ABSPATH . 'wp-includes/class-snoopy.php' );
253
  // Snoopy is an HTTP client in PHP
254
  $client = new Snoopy();
255
  $client->agent = $this->userAgent;
256
- $client->read_timeout = $this->fetchTimeOut;
257
  $client->use_gzip = $this->useGzip;
258
  if (is_array($headers) ) {
259
  $client->rawheaders = $headers;
@@ -472,6 +477,7 @@ profileImage;
472
  $options[$number]['number'] = $number;
473
  $options[$number]['title'] = attribute_escape($options[$number]['title']);
474
  $options[$number]['errmsg'] = attribute_escape($options[$number]['errmsg']);
 
475
  $options[$number]['username'] = attribute_escape($options[$number]['username']);
476
  $options[$number]['hiderss'] = (bool) $options[$number]['hiderss'];
477
  $options[$number]['avatar'] = (bool) $options[$number]['avatar'];
@@ -516,14 +522,15 @@ profileImage;
516
  */
517
  private function _showForm($args) {
518
 
519
- $defaultArgs = array( 'title' => '',
520
- 'errmsg' => '',
521
- 'username' => '',
522
- 'hiderss' => false,
523
- 'avatar' => false,
524
- 'items' => 10,
525
- 'showts' => 60 * 60 * 24,
526
- 'number' => '%i%' );
 
527
  $args = wp_parse_args( $args, $defaultArgs );
528
  extract( $args );
529
  ?>
@@ -549,6 +556,10 @@ profileImage;
549
  <label for="twitter-errmsg-<?php echo $number; ?>"><?php _e('What to display when Twitter is down (optional):'); ?></label>
550
  <input class="widefat" id="twitter-errmsg-<?php echo $number; ?>" name="widget-twitter[<?php echo $number; ?>][errmsg]" type="text" value="<?php echo $errmsg; ?>" />
551
  </p>
 
 
 
 
552
  <p>
553
  <label for="twitter-showts-<?php echo $number; ?>"><?php _e('Show date/time of Tweet (rather than 2 ____ ago):'); ?></label>
554
  <select id="twitter-showts-<?php echo $number; ?>" name="widget-twitter[<?php echo $number; ?>][showts]">
3
  * Plugin Name: Twitter Widget Pro
4
  * Plugin URI: http://xavisys.com/wordpress-twitter-widget/
5
  * Description: A widget that properly handles twitter feeds, including @username and link parsing, and can even display profile images for the users. Requires PHP5.
6
+ * Version: 1.2.2
7
  * Author: Aaron D. Campbell
8
  * Author URI: http://xavisys.com/
9
  */
10
 
11
+ define('TWP_VERSION', '1.2.2');
12
 
13
  /**
14
  * Changelog:
15
+ * 06/09/2008: 1.2.2
16
+ * - Fixed minor issue with Zend JSON Decoder
17
+ * - Added an option for Twitter timeout. 2 seconds wasn't enough for some people
18
+ *
19
+ * 06/09/2008: 1.2.1
20
  * - Fixed some minor errors in the collection code
21
  * - Added the admin options page (how did that get missed?!?)
22
  *
167
  */
168
  private function _parseFeed($widgetOptions) {
169
  $feedUrl = $this->_getFeedUrl($widgetOptions);
170
+ $resp = $this->_fetch_remote_file($feedUrl, $widgetOptions['fetchTimeOut']);
171
  if ( $resp->status >= 200 && $resp->status < 300 ) {
172
  if (function_exists('json_decode')) {
173
  return json_decode($resp->results);
252
  * @param array $headers - Raw headers to pass
253
  * @return Snoopy
254
  */
255
+ private function _fetch_remote_file ($url, $timeout = 2, $headers = "" ) {
256
+ $timeout = (!empty($timeout))? (int) $timeout : 2;
257
  require_once( ABSPATH . 'wp-includes/class-snoopy.php' );
258
  // Snoopy is an HTTP client in PHP
259
  $client = new Snoopy();
260
  $client->agent = $this->userAgent;
261
+ $client->read_timeout = $timeout;
262
  $client->use_gzip = $this->useGzip;
263
  if (is_array($headers) ) {
264
  $client->rawheaders = $headers;
477
  $options[$number]['number'] = $number;
478
  $options[$number]['title'] = attribute_escape($options[$number]['title']);
479
  $options[$number]['errmsg'] = attribute_escape($options[$number]['errmsg']);
480
+ $options[$number]['fetchTimeOut'] = attribute_escape($options[$number]['fetchTimeOut']);
481
  $options[$number]['username'] = attribute_escape($options[$number]['username']);
482
  $options[$number]['hiderss'] = (bool) $options[$number]['hiderss'];
483
  $options[$number]['avatar'] = (bool) $options[$number]['avatar'];
522
  */
523
  private function _showForm($args) {
524
 
525
+ $defaultArgs = array( 'title' => '',
526
+ 'errmsg' => '',
527
+ 'fetchTimeOut' => '2',
528
+ 'username' => '',
529
+ 'hiderss' => false,
530
+ 'avatar' => false,
531
+ 'items' => 10,
532
+ 'showts' => 60 * 60 * 24,
533
+ 'number' => '%i%' );
534
  $args = wp_parse_args( $args, $defaultArgs );
535
  extract( $args );
536
  ?>
556
  <label for="twitter-errmsg-<?php echo $number; ?>"><?php _e('What to display when Twitter is down (optional):'); ?></label>
557
  <input class="widefat" id="twitter-errmsg-<?php echo $number; ?>" name="widget-twitter[<?php echo $number; ?>][errmsg]" type="text" value="<?php echo $errmsg; ?>" />
558
  </p>
559
+ <p>
560
+ <label for="twitter-fetchTimeOut-<?php echo $number; ?>"><?php _e('Number of seconds to wait for a response from Twitter (default 2):'); ?></label>
561
+ <input class="widefat" id="twitter-fetchTimeOut-<?php echo $number; ?>" name="widget-twitter[<?php echo $number; ?>][fetchTimeOut]" type="text" value="<?php echo $fetchTimeOut; ?>" />
562
+ </p>
563
  <p>
564
  <label for="twitter-showts-<?php echo $number; ?>"><?php _e('Show date/time of Tweet (rather than 2 ____ ago):'); ?></label>
565
  <select id="twitter-showts-<?php echo $number; ?>" name="widget-twitter[<?php echo $number; ?>][showts]">