Version Description
- [Fixed] Serialization error fixed - changed base_64 fix for 4-byte emoji strip
Download this release
Release Info
Developer | Planet Interactive |
Plugin | Simple Twitter Tweets |
Version | 3.1 |
Comparing to | |
See all releases |
Code changes from version 3.0 to 3.1
- README.txt +3 -1
- simple-twitter-tweets.php +48 -44
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.9
|
7 |
-
Stable tag: 3.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -130,6 +130,8 @@ We've tested it and as far as we know it works great! Phew, but if you have an i
|
|
130 |
10. Style how you like, "Your Tweets your way"
|
131 |
|
132 |
== Changelog ==
|
|
|
|
|
133 |
|
134 |
= 3.0 =
|
135 |
* [Fixed] Class conflict error - check for use before including
|
4 |
Tags: Twitter, Stream, Tweets, Twitter OAuth, social
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.9
|
7 |
+
Stable tag: 3.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
130 |
10. Style how you like, "Your Tweets your way"
|
131 |
|
132 |
== Changelog ==
|
133 |
+
= 3.1 =
|
134 |
+
* [Fixed] Serialization error fixed - changed base_64 fix for 4-byte emoji strip
|
135 |
|
136 |
= 3.0 =
|
137 |
* [Fixed] Class conflict error - check for use before including
|
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 database to present past tweets when failure to access Twitters restrictive API occurs
|
6 |
Author: Ashley Sheinwald
|
7 |
-
Version: 3.
|
8 |
Author URI: http://www.planet-interactive.co.uk/
|
9 |
*/
|
10 |
|
@@ -106,6 +106,14 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
106 |
}
|
107 |
// END PROCESS LINKS - Using Entities
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
function form($instance){
|
110 |
|
111 |
//Set up some default widget settings.
|
@@ -287,17 +295,17 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
287 |
function update($new_instance, $old_instance){
|
288 |
$instance = $old_instance;
|
289 |
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
$instance['dataShowCount'] = $new_instance['dataShowCount'];
|
302 |
$instance['dataShowScreenName'] = $new_instance['dataShowScreenName'];
|
303 |
$instance['dataLang'] = $new_instance['dataLang'];
|
@@ -315,6 +323,7 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
315 |
}
|
316 |
|
317 |
function widget($args, $instance){
|
|
|
318 |
extract($args, EXTR_SKIP);
|
319 |
|
320 |
echo $before_widget;
|
@@ -322,19 +331,19 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
322 |
//Our variables from the widget settings.
|
323 |
$PI_title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
|
324 |
$PI_name = $instance['name'];
|
325 |
-
$PI_numTweets
|
326 |
-
$PI_cacheTime
|
327 |
|
328 |
//Setup Twitter API OAuth tokens
|
329 |
$PI_consumerKey = trim($instance['consumerKey']);
|
330 |
-
$PI_consumerSecret
|
331 |
$PI_accessToken = trim($instance['accessToken']);
|
332 |
-
$PI_accessTokenSecret
|
333 |
|
334 |
$PI_exclude_replies = isset( $instance['exclude_replies'] ) ? $instance['exclude_replies'] : false;
|
335 |
$PI_twitterFollow = isset( $instance['twitterFollow'] ) ? $instance['twitterFollow'] : false;
|
336 |
|
337 |
-
$PI_dataShowCount
|
338 |
$PI_dataShowScreenName = isset( $instance['dataShowScreenName'] ) ? $instance['dataShowScreenName'] : false;
|
339 |
$PI_dataLang = $instance['dataLang'];
|
340 |
|
@@ -346,7 +355,7 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
346 |
$PI_intentColor = $instance['intentColor'];
|
347 |
|
348 |
// Avatar
|
349 |
-
$PI_showAvatar
|
350 |
$PI_roundCorners = isset( $instance['roundCorners'] ) ? $instance['roundCorners'] : false;
|
351 |
$PI_avatarSize = $instance['avatarSize'];
|
352 |
|
@@ -376,41 +385,35 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
376 |
// Get from https://dev.twitter.com/
|
377 |
// Login - Create New Application, fill in details and use required data below
|
378 |
$consumerKey = trim($PI_consumerKey); // OAuth Key
|
379 |
-
$consumerSecret
|
380 |
-
$accessToken
|
381 |
$accessTokenSecret = trim($PI_accessTokenSecret); // OAuth Token Secret
|
382 |
|
383 |
-
$exclude_replies
|
384 |
-
$twitterFollow
|
385 |
|
386 |
$dataShowCount = ($PI_dataShowCount != "true") ? "false" : "true"; // Whether to show Twitter Follower Count
|
387 |
$dataShowScreenName = ($PI_dataShowScreenName != "true") ? "false" : "true"; // Whether to show Twitter Screen Name
|
388 |
-
$dataLang
|
389 |
|
390 |
-
$timeRef
|
391 |
-
$timeAgo
|
392 |
-
$twitterIntents
|
393 |
-
$twitterIntentsText
|
394 |
-
$intentColor
|
395 |
|
396 |
-
$showAvatar
|
397 |
$roundCorners = $PI_roundCorners;
|
398 |
-
$avatarSize
|
399 |
|
400 |
// COMMUNITY REQUEST! (1)
|
401 |
$transName = 'list-tweets-'.$name; // Name of value in database. [added $name for multiple account use]
|
402 |
$backupName = $transName . '-backup'; // Name of backup value in database.
|
403 |
|
404 |
-
//
|
405 |
-
|
406 |
-
// base64 fix for emoji ? --> if(false === ($tweets = unserialize(base64_decode(get_transient($transName) ))) ) :
|
407 |
-
// if not complete enough implement -> https://github.com/iamcal/php-emoji
|
408 |
-
// #####################################################
|
409 |
-
// if(false === ($tweets = get_transient($transName) ) ) :
|
410 |
-
if(false === ($tweets = unserialize(base64_decode(get_transient($transName) ))) ) :
|
411 |
|
412 |
// Get the tweets from Twitter.
|
413 |
-
//include 'twitteroauth/twitteroauth.php';
|
414 |
if ( ! class_exists('TwitterOAuth') )
|
415 |
include 'twitteroauth/twitteroauth.php';
|
416 |
|
@@ -459,8 +462,11 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
459 |
/* Alternative image sizes method: http://dev.twitter.com/doc/get/users/profile_image/:screen_name */
|
460 |
$image = $tweet->user->profile_image_url;
|
461 |
|
462 |
-
|
463 |
-
|
|
|
|
|
|
|
464 |
|
465 |
// Need to get time in Unix format.
|
466 |
$time = $tweet->created_at;
|
@@ -478,10 +484,8 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
478 |
);
|
479 |
endfor;
|
480 |
|
481 |
-
|
482 |
-
|
483 |
-
base64_encode(serialize(set_transient($transName, $tweets, 60 * $cacheTime)));
|
484 |
-
update_option($backupName, $tweets);
|
485 |
endif;
|
486 |
endif;
|
487 |
|
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 database to present past tweets when failure to access Twitters restrictive API occurs
|
6 |
Author: Ashley Sheinwald
|
7 |
+
Version: 3.1
|
8 |
Author URI: http://www.planet-interactive.co.uk/
|
9 |
*/
|
10 |
|
106 |
}
|
107 |
// END PROCESS LINKS - Using Entities
|
108 |
|
109 |
+
|
110 |
+
// Clean four-byte Emoji icons out of tweet text.
|
111 |
+
// MySQL utf8 columns cannot store four byte Unicode sequences
|
112 |
+
function twitter_api_strip_emoji( $text ){
|
113 |
+
// four byte utf8: 11110www 10xxxxxx 10yyyyyy 10zzzzzz
|
114 |
+
return preg_replace('/[\xF0-\xF7][\x80-\xBF]{3}/', '', $text );
|
115 |
+
}
|
116 |
+
|
117 |
function form($instance){
|
118 |
|
119 |
//Set up some default widget settings.
|
295 |
function update($new_instance, $old_instance){
|
296 |
$instance = $old_instance;
|
297 |
|
298 |
+
//Strip tags from title and name to remove HTML
|
299 |
+
$instance['title'] = strip_tags( $new_instance['title'] );
|
300 |
+
$instance['name'] = strip_tags( $new_instance['name'] );
|
301 |
+
$instance['numTweets'] = $new_instance['numTweets'];
|
302 |
+
$instance['cacheTime'] = $new_instance['cacheTime'];
|
303 |
+
$instance['consumerKey'] = trim($new_instance['consumerKey']);
|
304 |
+
$instance['consumerSecret'] = trim($new_instance['consumerSecret']);
|
305 |
+
$instance['accessToken'] = trim($new_instance['accessToken']);
|
306 |
+
$instance['accessTokenSecret'] = trim($new_instance['accessTokenSecret']);
|
307 |
+
$instance['exclude_replies'] = $new_instance['exclude_replies'];
|
308 |
+
$instance['twitterFollow'] = $new_instance['twitterFollow'];
|
309 |
$instance['dataShowCount'] = $new_instance['dataShowCount'];
|
310 |
$instance['dataShowScreenName'] = $new_instance['dataShowScreenName'];
|
311 |
$instance['dataLang'] = $new_instance['dataLang'];
|
323 |
}
|
324 |
|
325 |
function widget($args, $instance){
|
326 |
+
|
327 |
extract($args, EXTR_SKIP);
|
328 |
|
329 |
echo $before_widget;
|
331 |
//Our variables from the widget settings.
|
332 |
$PI_title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
|
333 |
$PI_name = $instance['name'];
|
334 |
+
$PI_numTweets = $instance['numTweets'];
|
335 |
+
$PI_cacheTime = $instance['cacheTime'];
|
336 |
|
337 |
//Setup Twitter API OAuth tokens
|
338 |
$PI_consumerKey = trim($instance['consumerKey']);
|
339 |
+
$PI_consumerSecret = trim($instance['consumerSecret']);
|
340 |
$PI_accessToken = trim($instance['accessToken']);
|
341 |
+
$PI_accessTokenSecret= trim($instance['accessTokenSecret']);
|
342 |
|
343 |
$PI_exclude_replies = isset( $instance['exclude_replies'] ) ? $instance['exclude_replies'] : false;
|
344 |
$PI_twitterFollow = isset( $instance['twitterFollow'] ) ? $instance['twitterFollow'] : false;
|
345 |
|
346 |
+
$PI_dataShowCount = isset( $instance['dataShowCount'] ) ? $instance['dataShowCount'] : false;
|
347 |
$PI_dataShowScreenName = isset( $instance['dataShowScreenName'] ) ? $instance['dataShowScreenName'] : false;
|
348 |
$PI_dataLang = $instance['dataLang'];
|
349 |
|
355 |
$PI_intentColor = $instance['intentColor'];
|
356 |
|
357 |
// Avatar
|
358 |
+
$PI_showAvatar = isset( $instance['showAvatar'] ) ? $instance['showAvatar'] : false;
|
359 |
$PI_roundCorners = isset( $instance['roundCorners'] ) ? $instance['roundCorners'] : false;
|
360 |
$PI_avatarSize = $instance['avatarSize'];
|
361 |
|
385 |
// Get from https://dev.twitter.com/
|
386 |
// Login - Create New Application, fill in details and use required data below
|
387 |
$consumerKey = trim($PI_consumerKey); // OAuth Key
|
388 |
+
$consumerSecret = trim($PI_consumerSecret); // OAuth Secret
|
389 |
+
$accessToken = trim($PI_accessToken); // OAuth Access Token
|
390 |
$accessTokenSecret = trim($PI_accessTokenSecret); // OAuth Token Secret
|
391 |
|
392 |
+
$exclude_replies = $PI_exclude_replies; // Leave out @replies?
|
393 |
+
$twitterFollow = $PI_twitterFollow; // Whether to show Twitter Follow button
|
394 |
|
395 |
$dataShowCount = ($PI_dataShowCount != "true") ? "false" : "true"; // Whether to show Twitter Follower Count
|
396 |
$dataShowScreenName = ($PI_dataShowScreenName != "true") ? "false" : "true"; // Whether to show Twitter Screen Name
|
397 |
+
$dataLang = $PI_dataLang; // Tell Twitter what Language is being used
|
398 |
|
399 |
+
$timeRef = $PI_timeRef; // Time ref: hours or short h
|
400 |
+
$timeAgo = $PI_timeAgo; // Human Time: ago ref or not
|
401 |
+
$twitterIntents = $PI_twitterIntents; // Intent on/off
|
402 |
+
$twitterIntentsText = $PI_twitterIntentsText; // Intents Text on/off
|
403 |
+
$intentColor = $PI_intentColor; // Intent icons colour
|
404 |
|
405 |
+
$showAvatar = $PI_showAvatar;
|
406 |
$roundCorners = $PI_roundCorners;
|
407 |
+
$avatarSize = $PI_avatarSize;
|
408 |
|
409 |
// COMMUNITY REQUEST! (1)
|
410 |
$transName = 'list-tweets-'.$name; // Name of value in database. [added $name for multiple account use]
|
411 |
$backupName = $transName . '-backup'; // Name of backup value in database.
|
412 |
|
413 |
+
// if(false === ($tweets = unserialize( base64_decode(get_transient( $transName ) ) ) ) ) :
|
414 |
+
if(false === ($tweets = get_transient( $transName ) ) ) :
|
|
|
|
|
|
|
|
|
|
|
415 |
|
416 |
// Get the tweets from Twitter.
|
|
|
417 |
if ( ! class_exists('TwitterOAuth') )
|
418 |
include 'twitteroauth/twitteroauth.php';
|
419 |
|
462 |
/* Alternative image sizes method: http://dev.twitter.com/doc/get/users/profile_image/:screen_name */
|
463 |
$image = $tweet->user->profile_image_url;
|
464 |
|
465 |
+
// Process Tweets - Use Twitter entities for correct URL, hash and mentions
|
466 |
+
$text = $this->process_links($tweet);
|
467 |
+
|
468 |
+
// lets strip 4-byte emojis
|
469 |
+
$text = $this->twitter_api_strip_emoji( $text );
|
470 |
|
471 |
// Need to get time in Unix format.
|
472 |
$time = $tweet->created_at;
|
484 |
);
|
485 |
endfor;
|
486 |
|
487 |
+
set_transient($transName, $tweets, 60 * $cacheTime);
|
488 |
+
update_option($backupName, $tweets );
|
|
|
|
|
489 |
endif;
|
490 |
endif;
|
491 |
|