Twitter Widget Pro - Version 2.2.4

Version Description

Uses new API urls, new "hide replies" support in the API, can show retweets, supports multiple profile image sizes

Download this release

Release Info

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

Code changes from version 2.2.3 to 2.2.4

Files changed (2) hide show
  1. readme.txt +10 -1
  2. wp-twitter-widget.php +123 -55
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: 3.0
6
  Tested up to: 3.2.1
7
- Stable tag: 2.2.3
8
 
9
  A widget that properly handles twitter feeds, including parsing @username, #hashtags, and URLs into links. Requires PHP5.
10
 
@@ -81,6 +81,9 @@ Aparently the database queries required to display the friends feed was causing
81
 
82
  == Upgrade Notice ==
83
 
 
 
 
84
  = 2.2.3 =
85
  Fixes links on 32 bit servers. If you are suffering from this I would recommend changing hosts (or talking to yours).
86
 
@@ -92,6 +95,12 @@ Better SEO by adding the ability to remove the "from" links - Thanks <a href="ht
92
 
93
  == Changelog ==
94
 
 
 
 
 
 
 
95
  = 2.2.3 =
96
  * The Twitter-pocolypse hit a while back but since so many servers are 64 bit it wasn't an issue. This fixes links for users on 32 bit servers.
97
  * Fix some notices thrown by translated strings
4
  Tags: twitter, widget, feed
5
  Requires at least: 3.0
6
  Tested up to: 3.2.1
7
+ Stable tag: 2.2.4
8
 
9
  A widget that properly handles twitter feeds, including parsing @username, #hashtags, and URLs into links. Requires PHP5.
10
 
81
 
82
  == Upgrade Notice ==
83
 
84
+ = 2.2.4 =
85
+ Uses new API urls, new "hide replies" support in the API, can show retweets, supports multiple profile image sizes
86
+
87
  = 2.2.3 =
88
  Fixes links on 32 bit servers. If you are suffering from this I would recommend changing hosts (or talking to yours).
89
 
95
 
96
  == Changelog ==
97
 
98
+ = 2.2.4 =
99
+ * Use the new API URLs
100
+ * Use the new "hide replies" option in the Twitter API
101
+ * Add support to show retweets
102
+ * Add support for multiple profile image sizes
103
+
104
  = 2.2.3 =
105
  * The Twitter-pocolypse hit a while back but since so many servers are 64 bit it wasn't an issue. This fixes links for users on 32 bit servers.
106
  * Fix some notices thrown by translated strings
wp-twitter-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Twitter Widget Pro
4
  * Plugin URI: http://xavisys.com/wordpress-plugins/wordpress-twitter-widget/
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.2.3
7
  * Author: Aaron D. Campbell
8
  * Author URI: http://xavisys.com/
9
  * License: GPLv2 or later
@@ -79,6 +79,20 @@ class WP_Widget_Twitter_Pro extends WP_Widget {
79
  ?>
80
  </select>
81
  </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  <p>
83
  <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'hidereplies' ); ?>" name="<?php echo $this->get_field_name( 'hidereplies' ); ?>"<?php checked( $instance['hidereplies'], 'true' ); ?> />
84
  <label for="<?php echo $this->get_field_id( 'hidereplies' ); ?>"><?php _e( 'Hide @replies', $this->_slug ); ?></label>
@@ -119,10 +133,6 @@ class WP_Widget_Twitter_Pro extends WP_Widget {
119
  <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'targetBlank' ); ?>" name="<?php echo $this->get_field_name( 'targetBlank' ); ?>"<?php checked( $instance['targetBlank'], 'true' ); ?> />
120
  <label for="<?php echo $this->get_field_id( 'targetBlank' ); ?>"><?php _e( 'Open links in a new window', $this->_slug ); ?></label>
121
  </p>
122
- <p>
123
- <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'avatar' ); ?>" name="<?php echo $this->get_field_name( 'avatar' ); ?>"<?php checked( $instance['avatar'], 'true' ); ?> />
124
- <label for="<?php echo $this->get_field_id( 'avatar' ); ?>"><?php _e( 'Show Profile Image', $this->_slug ); ?></label>
125
- </p>
126
  <p>
127
  <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'showXavisysLink' ); ?>" name="<?php echo $this->get_field_name( 'showXavisysLink' ); ?>"<?php checked( $instance['showXavisysLink'], 'true' ); ?> />
128
  <label for="<?php echo $this->get_field_id( 'showXavisysLink' ); ?>"><?php _e( 'Show Link to Twitter Widget Pro', $this->_slug ); ?></label>
@@ -166,6 +176,8 @@ class WP_Widget_Twitter_Pro extends WP_Widget {
166
  * It also helps us avoid name collisions.
167
  */
168
  class wpTwitterWidget extends XavisysPlugin {
 
 
169
  /**
170
  * @var wpTwitterWidget - Static property to hold our singleton instance
171
  */
@@ -246,6 +258,20 @@ class wpTwitterWidget extends XavisysPlugin {
246
  </select>
247
  </td>
248
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  <tr valign="top">
250
  <th scope="row">
251
  <label for="twp_errmsg"><?php _e( 'What to display when Twitter is down ( optional ):', $this->_slug ); ?></label>
@@ -291,6 +317,9 @@ class wpTwitterWidget extends XavisysPlugin {
291
  <?php _e( "Other Setting:", $this->_slug );?>
292
  </th>
293
  <td>
 
 
 
294
  <input class="checkbox" type="checkbox" value="true" id="twp_hidereplies" name="twp[hidereplies]"<?php checked( $this->_settings['twp']['hidereplies'], 'true' ); ?> />
295
  <label for="twp_hidereplies"><?php _e( 'Hide @replies', $this->_slug ); ?></label>
296
  <br />
@@ -303,9 +332,6 @@ class wpTwitterWidget extends XavisysPlugin {
303
  <input class="checkbox" type="checkbox" value="true" id="twp_targetBlank" name="twp[targetBlank]"<?php checked( $this->_settings['twp']['targetBlank'], 'true' ); ?> />
304
  <label for="twp_targetBlank"><?php _e( 'Open links in a new window', $this->_slug ); ?></label>
305
  <br />
306
- <input class="checkbox" type="checkbox" value="true" id="twp_avatar" name="twp[avatar]"<?php checked( $this->_settings['twp']['avatar'], 'true' ); ?> />
307
- <label for="twp_avatar"><?php _e( 'Show Profile Image', $this->_slug ); ?></label>
308
- <br />
309
  <input class="checkbox" type="checkbox" value="true" id="twp_showXavisysLink" name="twp[showXavisysLink]"<?php checked( $this->_settings['twp']['showXavisysLink'], 'true' ); ?> />
310
  <label for="twp_showXavisysLink"><?php _e( 'Show Link to Twitter Widget Pro', $this->_slug ); ?></label>
311
  </td>
@@ -482,9 +508,9 @@ class wpTwitterWidget extends XavisysPlugin {
482
  );
483
  $args['title'] = $this->_buildLink( $args['title'], $linkAttrs, current_user_can( 'unfiltered_html' ) );
484
  $widgetContent .= $args['before_title'] . $args['title'] . $args['after_title'];
485
- if ( !is_a( $tweets, 'wpTwitterWidgetException' ) && !empty( $tweets[0] ) && $args['avatar'] == 'true' ) {
486
  $widgetContent .= '<div class="twitter-avatar">';
487
- $widgetContent .= $this->_getProfileImage( $tweets[0]->user );
488
  $widgetContent .= '</div>';
489
  }
490
  $widgetContent .= '<ul>';
@@ -495,37 +521,35 @@ class wpTwitterWidget extends XavisysPlugin {
495
  } else {
496
  $count = 0;
497
  foreach ( $tweets as $tweet ) {
498
- if ( $args['hidereplies'] != 'true' || empty( $tweet->in_reply_to_user_id_str ) ) {
499
- // Set our "ago" string which converts the date to "# ___(s) ago"
500
- $tweet->ago = $this->_timeSince( strtotime( $tweet->created_at ), $args['showts'], $args['dateFormat'] );
501
- $entryContent = apply_filters( 'widget_twitter_content', $tweet->text );
502
- $from = sprintf( __( 'from %s', $this->_slug ), str_replace( '&', '&amp;', $tweet->source ) );
503
- $widgetContent .= '<li>';
504
- $widgetContent .= "<span class='entry-content'>{$entryContent}</span>";
505
- $widgetContent .= " <span class='entry-meta'>";
506
- $widgetContent .= "<span class='time-meta'>";
 
 
 
 
 
 
 
 
 
507
  $linkAttrs = array(
508
- 'href' => "http://twitter.com/{$tweet->user->screen_name}/statuses/{$tweet->id_str}"
 
509
  );
510
- $widgetContent .= $this->_buildLink( $tweet->ago, $linkAttrs );
511
  $widgetContent .= '</span>';
512
- if ( 'true' != $args['hidefrom'] )
513
- $widgetContent .= " <span class='from-meta'>{$from}</span>";
514
- if ( !empty( $tweet->in_reply_to_screen_name ) ) {
515
- $rtLinkText = sprintf( __( 'in reply to %s', $this->_slug ), $tweet->in_reply_to_screen_name );
516
- $widgetContent .= ' <span class="in-reply-to-meta">';
517
- $linkAttrs = array(
518
- 'href' => "http://twitter.com/{$tweet->in_reply_to_screen_name}/statuses/{$tweet->in_reply_to_status_id_str}",
519
- 'class' => 'reply-to'
520
- );
521
- $widgetContent .= $this->_buildLink( $rtLinkText, $linkAttrs );
522
- $widgetContent .= '</span>';
523
- }
524
- $widgetContent .= '</span></li>';
525
-
526
- if ( ++$count >= $args['items'] ) {
527
- break;
528
- }
529
  }
530
  }
531
  }
@@ -609,20 +633,40 @@ class wpTwitterWidget extends XavisysPlugin {
609
  if ( !in_array( $type, array( 'rss', 'json' ) ) ) {
610
  $type = 'json';
611
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
612
  if ( $count ) {
613
- $num = ( $widgetOptions['hidereplies'] )? 100:$widgetOptions['items'];
614
- $count = sprintf( '?count=%u', $num );
615
- } else {
616
- $count = '';
 
 
 
617
  }
618
- return sprintf( 'http://twitter.com/statuses/user_timeline/%1$s.%2$s%3$s', $widgetOptions['username'], $type, $count );
619
  }
620
 
621
  /**
622
- * Twitter displays all tweets that are less than 24 with something like
623
- * "about 4 hours ago" and ones older than 24 hours with a time and date.
624
- * This function allows us to simulate that functionality, but lets us
625
- * choose where the dividing line is.
626
  *
627
  * @param int $startTimestamp - The timestamp used to calculate time passed
628
  * @param int $max - Max number of seconds to conver to "ago" messages. 0 for all, -1 for none
@@ -670,14 +714,19 @@ class wpTwitterWidget extends XavisysPlugin {
670
  * Returns the Twitter user's profile image, linked to that user's profile
671
  *
672
  * @param object $user - Twitter User
 
673
  * @return string - Linked image ( XHTML )
674
  */
675
- private function _getProfileImage( $user ) {
676
  $linkAttrs = array(
677
  'href' => "http://twitter.com/{$user->screen_name}",
678
  'title' => $user->name
679
  );
680
- return $this->_buildLink( "<img alt='{$user->name}' src='{$user->profile_image_url}' />", $linkAttrs, true );
 
 
 
 
681
  }
682
 
683
  /**
@@ -699,8 +748,9 @@ class wpTwitterWidget extends XavisysPlugin {
699
  'username' => '',
700
  'hiderss' => false,
701
  'hidereplies' => false,
 
702
  'hidefrom' => false,
703
- 'avatar' => false,
704
  'showXavisysLink' => false,
705
  'targetBlank' => false,
706
  'items' => 10,
@@ -741,11 +791,14 @@ class wpTwitterWidget extends XavisysPlugin {
741
  if ( $attr['hidereplies'] && $attr['hidereplies'] != 'false' && $attr['hidereplies'] != '0' ) {
742
  $attr['hidereplies'] == true;
743
  }
 
 
 
744
  if ( $attr['hidefrom'] && $attr['hidefrom'] != 'false' && $attr['hidefrom'] != '0' ) {
745
  $attr['hidefrom'] == true;
746
  }
747
- if ( $attr['avatar'] && $attr['avatar'] != 'false' && $attr['avatar'] != '0' ) {
748
- $attr['avatar'] == true;
749
  }
750
  if ( $attr['showXavisysLink'] && $attr['showXavisysLink'] != 'false' && $attr['showXavisysLink'] != '0' ) {
751
  $attr['showXavisysLink'] == true;
@@ -765,8 +818,9 @@ class wpTwitterWidget extends XavisysPlugin {
765
  'username' => '',
766
  'hiderss' => false,
767
  'hidereplies' => false,
 
768
  'hidefrom' => false,
769
- 'avatar' => false,
770
  'showXavisysLink' => false,
771
  'targetBlank' => false,
772
  'items' => 10,
@@ -774,11 +828,25 @@ class wpTwitterWidget extends XavisysPlugin {
774
  'dateFormat' => __( 'h:i:s A F d, Y', $this->_slug ),
775
  );
776
 
777
- return wp_parse_args( $settings, $defaultArgs );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
778
  }
779
 
780
  public function getSettings( $settings ) {
781
- return wp_parse_args( $settings, $this->_settings['twp'] );
782
  }
783
  }
784
  // Instantiate our class
3
  * Plugin Name: Twitter Widget Pro
4
  * Plugin URI: http://xavisys.com/wordpress-plugins/wordpress-twitter-widget/
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.2.4
7
  * Author: Aaron D. Campbell
8
  * Author URI: http://xavisys.com/
9
  * License: GPLv2 or later
79
  ?>
80
  </select>
81
  </p>
82
+ <p>
83
+ <label for="<?php echo $this->get_field_id( 'avatar' ); ?>"><?php _e( 'Display profile image?', $this->_slug ); ?></label>
84
+ <select id="<?php echo $this->get_field_id( 'avatar' ); ?>" name="<?php echo $this->get_field_name( 'avatar' ); ?>">
85
+ <option value=""<?php selected( $instance['avatar'], '' ) ?>>Do not show</option>
86
+ <option value=""<?php selected( $instance['avatar'], 'mini' ) ?>>Mini - 24px by 24px</option>
87
+ <option value=""<?php selected( $instance['avatar'], 'normal' ) ?>>Normal - 48px by 48px</option>
88
+ <option value=""<?php selected( $instance['avatar'], 'bigger' ) ?>>Bigger - 73px by 73px</option>
89
+ <option value=""<?php selected( $instance['avatar'], 'original' ) ?>>Original</option>
90
+ </select>
91
+ </p>
92
+ <p>
93
+ <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'showretweets' ); ?>" name="<?php echo $this->get_field_name( 'showretweets' ); ?>"<?php checked( $instance['showretweets'], 'true' ); ?> />
94
+ <label for="<?php echo $this->get_field_id( 'showretweets' ); ?>"><?php _e( 'Include retweets', $this->_slug ); ?></label>
95
+ </p>
96
  <p>
97
  <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'hidereplies' ); ?>" name="<?php echo $this->get_field_name( 'hidereplies' ); ?>"<?php checked( $instance['hidereplies'], 'true' ); ?> />
98
  <label for="<?php echo $this->get_field_id( 'hidereplies' ); ?>"><?php _e( 'Hide @replies', $this->_slug ); ?></label>
133
  <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'targetBlank' ); ?>" name="<?php echo $this->get_field_name( 'targetBlank' ); ?>"<?php checked( $instance['targetBlank'], 'true' ); ?> />
134
  <label for="<?php echo $this->get_field_id( 'targetBlank' ); ?>"><?php _e( 'Open links in a new window', $this->_slug ); ?></label>
135
  </p>
 
 
 
 
136
  <p>
137
  <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'showXavisysLink' ); ?>" name="<?php echo $this->get_field_name( 'showXavisysLink' ); ?>"<?php checked( $instance['showXavisysLink'], 'true' ); ?> />
138
  <label for="<?php echo $this->get_field_id( 'showXavisysLink' ); ?>"><?php _e( 'Show Link to Twitter Widget Pro', $this->_slug ); ?></label>
176
  * It also helps us avoid name collisions.
177
  */
178
  class wpTwitterWidget extends XavisysPlugin {
179
+ private $_api_url = 'https://api.twitter.com/1/';
180
+
181
  /**
182
  * @var wpTwitterWidget - Static property to hold our singleton instance
183
  */
258
  </select>
259
  </td>
260
  </tr>
261
+ <tr valign="top">
262
+ <th scope="row">
263
+ <label for="twp_avatar"><?php _e( 'Display profile image?', $this->_slug ); ?></label>
264
+ </th>
265
+ <td>
266
+ <select id="twp_avatar" name="twp[avatar]">
267
+ <option value=""<?php selected( $this->_settings['twp']['avatar'], '' ) ?>>Do not show</option>
268
+ <option value=""<?php selected( $this->_settings['twp']['avatar'], 'mini' ) ?>>Mini - 24px by 24px</option>
269
+ <option value=""<?php selected( $this->_settings['twp']['avatar'], 'normal' ) ?>>Normal - 48px by 48px</option>
270
+ <option value=""<?php selected( $this->_settings['twp']['avatar'], 'bigger' ) ?>>Bigger - 73px by 73px</option>
271
+ <option value=""<?php selected( $this->_settings['twp']['avatar'], 'original' ) ?>>Original</option>
272
+ </select>
273
+ </td>
274
+ </tr>
275
  <tr valign="top">
276
  <th scope="row">
277
  <label for="twp_errmsg"><?php _e( 'What to display when Twitter is down ( optional ):', $this->_slug ); ?></label>
317
  <?php _e( "Other Setting:", $this->_slug );?>
318
  </th>
319
  <td>
320
+ <input class="checkbox" type="checkbox" value="true" id="twp_showretweets" name="twp[showretweets]"<?php checked( $this->_settings['twp']['showretweets'], 'true' ); ?> />
321
+ <label for="twp_showretweets"><?php _e( 'Include retweets', $this->_slug ); ?></label>
322
+ <br />
323
  <input class="checkbox" type="checkbox" value="true" id="twp_hidereplies" name="twp[hidereplies]"<?php checked( $this->_settings['twp']['hidereplies'], 'true' ); ?> />
324
  <label for="twp_hidereplies"><?php _e( 'Hide @replies', $this->_slug ); ?></label>
325
  <br />
332
  <input class="checkbox" type="checkbox" value="true" id="twp_targetBlank" name="twp[targetBlank]"<?php checked( $this->_settings['twp']['targetBlank'], 'true' ); ?> />
333
  <label for="twp_targetBlank"><?php _e( 'Open links in a new window', $this->_slug ); ?></label>
334
  <br />
 
 
 
335
  <input class="checkbox" type="checkbox" value="true" id="twp_showXavisysLink" name="twp[showXavisysLink]"<?php checked( $this->_settings['twp']['showXavisysLink'], 'true' ); ?> />
336
  <label for="twp_showXavisysLink"><?php _e( 'Show Link to Twitter Widget Pro', $this->_slug ); ?></label>
337
  </td>
508
  );
509
  $args['title'] = $this->_buildLink( $args['title'], $linkAttrs, current_user_can( 'unfiltered_html' ) );
510
  $widgetContent .= $args['before_title'] . $args['title'] . $args['after_title'];
511
+ if ( !is_a( $tweets, 'wpTwitterWidgetException' ) && !empty( $tweets[0] ) && !empty( $args['avatar'] ) ) {
512
  $widgetContent .= '<div class="twitter-avatar">';
513
+ $widgetContent .= $this->_getProfileImage( $tweets[0]->user, $args );
514
  $widgetContent .= '</div>';
515
  }
516
  $widgetContent .= '<ul>';
521
  } else {
522
  $count = 0;
523
  foreach ( $tweets as $tweet ) {
524
+ // Set our "ago" string which converts the date to "# ___(s) ago"
525
+ $tweet->ago = $this->_timeSince( strtotime( $tweet->created_at ), $args['showts'], $args['dateFormat'] );
526
+ $entryContent = apply_filters( 'widget_twitter_content', $tweet->text );
527
+ $from = sprintf( __( 'from %s', $this->_slug ), str_replace( '&', '&amp;', $tweet->source ) );
528
+ $widgetContent .= '<li>';
529
+ $widgetContent .= "<span class='entry-content'>{$entryContent}</span>";
530
+ $widgetContent .= " <span class='entry-meta'>";
531
+ $widgetContent .= "<span class='time-meta'>";
532
+ $linkAttrs = array(
533
+ 'href' => "http://twitter.com/{$tweet->user->screen_name}/statuses/{$tweet->id_str}"
534
+ );
535
+ $widgetContent .= $this->_buildLink( $tweet->ago, $linkAttrs );
536
+ $widgetContent .= '</span>';
537
+ if ( 'true' != $args['hidefrom'] )
538
+ $widgetContent .= " <span class='from-meta'>{$from}</span>";
539
+ if ( !empty( $tweet->in_reply_to_screen_name ) ) {
540
+ $rtLinkText = sprintf( __( 'in reply to %s', $this->_slug ), $tweet->in_reply_to_screen_name );
541
+ $widgetContent .= ' <span class="in-reply-to-meta">';
542
  $linkAttrs = array(
543
+ 'href' => "http://twitter.com/{$tweet->in_reply_to_screen_name}/statuses/{$tweet->in_reply_to_status_id_str}",
544
+ 'class' => 'reply-to'
545
  );
546
+ $widgetContent .= $this->_buildLink( $rtLinkText, $linkAttrs );
547
  $widgetContent .= '</span>';
548
+ }
549
+ $widgetContent .= '</span></li>';
550
+
551
+ if ( ++$count >= $args['items'] ) {
552
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
553
  }
554
  }
555
  }
633
  if ( !in_array( $type, array( 'rss', 'json' ) ) ) {
634
  $type = 'json';
635
  }
636
+ $req = $this->_api_url . "statuses/user_timeline.{$type}";
637
+
638
+ /**
639
+ * user_id
640
+ * screen_name *
641
+ * since_id
642
+ * count
643
+ * max_id
644
+ * page
645
+ * trim_user
646
+ * include_rts *
647
+ * include_entities
648
+ * exclude_replies *
649
+ * contributor_details
650
+ */
651
+
652
+ $req = add_query_arg( array( 'screen_name' => $widgetOptions['username'] ), $req );
653
  if ( $count ) {
654
+ $req = add_query_arg( array( 'count' => $widgetOptions['items'] ), $req );
655
+ }
656
+ if ( $widgetOptions['hidereplies'] ) {
657
+ $req = add_query_arg( array( 'exclude_replies' => 'true' ), $req );
658
+ }
659
+ if ( $widgetOptions['showretweets'] ) {
660
+ $req = add_query_arg( array( 'include_rts' => 'true' ), $req );
661
  }
662
+ return $req;
663
  }
664
 
665
  /**
666
+ * Twitter displays all tweets that are less than 24 hours old with
667
+ * something like "about 4 hours ago" and ones older than 24 hours with a
668
+ * time and date. This function allows us to simulate that functionality,
669
+ * but lets us choose where the dividing line is.
670
  *
671
  * @param int $startTimestamp - The timestamp used to calculate time passed
672
  * @param int $max - Max number of seconds to conver to "ago" messages. 0 for all, -1 for none
714
  * Returns the Twitter user's profile image, linked to that user's profile
715
  *
716
  * @param object $user - Twitter User
717
+ * @param array $args - Widget Arguments
718
  * @return string - Linked image ( XHTML )
719
  */
720
+ private function _getProfileImage( $user, $args = array() ) {
721
  $linkAttrs = array(
722
  'href' => "http://twitter.com/{$user->screen_name}",
723
  'title' => $user->name
724
  );
725
+ $img = $this->_api_url . 'users/profile_image';
726
+ $img = add_query_arg( array( 'screen_name' => $user->screen_name ), $img );
727
+ $img = add_query_arg( array( 'size' => $args['avatar'] ), $img );
728
+
729
+ return $this->_buildLink( "<img alt='{$user->name}' src='{$img}' />", $linkAttrs, true );
730
  }
731
 
732
  /**
748
  'username' => '',
749
  'hiderss' => false,
750
  'hidereplies' => false,
751
+ 'showretweets' => true,
752
  'hidefrom' => false,
753
+ 'avatar' => '',
754
  'showXavisysLink' => false,
755
  'targetBlank' => false,
756
  'items' => 10,
791
  if ( $attr['hidereplies'] && $attr['hidereplies'] != 'false' && $attr['hidereplies'] != '0' ) {
792
  $attr['hidereplies'] == true;
793
  }
794
+ if ( $attr['showretweets'] && $attr['showretweets'] != 'false' && $attr['showretweets'] != '0' ) {
795
+ $attr['showretweets'] == true;
796
+ }
797
  if ( $attr['hidefrom'] && $attr['hidefrom'] != 'false' && $attr['hidefrom'] != '0' ) {
798
  $attr['hidefrom'] == true;
799
  }
800
+ if ( !in_array( $attr['avatar'], array( 'bigger', 'normal', 'mini', 'original', '' ) ) ) {
801
+ $attr['avatar'] = 'normal';
802
  }
803
  if ( $attr['showXavisysLink'] && $attr['showXavisysLink'] != 'false' && $attr['showXavisysLink'] != '0' ) {
804
  $attr['showXavisysLink'] == true;
818
  'username' => '',
819
  'hiderss' => false,
820
  'hidereplies' => false,
821
+ 'showretweets' => true,
822
  'hidefrom' => false,
823
+ 'avatar' => '',
824
  'showXavisysLink' => false,
825
  'targetBlank' => false,
826
  'items' => 10,
828
  'dateFormat' => __( 'h:i:s A F d, Y', $this->_slug ),
829
  );
830
 
831
+ return $this->fixAvatar( wp_parse_args( $settings, $defaultArgs ) );
832
+ }
833
+
834
+ /**
835
+ * Now that we support all the profile image sizes we need to convert
836
+ * the old true/false to a size string
837
+ */
838
+ private function fixAvatar( $settings ) {
839
+ if ( false === $settings['avatar'] ) {
840
+ $settings['avatar'] = '';
841
+ } elseif ( !in_array( $settings['avatar'], array( 'bigger', 'normal', 'mini', 'original', false ) ) ) {
842
+ $settings['avatar'] = 'normal';
843
+ }
844
+
845
+ return $settings;
846
  }
847
 
848
  public function getSettings( $settings ) {
849
+ return $this->fixAvatar( wp_parse_args( $settings, $this->_settings['twp'] ) );
850
  }
851
  }
852
  // Instantiate our class