Version Description
- Settings page and other updates
Download this release
Release Info
Developer | grimmdude |
Plugin | Recent Tweets Widget |
Version | 1.5 |
Comparing to | |
See all releases |
Code changes from version 1.3 to 1.5
- assets/banner-772x250.png +0 -0
- assets/banner.psd +0 -0
- assets/icon-256x256.png +0 -0
- assets/icon-256x256.psd +0 -0
- readme.txt +11 -4
- recent-tweets.php +33 -11
- settings.php +22 -0
- widget.php +41 -30
assets/banner-772x250.png
CHANGED
Binary file
|
assets/banner.psd
ADDED
Binary file
|
assets/icon-256x256.png
ADDED
Binary file
|
assets/icon-256x256.psd
ADDED
Binary file
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Recent Tweets Widget ===
|
2 |
-
Contributors:
|
3 |
Donate link: http://themeprince.com/
|
4 |
-
Tags: recent tweets, twitter widget, twitter api v1.1, cache
|
5 |
Requires at least: 3.4.1
|
6 |
-
Tested up to:
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -39,6 +39,13 @@ You will need to visit [this link](https://dev.twitter.com/apps/ "Twitter"), sig
|
|
39 |
|
40 |
== Changelog ==
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
= 1.3 =
|
43 |
* Fix for special 4 byte UTF8 characters
|
44 |
|
1 |
=== Recent Tweets Widget ===
|
2 |
+
Contributors: noahkagan
|
3 |
Donate link: http://themeprince.com/
|
4 |
+
Tags: recent tweets, twitter widget, twitter api v1.1, cache, twitter, tweets, social media
|
5 |
Requires at least: 3.4.1
|
6 |
+
Tested up to: 4.2.2
|
7 |
+
Stable tag: 1.5
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
39 |
|
40 |
== Changelog ==
|
41 |
|
42 |
+
= 1.5 =
|
43 |
+
* Settings page and other updates
|
44 |
+
|
45 |
+
= 1.4 =
|
46 |
+
* PHP 5.5 deprecated preg_replace() function fix
|
47 |
+
* Added gettext calls for easier translation
|
48 |
+
|
49 |
= 1.3 =
|
50 |
* Fix for special 4 byte UTF8 characters
|
51 |
|
recent-tweets.php
CHANGED
@@ -4,12 +4,13 @@
|
|
4 |
Plugin Name: Recent Tweets Widget
|
5 |
Plugin URI: http://wordpress.org/extend/plugins/recent-tweets-widget/
|
6 |
Description: Recent Tweets Widget plugin for Twitter API v1.1 with Cache. It uses the new Twitter API v1.1 and stores tweets in the cache. It means that it will read status messages from your database and it doesn't query Twitter.com for every page load so you won't be rate limited. You can set how often you want to update the cache.
|
7 |
-
Version: 1.
|
8 |
-
Author:
|
9 |
-
Author URI: http://
|
10 |
*/
|
11 |
|
12 |
-
|
|
|
13 |
|
14 |
// make sure we don't expose any info if called directly
|
15 |
if ( !function_exists( 'add_action' ) ) {
|
@@ -17,22 +18,43 @@ Author URI: http://themeprince.com
|
|
17 |
exit;
|
18 |
}
|
19 |
|
20 |
-
|
21 |
define('TP_RECENT_TWEETS_PATH', plugin_dir_url( __FILE__ ));
|
22 |
|
23 |
//register stylesheet for widget
|
24 |
-
function tp_twitter_plugin_styles() {
|
25 |
wp_enqueue_style( 'tp_twitter_plugin_css', TP_RECENT_TWEETS_PATH . 'tp_twitter_plugin.css', array(), '1.0', 'screen' );
|
26 |
}
|
27 |
add_action( 'wp_enqueue_scripts', 'tp_twitter_plugin_styles' );
|
28 |
-
|
29 |
-
|
30 |
// include widget function
|
31 |
require_once('widget.php');
|
32 |
-
|
33 |
-
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
|
|
36 |
|
37 |
|
38 |
-
|
|
|
|
|
|
4 |
Plugin Name: Recent Tweets Widget
|
5 |
Plugin URI: http://wordpress.org/extend/plugins/recent-tweets-widget/
|
6 |
Description: Recent Tweets Widget plugin for Twitter API v1.1 with Cache. It uses the new Twitter API v1.1 and stores tweets in the cache. It means that it will read status messages from your database and it doesn't query Twitter.com for every page load so you won't be rate limited. You can set how often you want to update the cache.
|
7 |
+
Version: 1.5
|
8 |
+
Author: Noah Kagan
|
9 |
+
Author URI: http://sumome.com
|
10 |
*/
|
11 |
|
12 |
+
//error_reporting(E_ALL);
|
13 |
+
//ini_set('display_errors', '1');
|
14 |
|
15 |
// make sure we don't expose any info if called directly
|
16 |
if ( !function_exists( 'add_action' ) ) {
|
18 |
exit;
|
19 |
}
|
20 |
|
|
|
21 |
define('TP_RECENT_TWEETS_PATH', plugin_dir_url( __FILE__ ));
|
22 |
|
23 |
//register stylesheet for widget
|
24 |
+
function tp_twitter_plugin_styles() {
|
25 |
wp_enqueue_style( 'tp_twitter_plugin_css', TP_RECENT_TWEETS_PATH . 'tp_twitter_plugin.css', array(), '1.0', 'screen' );
|
26 |
}
|
27 |
add_action( 'wp_enqueue_scripts', 'tp_twitter_plugin_styles' );
|
28 |
+
|
|
|
29 |
// include widget function
|
30 |
require_once('widget.php');
|
|
|
|
|
31 |
|
32 |
+
// Link to settings page from plugins screen
|
33 |
+
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'add_action_links' );
|
34 |
+
|
35 |
+
function add_action_links ( $links ) {
|
36 |
+
$mylinks = array(
|
37 |
+
'<a href="' . admin_url( 'options-general.php?page=recent-tweets' ) . '">Settings</a>',
|
38 |
+
);
|
39 |
+
|
40 |
+
return array_merge( $links, $mylinks );
|
41 |
+
}
|
42 |
+
|
43 |
+
// Settings menu
|
44 |
+
add_action('admin_menu', 'tp_twitter_plugin_menu_item');
|
45 |
+
|
46 |
+
function tp_twitter_plugin_menu_item() {
|
47 |
+
add_options_page( 'Recent Tweets', 'Recent Tweets', 'manage_options', 'recent-tweets', 'tp_twitter_plugin_settings_page');
|
48 |
+
}
|
49 |
+
|
50 |
+
function tp_twitter_plugin_settings_page() {
|
51 |
+
include(plugin_dir_path( __FILE__ ).'/settings.php');
|
52 |
+
}
|
53 |
|
54 |
+
//add_option('recent-tweets-options', array('support-us' => 0));
|
55 |
|
56 |
|
57 |
+
function register_tp_twitter_setting() {
|
58 |
+
register_setting( 'tp_twitter_plugin_options', 'tp_twitter_plugin_options');
|
59 |
+
}
|
60 |
+
add_action( 'admin_init', 'register_tp_twitter_setting' );
|
settings.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$tp_twitter_plugin_options = get_option('tp_twitter_plugin_options');
|
3 |
+
?>
|
4 |
+
<div class="wrap">
|
5 |
+
<?php screen_icon(); ?>
|
6 |
+
<h2>Recent Tweets</h2>
|
7 |
+
<form method="post" action="options.php">
|
8 |
+
<?php settings_fields( 'tp_twitter_plugin_options' ); ?>
|
9 |
+
<table class="form-table">
|
10 |
+
<tr valign="top">
|
11 |
+
<th scope="row"><label for="support-us">Support Us!</label></th>
|
12 |
+
<td>
|
13 |
+
<select name="tp_twitter_plugin_options[support-us]" id="support-us">
|
14 |
+
<option value="1" <?php echo $tp_twitter_plugin_options['support-us'] == '1' ? 'selected="selected"' : ''; ?>>Yes</option>
|
15 |
+
<option value="0" <?php echo !array_key_exists('support-us', $tp_twitter_plugin_options) || $tp_twitter_plugin_options['support-us'] == '0' ? 'selected="selected"' : ''; ?>>No</option>
|
16 |
+
</select>
|
17 |
+
</td>
|
18 |
+
</tr>
|
19 |
+
</table>
|
20 |
+
<?php submit_button(); ?>
|
21 |
+
</form>
|
22 |
+
</div>
|
widget.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
parent::__construct(
|
8 |
'tp_widget_recent_tweets', // Base ID
|
9 |
'* Recent Tweets', // Name
|
10 |
-
array( 'description' => __( 'Display recent tweets', '
|
11 |
);
|
12 |
}
|
13 |
|
@@ -23,10 +23,9 @@
|
|
23 |
|
24 |
//check settings and die if not set
|
25 |
if(empty($instance['consumerkey']) || empty($instance['consumersecret']) || empty($instance['accesstoken']) || empty($instance['accesstokensecret']) || empty($instance['cachetime']) || empty($instance['username'])){
|
26 |
-
echo '<strong>Please fill all widget settings
|
27 |
return;
|
28 |
}
|
29 |
-
|
30 |
|
31 |
//check if cache needs update
|
32 |
$tp_twitter_plugin_last_cache_time = get_option('tp_twitter_plugin_last_cache_time');
|
@@ -37,7 +36,7 @@
|
|
37 |
if($diff >= $crt || empty($tp_twitter_plugin_last_cache_time)){
|
38 |
|
39 |
if(!require_once('twitteroauth.php')){
|
40 |
-
echo '<strong>Couldn\'t find twitteroauth.php
|
41 |
return;
|
42 |
}
|
43 |
|
@@ -53,7 +52,7 @@
|
|
53 |
|
54 |
if(!empty($tweets->errors)){
|
55 |
if($tweets->errors[0]->message == 'Invalid or expired token'){
|
56 |
-
echo '<strong>'.$tweets->errors[0]->message.'!</strong><br />You\'ll need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!' . $after_widget;
|
57 |
}else{
|
58 |
echo '<strong>'.$tweets->errors[0]->message.'</strong>' . $after_widget;
|
59 |
}
|
@@ -83,9 +82,8 @@
|
|
83 |
|
84 |
|
85 |
|
86 |
-
|
87 |
$tp_twitter_plugin_tweets = maybe_unserialize(get_option('tp_twitter_plugin_tweets'));
|
88 |
-
if(!empty($tp_twitter_plugin_tweets)){
|
89 |
print '
|
90 |
<div class="tp_recent_tweets">
|
91 |
<ul>';
|
@@ -102,7 +100,19 @@
|
|
102 |
}
|
103 |
|
104 |
print '
|
105 |
-
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
</div>';
|
107 |
}
|
108 |
|
@@ -139,21 +149,23 @@
|
|
139 |
$instance = wp_parse_args( (array) $instance, $defaults );
|
140 |
|
141 |
echo '
|
142 |
-
<p
|
|
|
|
|
143 |
<input type="text" name="'.$this->get_field_name( 'title' ).'" id="'.$this->get_field_id( 'title' ).'" value="'.esc_attr($instance['title']).'" class="widefat" /></p>
|
144 |
-
<p><label>Consumer Key
|
145 |
<input type="text" name="'.$this->get_field_name( 'consumerkey' ).'" id="'.$this->get_field_id( 'consumerkey' ).'" value="'.esc_attr($instance['consumerkey']).'" class="widefat" /></p>
|
146 |
-
<p><label>Consumer Secret
|
147 |
<input type="text" name="'.$this->get_field_name( 'consumersecret' ).'" id="'.$this->get_field_id( 'consumersecret' ).'" value="'.esc_attr($instance['consumersecret']).'" class="widefat" /></p>
|
148 |
-
<p><label>Access Token
|
149 |
<input type="text" name="'.$this->get_field_name( 'accesstoken' ).'" id="'.$this->get_field_id( 'accesstoken' ).'" value="'.esc_attr($instance['accesstoken']).'" class="widefat" /></p>
|
150 |
-
<p><label>Access Token Secret
|
151 |
<input type="text" name="'.$this->get_field_name( 'accesstokensecret' ).'" id="'.$this->get_field_id( 'accesstokensecret' ).'" value="'.esc_attr($instance['accesstokensecret']).'" class="widefat" /></p>
|
152 |
-
<p><label>Cache Tweets in every
|
153 |
<input type="text" name="'.$this->get_field_name( 'cachetime' ).'" id="'.$this->get_field_id( 'cachetime' ).'" value="'.esc_attr($instance['cachetime']).'" class="small-text" /> hours</p>
|
154 |
-
<p><label>Twitter Username
|
155 |
<input type="text" name="'.$this->get_field_name( 'username' ).'" id="'.$this->get_field_id( 'username' ).'" value="'.esc_attr($instance['username']).'" class="widefat" /></p>
|
156 |
-
<p><label>Tweets to display
|
157 |
<select type="text" name="'.$this->get_field_name( 'tweetstoshow' ).'" id="'.$this->get_field_id( 'tweetstoshow' ).'">';
|
158 |
$i = 1;
|
159 |
for(i; $i <= 10; $i++){
|
@@ -161,7 +173,7 @@
|
|
161 |
}
|
162 |
echo '
|
163 |
</select></p>
|
164 |
-
<p><label>Exclude replies
|
165 |
<input type="checkbox" name="'.$this->get_field_name( 'excludereplies' ).'" id="'.$this->get_field_id( 'excludereplies' ).'" value="true"';
|
166 |
if(!empty($instance['excludereplies']) && esc_attr($instance['excludereplies']) == 'true'){
|
167 |
print ' checked="checked"';
|
@@ -181,9 +193,8 @@
|
|
181 |
// the target
|
182 |
$target=$targetBlank ? " target=\"_blank\" " : "";
|
183 |
|
184 |
-
// convert link to url
|
185 |
-
$status = preg_replace(
|
186 |
-
]+)/e", "'<a href=\"$1\" title=\"$1\" $target >'. ((strlen('$1')>=$linkMaxLen ? substr('$1',0,$linkMaxLen).'...':'$1')).'</a>'", $status);
|
187 |
|
188 |
// convert @ to follow
|
189 |
$status = preg_replace("/(@([_a-z0-9\-]+))/i","<a href=\"http://twitter.com/$2\" title=\"Follow $2\" $target >$1</a>",$status);
|
@@ -201,7 +212,7 @@
|
|
201 |
if (!function_exists('tp_relative_time')) {
|
202 |
function tp_relative_time($a) {
|
203 |
//get current timestampt
|
204 |
-
$b = strtotime(
|
205 |
//get timestamp when tweet created
|
206 |
$c = strtotime($a);
|
207 |
//get difference
|
@@ -214,23 +225,23 @@
|
|
214 |
|
215 |
if(is_numeric($d) && $d > 0) {
|
216 |
//if less then 3 seconds
|
217 |
-
if($d < 3) return
|
218 |
//if less then minute
|
219 |
-
if($d < $minute) return floor($d) .
|
220 |
//if less then 2 minutes
|
221 |
-
if($d < $minute * 2) return
|
222 |
//if less then hour
|
223 |
-
if($d < $hour) return floor($d / $minute) .
|
224 |
//if less then 2 hours
|
225 |
-
if($d < $hour * 2) return
|
226 |
//if less then day
|
227 |
-
if($d < $day) return floor($d / $hour) .
|
228 |
//if more then day, but less then 2 days
|
229 |
-
if($d > $day && $d < $day * 2) return
|
230 |
//if less then year
|
231 |
-
if($d < $day * 365) return floor($d / $day) .
|
232 |
//else return more than a year
|
233 |
-
return
|
234 |
}
|
235 |
}
|
236 |
}
|
7 |
parent::__construct(
|
8 |
'tp_widget_recent_tweets', // Base ID
|
9 |
'* Recent Tweets', // Name
|
10 |
+
array( 'description' => __( 'Display recent tweets', 'tp_tweets' ), ) // Args
|
11 |
);
|
12 |
}
|
13 |
|
23 |
|
24 |
//check settings and die if not set
|
25 |
if(empty($instance['consumerkey']) || empty($instance['consumersecret']) || empty($instance['accesstoken']) || empty($instance['accesstokensecret']) || empty($instance['cachetime']) || empty($instance['username'])){
|
26 |
+
echo '<strong>'.__('Please fill all widget settings!','tp_tweets').'</strong>' . $after_widget;
|
27 |
return;
|
28 |
}
|
|
|
29 |
|
30 |
//check if cache needs update
|
31 |
$tp_twitter_plugin_last_cache_time = get_option('tp_twitter_plugin_last_cache_time');
|
36 |
if($diff >= $crt || empty($tp_twitter_plugin_last_cache_time)){
|
37 |
|
38 |
if(!require_once('twitteroauth.php')){
|
39 |
+
echo '<strong>'.__('Couldn\'t find twitteroauth.php!','tp_tweets').'</strong>' . $after_widget;
|
40 |
return;
|
41 |
}
|
42 |
|
52 |
|
53 |
if(!empty($tweets->errors)){
|
54 |
if($tweets->errors[0]->message == 'Invalid or expired token'){
|
55 |
+
echo '<strong>'.$tweets->errors[0]->message.'!</strong><br />' . __('You\'ll need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!','tp_tweets') . $after_widget;
|
56 |
}else{
|
57 |
echo '<strong>'.$tweets->errors[0]->message.'</strong>' . $after_widget;
|
58 |
}
|
82 |
|
83 |
|
84 |
|
|
|
85 |
$tp_twitter_plugin_tweets = maybe_unserialize(get_option('tp_twitter_plugin_tweets'));
|
86 |
+
if(!empty($tp_twitter_plugin_tweets) && is_array($tp_twitter_plugin_tweets)){
|
87 |
print '
|
88 |
<div class="tp_recent_tweets">
|
89 |
<ul>';
|
100 |
}
|
101 |
|
102 |
print '
|
103 |
+
</ul>';
|
104 |
+
|
105 |
+
// If we're being supported display the link
|
106 |
+
$tp_twitter_plugin_options = get_option('tp_twitter_plugin_options');
|
107 |
+
|
108 |
+
if ($tp_twitter_plugin_options['support-us'] == 1) {
|
109 |
+
print '<p><i>Check out the <a href="https://wordpress.org/plugins/sumome/" target="_blank">SumoMe</a> plugin</i></p>';
|
110 |
+
}
|
111 |
+
print '</div>';
|
112 |
+
}else{
|
113 |
+
print '
|
114 |
+
<div class="tp_recent_tweets">
|
115 |
+
' . __('<b>Error!</b> Couldn\'t retrieve tweets for some reason!','tp_tweets') . '
|
116 |
</div>';
|
117 |
}
|
118 |
|
149 |
$instance = wp_parse_args( (array) $instance, $defaults );
|
150 |
|
151 |
echo '
|
152 |
+
<p>Get your API keys & tokens at:<br /><a href="https://dev.twitter.com/apps/" target="_blank">https://dev.twitter.com/apps/</a></p>
|
153 |
+
<p><i>Check out our <a href="https://wordpress.org/plugins/sumome/" target="_blank">SumoMe</a> plugin</i></p>
|
154 |
+
<p><label>' . __('Title:','tp_tweets') . '</label>
|
155 |
<input type="text" name="'.$this->get_field_name( 'title' ).'" id="'.$this->get_field_id( 'title' ).'" value="'.esc_attr($instance['title']).'" class="widefat" /></p>
|
156 |
+
<p><label>' . __('Consumer Key:','tp_tweets') . '</label>
|
157 |
<input type="text" name="'.$this->get_field_name( 'consumerkey' ).'" id="'.$this->get_field_id( 'consumerkey' ).'" value="'.esc_attr($instance['consumerkey']).'" class="widefat" /></p>
|
158 |
+
<p><label>' . __('Consumer Secret:','tp_tweets') . '</label>
|
159 |
<input type="text" name="'.$this->get_field_name( 'consumersecret' ).'" id="'.$this->get_field_id( 'consumersecret' ).'" value="'.esc_attr($instance['consumersecret']).'" class="widefat" /></p>
|
160 |
+
<p><label>' . __('Access Token:','tp_tweets') . '</label>
|
161 |
<input type="text" name="'.$this->get_field_name( 'accesstoken' ).'" id="'.$this->get_field_id( 'accesstoken' ).'" value="'.esc_attr($instance['accesstoken']).'" class="widefat" /></p>
|
162 |
+
<p><label>' . __('Access Token Secret:','tp_tweets') . '</label>
|
163 |
<input type="text" name="'.$this->get_field_name( 'accesstokensecret' ).'" id="'.$this->get_field_id( 'accesstokensecret' ).'" value="'.esc_attr($instance['accesstokensecret']).'" class="widefat" /></p>
|
164 |
+
<p><label>' . __('Cache Tweets in every:','tp_tweets') . '</label>
|
165 |
<input type="text" name="'.$this->get_field_name( 'cachetime' ).'" id="'.$this->get_field_id( 'cachetime' ).'" value="'.esc_attr($instance['cachetime']).'" class="small-text" /> hours</p>
|
166 |
+
<p><label>' . __('Twitter Username:','tp_tweets') . '</label>
|
167 |
<input type="text" name="'.$this->get_field_name( 'username' ).'" id="'.$this->get_field_id( 'username' ).'" value="'.esc_attr($instance['username']).'" class="widefat" /></p>
|
168 |
+
<p><label>' . __('Tweets to display:','tp_tweets') . '</label>
|
169 |
<select type="text" name="'.$this->get_field_name( 'tweetstoshow' ).'" id="'.$this->get_field_id( 'tweetstoshow' ).'">';
|
170 |
$i = 1;
|
171 |
for(i; $i <= 10; $i++){
|
173 |
}
|
174 |
echo '
|
175 |
</select></p>
|
176 |
+
<p><label>' . __('Exclude replies:','tp_tweets') . '</label>
|
177 |
<input type="checkbox" name="'.$this->get_field_name( 'excludereplies' ).'" id="'.$this->get_field_id( 'excludereplies' ).'" value="true"';
|
178 |
if(!empty($instance['excludereplies']) && esc_attr($instance['excludereplies']) == 'true'){
|
179 |
print ' checked="checked"';
|
193 |
// the target
|
194 |
$target=$targetBlank ? " target=\"_blank\" " : "";
|
195 |
|
196 |
+
// convert link to url
|
197 |
+
$status = preg_replace('/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[A-Z0-9+&@#\/%=~_|]/i', '<a href="\0" target="_blank">\0</a>', $status);
|
|
|
198 |
|
199 |
// convert @ to follow
|
200 |
$status = preg_replace("/(@([_a-z0-9\-]+))/i","<a href=\"http://twitter.com/$2\" title=\"Follow $2\" $target >$1</a>",$status);
|
212 |
if (!function_exists('tp_relative_time')) {
|
213 |
function tp_relative_time($a) {
|
214 |
//get current timestampt
|
215 |
+
$b = strtotime('now');
|
216 |
//get timestamp when tweet created
|
217 |
$c = strtotime($a);
|
218 |
//get difference
|
225 |
|
226 |
if(is_numeric($d) && $d > 0) {
|
227 |
//if less then 3 seconds
|
228 |
+
if($d < 3) return __('right now','tp_tweets');
|
229 |
//if less then minute
|
230 |
+
if($d < $minute) return floor($d) . __(' seconds ago','tp_tweets');
|
231 |
//if less then 2 minutes
|
232 |
+
if($d < $minute * 2) return __('about 1 minute ago','tp_tweets');
|
233 |
//if less then hour
|
234 |
+
if($d < $hour) return floor($d / $minute) . __(' minutes ago','tp_tweets');
|
235 |
//if less then 2 hours
|
236 |
+
if($d < $hour * 2) return __('about 1 hour ago','tp_tweets');
|
237 |
//if less then day
|
238 |
+
if($d < $day) return floor($d / $hour) . __(' hours ago','tp_tweets');
|
239 |
//if more then day, but less then 2 days
|
240 |
+
if($d > $day && $d < $day * 2) return __('yesterday','tp_tweets');
|
241 |
//if less then year
|
242 |
+
if($d < $day * 365) return floor($d / $day) . __(' days ago','tp_tweets');
|
243 |
//else return more than a year
|
244 |
+
return __('over a year ago','tp_tweets');
|
245 |
}
|
246 |
}
|
247 |
}
|