Version Description
- [Added] SSL reference for avatar (profile pic) images for secure pages
- [Added] Check for data retrieval, handles foreach warning (bullet proof old bug)
- [Added] Defined 'ago' so when not used handles warning
- [Added] Clean inputs no whitespace issue
- [Updated] URL for Twitter apps creation updated (as it was moved)
Download this release
Release Info
Developer | Planet Interactive |
Plugin | Simple Twitter Tweets |
Version | 3.2 |
Comparing to | |
See all releases |
Code changes from version 3.1 to 3.2
- README.txt +20 -14
- simple-twitter-tweets.php +42 -28
README.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: Planet Interactive
|
|
3 |
Donate: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A9437VN7R36VN
|
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 |
|
@@ -50,9 +50,9 @@ Installation is as simple as 1,2,3 or maybe 4 because of Twitter :)
|
|
50 |
|
51 |
The Twitter Widget will never ask for your password, as it gets all your required data from the Open Authentication keys and secrets you will get by creating your application at Twitter. It also means that if you change your password, you won’t need to update any of the details of your Widget.
|
52 |
|
53 |
-
To find these details, go to https://
|
54 |
|
55 |
-
|
56 |
|
57 |
Enter a unique name (anything you want), a description (again this is just for you), and your site's URL. You can leave the Callback URL empty as it is not used for this implementation.
|
58 |
|
@@ -118,18 +118,24 @@ We've tested it and as far as we know it works great! Phew, but if you have an i
|
|
118 |
|
119 |
== Screenshots ==
|
120 |
|
121 |
-
1. Go to https://
|
122 |
-
2.
|
123 |
-
3.
|
124 |
-
4.
|
125 |
-
5.
|
126 |
-
6.
|
127 |
-
7.
|
128 |
-
8.
|
129 |
-
9.
|
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 |
|
3 |
Donate: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A9437VN7R36VN
|
4 |
Tags: Twitter, Stream, Tweets, Twitter OAuth, social
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 3.9.2
|
7 |
+
Stable tag: 3.2
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
50 |
|
51 |
The Twitter Widget will never ask for your password, as it gets all your required data from the Open Authentication keys and secrets you will get by creating your application at Twitter. It also means that if you change your password, you won’t need to update any of the details of your Widget.
|
52 |
|
53 |
+
To find these details, go to https://apps.twitter.com/ and sign in.
|
54 |
|
55 |
+
Center of the screen click "Create a New Application."
|
56 |
|
57 |
Enter a unique name (anything you want), a description (again this is just for you), and your site's URL. You can leave the Callback URL empty as it is not used for this implementation.
|
58 |
|
118 |
|
119 |
== Screenshots ==
|
120 |
|
121 |
+
1. Go to https://apps.twitter.com and Sign In
|
122 |
+
2. Create a new Application
|
123 |
+
3. Fill a name for your App, a description (this is for you) and your website address (URL)
|
124 |
+
4. Click "Create my access token"
|
125 |
+
5. If you've already installed in the "Simple Twitter Tweets" plugin go to Appearance->Widgets (otherwise install it first then go here)
|
126 |
+
6. Drag the "Simple Twitter Tweets" widget your widget area of choice
|
127 |
+
7. Fill in the widget options and correlating Twitter Application OAuth requirements, just copy and paste
|
128 |
+
8. New options for "Twitter Follow Button" and what elements to display
|
129 |
+
9. Style how you like, "Your Tweets your way"
|
|
|
130 |
|
131 |
== Changelog ==
|
132 |
+
= 3.2 =
|
133 |
+
* [Added] SSL reference for avatar (profile pic) images for secure pages
|
134 |
+
* [Added] Check for data retrieval, handles foreach warning (bullet proof old bug)
|
135 |
+
* [Added] Defined 'ago' so when not used handles warning
|
136 |
+
* [Added] Clean inputs no whitespace issue
|
137 |
+
* [Updated] URL for Twitter apps creation updated (as it was moved)
|
138 |
+
|
139 |
= 3.1 =
|
140 |
* [Fixed] Serialization error fixed - changed base_64 fix for 4-byte emoji strip
|
141 |
|
simple-twitter-tweets.php
CHANGED
@@ -4,11 +4,11 @@ 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 |
|
11 |
-
/* Copyright
|
12 |
|
13 |
This program is free software; you can redistribute it and/or modify
|
14 |
it under the terms of the GNU General Public License, version 2, as
|
@@ -147,26 +147,26 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
147 |
$instance = wp_parse_args( (array) $instance, $defaults );
|
148 |
$title = $instance['title'];
|
149 |
$name = $instance['name'];
|
150 |
-
$numTweets
|
151 |
-
$cacheTime
|
152 |
$consumerKey = trim($instance['consumerKey']);
|
153 |
$consumerSecret = trim($instance['consumerSecret']);
|
154 |
$accessToken = trim($instance['accessToken']);
|
155 |
-
$accessTokenSecret
|
156 |
$exclude_replies = $instance['exclude_replies'];
|
157 |
$twitterFollow = $instance['twitterFollow'];
|
158 |
-
$dataShowCount
|
159 |
$dataShowScreenName = $instance['dataShowScreenName'];
|
160 |
$dataLang = $instance['dataLang'];
|
161 |
// STARTING NEW FOR 2.0
|
162 |
$timeRef = $instance['timeRef'];
|
163 |
$timeAgo = $instance['timeAgo'];
|
164 |
-
$twitterIntents
|
165 |
$twitterIntentsText = $instance['twitterIntentsText'];
|
166 |
$intentColor = $instance['intentColor'];
|
167 |
$showAvatar = $instance['showAvatar'];
|
168 |
$roundCorners = $instance['roundCorners'];
|
169 |
-
$avatarSize
|
170 |
?>
|
171 |
|
172 |
<?php
|
@@ -298,26 +298,26 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
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']
|
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']
|
308 |
$instance['twitterFollow'] = $new_instance['twitterFollow'];
|
309 |
-
$instance['dataShowCount']
|
310 |
$instance['dataShowScreenName'] = $new_instance['dataShowScreenName'];
|
311 |
$instance['dataLang'] = $new_instance['dataLang'];
|
312 |
// STARTING NEW FOR 2.0
|
313 |
$instance['timeRef'] = $new_instance['timeRef'];
|
314 |
$instance['timeAgo'] = $new_instance['timeAgo'];
|
315 |
-
$instance['twitterIntents']
|
316 |
-
$instance['twitterIntentsText']
|
317 |
-
$instance['intentColor']
|
318 |
$instance['showAvatar'] = $new_instance['showAvatar'];
|
319 |
$instance['roundCorners'] = $new_instance['roundCorners'];
|
320 |
-
$instance['avatarSize']
|
321 |
|
322 |
return $instance;
|
323 |
}
|
@@ -332,13 +332,13 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
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
|
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;
|
@@ -379,12 +379,12 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
379 |
|
380 |
// Configuration.
|
381 |
$numTweets = $PI_numTweets; // Num tweets to show
|
382 |
-
$name
|
383 |
$cacheTime = $PI_cacheTime; // Time in minutes between updates.
|
384 |
|
385 |
// Get from https://dev.twitter.com/
|
386 |
// Login - Create New Application, fill in details and use required data below
|
387 |
-
$consumerKey
|
388 |
$consumerSecret = trim($PI_consumerSecret); // OAuth Secret
|
389 |
$accessToken = trim($PI_accessToken); // OAuth Access Token
|
390 |
$accessTokenSecret = trim($PI_accessTokenSecret); // OAuth Token Secret
|
@@ -399,12 +399,12 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
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
|
403 |
$intentColor = $PI_intentColor; // Intent icons colour
|
404 |
|
405 |
$showAvatar = $PI_showAvatar;
|
406 |
-
$roundCorners
|
407 |
-
$avatarSize
|
408 |
|
409 |
// COMMUNITY REQUEST! (1)
|
410 |
$transName = 'list-tweets-'.$name; // Name of value in database. [added $name for multiple account use]
|
@@ -431,8 +431,8 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
431 |
$fetchedTweets = $connection->get(
|
432 |
'statuses/user_timeline',
|
433 |
array(
|
434 |
-
'screen_name'
|
435 |
-
'count'
|
436 |
'exclude_replies' => $exclude_replies
|
437 |
)
|
438 |
);
|
@@ -440,7 +440,6 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
440 |
// Did the fetch fail?
|
441 |
if($connection->http_code != 200) :
|
442 |
$tweets = get_option($backupName); // False if there has never been data saved.
|
443 |
-
|
444 |
else :
|
445 |
// Fetch succeeded.
|
446 |
// Now update the array to store just what we need.
|
@@ -453,14 +452,26 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
453 |
// Core info.
|
454 |
$name = $tweet->user->name;
|
455 |
|
456 |
-
|
457 |
$screen_name = $tweet->user->screen_name;
|
458 |
|
459 |
$permalink = 'http://twitter.com/'. $name .'/status/'. $tweet->id_str;
|
460 |
$tweet_id = $tweet->id_str;
|
461 |
|
462 |
/* Alternative image sizes method: http://dev.twitter.com/doc/get/users/profile_image/:screen_name */
|
463 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
464 |
|
465 |
// Process Tweets - Use Twitter entities for correct URL, hash and mentions
|
466 |
$text = $this->process_links($tweet);
|
@@ -507,7 +518,7 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
507 |
|
508 |
// Now display the tweets, if we can.
|
509 |
if($tweets) : ?>
|
510 |
-
<?php foreach($tweets as $t) : ?>
|
511 |
<li<?php echo ($showAvatar) ? ' class="avatar"':""; ?><?php echo ($showAvatar && $avatarSize) ? ' style="margin-left:'.($avatarSize+5).'px"':""; ?>>
|
512 |
<?php
|
513 |
if ($showAvatar){
|
@@ -535,6 +546,9 @@ class PI_SimpleTwitterTweets extends WP_Widget{
|
|
535 |
// Ago - to show?
|
536 |
if($timeAgo == "true"){
|
537 |
$displayAgo = " ago";
|
|
|
|
|
|
|
538 |
}
|
539 |
// Use to make il8n compliant
|
540 |
printf(__('%1$s%2$s'), $timeDisplay, $displayAgo);
|
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.2
|
8 |
Author URI: http://www.planet-interactive.co.uk/
|
9 |
*/
|
10 |
|
11 |
+
/* Copyright 2014 Ashley Sheinwald (email : ashley@planet-interactive.co.uk)
|
12 |
|
13 |
This program is free software; you can redistribute it and/or modify
|
14 |
it under the terms of the GNU General Public License, version 2, as
|
147 |
$instance = wp_parse_args( (array) $instance, $defaults );
|
148 |
$title = $instance['title'];
|
149 |
$name = $instance['name'];
|
150 |
+
$numTweets = $instance['numTweets'];
|
151 |
+
$cacheTime = $instance['cacheTime'];
|
152 |
$consumerKey = trim($instance['consumerKey']);
|
153 |
$consumerSecret = trim($instance['consumerSecret']);
|
154 |
$accessToken = trim($instance['accessToken']);
|
155 |
+
$accessTokenSecret = trim($instance['accessTokenSecret']);
|
156 |
$exclude_replies = $instance['exclude_replies'];
|
157 |
$twitterFollow = $instance['twitterFollow'];
|
158 |
+
$dataShowCount = $instance['dataShowCount'];
|
159 |
$dataShowScreenName = $instance['dataShowScreenName'];
|
160 |
$dataLang = $instance['dataLang'];
|
161 |
// STARTING NEW FOR 2.0
|
162 |
$timeRef = $instance['timeRef'];
|
163 |
$timeAgo = $instance['timeAgo'];
|
164 |
+
$twitterIntents = $instance['twitterIntents'];
|
165 |
$twitterIntentsText = $instance['twitterIntentsText'];
|
166 |
$intentColor = $instance['intentColor'];
|
167 |
$showAvatar = $instance['showAvatar'];
|
168 |
$roundCorners = $instance['roundCorners'];
|
169 |
+
$avatarSize = $instance['avatarSize'];
|
170 |
?>
|
171 |
|
172 |
<?php
|
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'];
|
312 |
// STARTING NEW FOR 2.0
|
313 |
$instance['timeRef'] = $new_instance['timeRef'];
|
314 |
$instance['timeAgo'] = $new_instance['timeAgo'];
|
315 |
+
$instance['twitterIntents'] = $new_instance['twitterIntents'];
|
316 |
+
$instance['twitterIntentsText'] = $new_instance['twitterIntentsText'];
|
317 |
+
$instance['intentColor'] = strip_tags( $new_instance['intentColor'] );
|
318 |
$instance['showAvatar'] = $new_instance['showAvatar'];
|
319 |
$instance['roundCorners'] = $new_instance['roundCorners'];
|
320 |
+
$instance['avatarSize'] = strip_tags( $new_instance['avatarSize'] );
|
321 |
|
322 |
return $instance;
|
323 |
}
|
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;
|
379 |
|
380 |
// Configuration.
|
381 |
$numTweets = $PI_numTweets; // Num tweets to show
|
382 |
+
$name = $PI_name; // Twitter UserName
|
383 |
$cacheTime = $PI_cacheTime; // Time in minutes between updates.
|
384 |
|
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
|
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]
|
431 |
$fetchedTweets = $connection->get(
|
432 |
'statuses/user_timeline',
|
433 |
array(
|
434 |
+
'screen_name' => $name,
|
435 |
+
'count' => $totalToFetch,
|
436 |
'exclude_replies' => $exclude_replies
|
437 |
)
|
438 |
);
|
440 |
// Did the fetch fail?
|
441 |
if($connection->http_code != 200) :
|
442 |
$tweets = get_option($backupName); // False if there has never been data saved.
|
|
|
443 |
else :
|
444 |
// Fetch succeeded.
|
445 |
// Now update the array to store just what we need.
|
452 |
// Core info.
|
453 |
$name = $tweet->user->name;
|
454 |
|
455 |
+
// COMMUNITY REQUEST !!!!!! (2)
|
456 |
$screen_name = $tweet->user->screen_name;
|
457 |
|
458 |
$permalink = 'http://twitter.com/'. $name .'/status/'. $tweet->id_str;
|
459 |
$tweet_id = $tweet->id_str;
|
460 |
|
461 |
/* Alternative image sizes method: http://dev.twitter.com/doc/get/users/profile_image/:screen_name */
|
462 |
+
// Check for SSL via protocol https then display relevant image - thanks SO - this should do
|
463 |
+
if (isset($_SERVER['HTTPS']) &&
|
464 |
+
($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
|
465 |
+
isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
|
466 |
+
$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
|
467 |
+
// $protocol = 'https://';
|
468 |
+
$image = $tweet->user->profile_image_url_https;
|
469 |
+
}
|
470 |
+
else {
|
471 |
+
// $protocol = 'http://';
|
472 |
+
$image = $tweet->user->profile_image_url;
|
473 |
+
}
|
474 |
+
// $image = $tweet->user->profile_image_url;
|
475 |
|
476 |
// Process Tweets - Use Twitter entities for correct URL, hash and mentions
|
477 |
$text = $this->process_links($tweet);
|
518 |
|
519 |
// Now display the tweets, if we can.
|
520 |
if($tweets) : ?>
|
521 |
+
<?php foreach( (array) $tweets as $t) : // casting array to array just in case it's empty - then prevents PHP warning ?>
|
522 |
<li<?php echo ($showAvatar) ? ' class="avatar"':""; ?><?php echo ($showAvatar && $avatarSize) ? ' style="margin-left:'.($avatarSize+5).'px"':""; ?>>
|
523 |
<?php
|
524 |
if ($showAvatar){
|
546 |
// Ago - to show?
|
547 |
if($timeAgo == "true"){
|
548 |
$displayAgo = " ago";
|
549 |
+
}else{
|
550 |
+
// Added to counter 'no ago var' setting undefined variable warning
|
551 |
+
$displayAgo = "";
|
552 |
}
|
553 |
// Use to make il8n compliant
|
554 |
printf(__('%1$s%2$s'), $timeDisplay, $displayAgo);
|