WP twitter feeds - Version 1.0

Version Description

Download this release

Release Info

Developer vivacityinfotech.jaipur
Plugin Icon 128x128 WP twitter feeds
Version 1.0
Comparing to
See all releases

Version 1.0

README.txt ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
2
+ Contributors: vivacityinfotech.jaipur
3
+ Tags: twitter feeds, twitter timeline,twitter widget,twitter widget for wordpress,wp twitter widget,live tweets, live twitter feeds, tweets, feeds, twitter time line, twitter user tweets, twitter 1.1, twitter api
4
+ Requires at least: 3.0
5
+ Tested up to: 3.8
6
+ License: GPLv2 or later
7
+
8
+ WP Twitter Feeds - A simple widget which lets you add your latest tweets in just a few clicks on your website.
9
+
10
+ == Description ==
11
+
12
+ An easy Twitter feeds widget that provides facility to display twitter tweets on your website using the latest Twitter 1.1 API. A simple widget which lets you add your latest tweets in widget areas. Get started in just a few clicks and use the provided Widget to easily display your Tweets on your website.
13
+
14
+ Now you don`t need to copy and paste the code from twitter with your settings anymore, just install the plugin and set the options.
15
+ By option page, you can define the duration of fade effect, the number of tweet to see and other things.
16
+
17
+ The "WP Twitter Feeds" Widget will never require your Twitter password, because it based on Open Authentication (OAuth) keys and secrets, that you will get by creating your application at Twitter. It gets all your required data from API. Incase you change your password, you won’t need to update your Widget in your Blog.
18
+
19
+ = Plugin Features =
20
+
21
+ *Easy install
22
+ *Very easy to configure.
23
+ *Display Tweets with a Widget.
24
+ *You can choose to show a profile image, border color and much more with your Tweets.
25
+ *Multiple instance so you can use Twitter widget multiple places.
26
+ *Different color Options.
27
+ *Lightweight and loading fast
28
+ *Set maximum number of tweets to display
29
+ *Turn on/off displaying avatar
30
+ *Supports v1.1 of the Twitter API
31
+
32
+
33
+ = Rate Us / Feedback =
34
+
35
+ Please take the time to let us and others know about your experiences by leaving a review, so that we can improve the plugin for you and other users.
36
+
37
+ If you like the plugin please [Donate here](http://tinyurl.com/owxtkmt).
38
+
39
+ = Want More? =
40
+
41
+ If You Want more functionality or some modifications, just drop us a line what you want and We will try to add or modify the plugin functions.
42
+
43
+
44
+
45
+ == Available Languages ==
46
+
47
+ English
48
+
49
+ == Installation ==
50
+
51
+ Installation consists of following steps:
52
+
53
+ 1. Upload "WP Twitter Tweets" to the /wp-content/plugins/ directory
54
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
55
+ 3. Place the "WP Twitter Tweets" Widget on your sidebar and add twitter username with API details of Twitter.
56
+
57
+ == Frequently Asked Questions ==
58
+
59
+ = How to create a Twitter Application =
60
+
61
+ 1. Visit the Twitter Developers Site: The first thing you need to do is head on down to dev.twitter.com. In order to create an account, all you need to do is click on the “Sign In” link at the top right.
62
+
63
+ 2. Sign in with your Twitter Account: Next, sign in with the Twitter account you want to associate with your app. You do have a Twitter account don’t you?!
64
+
65
+ 3. Go to “My Applications”: Once you’re logged in, click on the downwards arrow to the right of your Twitter image and select “My Applications”. This is where all your registered Twitter apps will appear.
66
+
67
+ 4. Create a New Application: If you are new to the Developers site you won’t see any applications registered. Either way, it’s time to create our first application. To do this, click on the big “Create a new application” button.
68
+
69
+ 5. Fill in your Application Details: It’s been easy so far, but this screen often makes people confused. Don’t worry, it’s a lot easier than you think. First of all you need to give your app a unique name (one that no one else has used for their Twitter app). Since we’re going to be an creating app for personal use and not one that other people can register and use, just put your domain name in or perhaps even your name. You don’t have to worry much about the description– you can change this later. I’ve put “a set of Twitter tools for personal use”.Put your website in the website field– don’t worry that it isn’t (as Twitter ask) your application’s publicly accessible home page. However, this website will be where your app is hosted.For now ignore the Callback URL field. If you are allowing users to log into your app to authenticate themselves, you’d enter the URL where they would be returned after they’ve given permission to Twitter to use your app.Once you’ve done this, make sure you’ve read the “Developer Rules Of The Road” blurb, check the “Yes, I agree” box, fill in the CAPTCHA (don’t you just love them) and click the “create your Twitter Application” button. Hurrah!
70
+
71
+ 6. Create Your Access Token.
72
+
73
+ 7. Make a note of your OAuth Settings.
74
+
75
+ == Screenshots ==
76
+
77
+ 1. WP Twitter Feeds plugin installed and appears in the plugins menu.
78
+ 2. WP Twitter Feeds widget under Appearence->Widgets.
79
+ 3. WP Twitter Feeds widget under Appearence->Widgets.
80
+ 4. WP Twitter Feeds widget under Appearence->Widgets.
81
+ 5. WP Twitter Feeds widget under Appearence->Widgets.
82
+
83
+ == Changelog ==
84
+
85
+ = 1.0 =
86
+ * Initial release
controller/twitter_widget.class.php ADDED
@@ -0,0 +1,311 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php class wptt_TwitterTweets extends WP_Widget{
2
+
3
+ function form($instance){
4
+ $defaults=$this->get_defaults();
5
+ $instance = wp_parse_args( (array) $instance, $defaults );
6
+ $widget_title = $instance['title'];
7
+ $name = $instance['name'];
8
+ $tweets_count = $instance['tweets_cnt'];
9
+ $accessTokenSecret = trim($instance['accessTokenSecret']);
10
+ $replies_excl = $instance['replies_excl'];
11
+ $consumerSecret = trim($instance['consumerSecret']);
12
+ $accessToken = trim($instance['accessToken']);
13
+ $cache_transient = $instance['timeRef'];
14
+ $alter_ago_time = $instance['timeAgo'];
15
+ $twitterIntents = $instance['twitterIntents'];
16
+ //$dataShowCount = $instance['dataShowCount'];
17
+ $disp_screen_name = $instance['disp_scr_name'];
18
+ $timeto_store = $instance['store_time'];
19
+ $consumerKey = trim($instance['consumerKey']);
20
+ $intents_text = $instance['twitterIntentsText'];
21
+ $color_intents = $instance['intentColor'];
22
+ $showAvatar = $instance['showAvatar'];
23
+ $border_rad_avatar = $instance['border_rad'];
24
+ if (!in_array('curl', get_loaded_extensions())) {
25
+ echo '<p style="background-color:pink;padding:10px;border:1px solid red;"><strong>cURL is not installed!</strong></p>';
26
+ }
27
+ include('widget_html.php');
28
+ }
29
+ function get_defaults()
30
+ {
31
+ $data = array(
32
+ 'title' => 'Latest Tweets'
33
+ , 'name' => ''
34
+ , 'tweets_cnt' => 3
35
+ , 'store_time' => 4
36
+ , 'replies_excl' => true
37
+ , 'disp_scr_name' => false
38
+ , 'consumerKey' => ''
39
+ , 'consumerSecret' => ''
40
+ , 'accessToken' => ''
41
+ , 'accessTokenSecret' => ''
42
+ , 'dataLang' => 'en'
43
+ , 'timeRef' => false
44
+ , 'timeAgo' => true
45
+ , 'twitterIntents' => false
46
+ , 'twitterIntentsText' => false
47
+ , 'intentColor' => "#999999"
48
+ , 'showAvatar' => false
49
+ , 'border_rad' => false
50
+ );
51
+ return $data;
52
+ }
53
+ function wpltf_enqueue_js($hook) {
54
+ if( $hook != 'widgets.php' )
55
+ return;
56
+
57
+
58
+ global $wp_version;
59
+ if ( 3.5 <= $wp_version ){
60
+ wp_enqueue_style( 'wp-color-picker' );
61
+ wp_enqueue_script( 'wp-color-picker' );
62
+ }
63
+ else {
64
+ wp_enqueue_style( 'farbtastic' );
65
+ wp_enqueue_script( 'farbtastic' );
66
+ }
67
+ wp_enqueue_script('admin_js', plugins_url( '/js/admin_script.js' , dirname(__FILE__) ), array('jquery'));
68
+ wp_enqueue_script('user_validate', plugins_url( '/js/validate.js' , dirname(__FILE__) ), array('jquery'));
69
+ }
70
+ function sanitize_links($tweet) {
71
+ if(isset($tweet->retweeted_status)) {
72
+ $rt_section = current(explode(":", $tweet->text));
73
+ $text = $rt_section.": ";
74
+ $text .= $tweet->retweeted_status->text;
75
+ } else {
76
+ $text = $tweet->text;
77
+ }
78
+ $text = preg_replace('/((http)+(s)?:\/\/[^<>\s]+)/i', '<a href="$0" target="_blank" rel="nofollow">$0</a>', $text );
79
+ $text = preg_replace('/[@]+([A-Za-z0-9-_]+)/', '<a href="http://twitter.com/$1" target="_blank" rel="nofollow">@$1</a>', $text );
80
+ $text = preg_replace('/[#]+([A-Za-z0-9-_]+)/', '<a href="http://twitter.com/search?q=%23$1" target="_blank" rel="nofollow">$0</a>', $text );
81
+ return $text;
82
+
83
+ }
84
+ function update($new_instance, $old_instance){
85
+ $instance = $old_instance;
86
+
87
+ $instance['title'] = strip_tags( $new_instance['title'] );
88
+ $instance['name'] = strip_tags( $new_instance['name'] );
89
+ $instance['tweets_cnt'] = $new_instance['tweets_cnt'];
90
+ $instance['store_time'] = $new_instance['store_time'];
91
+ //$instance['dataShowCount'] = $new_instance['dataShowCount'];
92
+ $instance['disp_scr_name'] = $new_instance['disp_scr_name'];
93
+ $instance['timeAgo'] = $new_instance['timeAgo'];
94
+ $instance['twitterIntents'] = $new_instance['twitterIntents'];
95
+ $instance['twitterIntentsText'] = $new_instance['twitterIntentsText'];
96
+ $instance['intentColor'] = strip_tags( $new_instance['intentColor'] );
97
+ $instance['consumerKey'] = trim($new_instance['consumerKey']);
98
+ $instance['consumerSecret'] = trim($new_instance['consumerSecret']);
99
+ $instance['accessToken'] = trim($new_instance['accessToken']);
100
+ $instance['accessTokenSecret'] = trim($new_instance['accessTokenSecret']);
101
+ $instance['replies_excl'] = $new_instance['replies_excl'];
102
+ $instance['timeRef'] = $new_instance['timeRef'];
103
+ $instance['showAvatar'] = $new_instance['showAvatar'];
104
+ $instance['border_rad'] = $new_instance['border_rad'];
105
+ return $instance;
106
+ }
107
+ function __construct() {
108
+ add_action('admin_enqueue_scripts', array(&$this, 'wpltf_enqueue_js'));
109
+ if(!is_admin())
110
+ add_action( 'wp_enqueue_scripts', array( &$this, 'wpltf_register_styles' ) );
111
+ $widget_data = array('classname' => 'wptt_TwitterTweets', 'description' => 'A simple widget which lets you add your latest tweets in just a few clicks on your website.' );
112
+ $this->WP_Widget('wptt_TwitterTweets', 'WP Twitter Feeds', $widget_data);
113
+ }
114
+
115
+ function wpltf_register_styles() {
116
+ if(!is_admin()){
117
+ wp_register_style( 'wptt_front', plugins_url( 'wp-twitter-feeds/css/admin_style.min.css' ) );
118
+ wp_enqueue_style( 'wptt_front' );
119
+ }
120
+ }
121
+ function widget($args, $instance){
122
+ extract($args, EXTR_SKIP);
123
+
124
+ echo $before_widget;
125
+ $wpltf_wdgt_title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
126
+ $wpltf_wdgt_name = $instance['name'];
127
+ $wpltf_wdgt_consumerSecret = trim($instance['consumerSecret']);
128
+ $wpltf_wdgt_accessTokenSecret = trim($instance['accessTokenSecret']);
129
+ $widget_replies_excl = isset( $instance['replies_excl'] ) ? $instance['replies_excl'] : false;
130
+ $wpltf_wdgt_accessToken = trim($instance['accessToken']);
131
+ $wpltf_wdgt_tweets_cnt = $instance['tweets_cnt'];
132
+ $wpltf_wdgt_store_time = $instance['store_time'];
133
+ $wpltf_wdgt_consumerKey = trim($instance['consumerKey']);
134
+ //$wpltf_wdgt_dataShowCount = isset( $instance['dataShowCount'] ) ? $instance['dataShowCount'] : false;
135
+ $wpltf_wdgt_disp_scr_name = isset( $instance['disp_scr_name'] ) ? $instance['disp_scr_name'] : false;
136
+ $wpltf_wdgt_timeRef = isset( $instance['timeRef'] ) ? $instance['timeRef'] : false;
137
+ $wpltf_wdgt_timeAgo = isset( $instance['timeAgo'] ) ? $instance['timeAgo'] : false;
138
+ $wpltf_wdgt_twitterIntents = isset( $instance['twitterIntents'] ) ? $instance['twitterIntents'] : false;
139
+ $wpltf_wdgt_twitterIntentsText = isset( $instance['twitterIntentsText'] ) ? $instance['twitterIntentsText'] : false;
140
+ $wpltf_wdgt_intentColor = $instance['intentColor'];
141
+ $wpltf_wdgt_showAvatar = isset( $instance['showAvatar'] ) ? $instance['showAvatar'] : false;
142
+ $wpltf_wdgt_border_rad = isset( $instance['border_rad'] ) ? $instance['border_rad'] : false;
143
+ if (!empty($wpltf_wdgt_title))
144
+ echo $before_title . $wpltf_wdgt_title . $after_title;
145
+
146
+ ?>
147
+
148
+ <ul class="tweets">
149
+ <?php
150
+
151
+ $tweets_count = $wpltf_wdgt_tweets_cnt;
152
+ $name = $wpltf_wdgt_name;
153
+ $timeto_store = $wpltf_wdgt_store_time;
154
+ $consumerSecret = trim($wpltf_wdgt_consumerSecret);
155
+ $accessToken = trim($wpltf_wdgt_accessToken);
156
+ $accessTokenSecret = trim($wpltf_wdgt_accessTokenSecret);
157
+ $replies_excl = $widget_replies_excl;
158
+ $consumerKey = trim($wpltf_wdgt_consumerKey);
159
+ //$dataShowCount = ($wpltf_wdgt_dataShowCount != "true") ? "false" : "true";
160
+ $disp_screen_name = ($wpltf_wdgt_disp_scr_name != "true") ? "false" : "true";
161
+ $intents_text = $wpltf_wdgt_twitterIntentsText;
162
+ $color_intents = $wpltf_wdgt_intentColor;
163
+ $cache_transient = $wpltf_wdgt_timeRef;
164
+ $alter_ago_time = $wpltf_wdgt_timeAgo;
165
+ $twitterIntents = $wpltf_wdgt_twitterIntents;
166
+ $showAvatar = $wpltf_wdgt_showAvatar;
167
+ $border_rad_avatar = $wpltf_wdgt_border_rad;
168
+ $transName = 'list-tweets-'.$name;
169
+ $backupName = $transName . '-backup';
170
+ if(false === ($tweets = get_transient($transName) ) ) :
171
+ include 'twitteroauth/twitteroauth.php';
172
+
173
+ $api_call = new TwitterOAuth(
174
+ $consumerKey,
175
+ $consumerSecret,
176
+ $accessToken,
177
+ $accessTokenSecret
178
+ );
179
+ $totalToFetch = ($replies_excl) ? max(50, $tweets_count * 3) : $tweets_count;
180
+
181
+ $fetchedTweets = $api_call->get(
182
+ 'statuses/user_timeline',
183
+ array(
184
+ 'screen_name' => $name,
185
+ 'count' => $totalToFetch,
186
+ 'replies_excl' => $replies_excl
187
+ )
188
+ );
189
+
190
+ if($api_call->http_code != 200) :
191
+ $tweets = get_option($backupName);
192
+
193
+ else :
194
+ $limitToDisplay = min($tweets_count, count($fetchedTweets));
195
+
196
+ for($i = 0; $i < $limitToDisplay; $i++) :
197
+ $tweet = $fetchedTweets[$i];
198
+ $name = $tweet->user->name;
199
+ $screen_name = $tweet->user->screen_name;
200
+ $permalink = 'http://twitter.com/'. $name .'/status/'. $tweet->id_str;
201
+ $tweet_id = $tweet->id_str;
202
+ $image = $tweet->user->profile_image_url;
203
+ $text = $this->sanitize_links($tweet);
204
+ $time = $tweet->created_at;
205
+ $time = date_parse($time);
206
+ $uTime = mktime($time['hour'], $time['minute'], $time['second'], $time['month'], $time['day'], $time['year']);
207
+ $tweets[] = array(
208
+ 'text' => $text,
209
+ 'scr_name'=>$screen_name,
210
+ 'name' => $name,
211
+ 'permalink' => $permalink,
212
+ 'image' => $image,
213
+ 'time' => $uTime,
214
+ 'tweet_id' => $tweet_id
215
+ );
216
+ endfor;
217
+ set_transient($transName, $tweets, 60 * $timeto_store);
218
+ update_option($backupName, $tweets);
219
+ endif;
220
+ endif;
221
+ function twitter_time_diff( $from, $to = '' ) {
222
+ $diff = human_time_diff($from,$to);
223
+ $replace = array(
224
+ ' hour' => 'h',
225
+ ' hours' => 'h',
226
+ ' day' => 'd',
227
+ ' days' => 'd',
228
+ ' minute' => 'm',
229
+ ' minutes' => 'm',
230
+ ' second' => 's',
231
+ ' seconds' => 's',
232
+ );
233
+ return strtr($diff,$replace);
234
+ }
235
+ if($tweets) : ?>
236
+ <?php foreach($tweets as $t) : ?>
237
+ <li<?php echo ($showAvatar) ? ' class="avatar"':""; ?>>
238
+ <?php
239
+ echo '<div class="tweet_wrap"><div class="wdtf-user-card ltr">';
240
+ if ($showAvatar){
241
+
242
+ echo '<img ';
243
+ echo 'width="45px" height="45px"';
244
+ echo 'src="'.$t['image'].'" alt="Tweet Avatar" class="';
245
+ echo ($border_rad_avatar) ? 'circular':'';
246
+ echo '"/>';
247
+ }
248
+ if(!isset($screen_name)){$screen_name = $name;}
249
+
250
+ if($disp_screen_name!='false')
251
+ {
252
+ echo '<div class="wdtf-screen-name">';
253
+ echo "<span class=\"screen_name\">{$t['name']}</span><br>";
254
+ echo "<a href=\"https://twitter.com/{$screen_name}\" target=\"_blank\" dir=\"ltr\">@{$screen_name}</a></div>";
255
+
256
+ }
257
+ echo '<div class="clear"></div></div>';
258
+ ?>
259
+ <div class="tweet_data">
260
+ <?php echo $t['text']; ?>
261
+ </div>
262
+ <br/>
263
+ <div class="times">
264
+ <em>
265
+
266
+ <a href="http://www.twitter.com/<?php echo $screen_name; ?>" target="_blank" title="Follow <?php echo $name; ?> on Twitter [Opens new window]">
267
+ <?php
268
+ if($cache_transient == "true"){
269
+ $timeDisplay = twitter_time_diff($t['time'], current_time('timestamp'));
270
+ }else{
271
+ $timeDisplay = human_time_diff($t['time'], current_time('timestamp'));
272
+ }
273
+ if($alter_ago_time == "true"){
274
+ $displayAgo = " ago";
275
+ }
276
+ printf(__('%1$s%2$s'), $timeDisplay, $displayAgo);
277
+
278
+ ?>
279
+ </a>
280
+ </em>
281
+ </div>
282
+ <?php if($twitterIntents == "true"){
283
+ ?>
284
+ <div class="tweets-intent-data">
285
+ <a href="http://twitter.com/intent/tweet?in_reply_to=<?php echo $t['tweet_id']; ?>" data-lang="en" class="in-reply-to" title="Reply" target="_blank">
286
+ <span aria-hidden="true" data-icon="&#xf079;" <?php echo ($color_intents) ? 'style="color:'.$color_intents.';"' :''; ?>></span>
287
+ </a>
288
+ <a href="http://twitter.com/intent/retweet?tweet_id=<?php echo $t['tweet_id']; ?>" data-lang="en" class="retweet" title="Retweet" target="_blank">
289
+ <span aria-hidden="true" data-icon="&#xf112;" <?php echo ($color_intents) ? 'style="color:'.$color_intents.';"' :''; ?>></span>
290
+ </a>
291
+ <a href="http://twitter.com/intent/favorite?tweet_id=<?php echo $t['tweet_id']; ?>" data-lang="en" class="favorite" title="Favorite" target="_blank">
292
+ <span aria-hidden="true" data-icon="&#xf005;" <?php echo ($color_intents) ? 'style="color:'.$color_intents.';"' :''; ?>></span>
293
+ </a>
294
+ </div>
295
+ <?php } ?>
296
+ <div class="clear"></div>
297
+ </div><div class="clear"></div>
298
+ </li>
299
+ <?php endforeach; ?>
300
+
301
+ <?php else : ?>
302
+ <li>Waiting for twitter.com...Try reloading the page again </li>
303
+ <?php endif; ?>
304
+ </ul>
305
+ <?php
306
+ echo $after_widget;
307
+ }
308
+
309
+ }
310
+
311
+ ?>
controller/twitteroauth/OAuth.php ADDED
@@ -0,0 +1,674 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!class_exists('OAuthException')) {
3
+ class OAuthException extends Exception {
4
+
5
+ }
6
+ }
7
+
8
+ class OAuthConsumer {
9
+ public $key;
10
+ public $secret;
11
+
12
+ function __construct($key, $secret, $callback_url=NULL) {
13
+ $this->key = $key;
14
+ $this->secret = $secret;
15
+ $this->callback_url = $callback_url;
16
+ }
17
+
18
+ function __toString() {
19
+ return "OAuthConsumer[key=$this->key,secret=$this->secret]";
20
+ }
21
+ }
22
+
23
+ class OAuthToken {
24
+ public $key;
25
+ public $secret;
26
+
27
+ function __construct($key, $secret) {
28
+ $this->key = $key;
29
+ $this->secret = $secret;
30
+ }
31
+
32
+
33
+ function to_string() {
34
+ return "oauth_token=" .
35
+ OAuthUtil::urlencode_rfc3986($this->key) .
36
+ "&oauth_token_secret=" .
37
+ OAuthUtil::urlencode_rfc3986($this->secret);
38
+ }
39
+
40
+ function __toString() {
41
+ return $this->to_string();
42
+ }
43
+ }
44
+
45
+ abstract class OAuthSignatureMethod {
46
+
47
+ abstract public function get_name();
48
+
49
+
50
+ abstract public function build_signature($request, $consumer, $token);
51
+
52
+ public function check_signature($request, $consumer, $token, $signature) {
53
+ $built = $this->build_signature($request, $consumer, $token);
54
+ return $built == $signature;
55
+ }
56
+ }
57
+
58
+ class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
59
+ function get_name() {
60
+ return "HMAC-SHA1";
61
+ }
62
+
63
+ public function build_signature($request, $consumer, $token) {
64
+ $base_string = $request->get_signature_base_string();
65
+ $request->base_string = $base_string;
66
+
67
+ $key_parts = array(
68
+ $consumer->secret,
69
+ ($token) ? $token->secret : ""
70
+ );
71
+
72
+ $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
73
+ $key = implode('&', $key_parts);
74
+
75
+ return base64_encode(hash_hmac('sha1', $base_string, $key, true));
76
+ }
77
+ }
78
+
79
+
80
+ class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
81
+ public function get_name() {
82
+ return "PLAINTEXT";
83
+ }
84
+
85
+
86
+ public function build_signature($request, $consumer, $token) {
87
+ $key_parts = array(
88
+ $consumer->secret,
89
+ ($token) ? $token->secret : ""
90
+ );
91
+
92
+ $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
93
+ $key = implode('&', $key_parts);
94
+ $request->base_string = $key;
95
+
96
+ return $key;
97
+ }
98
+ }
99
+
100
+
101
+ abstract class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
102
+ public function get_name() {
103
+ return "RSA-SHA1";
104
+ }
105
+
106
+
107
+ protected abstract function fetch_public_cert(&$request);
108
+
109
+
110
+ protected abstract function fetch_private_cert(&$request);
111
+
112
+ public function build_signature($request, $consumer, $token) {
113
+ $base_string = $request->get_signature_base_string();
114
+ $request->base_string = $base_string;
115
+
116
+
117
+ $cert = $this->fetch_private_cert($request);
118
+
119
+ $privatekeyid = openssl_get_privatekey($cert);
120
+
121
+ $ok = openssl_sign($base_string, $signature, $privatekeyid);
122
+
123
+ openssl_free_key($privatekeyid);
124
+
125
+ return base64_encode($signature);
126
+ }
127
+
128
+ public function check_signature($request, $consumer, $token, $signature) {
129
+ $decoded_sig = base64_decode($signature);
130
+
131
+ $base_string = $request->get_signature_base_string();
132
+
133
+ $cert = $this->fetch_public_cert($request);
134
+
135
+ $publickeyid = openssl_get_publickey($cert);
136
+
137
+ $ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
138
+
139
+ openssl_free_key($publickeyid);
140
+
141
+ return $ok == 1;
142
+ }
143
+ }
144
+
145
+ class OAuthRequest {
146
+ private $parameters;
147
+ private $http_method;
148
+ private $http_url;
149
+ public $base_string;
150
+ public static $version = '1.0';
151
+ public static $POST_INPUT = 'php://input';
152
+
153
+ function __construct($http_method, $http_url, $parameters=NULL) {
154
+ @$parameters or $parameters = array();
155
+ $parameters = array_merge( OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
156
+ $this->parameters = $parameters;
157
+ $this->http_method = $http_method;
158
+ $this->http_url = $http_url;
159
+ }
160
+
161
+ public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
162
+ $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
163
+ ? 'http'
164
+ : 'https';
165
+ @$http_url or $http_url = $scheme .
166
+ '://' . $_SERVER['HTTP_HOST'] .
167
+ ':' .
168
+ $_SERVER['SERVER_PORT'] .
169
+ $_SERVER['REQUEST_URI'];
170
+ @$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
171
+
172
+
173
+ if (!$parameters) {
174
+
175
+ $request_headers = OAuthUtil::get_headers();
176
+
177
+
178
+ $parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
179
+
180
+ if ($http_method == "POST"
181
+ && @strstr($request_headers["Content-Type"],
182
+ "application/x-www-form-urlencoded")
183
+ ) {
184
+ $post_data = OAuthUtil::parse_parameters(
185
+ file_get_contents(self::$POST_INPUT)
186
+ );
187
+ $parameters = array_merge($parameters, $post_data);
188
+ }
189
+
190
+ if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
191
+ $header_parameters = OAuthUtil::split_header(
192
+ $request_headers['Authorization']
193
+ );
194
+ $parameters = array_merge($parameters, $header_parameters);
195
+ }
196
+
197
+ }
198
+
199
+ return new OAuthRequest($http_method, $http_url, $parameters);
200
+ }
201
+
202
+ public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
203
+ @$parameters or $parameters = array();
204
+ $defaults = array("oauth_version" => OAuthRequest::$version,
205
+ "oauth_nonce" => OAuthRequest::generate_nonce(),
206
+ "oauth_timestamp" => OAuthRequest::generate_timestamp(),
207
+ "oauth_consumer_key" => $consumer->key);
208
+ if ($token)
209
+ $defaults['oauth_token'] = $token->key;
210
+
211
+ $parameters = array_merge($defaults, $parameters);
212
+
213
+ return new OAuthRequest($http_method, $http_url, $parameters);
214
+ }
215
+
216
+ public function set_parameter($name, $value, $allow_duplicates = true) {
217
+ if ($allow_duplicates && isset($this->parameters[$name])) {
218
+ if (is_scalar($this->parameters[$name])) {
219
+
220
+ $this->parameters[$name] = array($this->parameters[$name]);
221
+ }
222
+
223
+ $this->parameters[$name][] = $value;
224
+ } else {
225
+ $this->parameters[$name] = $value;
226
+ }
227
+ }
228
+
229
+ public function get_parameter($name) {
230
+ return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
231
+ }
232
+
233
+ public function get_parameters() {
234
+ return $this->parameters;
235
+ }
236
+
237
+ public function unset_parameter($name) {
238
+ unset($this->parameters[$name]);
239
+ }
240
+
241
+ public function get_signable_parameters() {
242
+
243
+ $params = $this->parameters;
244
+
245
+
246
+ if (isset($params['oauth_signature'])) {
247
+ unset($params['oauth_signature']);
248
+ }
249
+
250
+ return OAuthUtil::build_http_query($params);
251
+ }
252
+
253
+ public function get_signature_base_string() {
254
+ $parts = array(
255
+ $this->get_normalized_http_method(),
256
+ $this->get_normalized_http_url(),
257
+ $this->get_signable_parameters()
258
+ );
259
+
260
+ $parts = OAuthUtil::urlencode_rfc3986($parts);
261
+
262
+ return implode('&', $parts);
263
+ }
264
+
265
+ public function get_normalized_http_method() {
266
+ return strtoupper($this->http_method);
267
+ }
268
+
269
+ public function get_normalized_http_url() {
270
+ $parts = parse_url($this->http_url);
271
+
272
+ $port = @$parts['port'];
273
+ $scheme = $parts['scheme'];
274
+ $host = $parts['host'];
275
+ $path = @$parts['path'];
276
+
277
+ $port or $port = ($scheme == 'https') ? '443' : '80';
278
+
279
+ if (($scheme == 'https' && $port != '443')
280
+ || ($scheme == 'http' && $port != '80')) {
281
+ $host = "$host:$port";
282
+ }
283
+ return "$scheme://$host$path";
284
+ }
285
+
286
+ public function to_url() {
287
+ $post_data = $this->to_postdata();
288
+ $out = $this->get_normalized_http_url();
289
+ if ($post_data) {
290
+ $out .= '?'.$post_data;
291
+ }
292
+ return $out;
293
+ }
294
+
295
+ public function to_postdata() {
296
+ return OAuthUtil::build_http_query($this->parameters);
297
+ }
298
+
299
+ public function to_header($realm=null) {
300
+ $first = true;
301
+ if($realm) {
302
+ $out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
303
+ $first = false;
304
+ } else
305
+ $out = 'Authorization: OAuth';
306
+
307
+ $total = array();
308
+ foreach ($this->parameters as $k => $v) {
309
+ if (substr($k, 0, 5) != "oauth") continue;
310
+ if (is_array($v)) {
311
+ throw new OAuthException('Arrays not supported in headers');
312
+ }
313
+ $out .= ($first) ? ' ' : ',';
314
+ $out .= OAuthUtil::urlencode_rfc3986($k) .
315
+ '="' .
316
+ OAuthUtil::urlencode_rfc3986($v) .
317
+ '"';
318
+ $first = false;
319
+ }
320
+ return $out;
321
+ }
322
+
323
+ public function __toString() {
324
+ return $this->to_url();
325
+ }
326
+
327
+
328
+ public function sign_request($signature_method, $consumer, $token) {
329
+ $this->set_parameter(
330
+ "oauth_signature_method",
331
+ $signature_method->get_name(),
332
+ false
333
+ );
334
+ $signature = $this->build_signature($signature_method, $consumer, $token);
335
+ $this->set_parameter("oauth_signature", $signature, false);
336
+ }
337
+
338
+ public function build_signature($signature_method, $consumer, $token) {
339
+ $signature = $signature_method->build_signature($this, $consumer, $token);
340
+ return $signature;
341
+ }
342
+
343
+
344
+ private static function generate_timestamp() {
345
+ return time();
346
+ }
347
+
348
+
349
+ private static function generate_nonce() {
350
+ $mt = microtime();
351
+ $rand = mt_rand();
352
+
353
+ return md5($mt . $rand); // md5s look nicer than numbers
354
+ }
355
+ }
356
+
357
+ class OAuthServer {
358
+ protected $timestamp_threshold = 300; // in seconds, five minutes
359
+ protected $version = '1.0'; // hi blaine
360
+ protected $signature_methods = array();
361
+
362
+ protected $data_store;
363
+
364
+ function __construct($data_store) {
365
+ $this->data_store = $data_store;
366
+ }
367
+
368
+ public function add_signature_method($signature_method) {
369
+ $this->signature_methods[$signature_method->get_name()] =
370
+ $signature_method;
371
+ }
372
+
373
+ public function fetch_request_token(&$request) {
374
+ $this->get_version($request);
375
+
376
+ $consumer = $this->get_consumer($request);
377
+ $token = NULL;
378
+
379
+ $this->check_signature($request, $consumer, $token);
380
+
381
+ $callback = $request->get_parameter('oauth_callback');
382
+ $new_token = $this->data_store->new_request_token($consumer, $callback);
383
+
384
+ return $new_token;
385
+ }
386
+
387
+
388
+ public function fetch_access_token(&$request) {
389
+ $this->get_version($request);
390
+
391
+ $consumer = $this->get_consumer($request);
392
+
393
+ $token = $this->get_token($request, $consumer, "request");
394
+
395
+ $this->check_signature($request, $consumer, $token);
396
+
397
+ $verifier = $request->get_parameter('oauth_verifier');
398
+ $new_token = $this->data_store->new_access_token($token, $consumer, $verifier);
399
+
400
+ return $new_token;
401
+ }
402
+
403
+ public function verify_request(&$request) {
404
+ $this->get_version($request);
405
+ $consumer = $this->get_consumer($request);
406
+ $token = $this->get_token($request, $consumer, "access");
407
+ $this->check_signature($request, $consumer, $token);
408
+ return array($consumer, $token);
409
+ }
410
+
411
+ private function get_version(&$request) {
412
+ $version = $request->get_parameter("oauth_version");
413
+ if (!$version) {
414
+ $version = '1.0';
415
+ }
416
+ if ($version !== $this->version) {
417
+ throw new OAuthException("OAuth version '$version' not supported");
418
+ }
419
+ return $version;
420
+ }
421
+
422
+ private function get_signature_method(&$request) {
423
+ $signature_method =
424
+ @$request->get_parameter("oauth_signature_method");
425
+
426
+ if (!$signature_method) {
427
+ throw new OAuthException('No signature method parameter. This parameter is required');
428
+ }
429
+
430
+ if (!in_array($signature_method,
431
+ array_keys($this->signature_methods))) {
432
+ throw new OAuthException(
433
+ "Signature method '$signature_method' not supported " .
434
+ "try one of the following: " .
435
+ implode(", ", array_keys($this->signature_methods))
436
+ );
437
+ }
438
+ return $this->signature_methods[$signature_method];
439
+ }
440
+
441
+ private function get_consumer(&$request) {
442
+ $consumer_key = @$request->get_parameter("oauth_consumer_key");
443
+ if (!$consumer_key) {
444
+ throw new OAuthException("Invalid consumer key");
445
+ }
446
+
447
+ $consumer = $this->data_store->lookup_consumer($consumer_key);
448
+ if (!$consumer) {
449
+ throw new OAuthException("Invalid consumer");
450
+ }
451
+
452
+ return $consumer;
453
+ }
454
+
455
+
456
+ private function get_token(&$request, $consumer, $token_type="access") {
457
+ $token_field = @$request->get_parameter('oauth_token');
458
+ $token = $this->data_store->lookup_token(
459
+ $consumer, $token_type, $token_field
460
+ );
461
+ if (!$token) {
462
+ throw new OAuthException("Invalid $token_type token: $token_field");
463
+ }
464
+ return $token;
465
+ }
466
+
467
+
468
+ private function check_signature(&$request, $consumer, $token) {
469
+ $timestamp = @$request->get_parameter('oauth_timestamp');
470
+ $nonce = @$request->get_parameter('oauth_nonce');
471
+
472
+ $this->check_timestamp($timestamp);
473
+ $this->check_nonce($consumer, $token, $nonce, $timestamp);
474
+
475
+ $signature_method = $this->get_signature_method($request);
476
+
477
+ $signature = $request->get_parameter('oauth_signature');
478
+ $valid_sig = $signature_method->check_signature(
479
+ $request,
480
+ $consumer,
481
+ $token,
482
+ $signature
483
+ );
484
+
485
+ if (!$valid_sig) {
486
+ throw new OAuthException("Invalid signature");
487
+ }
488
+ }
489
+
490
+ private function check_timestamp($timestamp) {
491
+ if( ! $timestamp )
492
+ throw new OAuthException(
493
+ 'Missing timestamp parameter. The parameter is required'
494
+ );
495
+
496
+ $now = time();
497
+ if (abs($now - $timestamp) > $this->timestamp_threshold) {
498
+ throw new OAuthException(
499
+ "Expired timestamp, yours $timestamp, ours $now"
500
+ );
501
+ }
502
+ }
503
+
504
+ private function check_nonce($consumer, $token, $nonce, $timestamp) {
505
+ if( ! $nonce )
506
+ throw new OAuthException(
507
+ 'Missing nonce parameter. The parameter is required'
508
+ );
509
+
510
+ $found = $this->data_store->lookup_nonce(
511
+ $consumer,
512
+ $token,
513
+ $nonce,
514
+ $timestamp
515
+ );
516
+ if ($found) {
517
+ throw new OAuthException("Nonce already used: $nonce");
518
+ }
519
+ }
520
+
521
+ }
522
+
523
+ class OAuthDataStore {
524
+ function lookup_consumer($consumer_key) {
525
+
526
+ }
527
+
528
+ function lookup_token($consumer, $token_type, $token) {
529
+
530
+ }
531
+
532
+ function lookup_nonce($consumer, $token, $nonce, $timestamp) {
533
+
534
+ }
535
+
536
+ function new_request_token($consumer, $callback = null) {
537
+
538
+ }
539
+
540
+ function new_access_token($token, $consumer, $verifier = null) {
541
+
542
+ }
543
+
544
+ }
545
+
546
+ class OAuthUtil {
547
+ public static function urlencode_rfc3986($input) {
548
+ if (is_array($input)) {
549
+ return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
550
+ } else if (is_scalar($input)) {
551
+ return str_replace(
552
+ '+',
553
+ ' ',
554
+ str_replace('%7E', '~', rawurlencode($input))
555
+ );
556
+ } else {
557
+ return '';
558
+ }
559
+ }
560
+
561
+ public static function urldecode_rfc3986($string) {
562
+ return urldecode($string);
563
+ }
564
+
565
+ public static function split_header($header, $only_allow_oauth_parameters = true) {
566
+ $pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
567
+ $offset = 0;
568
+ $params = array();
569
+ while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
570
+ $match = $matches[0];
571
+ $header_name = $matches[2][0];
572
+ $header_content = (isset($matches[5])) ? $matches[5][0] : $matches[4][0];
573
+ if (preg_match('/^oauth_/', $header_name) || !$only_allow_oauth_parameters) {
574
+ $params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
575
+ }
576
+ $offset = $match[1] + strlen($match[0]);
577
+ }
578
+
579
+ if (isset($params['realm'])) {
580
+ unset($params['realm']);
581
+ }
582
+
583
+ return $params;
584
+ }
585
+
586
+ public static function get_headers() {
587
+ if (function_exists('apache_request_headers')) {
588
+
589
+ $headers = apache_request_headers();
590
+
591
+ $out = array();
592
+ foreach( $headers AS $key => $value ) {
593
+ $key = str_replace(
594
+ " ",
595
+ "-",
596
+ ucwords(strtolower(str_replace("-", " ", $key)))
597
+ );
598
+ $out[$key] = $value;
599
+ }
600
+ } else {
601
+
602
+ $out = array();
603
+ if( isset($_SERVER['CONTENT_TYPE']) )
604
+ $out['Content-Type'] = $_SERVER['CONTENT_TYPE'];
605
+ if( isset($_ENV['CONTENT_TYPE']) )
606
+ $out['Content-Type'] = $_ENV['CONTENT_TYPE'];
607
+
608
+ foreach ($_SERVER as $key => $value) {
609
+ if (substr($key, 0, 5) == "HTTP_") {
610
+
611
+ $key = str_replace(
612
+ " ",
613
+ "-",
614
+ ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
615
+ );
616
+ $out[$key] = $value;
617
+ }
618
+ }
619
+ }
620
+ return $out;
621
+ }
622
+
623
+ public static function parse_parameters( $input ) {
624
+ if (!isset($input) || !$input) return array();
625
+
626
+ $pairs = explode('&', $input);
627
+
628
+ $parsed_parameters = array();
629
+ foreach ($pairs as $pair) {
630
+ $split = explode('=', $pair, 2);
631
+ $parameter = OAuthUtil::urldecode_rfc3986($split[0]);
632
+ $value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
633
+
634
+ if (isset($parsed_parameters[$parameter])) {
635
+
636
+
637
+ if (is_scalar($parsed_parameters[$parameter])) {
638
+
639
+ $parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
640
+ }
641
+
642
+ $parsed_parameters[$parameter][] = $value;
643
+ } else {
644
+ $parsed_parameters[$parameter] = $value;
645
+ }
646
+ }
647
+ return $parsed_parameters;
648
+ }
649
+
650
+ public static function build_http_query($params) {
651
+ if (!$params) return '';
652
+
653
+ $keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
654
+ $values = OAuthUtil::urlencode_rfc3986(array_values($params));
655
+ $params = array_combine($keys, $values);
656
+
657
+ uksort($params, 'strcmp');
658
+
659
+ $pairs = array();
660
+ foreach ($params as $parameter => $value) {
661
+ if (is_array($value)) {
662
+
663
+ natsort($value);
664
+ foreach ($value as $duplicate_value) {
665
+ $pairs[] = $parameter . '=' . $duplicate_value;
666
+ }
667
+ } else {
668
+ $pairs[] = $parameter . '=' . $value;
669
+ }
670
+ }
671
+
672
+ return implode('&', $pairs);
673
+ }
674
+ }
controller/twitteroauth/twitteroauth.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once('OAuth.php');
3
+
4
+ class TwitterOAuth {
5
+
6
+ public $http_code;
7
+ public $url;
8
+ public $host = "https://api.twitter.com/1.1/";
9
+ public $timeout = 30;
10
+ public $connecttimeout = 30;
11
+ public $ssl_verifypeer = FALSE;
12
+ public $format = 'json';
13
+ public $decode_json = TRUE;
14
+ public $http_info;
15
+ public $useragent = 'TwitterOAuth v0.2.0-beta2';
16
+ function accessTokenURL() { return 'https://api.twitter.com/oauth/access_token'; }
17
+ function authenticateURL() { return 'https://api.twitter.com/oauth/authenticate'; }
18
+ function authorizeURL() { return 'https://api.twitter.com/oauth/authorize'; }
19
+ function requestTokenURL() { return 'https://api.twitter.com/oauth/request_token'; }
20
+
21
+ function lastStatusCode() { return $this->http_status; }
22
+ function lastAPICall() { return $this->last_awptt_widget_call; }
23
+
24
+ function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
25
+ $this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
26
+ $this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
27
+ if (!empty($oauth_token) && !empty($oauth_token_secret)) {
28
+ $this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
29
+ } else {
30
+ $this->token = NULL;
31
+ }
32
+ }
33
+
34
+
35
+
36
+ function getRequestToken($oauth_callback) {
37
+ $parameters = array();
38
+ $parameters['oauth_callback'] = $oauth_callback;
39
+ $request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
40
+ $token = OAuthUtil::parse_parameters($request);
41
+ $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
42
+ return $token;
43
+ }
44
+
45
+ function getAuthorizeURL($token, $sign_in_with_twitter = TRUE) {
46
+ if (is_array($token)) {
47
+ $token = $token['oauth_token'];
48
+ }
49
+ if (empty($sign_in_with_twitter)) {
50
+ return $this->authorizeURL() . "?oauth_token={$token}";
51
+ } else {
52
+ return $this->authenticateURL() . "?oauth_token={$token}";
53
+ }
54
+ }
55
+
56
+
57
+ function getAccessToken($oauth_verifier) {
58
+ $parameters = array();
59
+ $parameters['oauth_verifier'] = $oauth_verifier;
60
+ $request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
61
+ $token = OAuthUtil::parse_parameters($request);
62
+ $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
63
+ return $token;
64
+ }
65
+
66
+
67
+ function getXAuthToken($username, $password) {
68
+ $parameters = array();
69
+ $parameters['x_auth_username'] = $username;
70
+ $parameters['x_auth_password'] = $password;
71
+ $parameters['x_auth_mode'] = 'client_auth';
72
+ $request = $this->oAuthRequest($this->accessTokenURL(), 'POST', $parameters);
73
+ $token = OAuthUtil::parse_parameters($request);
74
+ $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
75
+ return $token;
76
+ }
77
+
78
+ function get($url, $parameters = array()) {
79
+ $response = $this->oAuthRequest($url, 'GET', $parameters);
80
+ if ($this->format === 'json' && $this->decode_json) {
81
+ return json_decode($response);
82
+ }
83
+ return $response;
84
+ }
85
+
86
+ function post($url, $parameters = array()) {
87
+ $response = $this->oAuthRequest($url, 'POST', $parameters);
88
+ if ($this->format === 'json' && $this->decode_json) {
89
+ return json_decode($response);
90
+ }
91
+ return $response;
92
+ }
93
+
94
+ function delete($url, $parameters = array()) {
95
+ $response = $this->oAuthRequest($url, 'DELETE', $parameters);
96
+ if ($this->format === 'json' && $this->decode_json) {
97
+ return json_decode($response);
98
+ }
99
+ return $response;
100
+ }
101
+
102
+
103
+ function oAuthRequest($url, $method, $parameters) {
104
+ if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
105
+ $url = "{$this->host}{$url}.{$this->format}";
106
+ }
107
+ $request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
108
+ $request->sign_request($this->sha1_method, $this->consumer, $this->token);
109
+ switch ($method) {
110
+ case 'GET':
111
+ return $this->http($request->to_url(), 'GET');
112
+ default:
113
+ return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
114
+ }
115
+ }
116
+
117
+ function http($url, $method, $postfields = NULL) {
118
+ $this->http_info = array();
119
+ $ci = curl_init();
120
+
121
+ curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
122
+ curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
123
+ curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
124
+ curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
125
+ curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
126
+ curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
127
+ curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
128
+ curl_setopt($ci, CURLOPT_HEADER, FALSE);
129
+
130
+ switch ($method) {
131
+ case 'POST':
132
+ curl_setopt($ci, CURLOPT_POST, TRUE);
133
+ if (!empty($postfields)) {
134
+ curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
135
+ }
136
+ break;
137
+ case 'DELETE':
138
+ curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
139
+ if (!empty($postfields)) {
140
+ $url = "{$url}?{$postfields}";
141
+ }
142
+ }
143
+
144
+ curl_setopt($ci, CURLOPT_URL, $url);
145
+ $response = curl_exec($ci);
146
+ $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
147
+ $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
148
+ $this->url = $url;
149
+ curl_close ($ci);
150
+ return $response;
151
+ }
152
+
153
+ function getHeader($ch, $header) {
154
+ $i = strpos($header, ':');
155
+ if (!empty($i)) {
156
+ $key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
157
+ $value = trim(substr($header, $i + 2));
158
+ $this->http_header[$key] = $value;
159
+ }
160
+ return strlen($header);
161
+ }
162
+ }
controller/widget_html.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <style>input.user-validator-valid {
2
+ background-color: #99FFAC;
3
+ color: #2C823C;
4
+ font-weight:bold;
5
+ }
6
+ input.user-validator-invalid {
7
+ background-color: #ff9988;
8
+ color: #660011;
9
+ font-weight:bold;
10
+ }
11
+ </style>
12
+ <p>
13
+ <label for="<?php echo $this->get_field_id('title'); ?>">Widget 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($widget_title); ?>" /></label>
14
+ </p>
15
+ <p>
16
+ <label for="<?php echo $this->get_field_id('name'); ?>">Twitter User Name: <input class="widefat twitter_user_name" 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>
17
+ <input type="text" disabled="disabled" value="Start entering your user name" class="widefat user-validator">
18
+ </p>
19
+ <p>
20
+ <label for="<?php echo $this->get_field_id('store_time'); ?>">Tweets Cache Time (in minutes): <input class="widefat" id="<?php echo $this->get_field_id('store_time'); ?>" name="<?php echo $this->get_field_name('store_time'); ?>" type="text" value="<?php echo esc_attr($timeto_store); ?>" /></label>
21
+ </p>
22
+ <p>
23
+ <label for="<?php echo $this->get_field_id('tweets_cnt'); ?>">Number of Tweets to Fetch: <input class="widefat" id="<?php echo $this->get_field_id('tweets_cnt'); ?>" name="<?php echo $this->get_field_name('tweets_cnt'); ?>" type="text" value="<?php echo esc_attr($tweets_count); ?>" /></label>
24
+ </p>
25
+
26
+ <h4 style="width:100%; text-align:center;">Twitter API Settings</h4>
27
+ <div style="padding:10px;">
28
+ <p>
29
+ <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>
30
+ </p>
31
+ <p>
32
+ <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>
33
+ </p>
34
+ <p>
35
+ <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>
36
+ </p>
37
+ <p>
38
+ <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>
39
+ </p>
40
+
41
+ </div>
42
+ <h4 style="width:100%; text-align:center;">Advanced Options</h4>
43
+ <div style="padding:10px;">
44
+ <p>
45
+ <input class="checkbox" type="checkbox" value="true" <?php checked( (isset( $instance['twitterIntents']) && ($instance['twitterIntents'] == "true") ), true ); ?> id="<?php echo $this->get_field_id( 'twitterIntents' ); ?>" name="<?php echo $this->get_field_name( 'twitterIntents' ); ?>" />
46
+ <label for="<?php echo $this->get_field_id( 'twitterIntents' ); ?>">Show Twitter Intents</label>
47
+ </p>
48
+ <p>
49
+ <input class="checkbox" type="checkbox" value="true" <?php checked( (isset( $instance['twitterIntentsText']) && ($instance['twitterIntentsText'] == "true") ), true ); ?> id="<?php echo $this->get_field_id( 'twitterIntentsText' ); ?>" name="<?php echo $this->get_field_name( 'twitterIntentsText' ); ?>" />
50
+ <label for="<?php echo $this->get_field_id( 'twitterIntentsText' ); ?>">Hide Twitter Intents Text</label>
51
+ </p>
52
+ <p>
53
+ <label for="<?php echo $this->get_field_id('intentColor'); ?>">Colour for Intent icons: <input class="intentColor widefat" id="<?php echo $this->get_field_id('intentColor'); ?>" name="<?php echo $this->get_field_name('intentColor'); ?>" type="text" value="<?php echo esc_attr($color_intents); ?>" /></label>
54
+ <div id="colorpicker"></div>
55
+ </p>
56
+ <p>
57
+ <input class="checkbox" type="checkbox" value="true" <?php checked( ( isset( $instance['border_rad']) && ($instance['showAvatar'] == "true") ), true ); ?> id="<?php echo $this->get_field_id( 'border_rad' ); ?>" name="<?php echo $this->get_field_name( 'border_rad' ); ?>" />
58
+ <label for="<?php echo $this->get_field_id( 'border_rad' ); ?>">Circular Avatar image</label>
59
+ </p>
60
+ <p>
61
+ <input class="checkbox" type="checkbox" value="true" <?php checked( ( isset( $instance['showAvatar']) && ($instance['showAvatar'] == "true") ), true ); ?> id="<?php echo $this->get_field_id( 'showAvatar' ); ?>" name="<?php echo $this->get_field_name( 'showAvatar' ); ?>" />
62
+ <label for="<?php echo $this->get_field_id( 'showAvatar' ); ?>">Display avatar image</label>
63
+ </p>
64
+
65
+ <p>
66
+ <input class="checkbox" type="checkbox" <?php checked( isset( $instance['replies_excl']), true ); ?> id="<?php echo $this->get_field_id( 'replies_excl' ); ?>" name="<?php echo $this->get_field_name( 'replies_excl' ); ?>" />
67
+ <label for="<?php echo $this->get_field_id( 'replies_excl' ); ?>">Exclude @replies</label>
68
+ </p>
69
+ <p>
70
+ <input class="checkbox" type="checkbox" value="true" <?php checked( (isset( $instance['timeAgo']) && ($instance['timeAgo'] == "true") ), true ); ?> id="<?php echo $this->get_field_id( 'timeAgo' ); ?>" name="<?php echo $this->get_field_name( 'timeAgo' ); ?>" value="true" />
71
+ <label for="<?php echo $this->get_field_id( 'timeAgo' ); ?>">Show "ago" after the time</label>
72
+ </p>
73
+ <p>
74
+ <input class="checkbox" type="checkbox" value="true" <?php checked( (isset( $instance['timeRef']) && ($instance['timeRef'] == "true") ), true ); ?> id="<?php echo $this->get_field_id( 'timeRef' ); ?>" name="<?php echo $this->get_field_name( 'timeRef' ); ?>" />
75
+ <label for="<?php echo $this->get_field_id( 'timeRef' ); ?>">Set Twitter like short time</label>
76
+ </p>
77
+ <p>
78
+ <input class="checkbox" type="checkbox" <?php checked( (isset( $instance['disp_scr_name']) && ($instance['disp_scr_name'] == "true") ), true ); ?> id="<?php echo $this->get_field_id( 'disp_scr_name' ); ?>" name="<?php echo $this->get_field_name( 'disp_scr_name' ); ?>" value="true" />
79
+ <label for="<?php echo $this->get_field_id( 'disp_scr_name' ); ?>">Show Twitter Screen Name</label>
80
+ </p>
81
+ </div>
css/admin_style.min.css ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @font-face{font-family:'wpltf_intents';src:url('fonts/wpltf_intents.eot')}@font-face{font-family:'wpltf_intents';src:url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAWQAA0AAAAACAgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABMAAAABoAAAAcZoSdXkdERUYAAAFMAAAAHwAAACAANQAGT1MvMgAAAWwAAABHAAAAVi7i3BxjbWFwAAABtAAAAFUAAAFqodkD8Wdhc3AAAAIMAAAACAAAAAj//wADZ2x5ZgAAAhQAAAHQAAACXJAtYUdoZWFkAAAD5AAAADMAAAA2/fluKWhoZWEAAAQYAAAAIAAAACQDif/paG10eAAABDgAAAAYAAAAIAlVAABsb2NhAAAEUAAAABIAAAASAewBNG1heHAAAARkAAAAHQAAACAATABPbmFtZQAABIQAAADXAAABuXl6fnVwb3N0AAAFXAAAADQAAABaJCWFRHicY2BgYGQAgpOd+YYg+lztdDEYDQBAyQXkAAB4nGNgZGBg4ANiCQYQYGJgZGBmYAeSLGAeAwAEsQA8AHicY2BkPMA4gYGVgYNRmdGSgYHBDkpfZxBjKGZgYGJgZWaAAwEEkyEgzTWFweEBw0chxob/Bxg0GBsYHBoYGBhBcgCOlwsBAHicY2BgYGaAYBkGRgYQSAHyGMF8FgYPIM3HwMHAxMDGwPCA4QPDB9YPlR+F/v8HKUTlK7ALMAsw8nfzfYaagwQYgbphgoxMQIIJXQG6juEHAJ1mEWUAAAAAAAAB//8AAnicVZG5bttAEEB39hhKS5qWFR4WdFgiYVFHIDG8rEBwxC5FYsBdDDiFECCGS8GVGxv6BH+CviFfwC8J3AZp8gVWlsrhZLGzcwLzZpYAIdsCClgTSsgB9KB4ymH9lBN1ytyjyq3IS0KOLc0yQUPf66dJlmZpMhFjsC30ptBPFpBFThviyHWg6HJGGeccoFI7bAXB4UwaYi3UNeTsy3DvevQWqhrlgtMqHJiNQdvZq7AcZVmhRGL+uaf60x3EI3TJMXlXEuAYvAlNTvkOoux5BI5dhu24NE+sfdjxKMI5pP5fM+pQq83jyIFcsB+UAQ1R8nNeUyIxfOB0QDf8XJji2X8urDABDDgwNriWiHyJuOSIcslCdvWfS9m/pX92+B02cEu8coJ9cC0FXJL9XuUCgvKlahbqwAYvbSE4rlbIUYB9ieb9TGHO7s2vQru4oww1Np8zDYHfXWhC0vqNlDf1X6vabrff1H99IKFyUMtOUOv7HtqWO4GgVF4Q2pbjqs5BB3bKiaM3NE3SDIpGq6O3jpqDfsZef/KNofti1DWMarU67US5rudnp1cLvwljndd7NWxnfV2yeGQ3XjV16MXIacuHAIbT9x8niBYhPwFSAFEqeJxjYGRgYADiMywHV8fz23xl4GY8ABRhOFc7XQxG/////wDjA8YGIJeDgQkkCgByZg3DAHicY2BkYGBs+H+AQYPxwf///xwYHzAARVAABwC4bQdxeJxjPMAAAVMhFCOQz/gAiBdA2ABAiwRbAAAAAAAAAAAADgBOALAA5gEuAAB4nGNgZGBg4GDwYWBiAAEQycgAEnMA8xkACqsAnAAAAHicjY6xDcIwEEV/QgChIEqgdEFB48gOVBE1NVU2iFAaR0o8ByWrMAYDMAYDwHc4IYQosOW753/f5wMwxRkRwoqQYikcY4yt8ABrnIQTeq7CQ/JdeIQ0WtAZJRMq8/5V4BgzrIQHOGAnnNBzER6Sb8Ij8gMdPLdGDcdc9bEDOu917XzlPC9ftbe+R9NrIbc40qGQI4NhLnh+937VLLfmMYw5o8WGDRvn9017rFSeGVWojyl4s1Zbo3Nj6fxn7JJ6S7XuxwxfhtFQVm1XN07ZzPzV5wlIcketAHicY2BiwA84gJiRgYmRiZGZkYWRlZGNvTQv083AwABCm1uCaUNDI6i4KYh2BcoDAOnwCww=) format('woff'),url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAANAIAAAwBQRkZUTWaEnV4AAAfsAAAAHEdERUYANQAGAAAHzAAAACBPUy8yLuLcHAAAAVgAAABWY21hcKHZA/EAAAHQAAABamdhc3D//wADAAAHxAAAAAhnbHlmkC1hRwAAA1AAAAJcaGVhZP35bikAAADcAAAANmhoZWEDif/pAAABFAAAACRobXR4CVUAAAAAAbAAAAAgbG9jYQHsATQAAAM8AAAAEm1heHAATABPAAABOAAAACBuYW1leXp+dQAABawAAAG5cG9zdCQlhUQAAAdoAAAAWgABAAAAAQAAzATBq18PPPUACwHAAAAAAM59lxYAAAAAzn2XFv///8AB4AGAAAAACAACAAAAAAAAAAEAAAGA/8AAKAHg///+QAHgAAEAAAAAAAAAAAAAAAAAAAAIAAEAAAAIAEwAAgAAAAAAAgAAAAEAAQAAAEAAAAAAAAAAAQHAAZAABQAIASMBOQAAAD4BIwE5AAAA1wAWAHMAAAIABQMAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUGZFZABA4ADxEgGA/8AAKAGAAECAAAABAAAAAAAAAcAAAAAAAAAAlQAAAAAAAAHAAAAB4AAAAaAAAAHAAAAAAAADAAAAAwAAABwAAQAAAAAAZAADAAEAAAAcAAQASAAAAA4ACAACAAYAAOAA8ADwBfB58RL//wAAAADgAPAA8AXwefES//8AACAHEAMQAQ+LDvMAAQAAAAAAAAAAAAAAAAAAAAABBgAAAQAAAAAAAAABAgAAAAIAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgBOALAA5gEuAAAAAQAA/8ABwAGAAAIAABEBIQHA/kABgP5AAAAAAAEAAP/gAcABcAAsAAAlFAcUDgEHBiMiJjU0NjU2NTQuBSsBFRQGIi8BJjQ/ATYyFh0BMzIXFgHAIAQDAgMEBAQBAQgQGBwnJxg4CgwFgAUFgAUMCjiyKQ1oKkcBCQcCBAUEAgkBEQ4ZKB0WDQgDQAYKBYAFDAWABQoGQGUhAAAAAgAAAAAB4AEgACUASwAAJRQGKwEiLgI0PQQjIiY1ND8BNjIfARYVFAYrARUzMh8BFjcUDwEGIi8BJjU0NjsBNSMiLwEmNTQ2OwEyHgIUHQQzMhYBQAUD8AIDAQIwBgoEUAQQBFAECgYwkAQCKAKgBFAFDgVQBAoGMJAEAigCBQPwAgMBAjAGCggDBQEDAQQBAwMoaAoGBgRgBgZgBAYGCmADMANmBgRgBgZgBAYGCmADMAIDAwUBAwEEAQMDKGgKAAAAAAEAAP/rAaABeAAiAAAlFA8BFxQVFAYjIi8BBwYjIiY1ND8BJyY1ND8CNjIfAhYBoAZbFQUFBAZwcAYEBgUBFVsGDn44BBAEOH4O3gUHWH0CAwYHAzs7AwcGAQR9WAcFCgIScgoKchICAAAAAAH////pAcABVwAwAAABBgc2NwYHJiMiBhUUFy4BJwYVFBciJzAVFBYXBiMiJx4BFwYjIicWMzI+AjU0NTYBwBkcHgscHxsoJjYDOWIjDCkXEyogDAwJCQkvHjJACwtATT1mPyMbASsLBBIhEAYdNiYLCgMzKhUZMRsLASEzBgQCHCMBJwEpL0xcLgYGFAAAAAAADACWAAEAAAAAAAEACwAYAAEAAAAAAAIABwA0AAEAAAAAAAMAKACOAAEAAAAAAAQACwDPAAEAAAAAAAUACwDzAAEAAAAAAAYACwEXAAMAAQQJAAEAFgAAAAMAAQQJAAIADgAkAAMAAQQJAAMAUAA8AAMAAQQJAAQAFgC3AAMAAQQJAAUAFgDbAAMAAQQJAAYAFgD/AHMAdAB0AC0AaQBuAHQAZQBuAHQAcwAAc3R0LWludGVudHMAAGkAbgB0AGUAbgB0AHMAAGludGVudHMAAEYAbwBuAHQARgBvAHIAZwBlACAAMgAuADAAIAA6ACAAcwB0AHQALQBpAG4AdABlAG4AdABzACAAOgAgADEAMQAtADEAMAAtADIAMAAxADMAAEZvbnRGb3JnZSAyLjAgOiBzdHQtaW50ZW50cyA6IDExLTEwLTIwMTMAAHMAdAB0AC0AaQBuAHQAZQBuAHQAcwAAc3R0LWludGVudHMAAFYAZQByAHMAaQBvAG4AIAAxAC4AMAAAVmVyc2lvbiAxLjAAAHMAdAB0AC0AaQBuAHQAZQBuAHQAcwAAc3R0LWludGVudHMAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAEAAgECAQMBBAEFAQYHdW5pRjAwMAd1bmlGMDc5B3VuaUYxMTIHdW5pRjAwNQd1bmlFMDAwAAAAAAAB//8AAgABAAAADgAAABgAAAAAAAIAAQADAAcAAQAEAAAAAgAAAAAAAQAAAADJiW8xAAAAAM59lxYAAAAAzn2XFg==) format('truetype');font-weight:normal;font-style:normal}
2
+ .tweets li{-ms-word-break:break-all;word-break:break-all;word-break:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto}.avatar{margin-bottom:15px;}
3
+ .avatar img{float:left;margin-right:10px}.circular{-webkit-border-radius:50% !important;-moz-border-radius:50% !important;border-radius:50% !important;}.tweets-intent-data{margin-top:5px;float:right;}.tweets-intent-data a{margin-right:5px}
4
+ [data-icon]:before{font-family:'wpltf_intents';content:attr(data-icon);speak:none;font-weight:normal;font-variant:normal;font-size:14px;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
5
+ .pi-visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}
6
+ div.wdtf-user-card {
7
+ width:100%;
8
+ margin-bottom: 5px;
9
+ float: left;
10
+ }
11
+ .tweets li{font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;}
12
+ .tweet_data{float:left;}
13
+ .tweets .avatar .tweet_data a{color: #0084B4;text-decoration:none;
14
+ }
15
+ .tweets-intent-data a{text-decoration:none;}
16
+ .tweets .avatar .tweet_data a:hover{text-decoration: underline;}
17
+ div.wdtf-screen-name {
18
+ margin-left: 4px;float: left;
19
+ font-size:13px;
20
+ line-height: 18px;
21
+ }
22
+
23
+
24
+ div.wdtf-screen-name span.screen_name{font-weight:bold;}
25
+ div.times{float:left;}
css/fonts/wpltf_intents.dev.svg ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
+ <svg xmlns="http://www.w3.org/2000/svg">
4
+ <metadata>
5
+ This is a custom SVG font generated by IcoMoon.
6
+ <iconset grid="14"></iconset>
7
+ </metadata>
8
+ <defs>
9
+ <font id="stt-intents" horiz-adv-x="448" >
10
+ <font-face units-per-em="448" ascent="384" descent="-64" />
11
+ <missing-glyph horiz-adv-x="448" />
12
+ <glyph class="hidden" unicode="&#xf000;" d="M0,384L 448 -64L0 -64 z" horiz-adv-x="0" />
13
+ <glyph unicode="&#xf079;" d="M 448,104q0-41.5 -31.75-112.75q-0.75-1.75 -2.625-6t-3.375-7.5t-3.25-5.5q-3-4.25 -7-4.25q-3.75,0 -5.875,2.5t-2.125,6.25q0,2.25 0.625,6.625t 0.625,5.875q 1.25,17 1.25,30.75q0,25.25 -4.375,45.25t-12.125,34.625t-20,25.25t-26.375,17.375t-33.25,10.625t-38.5,5.375t-43.875,1.5l-56,0 l0-64 q0-6.5 -4.75-11.25t-11.25-4.75t-11.25,4.75 l-128,128q-4.75,4.75 -4.75,11.25t 4.75,11.25l 128,128q 4.75,4.75 11.25,4.75t 11.25-4.75t 4.75-11.25l0-64 l 56,0 q 178.25,0 218.75-100.75q 13.25-33.5 13.25-83.25z" data-tags="reply, arrow, left" />
14
+ <glyph unicode="&#xf112;" d="M 320,8q0-3.25 -2.375-5.625t-5.625-2.375l-240,0 q-2,0 -3.375,0.5t-2.25,1.75t-1.375,2t-0.75,2.875t-0.25,2.875l0,3.25 l0,2.75 l0,40 l0,104 l-48,0 q-6.5,0 -11.25,4.75t-4.75,11.25q0,6 3.75,10.25l 80,96q 4.75,5.5 12.25,5.5t 12.25-5.5l 80-96q 3.75-4.25 3.75-10.25q0-6.5 -4.75-11.25t-11.25-4.75l-48,0 l0-96 l 144,0 q 4,0 6.25-2.75l 40-48q 1.75-2.75 1.75-5.25 zM 480,112q0-6 -3.75-10.25l-80-96q-5-5.75 -12.25-5.75t-12.25,5.75l-80,96q-3.75,4.25 -3.75,10.25q0,6.5 4.75,11.25t 11.25,4.75l 48,0 l0,96 l-144,0 q-4,0 -6.25,3l-40,48q-1.75,2.25 -1.75,5q0,3.25 2.375,5.625t 5.625,2.375l 240,0 q 2,0 3.375-0.5t 2.25-1.75t 1.375-2t 0.75-2.875t 0.25-2.875l0-3.25 l0-2.75 l0-40 l0-104 l 48,0 q 6.5,0 11.25-4.75t 4.75-11.25z " horiz-adv-x="480" data-tags="retweet, loop, arrows" />
15
+ <glyph unicode="&#xf005;" d="M 416,222.25q0-5.5 -6.5-12l-90.75-88.5l 21.5-125q 0.25-1.75 0.25-5q0-5.25 -2.625-8.875t-7.625-3.625q-4.75,0 -10,3l-112.25,59l-112.25-59q-5.5-3 -10-3q-5.25,0 -7.875,3.625t-2.625,8.875q0,1.5 0.5,5l 21.5,125l-91,88.5q-6.25,6.75 -6.25,12q0,9.25 14,11.5l 125.5,18.25l 56.25,113.75q 4.75,10.25 12.25,10.25t 12.25-10.25l 56.25-113.75 l 125.5-18.25q 14-2.25 14-11.5z" horiz-adv-x="416" data-tags="star, favorite, rate" />
16
+ <glyph unicode="&#xe000;" d="M 448,298.942c-16.483-7.31-34.197-12.251-52.789-14.473c 18.975,11.375, 33.55,29.387, 40.413,50.851
17
+ c-17.761-10.534-37.431-18.183-58.367-22.304c-16.765,17.863-40.653,29.024-67.089,29.024c-50.76,0-91.913-41.15-91.913-91.909
18
+ c0-7.204, 0.813-14.219, 2.38-20.947c-76.388,3.834-144.113,40.425-189.445,96.034c-7.912-13.575-12.445-29.363-12.445-46.208
19
+ c0-31.889, 16.226-60.022, 40.889-76.504c-15.067,0.478-29.239,4.612-41.63,11.497c-0.009-0.383-0.009-0.768-0.009-1.156
20
+ c0-44.532, 31.683-81.68, 73.728-90.125c-7.711-2.1-15.832-3.225-24.215-3.225c-5.923,0-11.68,0.578-17.293,1.65
21
+ c 11.697-36.514, 45.64-63.090, 85.86-63.829c-31.456-24.653-71.088-39.346-114.151-39.346c-7.419,0-14.735,0.435-21.926,1.286
22
+ c 40.675-26.079, 88.988-41.297, 140.893-41.297c 169.060,0, 261.51,140.054, 261.51,261.513c0,3.985-0.090,7.948-0.267,11.891
23
+ C 420.096,264.324, 435.678,280.511, 448,298.942z" data-tags="twitter, tweet, social" />
24
+ <glyph unicode="&#x20;" horiz-adv-x="224" />
25
+ </font></defs></svg>
css/fonts/wpltf_intents.eot ADDED
Binary file
css/fonts/wpltf_intents.svg ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
+ <svg xmlns="http://www.w3.org/2000/svg">
4
+ <metadata>
5
+ This is a custom SVG font generated by IcoMoon.
6
+ <iconset grid="14"></iconset>
7
+ </metadata>
8
+ <defs>
9
+ <font id="stt-intents" horiz-adv-x="448" >
10
+ <font-face units-per-em="448" ascent="384" descent="-64" />
11
+ <missing-glyph horiz-adv-x="448" />
12
+ <glyph class="hidden" unicode="&#xf000;" d="M0,384L 448 -64L0 -64 z" horiz-adv-x="0" />
13
+ <glyph unicode="&#xf079;" d="M 448,104q0-41.5 -31.75-112.75q-0.75-1.75 -2.625-6t-3.375-7.5t-3.25-5.5q-3-4.25 -7-4.25q-3.75,0 -5.875,2.5t-2.125,6.25q0,2.25 0.625,6.625t 0.625,5.875q 1.25,17 1.25,30.75q0,25.25 -4.375,45.25t-12.125,34.625t-20,25.25t-26.375,17.375t-33.25,10.625t-38.5,5.375t-43.875,1.5l-56,0 l0-64 q0-6.5 -4.75-11.25t-11.25-4.75t-11.25,4.75 l-128,128q-4.75,4.75 -4.75,11.25t 4.75,11.25l 128,128q 4.75,4.75 11.25,4.75t 11.25-4.75t 4.75-11.25l0-64 l 56,0 q 178.25,0 218.75-100.75q 13.25-33.5 13.25-83.25z" />
14
+ <glyph unicode="&#xf112;" d="M 320,8q0-3.25 -2.375-5.625t-5.625-2.375l-240,0 q-2,0 -3.375,0.5t-2.25,1.75t-1.375,2t-0.75,2.875t-0.25,2.875l0,3.25 l0,2.75 l0,40 l0,104 l-48,0 q-6.5,0 -11.25,4.75t-4.75,11.25q0,6 3.75,10.25l 80,96q 4.75,5.5 12.25,5.5t 12.25-5.5l 80-96q 3.75-4.25 3.75-10.25q0-6.5 -4.75-11.25t-11.25-4.75l-48,0 l0-96 l 144,0 q 4,0 6.25-2.75l 40-48q 1.75-2.75 1.75-5.25 zM 480,112q0-6 -3.75-10.25l-80-96q-5-5.75 -12.25-5.75t-12.25,5.75l-80,96q-3.75,4.25 -3.75,10.25q0,6.5 4.75,11.25t 11.25,4.75l 48,0 l0,96 l-144,0 q-4,0 -6.25,3l-40,48q-1.75,2.25 -1.75,5q0,3.25 2.375,5.625t 5.625,2.375l 240,0 q 2,0 3.375-0.5t 2.25-1.75t 1.375-2t 0.75-2.875t 0.25-2.875l0-3.25 l0-2.75 l0-40 l0-104 l 48,0 q 6.5,0 11.25-4.75t 4.75-11.25z " horiz-adv-x="480" />
15
+ <glyph unicode="&#xf005;" d="M 416,222.25q0-5.5 -6.5-12l-90.75-88.5l 21.5-125q 0.25-1.75 0.25-5q0-5.25 -2.625-8.875t-7.625-3.625q-4.75,0 -10,3l-112.25,59l-112.25-59q-5.5-3 -10-3q-5.25,0 -7.875,3.625t-2.625,8.875q0,1.5 0.5,5l 21.5,125l-91,88.5q-6.25,6.75 -6.25,12q0,9.25 14,11.5l 125.5,18.25l 56.25,113.75q 4.75,10.25 12.25,10.25t 12.25-10.25l 56.25-113.75 l 125.5-18.25q 14-2.25 14-11.5z" horiz-adv-x="416" />
16
+ <glyph unicode="&#xe000;" d="M 448,298.942c-16.483-7.31-34.197-12.251-52.789-14.473c 18.975,11.375, 33.55,29.387, 40.413,50.851
17
+ c-17.761-10.534-37.431-18.183-58.367-22.304c-16.765,17.863-40.653,29.024-67.089,29.024c-50.76,0-91.913-41.15-91.913-91.909
18
+ c0-7.204, 0.813-14.219, 2.38-20.947c-76.388,3.834-144.113,40.425-189.445,96.034c-7.912-13.575-12.445-29.363-12.445-46.208
19
+ c0-31.889, 16.226-60.022, 40.889-76.504c-15.067,0.478-29.239,4.612-41.63,11.497c-0.009-0.383-0.009-0.768-0.009-1.156
20
+ c0-44.532, 31.683-81.68, 73.728-90.125c-7.711-2.1-15.832-3.225-24.215-3.225c-5.923,0-11.68,0.578-17.293,1.65
21
+ c 11.697-36.514, 45.64-63.090, 85.86-63.829c-31.456-24.653-71.088-39.346-114.151-39.346c-7.419,0-14.735,0.435-21.926,1.286
22
+ c 40.675-26.079, 88.988-41.297, 140.893-41.297c 169.060,0, 261.51,140.054, 261.51,261.513c0,3.985-0.090,7.948-0.267,11.891
23
+ C 420.096,264.324, 435.678,280.511, 448,298.942z" />
24
+ <glyph unicode="&#x20;" horiz-adv-x="224" />
25
+ </font></defs></svg>
css/fonts/wpltf_intents.ttf ADDED
Binary file
css/fonts/wpltf_intents.woff ADDED
Binary file
js/admin_script.js ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($) {
2
+
3
+ "use strict";
4
+
5
+ // USe function so we can recall on save
6
+ function updateColorPicker(){
7
+ // Checks if the color picker widget exists in jQuery UI
8
+ // If it exists then initialize the WordPress color picker on our text input field
9
+ if( typeof jQuery.wp === 'object' && typeof jQuery.wp.wpColorPicker === 'function' ){
10
+ var sttOptions = {
11
+ // you can declare a default color here,
12
+ // or in the data-default-color attribute on the input
13
+ defaultColor: false,
14
+ // a callback to fire whenever the color changes to a valid color
15
+ change: function(event, ui){},
16
+ // a callback to fire when the input is emptied or an invalid color
17
+ clear: function() {},
18
+ // hide the color picker controls on load
19
+ hide: true,
20
+ // show a group of common colors beneath the square
21
+ // or, supply an array of colors to customize further
22
+ palettes: true
23
+ };
24
+ jQuery( '.intentColor' ).wpColorPicker(sttOptions);
25
+ } else {
26
+ // We use farbtastic if the WordPress color picker widget doesn't exist
27
+ jQuery( '#colorpicker' ).farbtastic( 'intentColor' );
28
+ }
29
+ }
30
+ updateColorPicker();
31
+ // Widget Button reveals
32
+ $('.secrets > div, .avatar > div, .twitterFollow > div, .modTime > div, .twitterIntents > div').hide();
33
+
34
+ $(document).on('click', '.secrets h4, .avatar h4, .twitterFollow h4, .modTime h4, .twitterIntents h4', function() {
35
+ // var tFollow = $(this).next('div');
36
+ $(this).next('div').slideToggle('fast', function() {
37
+ if(!$(this).is(":hidden")) {
38
+ $(this).siblings('h4').children('span').html("&#9650;");
39
+ }else{
40
+ $(this).siblings('h4').children('span').html("&#9660;");
41
+ }
42
+ });
43
+ });
44
+
45
+ // Widget Saved
46
+ $(document).ajaxSuccess(function(e, xhr, settings) {
47
+ // reset toggles - clean view
48
+ $('.secrets > div, .avatar > div, .twitterFollow > div, .modTime > div, .twitterIntents > div').slideUp();
49
+ $('.secrets h4 > span, .avatar h4 > span, .twitterFollow h4 > span, .modTime h4 > span, .twitterIntents h4 > span').html("&#9660;");
50
+
51
+ // re-initiate the colour picker
52
+ if(settings.data.search('action=save-widget') != -1 ) {
53
+ $('.intentColor .wp-picker-container').remove();
54
+ updateColorPicker();
55
+ }
56
+ }); // END AJAX success
57
+
58
+ }); // END READY
js/validate.js ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function ($) {
2
+
3
+ var timer,
4
+ lastResult;
5
+
6
+
7
+ start();
8
+
9
+
10
+ $('div[id*=widget-wptt_twittertweets]').on('ajaxComplete', function() {
11
+ start();
12
+ });
13
+
14
+ $(document).on( "keyup", '.twitter_user_name', function() {
15
+ clearTimeout(timer);
16
+ var userInput = this.value,
17
+ defaultValue = $('.user-validator').prop("defaultValue"),
18
+ delay = 500;
19
+ if(userInput == '') {
20
+ $('.user-validator')
21
+ .removeClass('user-validator-valid user-validator-invalid')
22
+ .val( defaultValue );
23
+
24
+ return;
25
+ }
26
+ $('.user-validator').val('checking...');
27
+
28
+ timer = setTimeout(function() {
29
+ validateScreenName( userInput );
30
+ }, delay);
31
+
32
+ });
33
+
34
+ function validateScreenName( name ) {
35
+
36
+ $.ajax({
37
+ dataType: "json",
38
+ url: ajaxurl,
39
+ data: { screen_name: name ,action:'userValidate'},
40
+ success: function(data) {
41
+ setValidatorTo( data );
42
+ lastResult = data;
43
+ }
44
+ });
45
+ }
46
+
47
+ function setValidatorTo( obj ) {
48
+ $('.user-validator')
49
+ .val(obj.data)
50
+ .removeClass('user-validator-valid user-validator-invalid')
51
+ .addClass(obj.class);
52
+ }
53
+
54
+ function start() {
55
+
56
+ if( lastResult )
57
+ setValidatorTo( lastResult );
58
+ }
59
+ });
libs/console.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function logConsole($name, $data = NULL, $jsEval = FALSE){
3
+
4
+ if (! $name) return false;
5
+
6
+ $isevaled = false;
7
+ $type = ($data || gettype($data)) ? 'Type: ' . gettype($data) : '';
8
+
9
+ if ($jsEval && (is_array($data) || is_object($data)))
10
+ {
11
+ $data = 'eval(' . preg_replace('#[\s\r\n\t\0\x0B]+#', '', json_encode($data)) . ')';
12
+ $isevaled = true;
13
+ }
14
+ else
15
+ {
16
+ $data = json_encode($data);
17
+ }
18
+
19
+ # sanitalize
20
+ $data = $data ? $data : '';
21
+ $search_array = array("#'#", '#""#', "#''#", "#\n#", "#\r\n#");
22
+ $replace_array = array('"', '', '', '\\n', '\\n');
23
+ $data = preg_replace($search_array, $replace_array, $data);
24
+ $data = ltrim(rtrim($data, '"'), '"');
25
+ $data = $isevaled ? $data : ($data[0] === "'") ? $data : "'" . $data . "'";
26
+
27
+ $js = <<<JSCODE
28
+ \n<script>
29
+ // fallback - to deal with IE (or browsers that don't have console)
30
+ if (! window.console) console = {};
31
+ console.log = console.log || function(name, data){};
32
+ // end of fallback
33
+
34
+ console.log('$name');
35
+ console.log('------------------------------------------');
36
+ console.log('$type');
37
+ console.log($data);
38
+ console.log('\\n');
39
+ </script>
40
+ JSCODE;
41
+
42
+ echo $js;
43
+ }
44
+ ?>
twitter_usr_validation.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ add_action('wp_ajax_userValidate','do_user_validation');
3
+ function do_user_validation()
4
+ {
5
+ header('Content-type: application/json');
6
+
7
+ $username = $_GET['screen_name'];
8
+
9
+ $url="https://twitter.com/intent/user?screen_name=".$username;
10
+ if(!@file_get_contents($url)) {
11
+ $data = array(
12
+ 'data' => "Invalid screen name",
13
+ 'class' => 'user-validator-invalid'
14
+ );
15
+ }
16
+ else {
17
+ $data = array(
18
+ 'data' => "Valid screen name",
19
+ 'class' => 'user-validator-valid'
20
+ );
21
+ }
22
+ echo json_encode( $data );
23
+ exit();
24
+ }
25
+ ?>
views/dynamic_html.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p>
2
+ <label for="<?php echo $this->get_field_id('title'); ?>">Widget 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($widget_title); ?>" /></label>
3
+ </p>
4
+ <p>
5
+ <label for="<?php echo $this->get_field_id('name'); ?>">Twitter Name (excluding @ 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>
6
+ </p>
7
+ <p>
8
+ <label for="<?php echo $this->get_field_id('store_time'); ?>">Tweets Cache Time (in minutes): <input class="widefat" id="<?php echo $this->get_field_id('store_time'); ?>" name="<?php echo $this->get_field_name('store_time'); ?>" type="text" value="<?php echo esc_attr($timeto_store); ?>" /></label>
9
+ </p>
10
+ <p>
11
+ <label for="<?php echo $this->get_field_id('tweets_cnt'); ?>">Number of Tweets to Fetch: <input class="widefat" id="<?php echo $this->get_field_id('tweets_cnt'); ?>" name="<?php echo $this->get_field_name('tweets_cnt'); ?>" type="text" value="<?php echo esc_attr($tweets_count); ?>" /></label>
12
+ </p>
13
+
14
+ <h4 style="width:100%; text-align:center;">Twitter API Options</h4>
15
+ <div style="padding:10px;">
16
+ <p>
17
+ <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>
18
+ </p>
19
+ <p>
20
+ <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>
21
+ </p>
22
+ <p>
23
+ <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>
24
+ </p>
25
+ <p>
26
+ <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>
27
+ </p>
28
+
29
+ </div>
30
+ <h4 style="width:100%; text-align:center;">Advanced Options</h4>
31
+ <div style="padding:10px;">
32
+ <p>
33
+ <input class="checkbox" type="checkbox" value="true" <?php checked( (isset( $instance['twitterIntents']) && ($instance['twitterIntents'] == "true") ), true ); ?> id="<?php echo $this->get_field_id( 'twitterIntents' ); ?>" name="<?php echo $this->get_field_name( 'twitterIntents' ); ?>" />
34
+ <label for="<?php echo $this->get_field_id( 'twitterIntents' ); ?>">Show Twitter Intents</label>
35
+ </p>
36
+ <p>
37
+ <input class="checkbox" type="checkbox" value="true" <?php checked( (isset( $instance['twitterIntentsText']) && ($instance['twitterIntentsText'] == "true") ), true ); ?> id="<?php echo $this->get_field_id( 'twitterIntentsText' ); ?>" name="<?php echo $this->get_field_name( 'twitterIntentsText' ); ?>" />
38
+ <label for="<?php echo $this->get_field_id( 'twitterIntentsText' ); ?>">Hide Twitter Intents Text</label>
39
+ </p>
40
+ <p>
41
+ <label for="<?php echo $this->get_field_id('intentColor'); ?>">Colour for Intent icons: <input class="intentColor" id="<?php echo $this->get_field_id('intentColor'); ?>" name="<?php echo $this->get_field_name('intentColor'); ?>" type="text" value="<?php echo esc_attr($color_intents); ?>" /></label>
42
+ <div id="colorpicker"></div>
43
+ </p>
44
+ <p>
45
+ <input class="checkbox" type="checkbox" value="true" <?php checked( ( isset( $instance['border_rad']) && ($instance['showAvatar'] == "true") ), true ); ?> id="<?php echo $this->get_field_id( 'border_rad' ); ?>" name="<?php echo $this->get_field_name( 'border_rad' ); ?>" />
46
+ <label for="<?php echo $this->get_field_id( 'border_rad' ); ?>">Circular Avatar image</label>
47
+ </p>
48
+ <p>
49
+ <input class="checkbox" type="checkbox" value="true" <?php checked( ( isset( $instance['showAvatar']) && ($instance['showAvatar'] == "true") ), true ); ?> id="<?php echo $this->get_field_id( 'showAvatar' ); ?>" name="<?php echo $this->get_field_name( 'showAvatar' ); ?>" />
50
+ <label for="<?php echo $this->get_field_id( 'showAvatar' ); ?>">Display avatar image</label>
51
+ </p>
52
+ <p>
53
+ <label for="<?php echo $this->get_field_id('avatarSize'); ?>">Size of Avatar (default: 48): <input class="widefat" id="<?php echo $this->get_field_id('avatarSize'); ?>" name="<?php echo $this->get_field_name('avatarSize'); ?>" type="text" value="<?php echo esc_attr($avatarSize); ?>" /><br><em>only numeric values allowed</em></label>
54
+ </p>
55
+ <p>
56
+ <input class="checkbox" type="checkbox" <?php checked( isset( $instance['replies_excl']), true ); ?> id="<?php echo $this->get_field_id( 'replies_excl' ); ?>" name="<?php echo $this->get_field_name( 'replies_excl' ); ?>" />
57
+ <label for="<?php echo $this->get_field_id( 'replies_excl' ); ?>">Exclude_@replies</label>
58
+ </p>
59
+ <p>
60
+ <input class="checkbox" type="checkbox" value="true" <?php checked( (isset( $instance['timeAgo']) && ($instance['timeAgo'] == "true") ), true ); ?> id="<?php echo $this->get_field_id( 'timeAgo' ); ?>" name="<?php echo $this->get_field_name( 'timeAgo' ); ?>" value="true" />
61
+ <label for="<?php echo $this->get_field_id( 'timeAgo' ); ?>">Show "ago" after the time</label>
62
+ </p>
63
+ <p>
64
+ <input class="checkbox" type="checkbox" value="true" <?php checked( (isset( $instance['timeRef']) && ($instance['timeRef'] == "true") ), true ); ?> id="<?php echo $this->get_field_id( 'timeRef' ); ?>" name="<?php echo $this->get_field_name( 'timeRef' ); ?>" />
65
+ <label for="<?php echo $this->get_field_id( 'timeRef' ); ?>">Change to Twitter style short time</label>
66
+ </p>
67
+ <p>
68
+ <input class="checkbox" type="checkbox" <?php checked( (isset( $instance['disp_scr_name']) && ($instance['disp_scr_name'] == "true") ), true ); ?> id="<?php echo $this->get_field_id( 'disp_scr_name' ); ?>" name="<?php echo $this->get_field_name( 'disp_scr_name' ); ?>" value="true" />
69
+ <label for="<?php echo $this->get_field_id( 'disp_scr_name' ); ?>">Show Twitter Screen Name</label>
70
+ </p>
71
+ <p>
72
+ <input class="checkbox" type="checkbox" <?php checked( (isset( $instance['twitterFollow']) && ($instance['twitterFollow'] == "on") ), true ); ?> id="<?php echo $this->get_field_id( 'twitterFollow' ); ?>" name="<?php echo $this->get_field_name( 'twitterFollow' ); ?>" />
73
+ <label for="<?php echo $this->get_field_id( 'twitterFollow' ); ?>">Show Twitter Follow Button</label>
74
+ </p>
75
+ <p>
76
+ <input class="checkbox" type="checkbox" <?php checked( (isset( $instance['dataShowCount']) && ($instance['dataShowCount'] == "true") ), true ); ?> id="<?php echo $this->get_field_id( 'dataShowCount' ); ?>" name="<?php echo $this->get_field_name( 'dataShowCount' ); ?>" value="true" />
77
+ <label for="<?php echo $this->get_field_id( 'dataShowCount' ); ?>">Show Twitter Followers Count</label>
78
+ </p>
79
+ <p>
80
+ <label for="<?php echo $this->get_field_id('dataLang'); ?>">Tweets 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>
81
+ </p>
82
+ </div>
wp-latest-twitter-tweets.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: WP Twitter Feeds
4
+ Plugin URI: http://www.vivacityinfotech.com/
5
+ Description: An easy Twitter feeds widget that provides facility to display twitter tweets on your website using new Twitter 1.1 API.
6
+ Author: vivacityinfotech
7
+ Version: 1.0
8
+ Author URI: http://www.vivacityinfotech.com/
9
+ */
10
+ include('twitter_usr_validation.php');
11
+ require_once('controller/twitter_widget.class.php');
12
+ add_action( 'widgets_init', 'wpltf_reg_widget');
13
+ function wpltf_reg_widget()
14
+ {
15
+
16
+ register_widget("wptt_TwitterTweets");
17
+ }
18
+ ?>