Simple Twitter Tweets - Version 1.3

Version Description

Added * Hash Tag linking and ReTweet @names linking * Name reference added to hover state attribute for date link Screen Names - better than username reference

Updated * Updated depricated functions to ensure future compatibility * Rewrote link creation for URLs in tweets

Fixed * Fixed screen name reference for Twitter date links

Download this release

Release Info

Developer Planet Interactive
Plugin Icon 128x128 Simple Twitter Tweets
Version 1.3
Comparing to
See all releases

Code changes from version 1.2.1 to 1.3

Files changed (2) hide show
  1. README.txt +15 -3
  2. simple-twitter-tweets.php +23 -15
README.txt CHANGED
@@ -4,7 +4,7 @@ Donate: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A94
4
  Tags: Twitter, Stream, Tweets, Twitter OAuth, social
5
  Requires at least: 3.0
6
  Tested up to: 3.5.2
7
- Stable tag: 1.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -115,6 +115,18 @@ As far as we know it just works! Phew, but if you have an issue or you want to p
115
 
116
  == Changelog ==
117
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  = 1.2 =
119
  * Added Twitter name reference enabling database backup for multiple account use
120
  * Added Twitter Follow Button and configuration options
@@ -128,5 +140,5 @@ As far as we know it just works! Phew, but if you have an issue or you want to p
128
 
129
  == Upgrade Notice ==
130
 
131
- = 1.2 =
132
- Multiple account use enabled, "Twitter Follow Button" added with display options.
4
  Tags: Twitter, Stream, Tweets, Twitter OAuth, social
5
  Requires at least: 3.0
6
  Tested up to: 3.5.2
7
+ Stable tag: 1.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
115
 
116
  == Changelog ==
117
 
118
+ = 1.3 =
119
+ Added
120
+ * Hash Tag linking and ReTweet @names linking
121
+ * Name reference added to hover state attribute for date link Screen Names - better than username reference
122
+
123
+ Updated
124
+ * Updated depricated functions to ensure future compatibility
125
+ * Rewrote link creation for URLs in tweets
126
+
127
+ Fixed
128
+ * Fixed screen name reference for Twitter date links
129
+
130
  = 1.2 =
131
  * Added Twitter name reference enabling database backup for multiple account use
132
  * Added Twitter Follow Button and configuration options
140
 
141
  == Upgrade Notice ==
142
 
143
+ = 1.3 =
144
+ Fixed screen name reference in links, NEW Hash Tag and Twitter Name linking, link creation rewritten and more.
simple-twitter-tweets.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Simple Twitter Tweets
4
  Plugin URI: http://www.planet-interactive.co.uk/simple-twitter-tweets
5
  Description: Display last x number tweets from Twitter API stream, store locally in dataabse to present past tweets when failure to access Twitters restrictive API occurs
6
  Author: Ashley Sheinwald
7
- Version: 1.2.1
8
  Author URI: http://www.planet-interactive.co.uk/
9
  */
10
 
@@ -80,28 +80,28 @@ class PI_SimpleTwitterTweets extends WP_Widget{
80
  $dataLang = $instance['dataLang'];
81
  ?>
82
  <p>
83
- <label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label>
84
  </p>
85
  <p>
86
- <label for="<?php echo $this->get_field_id('name'); ?>">Twitter Name (without @ symbol): <input class="widefat" id="<?php echo $this->get_field_id('name'); ?>" name="<?php echo $this->get_field_name('name'); ?>" type="text" value="<?php echo attribute_escape($name); ?>" /></label>
87
  </p>
88
  <p>
89
- <label for="<?php echo $this->get_field_id('numTweets'); ?>">Number of Tweets: <input class="widefat" id="<?php echo $this->get_field_id('numTweets'); ?>" name="<?php echo $this->get_field_name('numTweets'); ?>" type="text" value="<?php echo attribute_escape($numTweets); ?>" /></label>
90
  </p>
91
  <p>
92
- <label for="<?php echo $this->get_field_id('cacheTime'); ?>">Time in Minutes between updates: <input class="widefat" id="<?php echo $this->get_field_id('cacheTime'); ?>" name="<?php echo $this->get_field_name('cacheTime'); ?>" type="text" value="<?php echo attribute_escape($cacheTime); ?>" /></label>
93
  </p>
94
  <p>
95
- <label for="<?php echo $this->get_field_id('consumerKey'); ?>">Consumer Key: <input class="widefat" id="<?php echo $this->get_field_id('consumerKey'); ?>" name="<?php echo $this->get_field_name('consumerKey'); ?>" type="text" value="<?php echo attribute_escape($consumerKey); ?>" /></label>
96
  </p>
97
  <p>
98
- <label for="<?php echo $this->get_field_id('consumerSecret'); ?>">Consumer Secret: <input class="widefat" id="<?php echo $this->get_field_id('consumerSecret'); ?>" name="<?php echo $this->get_field_name('consumerSecret'); ?>" type="text" value="<?php echo attribute_escape($consumerSecret); ?>" /></label>
99
  </p>
100
  <p>
101
- <label for="<?php echo $this->get_field_id('accessToken'); ?>">Access Token: <input class="widefat" id="<?php echo $this->get_field_id('accessToken'); ?>" name="<?php echo $this->get_field_name('accessToken'); ?>" type="text" value="<?php echo attribute_escape($accessToken); ?>" /></label>
102
  </p>
103
  <p>
104
- <label for="<?php echo $this->get_field_id('accessTokenSecret'); ?>">Access Token Secret: <input class="widefat" id="<?php echo $this->get_field_id('accessTokenSecret'); ?>" name="<?php echo $this->get_field_name('accessTokenSecret'); ?>" type="text" value="<?php echo attribute_escape($accessTokenSecret); ?>" /></label>
105
  </p>
106
  <p>
107
  <input class="checkbox" type="checkbox" <?php checked( isset( $instance['exclude_replies']), true ); ?> id="<?php echo $this->get_field_id( 'exclude_replies' ); ?>" name="<?php echo $this->get_field_name( 'exclude_replies' ); ?>" />
@@ -124,7 +124,7 @@ class PI_SimpleTwitterTweets extends WP_Widget{
124
  <label for="<?php echo $this->get_field_id( 'dataShowCount' ); ?>"><?php _e('Show Twitter Followers Count', 'pi-tweet'); ?></label>
125
  </p>
126
  <p>
127
- <label for="<?php echo $this->get_field_id('dataLang'); ?>">Language: <input class="widefat" id="<?php echo $this->get_field_id('dataLang'); ?>" name="<?php echo $this->get_field_name('dataLang'); ?>" type="text" value="<?php echo attribute_escape($dataLang); ?>" /></label>
128
  </p>
129
  </div>
130
  </div>
@@ -213,6 +213,7 @@ class PI_SimpleTwitterTweets extends WP_Widget{
213
  $dataShowScreenName = ($PI_dataShowScreenName != "true") ? "false" : "true"; // Whether to show Twitter Screen Name
214
  $dataLang = $PI_dataLang; // Tell Twitter what Language is being used
215
 
 
216
  $transName = 'list-tweets-'.$name; // Name of value in database. [added $name for multiple account use]
217
  $backupName = $transName . '-backup'; // Name of backup value in database.
218
 
@@ -257,15 +258,22 @@ class PI_SimpleTwitterTweets extends WP_Widget{
257
 
258
  // Core info.
259
  $name = $tweet->user->name;
 
 
 
 
260
  $permalink = 'http://twitter.com/'. $name .'/status/'. $tweet->id_str;
261
 
262
  /* Alternative image sizes method: http://dev.twitter.com/doc/get/users/profile_image/:screen_name */
263
  $image = $tweet->user->profile_image_url;
264
 
265
- // Message. Convert links to real links.
266
- $pattern = '/http:(\S)+/';
267
- $replace = '<a href="${0}" target="_blank" rel="nofollow">${0}</a>';
268
- $text = preg_replace($pattern, $replace, $tweet->text);
 
 
 
269
 
270
  // Need to get time in Unix format.
271
  $time = $tweet->created_at;
@@ -293,7 +301,7 @@ class PI_SimpleTwitterTweets extends WP_Widget{
293
  <?php foreach($tweets as $t) : ?>
294
  <li><?php echo $t['text']; ?>
295
  <br/><em>
296
- <a href="http://www.twitter.com/<?php echo $name; ?>" target="_blank" title="Follow <?php echo $name; ?> on Twitter [Opens new window]"><?php echo human_time_diff($t['time'], current_time('timestamp')); ?> ago</a>
297
  </em>
298
  </li>
299
  <?php endforeach; ?>
4
  Plugin URI: http://www.planet-interactive.co.uk/simple-twitter-tweets
5
  Description: Display last x number tweets from Twitter API stream, store locally in dataabse to present past tweets when failure to access Twitters restrictive API occurs
6
  Author: Ashley Sheinwald
7
+ Version: 1.3
8
  Author URI: http://www.planet-interactive.co.uk/
9
  */
10
 
80
  $dataLang = $instance['dataLang'];
81
  ?>
82
  <p>
83
+ <label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label>
84
  </p>
85
  <p>
86
+ <label for="<?php echo $this->get_field_id('name'); ?>">Twitter Name (without @ symbol): <input class="widefat" id="<?php echo $this->get_field_id('name'); ?>" name="<?php echo $this->get_field_name('name'); ?>" type="text" value="<?php echo esc_attr($name); ?>" /></label>
87
  </p>
88
  <p>
89
+ <label for="<?php echo $this->get_field_id('numTweets'); ?>">Number of Tweets: <input class="widefat" id="<?php echo $this->get_field_id('numTweets'); ?>" name="<?php echo $this->get_field_name('numTweets'); ?>" type="text" value="<?php echo esc_attr($numTweets); ?>" /></label>
90
  </p>
91
  <p>
92
+ <label for="<?php echo $this->get_field_id('cacheTime'); ?>">Time in Minutes between updates: <input class="widefat" id="<?php echo $this->get_field_id('cacheTime'); ?>" name="<?php echo $this->get_field_name('cacheTime'); ?>" type="text" value="<?php echo esc_attr($cacheTime); ?>" /></label>
93
  </p>
94
  <p>
95
+ <label for="<?php echo $this->get_field_id('consumerKey'); ?>">Consumer Key: <input class="widefat" id="<?php echo $this->get_field_id('consumerKey'); ?>" name="<?php echo $this->get_field_name('consumerKey'); ?>" type="text" value="<?php echo esc_attr($consumerKey); ?>" /></label>
96
  </p>
97
  <p>
98
+ <label for="<?php echo $this->get_field_id('consumerSecret'); ?>">Consumer Secret: <input class="widefat" id="<?php echo $this->get_field_id('consumerSecret'); ?>" name="<?php echo $this->get_field_name('consumerSecret'); ?>" type="text" value="<?php echo esc_attr($consumerSecret); ?>" /></label>
99
  </p>
100
  <p>
101
+ <label for="<?php echo $this->get_field_id('accessToken'); ?>">Access Token: <input class="widefat" id="<?php echo $this->get_field_id('accessToken'); ?>" name="<?php echo $this->get_field_name('accessToken'); ?>" type="text" value="<?php echo esc_attr($accessToken); ?>" /></label>
102
  </p>
103
  <p>
104
+ <label for="<?php echo $this->get_field_id('accessTokenSecret'); ?>">Access Token Secret: <input class="widefat" id="<?php echo $this->get_field_id('accessTokenSecret'); ?>" name="<?php echo $this->get_field_name('accessTokenSecret'); ?>" type="text" value="<?php echo esc_attr($accessTokenSecret); ?>" /></label>
105
  </p>
106
  <p>
107
  <input class="checkbox" type="checkbox" <?php checked( isset( $instance['exclude_replies']), true ); ?> id="<?php echo $this->get_field_id( 'exclude_replies' ); ?>" name="<?php echo $this->get_field_name( 'exclude_replies' ); ?>" />
124
  <label for="<?php echo $this->get_field_id( 'dataShowCount' ); ?>"><?php _e('Show Twitter Followers Count', 'pi-tweet'); ?></label>
125
  </p>
126
  <p>
127
+ <label for="<?php echo $this->get_field_id('dataLang'); ?>">Language: <input class="widefat" id="<?php echo $this->get_field_id('dataLang'); ?>" name="<?php echo $this->get_field_name('dataLang'); ?>" type="text" value="<?php echo esc_attr($dataLang); ?>" /></label>
128
  </p>
129
  </div>
130
  </div>
213
  $dataShowScreenName = ($PI_dataShowScreenName != "true") ? "false" : "true"; // Whether to show Twitter Screen Name
214
  $dataLang = $PI_dataLang; // Tell Twitter what Language is being used
215
 
216
+ // COMMUNITY REQUEST !!!!!! (1)
217
  $transName = 'list-tweets-'.$name; // Name of value in database. [added $name for multiple account use]
218
  $backupName = $transName . '-backup'; // Name of backup value in database.
219
 
258
 
259
  // Core info.
260
  $name = $tweet->user->name;
261
+
262
+ // COMMUNITY REQUEST !!!!!! (2)
263
+ $screen_name = $tweet->user->screen_name;
264
+
265
  $permalink = 'http://twitter.com/'. $name .'/status/'. $tweet->id_str;
266
 
267
  /* Alternative image sizes method: http://dev.twitter.com/doc/get/users/profile_image/:screen_name */
268
  $image = $tweet->user->profile_image_url;
269
 
270
+ // NEW Link Creation from clickable items in the text
271
+ $linkCheck = preg_replace('/((http)+(s)?:\/\/[^<>\s]+)/i', '<a href="$0" target="_blank" rel="nofollow">$0</a>', $tweet->text );
272
+ // Clickable Twitter names
273
+ $personCheck = preg_replace('/[@]+([A-Za-z0-9-_]+)/', '<a href="http://twitter.com/$1" target="_blank" rel="nofollow">$1</a>', $linkCheck );
274
+ // Clickable Twitter hash tags
275
+ $text = preg_replace('/[#]+([A-Za-z0-9-_]+)/', '<a href="http://twitter.com/search?q=%23$1" target="_blank" rel="nofollow">$0</a>', $personCheck );
276
+ // END TWEET CONTENT REGEX
277
 
278
  // Need to get time in Unix format.
279
  $time = $tweet->created_at;
301
  <?php foreach($tweets as $t) : ?>
302
  <li><?php echo $t['text']; ?>
303
  <br/><em>
304
+ <a href="http://www.twitter.com/<?php echo $screen_name; ?>" target="_blank" title="Follow <?php echo $name; ?> on Twitter [Opens new window]"><?php echo human_time_diff($t['time'], current_time('timestamp')); ?> ago</a>
305
  </em>
306
  </li>
307
  <?php endforeach; ?>