Twitter Widget Pro - Version 2.3.0

Version Description

Fewer "could not connect to Twitter" messages, new links (reply, retweet, favorite), new follow button, and avatar fixes

Download this release

Release Info

Developer aaroncampbell
Plugin Icon wp plugin Twitter Widget Pro
Version 2.3.0
Comparing to
See all releases

Code changes from version 2.2.4 to 2.3.0

languages/twitter-widget-pro.pot CHANGED
@@ -4,7 +4,7 @@ msgid ""
4
  msgstr ""
5
  "Project-Id-Version: \n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/twitter-widget-pro\n"
7
- "POT-Creation-Date: 2011-07-19 16:31:27+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -62,181 +62,201 @@ msgid ""
62
  "enhancements, please use the <a href=\"%s\">Xavisys Support Forums</a>."
63
  msgstr ""
64
 
65
- #: wp-twitter-widget.php:42
66
  msgid "Follow a Twitter Feed"
67
  msgstr ""
68
 
69
- #: wp-twitter-widget.php:49 wp-twitter-widget.php:176
70
  msgid "Twitter Widget Pro"
71
  msgstr ""
72
 
73
- #: wp-twitter-widget.php:64 wp-twitter-widget.php:220
74
  msgid "Twitter username:"
75
  msgstr ""
76
 
77
- #: wp-twitter-widget.php:68 wp-twitter-widget.php:228
78
  msgid "Give the feed a title ( optional ):"
79
  msgstr ""
80
 
81
- #: wp-twitter-widget.php:72 wp-twitter-widget.php:236
82
  msgid "How many items would you like to display?"
83
  msgstr ""
84
 
85
- #: wp-twitter-widget.php:83 wp-twitter-widget.php:294
 
 
 
 
 
 
 
 
86
  msgid "Hide @replies"
87
  msgstr ""
88
 
89
- #: wp-twitter-widget.php:87 wp-twitter-widget.php:297
90
  msgid "Hide sending applications"
91
  msgstr ""
92
 
93
- #: wp-twitter-widget.php:90 wp-twitter-widget.php:250
 
 
 
 
 
 
 
 
94
  msgid "What to display when Twitter is down ( optional ):"
95
  msgstr ""
96
 
97
- #: wp-twitter-widget.php:94 wp-twitter-widget.php:258
98
  msgid "Number of seconds to wait for a response from Twitter ( default 2 ):"
99
  msgstr ""
100
 
101
- #: wp-twitter-widget.php:98 wp-twitter-widget.php:266
102
  msgid "Show date/time of Tweet ( rather than 2 ____ ago ):"
103
  msgstr ""
104
 
105
- #: wp-twitter-widget.php:100 wp-twitter-widget.php:270
106
  msgid "Always"
107
  msgstr ""
108
 
109
- #: wp-twitter-widget.php:101 wp-twitter-widget.php:271
110
  msgid "If over an hour old"
111
  msgstr ""
112
 
113
- #: wp-twitter-widget.php:102 wp-twitter-widget.php:272
114
  msgid "If over a day old"
115
  msgstr ""
116
 
117
- #: wp-twitter-widget.php:103 wp-twitter-widget.php:273
118
  msgid "If over a week old"
119
  msgstr ""
120
 
121
- #: wp-twitter-widget.php:104 wp-twitter-widget.php:274
122
  msgid "If over a month old"
123
  msgstr ""
124
 
125
- #: wp-twitter-widget.php:105 wp-twitter-widget.php:275
126
  msgid "If over a year old"
127
  msgstr ""
128
 
129
- #: wp-twitter-widget.php:106 wp-twitter-widget.php:276
130
  msgid "Never"
131
  msgstr ""
132
 
133
- #: wp-twitter-widget.php:110 wp-twitter-widget.php:282
134
  msgid ""
135
  "Format to dispaly the date in, uses <a href=\"%s\">PHP date()</a> format:"
136
  msgstr ""
137
 
138
- #: wp-twitter-widget.php:115 wp-twitter-widget.php:300
139
- msgid "Hide RSS Icon and Link"
140
- msgstr ""
141
-
142
- #: wp-twitter-widget.php:119 wp-twitter-widget.php:303
143
  msgid "Open links in a new window"
144
  msgstr ""
145
 
146
- #: wp-twitter-widget.php:123 wp-twitter-widget.php:306
147
- msgid "Show Profile Image"
148
- msgstr ""
149
-
150
- #: wp-twitter-widget.php:127 wp-twitter-widget.php:309
151
  msgid "Show Link to Twitter Widget Pro"
152
  msgstr ""
153
 
154
- #: wp-twitter-widget.php:177
155
  msgid "Twitter Widget"
156
  msgstr ""
157
 
158
- #: wp-twitter-widget.php:212
159
  msgid "General Settings"
160
  msgstr ""
161
 
162
- #: wp-twitter-widget.php:290
163
  msgid "Other Setting:"
164
  msgstr ""
165
 
166
- #: wp-twitter-widget.php:466
167
- msgid "Syndicate this content"
168
- msgstr ""
169
-
170
- #: wp-twitter-widget.php:493
171
  msgid "No Tweets Available"
172
  msgstr ""
173
 
174
- #: wp-twitter-widget.php:501
175
  msgid "from %s"
176
  msgstr ""
177
 
178
- #: wp-twitter-widget.php:514
179
  msgid "in reply to %s"
180
  msgstr ""
181
 
182
- #: wp-twitter-widget.php:536
183
- msgid "Get Twitter Widget for your WordPress site"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  msgstr ""
185
 
186
- #: wp-twitter-widget.php:538
187
  msgid "Powered by"
188
  msgstr ""
189
 
190
- #: wp-twitter-widget.php:579
191
  msgid "Invalid Twitter Response."
192
  msgstr ""
193
 
194
- #: wp-twitter-widget.php:593
195
  msgid "Could not connect to Twitter"
196
  msgstr ""
197
 
198
- #: wp-twitter-widget.php:656
199
  msgid "about %s year ago"
200
  msgid_plural "about %s years ago"
201
  msgstr[0] ""
202
  msgstr[1] ""
203
 
204
- #: wp-twitter-widget.php:657
205
  msgid "about %s month ago"
206
  msgid_plural "about %s months ago"
207
  msgstr[0] ""
208
  msgstr[1] ""
209
 
210
- #: wp-twitter-widget.php:658
211
  msgid "about %s week ago"
212
  msgid_plural "about %s weeks ago"
213
  msgstr[0] ""
214
  msgstr[1] ""
215
 
216
- #: wp-twitter-widget.php:659
217
  msgid "about %s day ago"
218
  msgid_plural "about %s days ago"
219
  msgstr[0] ""
220
  msgstr[1] ""
221
 
222
- #: wp-twitter-widget.php:660
223
  msgid "about %s hour ago"
224
  msgid_plural "about %s hours ago"
225
  msgstr[0] ""
226
  msgstr[1] ""
227
 
228
- #: wp-twitter-widget.php:661
229
  msgid "about %s minute ago"
230
  msgid_plural "about %s minutes ago"
231
  msgstr[0] ""
232
  msgstr[1] ""
233
 
234
- #: wp-twitter-widget.php:662
235
  msgid "about %s second ago"
236
  msgid_plural "about %s seconds ago"
237
  msgstr[0] ""
238
  msgstr[1] ""
239
 
240
- #: wp-twitter-widget.php:707 wp-twitter-widget.php:773
241
  msgid "h:i:s A F d, Y"
242
  msgstr ""
4
  msgstr ""
5
  "Project-Id-Version: \n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/twitter-widget-pro\n"
7
+ "POT-Creation-Date: 2011-08-31 23:46:45+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
62
  "enhancements, please use the <a href=\"%s\">Xavisys Support Forums</a>."
63
  msgstr ""
64
 
65
+ #: wp-twitter-widget.php:43
66
  msgid "Follow a Twitter Feed"
67
  msgstr ""
68
 
69
+ #: wp-twitter-widget.php:50 wp-twitter-widget.php:193
70
  msgid "Twitter Widget Pro"
71
  msgstr ""
72
 
73
+ #: wp-twitter-widget.php:65 wp-twitter-widget.php:237
74
  msgid "Twitter username:"
75
  msgstr ""
76
 
77
+ #: wp-twitter-widget.php:69 wp-twitter-widget.php:245
78
  msgid "Give the feed a title ( optional ):"
79
  msgstr ""
80
 
81
+ #: wp-twitter-widget.php:73 wp-twitter-widget.php:253
82
  msgid "How many items would you like to display?"
83
  msgstr ""
84
 
85
+ #: wp-twitter-widget.php:83 wp-twitter-widget.php:267
86
+ msgid "Display profile image?"
87
+ msgstr ""
88
+
89
+ #: wp-twitter-widget.php:94 wp-twitter-widget.php:325
90
+ msgid "Include retweets"
91
+ msgstr ""
92
+
93
+ #: wp-twitter-widget.php:98 wp-twitter-widget.php:328
94
  msgid "Hide @replies"
95
  msgstr ""
96
 
97
+ #: wp-twitter-widget.php:102 wp-twitter-widget.php:331
98
  msgid "Hide sending applications"
99
  msgstr ""
100
 
101
+ #: wp-twitter-widget.php:106 wp-twitter-widget.php:334
102
+ msgid "Show Tweet Intents (reply, retweet, favorite)"
103
+ msgstr ""
104
+
105
+ #: wp-twitter-widget.php:110 wp-twitter-widget.php:337
106
+ msgid "Show Follow Link"
107
+ msgstr ""
108
+
109
+ #: wp-twitter-widget.php:113 wp-twitter-widget.php:281
110
  msgid "What to display when Twitter is down ( optional ):"
111
  msgstr ""
112
 
113
+ #: wp-twitter-widget.php:117 wp-twitter-widget.php:289
114
  msgid "Number of seconds to wait for a response from Twitter ( default 2 ):"
115
  msgstr ""
116
 
117
+ #: wp-twitter-widget.php:121 wp-twitter-widget.php:297
118
  msgid "Show date/time of Tweet ( rather than 2 ____ ago ):"
119
  msgstr ""
120
 
121
+ #: wp-twitter-widget.php:123 wp-twitter-widget.php:301
122
  msgid "Always"
123
  msgstr ""
124
 
125
+ #: wp-twitter-widget.php:124 wp-twitter-widget.php:302
126
  msgid "If over an hour old"
127
  msgstr ""
128
 
129
+ #: wp-twitter-widget.php:125 wp-twitter-widget.php:303
130
  msgid "If over a day old"
131
  msgstr ""
132
 
133
+ #: wp-twitter-widget.php:126 wp-twitter-widget.php:304
134
  msgid "If over a week old"
135
  msgstr ""
136
 
137
+ #: wp-twitter-widget.php:127 wp-twitter-widget.php:305
138
  msgid "If over a month old"
139
  msgstr ""
140
 
141
+ #: wp-twitter-widget.php:128 wp-twitter-widget.php:306
142
  msgid "If over a year old"
143
  msgstr ""
144
 
145
+ #: wp-twitter-widget.php:129 wp-twitter-widget.php:307
146
  msgid "Never"
147
  msgstr ""
148
 
149
+ #: wp-twitter-widget.php:133 wp-twitter-widget.php:313
150
  msgid ""
151
  "Format to dispaly the date in, uses <a href=\"%s\">PHP date()</a> format:"
152
  msgstr ""
153
 
154
+ #: wp-twitter-widget.php:138 wp-twitter-widget.php:340
 
 
 
 
155
  msgid "Open links in a new window"
156
  msgstr ""
157
 
158
+ #: wp-twitter-widget.php:142 wp-twitter-widget.php:343
 
 
 
 
159
  msgid "Show Link to Twitter Widget Pro"
160
  msgstr ""
161
 
162
+ #: wp-twitter-widget.php:194
163
  msgid "Twitter Widget"
164
  msgstr ""
165
 
166
+ #: wp-twitter-widget.php:229
167
  msgid "General Settings"
168
  msgstr ""
169
 
170
+ #: wp-twitter-widget.php:321
171
  msgid "Other Setting:"
172
  msgstr ""
173
 
174
+ #: wp-twitter-widget.php:499
 
 
 
 
175
  msgid "No Tweets Available"
176
  msgstr ""
177
 
178
+ #: wp-twitter-widget.php:517
179
  msgid "from %s"
180
  msgstr ""
181
 
182
+ #: wp-twitter-widget.php:521
183
  msgid "in reply to %s"
184
  msgstr ""
185
 
186
+ #: wp-twitter-widget.php:535
187
+ msgid "Reply"
188
+ msgstr ""
189
+
190
+ #: wp-twitter-widget.php:543
191
+ msgid "Retweet"
192
+ msgstr ""
193
+
194
+ #: wp-twitter-widget.php:551
195
+ msgid "Favorite"
196
+ msgstr ""
197
+
198
+ #: wp-twitter-widget.php:574
199
+ msgid "Follow %s"
200
+ msgstr ""
201
+
202
+ #: wp-twitter-widget.php:584
203
+ msgid "Brought to you by Xavisys - A WordPress development company"
204
  msgstr ""
205
 
206
+ #: wp-twitter-widget.php:586
207
  msgid "Powered by"
208
  msgstr ""
209
 
210
+ #: wp-twitter-widget.php:635
211
  msgid "Invalid Twitter Response."
212
  msgstr ""
213
 
214
+ #: wp-twitter-widget.php:645
215
  msgid "Could not connect to Twitter"
216
  msgstr ""
217
 
218
+ #: wp-twitter-widget.php:727
219
  msgid "about %s year ago"
220
  msgid_plural "about %s years ago"
221
  msgstr[0] ""
222
  msgstr[1] ""
223
 
224
+ #: wp-twitter-widget.php:728
225
  msgid "about %s month ago"
226
  msgid_plural "about %s months ago"
227
  msgstr[0] ""
228
  msgstr[1] ""
229
 
230
+ #: wp-twitter-widget.php:729
231
  msgid "about %s week ago"
232
  msgid_plural "about %s weeks ago"
233
  msgstr[0] ""
234
  msgstr[1] ""
235
 
236
+ #: wp-twitter-widget.php:730
237
  msgid "about %s day ago"
238
  msgid_plural "about %s days ago"
239
  msgstr[0] ""
240
  msgstr[1] ""
241
 
242
+ #: wp-twitter-widget.php:731
243
  msgid "about %s hour ago"
244
  msgid_plural "about %s hours ago"
245
  msgstr[0] ""
246
  msgstr[1] ""
247
 
248
+ #: wp-twitter-widget.php:732
249
  msgid "about %s minute ago"
250
  msgid_plural "about %s minutes ago"
251
  msgstr[0] ""
252
  msgstr[1] ""
253
 
254
+ #: wp-twitter-widget.php:733
255
  msgid "about %s second ago"
256
  msgid_plural "about %s seconds ago"
257
  msgstr[0] ""
258
  msgstr[1] ""
259
 
260
+ #: wp-twitter-widget.php:785 wp-twitter-widget.php:858
261
  msgid "h:i:s A F d, Y"
262
  msgstr ""
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: aaroncampbell
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal%40xavisys%2ecom&item_name=Twitter%20Widget%20Pro&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8
4
  Tags: twitter, widget, feed
5
  Requires at least: 3.0
6
- Tested up to: 3.2.1
7
- Stable tag: 2.2.4
8
 
9
  A widget that properly handles twitter feeds, including parsing @username, #hashtags, and URLs into links. Requires PHP5.
10
 
@@ -15,6 +15,8 @@ link parsing. It supports displaying profiles images, and even lets you control
15
  whether to display the time and date of a tweet or how log ago it happened
16
  (about 5 hours ago, etc). Requires PHP5.
17
 
 
 
18
  == Installation ==
19
 
20
  1. Verify that you have PHP5, which is required for this plugin.
@@ -24,10 +26,6 @@ whether to display the time and date of a tweet or how log ago it happened
24
 
25
  == Frequently Asked Questions ==
26
 
27
- = Can I use more than one instance of this widget? =
28
-
29
- Yes, Twitter Widget Pro employs the multi-widget pattern, which allows you to not only have more than one instance of this widget on your site, but even allows more than one instance of this widget in a single sidebar.
30
-
31
  = Can I follow more than one feed? =
32
 
33
  Absolutely, each instance of the widget can have different settings and track different feeds.
@@ -53,7 +51,7 @@ However, there are more things you can control.
53
  * hiderss - set to true to hide the RSS icon (defaults to false)
54
  * hidereplies - set to true to hide @replies that are sent from the account (defaults to false)
55
  * hidefrom - set to true to hide the "from ____" link that shows the application the tweet was sent from (defaults to false)
56
- * avatar - set to true to display the avatar from the Twitter account (defaults to false)
57
  * targetBlank - set to true to have all links open in a new window (defaults to false)
58
  * showXavisysLink - set to true to display a link to the Twitter Widget Pro page. We greatly appreciate your support in linking to this page so others can find this useful plugin too! (defaults to false)
59
  * items - The number of items to display (defaults to 10)
@@ -61,6 +59,9 @@ However, there are more things you can control.
61
  * showts - Number of seconds old a tweet has to be to show ___ ago rather than a date/time (defaults to 86400 seconds which is 24 hours)
62
  * dateFormat - The format for dates (defaults to'h:i:s A F d, Y' or it's localization)
63
  * title - The title of the widget (defaults to 'Twitter: Username')
 
 
 
64
 
65
  You can see these put into action by trying something like:
66
 
@@ -68,6 +69,55 @@ You can see these put into action by trying something like:
68
  * `[twitter-widget username="wpinformer" before_widget="<div class='half-box'>" after_widget="</div>" before_title="<h1>" after_title="</h1>" errmsg="Uh oh!" hiderss="true" hidereplies="true" targetBlank="true" avatar="1" showXavisysLink="1" items="3" showts="60" title="Your Title"]`
69
  * `[twitter-widget username="wpinformer"]`
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  = Why can't I display a friends feed anymore? =
72
 
73
  Aparently the database queries required to display the friends feed was causing twitter to crash, so they removed it. Unfortunately, this is outside my control.
@@ -81,20 +131,22 @@ Aparently the database queries required to display the friends feed was causing
81
 
82
  == Upgrade Notice ==
83
 
 
 
 
84
  = 2.2.4 =
85
  Uses new API urls, new "hide replies" support in the API, can show retweets, supports multiple profile image sizes
86
 
87
- = 2.2.3 =
88
- Fixes links on 32 bit servers. If you are suffering from this I would recommend changing hosts (or talking to yours).
89
-
90
- = 2.2.2 =
91
- Fixes issue introduced in 2.2.1 with an incorrect function name (sorry about that)
92
-
93
- = 2.2.1 =
94
- Better SEO by adding the ability to remove the "from" links - Thanks <a href="http://yoast.com/">Joost de Valk</a>
95
-
96
  == Changelog ==
97
 
 
 
 
 
 
 
 
 
98
  = 2.2.4 =
99
  * Use the new API URLs
100
  * Use the new "hide replies" option in the Twitter API
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal%40xavisys%2ecom&item_name=Twitter%20Widget%20Pro&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8
4
  Tags: twitter, widget, feed
5
  Requires at least: 3.0
6
+ Tested up to: 3.3.0
7
+ Stable tag: 2.3.0
8
 
9
  A widget that properly handles twitter feeds, including parsing @username, #hashtags, and URLs into links. Requires PHP5.
10
 
15
  whether to display the time and date of a tweet or how log ago it happened
16
  (about 5 hours ago, etc). Requires PHP5.
17
 
18
+ Author: <a href="http://xavisys.com/" title="WordPress development">Aaron D. Campbell</a>
19
+
20
  == Installation ==
21
 
22
  1. Verify that you have PHP5, which is required for this plugin.
26
 
27
  == Frequently Asked Questions ==
28
 
 
 
 
 
29
  = Can I follow more than one feed? =
30
 
31
  Absolutely, each instance of the widget can have different settings and track different feeds.
51
  * hiderss - set to true to hide the RSS icon (defaults to false)
52
  * hidereplies - set to true to hide @replies that are sent from the account (defaults to false)
53
  * hidefrom - set to true to hide the "from ____" link that shows the application the tweet was sent from (defaults to false)
54
+ * avatar - set to one of the available sizes (mini, normal, bigger, or original) (defaults to none)
55
  * targetBlank - set to true to have all links open in a new window (defaults to false)
56
  * showXavisysLink - set to true to display a link to the Twitter Widget Pro page. We greatly appreciate your support in linking to this page so others can find this useful plugin too! (defaults to false)
57
  * items - The number of items to display (defaults to 10)
59
  * showts - Number of seconds old a tweet has to be to show ___ ago rather than a date/time (defaults to 86400 seconds which is 24 hours)
60
  * dateFormat - The format for dates (defaults to'h:i:s A F d, Y' or it's localization)
61
  * title - The title of the widget (defaults to 'Twitter: Username')
62
+ * showretweets - set to true to show retweets, false to hide them (defaults to true)
63
+ * showintents - set to true to show the reply, retweet, and favorite links for each tweet, false to hide them (defaults to true)
64
+ * showfollow - set to true to show the follow button after tweets, false to hide it (defaults to true)
65
 
66
  You can see these put into action by trying something like:
67
 
69
  * `[twitter-widget username="wpinformer" before_widget="<div class='half-box'>" after_widget="</div>" before_title="<h1>" after_title="</h1>" errmsg="Uh oh!" hiderss="true" hidereplies="true" targetBlank="true" avatar="1" showXavisysLink="1" items="3" showts="60" title="Your Title"]`
70
  * `[twitter-widget username="wpinformer"]`
71
 
72
+ = How can I style it to look nicer? =
73
+
74
+ There are plenty of CSS classes throughout the HTML that is generated, and you can use those to style things. Here is some sample CSS that I use with the <a href="essencetheme.com" title="Essence Theme for WordPress">Essence Theme</a>. You'll need to get the "Everything" sprite from <a href="https://dev.twitter.com/docs/image-resources">Twitter's Image Resources</a>.
75
+ `
76
+ .widget_twitter div {
77
+ padding:0;
78
+ }
79
+
80
+ .widget_twitter ul li {
81
+ margin-bottom:5px;
82
+ }
83
+
84
+ .widget_twitter .follow-button,
85
+ .widget_twitter .xavisys-link {
86
+ margin:0 10px 10px 25px;
87
+ }
88
+
89
+ .widget_twitter .entry-meta {
90
+ display:block;
91
+ font-size:80%;
92
+ }
93
+
94
+ .widget_twitter .intent-meta a {
95
+ background: url(images/everything-spritev2.png); /** from Twitter ressources */
96
+ display: inline-block;
97
+ height: 16px;
98
+ text-indent: -9999px;
99
+ width: 16px;
100
+ }
101
+ .widget_twitter .intent-meta a.in-reply-to {
102
+ background-position: 0 center;
103
+ }
104
+ .widget_twitter .intent-meta a:hover.in-reply-to {
105
+ background-position: -16px center;
106
+ }
107
+ .widget_twitter .intent-meta a.favorite {
108
+ background-position: -32px center;
109
+ }
110
+ .widget_twitter .intent-meta a:hover.favorite {
111
+ background-position: -48px center;
112
+ }
113
+ .widget_twitter .intent-meta a.retweet {
114
+ background-position: -80px center;
115
+ }
116
+ .widget_twitter .intent-meta a:hover.retweet {
117
+ background-position: -96px center;
118
+ }
119
+ `
120
+
121
  = Why can't I display a friends feed anymore? =
122
 
123
  Aparently the database queries required to display the friends feed was causing twitter to crash, so they removed it. Unfortunately, this is outside my control.
131
 
132
  == Upgrade Notice ==
133
 
134
+ = 2.3.0 =
135
+ Fewer "could not connect to Twitter" messages, new links (reply, retweet, favorite), new follow button, and avatar fixes
136
+
137
  = 2.2.4 =
138
  Uses new API urls, new "hide replies" support in the API, can show retweets, supports multiple profile image sizes
139
 
 
 
 
 
 
 
 
 
 
140
  == Changelog ==
141
 
142
+ = 2.3.0 =
143
+ * Integrate Mark Jaquith's TLC Transients https://gist.github.com/1149945 which lets us only get rid of old tweets once we have successfully received new ones.
144
+ * Add Twitter Web Intents (reply, retweet, favorite)
145
+ * Add option for Twitter Follow button
146
+ * Fix issues with saving avatar sizes
147
+ * Remove "Hide RSS Icon and Link" option - Decisions not options.
148
+ * Removed link from title. Use the follow button option or if you have unfiltered_html privileges you can enter the HTML link as the title.
149
+
150
  = 2.2.4 =
151
  * Use the new API URLs
152
  * Use the new "hide replies" option in the Twitter API
tlc-transients.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TLC_Transient_Update_Server {
4
+ public function __construct() {
5
+ add_action( 'init', array( $this, 'init' ) );
6
+ }
7
+
8
+ public function init() {
9
+ if ( isset( $_POST['_tlc_update'] ) ) {
10
+ $update = get_transient( 'tlc_update__' . $_POST['key'] );
11
+ if ( $update && $update[0] == $_POST['_tlc_update'] ) {
12
+ tlc_transient( $update[1] )
13
+ ->expires_in( $update[2] )
14
+ ->updates_with( $update[3], (array) $update[4] )
15
+ ->set_lock( $update[0] )
16
+ ->fetch_and_cache();
17
+ }
18
+ exit();
19
+ }
20
+ }
21
+ }
22
+
23
+ new TLC_Transient_Update_Server;
24
+
25
+ if ( !class_exists( 'TLC_Transient' ) ) {
26
+ class TLC_Transient {
27
+ public $key;
28
+ private $lock;
29
+ private $callback;
30
+ private $params;
31
+ private $expiration = 0;
32
+ private $force_background_updates = false;
33
+
34
+ public function __construct( $key ) {
35
+ $this->key = $key;
36
+ }
37
+
38
+ public function get() {
39
+ $data = get_transient( $this->key );
40
+ if ( false === $data ) {
41
+ // Hard expiration
42
+ if ( $this->force_background_updates ) {
43
+ // In this mode, we never do a just-in-time update
44
+ // We return false, and schedule a fetch on shutdown
45
+ $this->schedule_background_fetch();
46
+ return false;
47
+ } else {
48
+ // Bill O'Reilly mode: "We'll do it live!"
49
+ return $this->fetch_and_cache();
50
+ }
51
+ } else {
52
+ // Soft expiration
53
+ if ( $data[0] !== 0 && $data[0] < time() )
54
+ $this->schedule_background_fetch();
55
+ return $data[1];
56
+ }
57
+ }
58
+
59
+ private function schedule_background_fetch() {
60
+ if ( !$this->has_update_lock() ) {
61
+ set_transient( 'tlc_update__' . $this->key, array( $this->new_update_lock(), $this->key, $this->expiration, $this->callback, $this->params ) );
62
+ add_action( 'shutdown', array( $this, 'spawn_server' ) );
63
+ }
64
+ return $this;
65
+ }
66
+
67
+ public function spawn_server() {
68
+ $server_url = home_url( '/?tlc_transients_request' );
69
+ wp_remote_post( $server_url, array( 'body' => array( '_tlc_update' => $this->lock, 'key' => $this->key ), 'timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters( 'https_local_ssl_verify', true ) ) );
70
+ }
71
+
72
+ public function fetch_and_cache() {
73
+ // If you don't supply a callback, we can't update it for you!
74
+ if ( empty( $this->callback ) )
75
+ return false;
76
+ if ( $this->has_update_lock() && !$this->owns_update_lock() )
77
+ return; // Race... let the other process handle it
78
+ try {
79
+ $data = call_user_func_array( $this->callback, $this->params );
80
+ $this->set( $data );
81
+ } catch( Exception $e ) {}
82
+ $this->release_update_lock();
83
+ return $data;
84
+ }
85
+
86
+ public function set( $data ) {
87
+ // We set the timeout as part of the transient data.
88
+ // The actual transient has no TTL. This allows for soft expiration.
89
+ $expiration = ( $this->expiration > 0 ) ? time() + $this->expiration : 0;
90
+ set_transient( $this->key, array( $expiration, $data ) );
91
+ return $this;
92
+ }
93
+
94
+ public function updates_with( $callback, $params = array() ) {
95
+ $this->callback = $callback;
96
+ if ( is_array( $params ) )
97
+ $this->params = $params;
98
+ return $this;
99
+ }
100
+
101
+ private function new_update_lock() {
102
+ $this->lock = md5( uniqid( microtime() . mt_rand(), true ) );
103
+ return $this->lock;
104
+ }
105
+
106
+ private function release_update_lock() {
107
+ delete_transient( 'tlc_update__' . $this->key );
108
+ }
109
+
110
+ private function get_update_lock() {
111
+ $lock = get_transient( 'tlc_update__' . $this->key );
112
+ if ( $lock )
113
+ return $lock[0];
114
+ else
115
+ return false;
116
+ }
117
+
118
+ private function has_update_lock() {
119
+ return (bool) $this->get_update_lock();
120
+ }
121
+
122
+ private function owns_update_lock() {
123
+ return $this->lock == $this->get_update_lock();
124
+ }
125
+
126
+ public function expires_in( $seconds ) {
127
+ $this->expiration = (int) $seconds;
128
+ return $this;
129
+ }
130
+
131
+ public function set_lock( $lock ) {
132
+ $this->lock = $lock;
133
+ return $this;
134
+ }
135
+
136
+ public function background_only() {
137
+ $this->force_background_updates = true;
138
+ return $this;
139
+ }
140
+ }
141
+ }
142
+
143
+ // API so you don't have to use "new"
144
+ function tlc_transient( $key ) {
145
+ $transient = new TLC_Transient( $key );
146
+ return $transient;
147
+ }
wp-twitter-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Twitter Widget Pro
4
  * Plugin URI: http://xavisys.com/wordpress-plugins/wordpress-twitter-widget/
5
  * Description: A widget that properly handles twitter feeds, including @username, #hashtag, and link parsing. It can even display profile images for the users. Requires PHP5.
6
- * Version: 2.2.4
7
  * Author: Aaron D. Campbell
8
  * Author URI: http://xavisys.com/
9
  * License: GPLv2 or later
@@ -28,8 +28,8 @@
28
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
  */
30
 
 
31
  require_once( 'xavisys-plugin-framework.php' );
32
- class wpTwitterWidgetException extends Exception {}
33
 
34
  /**
35
  * WP_Widget_Twitter_Pro is the class that handles the main widget.
@@ -83,10 +83,10 @@ class WP_Widget_Twitter_Pro extends WP_Widget {
83
  <label for="<?php echo $this->get_field_id( 'avatar' ); ?>"><?php _e( 'Display profile image?', $this->_slug ); ?></label>
84
  <select id="<?php echo $this->get_field_id( 'avatar' ); ?>" name="<?php echo $this->get_field_name( 'avatar' ); ?>">
85
  <option value=""<?php selected( $instance['avatar'], '' ) ?>>Do not show</option>
86
- <option value=""<?php selected( $instance['avatar'], 'mini' ) ?>>Mini - 24px by 24px</option>
87
- <option value=""<?php selected( $instance['avatar'], 'normal' ) ?>>Normal - 48px by 48px</option>
88
- <option value=""<?php selected( $instance['avatar'], 'bigger' ) ?>>Bigger - 73px by 73px</option>
89
- <option value=""<?php selected( $instance['avatar'], 'original' ) ?>>Original</option>
90
  </select>
91
  </p>
92
  <p>
@@ -101,6 +101,14 @@ class WP_Widget_Twitter_Pro extends WP_Widget {
101
  <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'hidefrom' ); ?>" name="<?php echo $this->get_field_name( 'hidefrom' ); ?>"<?php checked( $instance['hidefrom'], 'true' ); ?> />
102
  <label for="<?php echo $this->get_field_id( 'hidefrom' ); ?>"><?php _e( 'Hide sending applications', $this->_slug ); ?></label>
103
  </p>
 
 
 
 
 
 
 
 
104
  <p>
105
  <label for="<?php echo $this->get_field_id( 'errmsg' ); ?>"><?php _e( 'What to display when Twitter is down ( optional ):', $this->_slug ); ?></label>
106
  <input class="widefat" id="<?php echo $this->get_field_id( 'errmsg' ); ?>" name="<?php echo $this->get_field_name( 'errmsg' ); ?>" type="text" value="<?php esc_attr_e( $instance['errmsg'] ); ?>" />
@@ -125,10 +133,6 @@ class WP_Widget_Twitter_Pro extends WP_Widget {
125
  <label for="<?php echo $this->get_field_id( 'dateFormat' ); ?>"><?php echo sprintf( __( 'Format to dispaly the date in, uses <a href="%s">PHP date()</a> format:', $this->_slug ), 'http://php.net/date' ); ?></label>
126
  <input class="widefat" id="<?php echo $this->get_field_id( 'dateFormat' ); ?>" name="<?php echo $this->get_field_name( 'dateFormat' ); ?>" type="text" value="<?php esc_attr_e( $instance['dateFormat'] ); ?>" />
127
  </p>
128
- <p>
129
- <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'hiderss' ); ?>" name="<?php echo $this->get_field_name( 'hiderss' ); ?>"<?php checked( $instance['hiderss'], 'true' ); ?> />
130
- <label for="<?php echo $this->get_field_id( 'hiderss' ); ?>"><?php _e( 'Hide RSS Icon and Link', $this->_slug ); ?></label>
131
- </p>
132
  <p>
133
  <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'targetBlank' ); ?>" name="<?php echo $this->get_field_name( 'targetBlank' ); ?>"<?php checked( $instance['targetBlank'], 'true' ); ?> />
134
  <label for="<?php echo $this->get_field_id( 'targetBlank' ); ?>"><?php _e( 'Open links in a new window', $this->_slug ); ?></label>
@@ -211,9 +215,9 @@ class wpTwitterWidget extends XavisysPlugin {
211
  * Function to instantiate our class and make it a singleton
212
  */
213
  public static function getInstance() {
214
- if ( !self::$instance ) {
215
  self::$instance = new self;
216
- }
217
  return self::$instance;
218
  }
219
 
@@ -265,10 +269,10 @@ class wpTwitterWidget extends XavisysPlugin {
265
  <td>
266
  <select id="twp_avatar" name="twp[avatar]">
267
  <option value=""<?php selected( $this->_settings['twp']['avatar'], '' ) ?>>Do not show</option>
268
- <option value=""<?php selected( $this->_settings['twp']['avatar'], 'mini' ) ?>>Mini - 24px by 24px</option>
269
- <option value=""<?php selected( $this->_settings['twp']['avatar'], 'normal' ) ?>>Normal - 48px by 48px</option>
270
- <option value=""<?php selected( $this->_settings['twp']['avatar'], 'bigger' ) ?>>Bigger - 73px by 73px</option>
271
- <option value=""<?php selected( $this->_settings['twp']['avatar'], 'original' ) ?>>Original</option>
272
  </select>
273
  </td>
274
  </tr>
@@ -326,8 +330,11 @@ class wpTwitterWidget extends XavisysPlugin {
326
  <input class="checkbox" type="checkbox" value="true" id="twp_hidefrom" name="twp[hidefrom]"<?php checked( $this->_settings['twp']['hidefrom'], 'true' ); ?> />
327
  <label for="twp_hidefrom"><?php _e( 'Hide sending applications', $this->_slug ); ?></label>
328
  <br />
329
- <input class="checkbox" type="checkbox" value="true" id="twp_hiderss" name="twp[hiderss]"<?php checked( $this->_settings['twp']['hiderss'], 'true' ); ?> />
330
- <label for="twp_hiderss"><?php _e( 'Hide RSS Icon and Link', $this->_slug ); ?></label>
 
 
 
331
  <br />
332
  <input class="checkbox" type="checkbox" value="true" id="twp_targetBlank" name="twp[targetBlank]"<?php checked( $this->_settings['twp']['targetBlank'], 'true' ); ?> />
333
  <label for="twp_targetBlank"><?php _e( 'Open links in a new window', $this->_slug ); ?></label>
@@ -429,20 +436,20 @@ class wpTwitterWidget extends XavisysPlugin {
429
  $attributes = array_filter( wp_parse_args( $attributes ), array( $this, '_notEmpty' ) );
430
  $attributes = apply_filters( 'widget_twitter_link_attributes', $attributes );
431
  $attributes = wp_parse_args( $attributes );
432
- if ( strtolower( 'www' == substr( $attributes['href'], 0, 3 ) ) ) {
433
  $attributes['href'] = 'http://' . $attributes['href'];
434
- }
435
  $text = apply_filters( 'widget_twitter_link_text', $text );
436
  $link = '<a';
437
  foreach ( $attributes as $name => $value ) {
438
  $link .= ' ' . esc_attr( $name ) . '="' . esc_attr( $value ) . '"';
439
  }
440
  $link .= '>';
441
- if ( $noFilter ) {
442
  $link .= $text;
443
- } else {
444
  $link .= esc_html( $text );
445
- }
446
  $link .= '</a>';
447
  return $link;
448
  }
@@ -459,64 +466,36 @@ class wpTwitterWidget extends XavisysPlugin {
459
  public function display( $args ) {
460
  $args = wp_parse_args( $args );
461
 
462
- if ( $args['targetBlank'] ) {
463
  add_filter( 'widget_twitter_link_attributes', array( $this, 'targetBlank' ) );
464
- }
465
 
466
  // Validate our options
467
  $args['items'] = (int) $args['items'];
468
- if ( $args['items'] < 1 || 20 < $args['items'] ) {
469
  $args['items'] = 10;
470
- }
471
- if ( !isset( $args['showts'] ) ) {
472
  $args['showts'] = 86400;
473
- }
474
 
475
- try {
476
- $tweets = $this->_getTweets( $args );
477
- } catch ( wpTwitterWidgetException $e ) {
478
- $tweets = $e;
479
- }
480
 
481
  $widgetContent = $args['before_widget'] . '<div>';
482
 
483
- // If "hide rss" hasn't been checked, show the linked icon
484
- if ( $args['hiderss'] != 'true' ) {
485
- if ( file_exists( dirname( __FILE__ ) . '/rss.png' ) ) {
486
- $icon = str_replace( ABSPATH, get_option( 'siteurl' ).'/', dirname( __FILE__ ) ) . '/rss.png';
487
- } else {
488
- $icon = get_option( 'siteurl' ).'/wp-includes/images/rss.png';
489
- }
490
- $feedUrl = $this->_getFeedUrl( $args, 'rss', false );
491
- $linkAttrs = array(
492
- 'class' => 'twitterwidget twitterwidget-rss',
493
- 'title' => __( 'Syndicate this content', $this->_slug ),
494
- 'href' => $feedUrl
495
- );
496
-
497
- $args['before_title'] .= $this->_buildLink( "<img style='background:orange;color:white;border:none;' width='14' height='14' src='{$icon}' alt='RSS' />", $linkAttrs, true );
498
- }
499
- $twitterLink = 'http://twitter.com/' . $args['username'];
500
-
501
- if ( empty( $args['title'] ) ) {
502
  $args['title'] = "Twitter: {$args['username']}";
503
- }
504
- $linkAttrs = array(
505
- 'class' => 'twitterwidget twitterwidget-title',
506
- 'title' => "Twitter: {$args['username']}",
507
- 'href' => $twitterLink
508
- );
509
- $args['title'] = $this->_buildLink( $args['title'], $linkAttrs, current_user_can( 'unfiltered_html' ) );
510
  $widgetContent .= $args['before_title'] . $args['title'] . $args['after_title'];
511
- if ( !is_a( $tweets, 'wpTwitterWidgetException' ) && !empty( $tweets[0] ) && !empty( $args['avatar'] ) ) {
512
  $widgetContent .= '<div class="twitter-avatar">';
513
  $widgetContent .= $this->_getProfileImage( $tweets[0]->user, $args );
514
  $widgetContent .= '</div>';
515
  }
516
  $widgetContent .= '<ul>';
517
- if ( is_a( $tweets, 'wpTwitterWidgetException' ) ) {
518
- $widgetContent .= '<li class="wpTwitterWidgetError">' . $tweets->getMessage() . '</li>';
519
- } else if ( count( $tweets ) == 0 ) {
520
  $widgetContent .= '<li class="wpTwitterWidgetEmpty">' . __( 'No Tweets Available', $this->_slug ) . '</li>';
521
  } else {
522
  $count = 0;
@@ -524,7 +503,6 @@ class wpTwitterWidget extends XavisysPlugin {
524
  // Set our "ago" string which converts the date to "# ___(s) ago"
525
  $tweet->ago = $this->_timeSince( strtotime( $tweet->created_at ), $args['showts'], $args['dateFormat'] );
526
  $entryContent = apply_filters( 'widget_twitter_content', $tweet->text );
527
- $from = sprintf( __( 'from %s', $this->_slug ), str_replace( '&', '&amp;', $tweet->source ) );
528
  $widgetContent .= '<li>';
529
  $widgetContent .= "<span class='entry-content'>{$entryContent}</span>";
530
  $widgetContent .= " <span class='entry-meta'>";
@@ -534,8 +512,11 @@ class wpTwitterWidget extends XavisysPlugin {
534
  );
535
  $widgetContent .= $this->_buildLink( $tweet->ago, $linkAttrs );
536
  $widgetContent .= '</span>';
537
- if ( 'true' != $args['hidefrom'] )
 
 
538
  $widgetContent .= " <span class='from-meta'>{$from}</span>";
 
539
  if ( !empty( $tweet->in_reply_to_screen_name ) ) {
540
  $rtLinkText = sprintf( __( 'in reply to %s', $this->_slug ), $tweet->in_reply_to_screen_name );
541
  $widgetContent .= ' <span class="in-reply-to-meta">';
@@ -546,28 +527,83 @@ class wpTwitterWidget extends XavisysPlugin {
546
  $widgetContent .= $this->_buildLink( $rtLinkText, $linkAttrs );
547
  $widgetContent .= '</span>';
548
  }
549
- $widgetContent .= '</span></li>';
550
 
551
- if ( ++$count >= $args['items'] ) {
552
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
553
  }
 
 
 
 
554
  }
555
  }
556
 
557
- if ( $args['showXavisysLink'] == 'true' ) {
558
- $widgetContent .= '<li class="xavisys-link"><span class="xavisys-link-text">';
 
 
 
 
 
 
 
 
 
 
 
 
 
559
  $linkAttrs = array(
560
  'href' => 'http://xavisys.com/wordpress-plugins/wordpress-twitter-widget/',
561
- 'title' => __( 'Get Twitter Widget for your WordPress site', $this->_slug )
562
  );
563
  $widgetContent .= __( 'Powered by', $this->_slug );
564
  $widgetContent .= $this->_buildLink( 'WordPress Twitter Widget Pro', $linkAttrs );
565
- $widgetContent .= '</span></li>';
 
 
 
 
 
 
 
 
 
 
566
  }
567
- $widgetContent .= '</ul></div>' . $args['after_widget'];
568
  return $widgetContent;
569
  }
570
 
 
 
 
 
571
  /**
572
  * Gets tweets, from cache if possible
573
  *
@@ -575,16 +611,11 @@ class wpTwitterWidget extends XavisysPlugin {
575
  * @return array - Array of objects
576
  */
577
  private function _getTweets( $widgetOptions ) {
578
- $key = md5( $this->_getFeedUrl( $widgetOptions ) );
579
- if ( false === ( $tweets = get_site_transient( 'twp_' . $key ) ) ) {
580
- try {
581
- $tweets = $this->_parseFeed( $widgetOptions );
582
- set_site_transient( 'twp_' . $key, $tweets, 300 ); // cache for 5 minutes
583
- } catch ( wpTwitterWidgetException $e ) {
584
- throw $e;
585
- }
586
- }
587
- return $tweets;
588
  }
589
 
590
  /**
@@ -593,32 +624,28 @@ class wpTwitterWidget extends XavisysPlugin {
593
  * @param array $widgetOptions - settings needed to get feed url, etc
594
  * @return array
595
  */
596
- private function _parseFeed( $widgetOptions ) {
597
  $feedUrl = $this->_getFeedUrl( $widgetOptions );
598
  $resp = wp_remote_request( $feedUrl, array( 'timeout' => $widgetOptions['fetchTimeOut'] ) );
599
 
600
  if ( !is_wp_error( $resp ) && $resp['response']['code'] >= 200 && $resp['response']['code'] < 300 ) {
601
  $decodedResponse = json_decode( $resp['body'] );
602
  if ( empty( $decodedResponse ) ) {
603
- if ( empty( $widgetOptions['errmsg'] ) ) {
604
  $widgetOptions['errmsg'] = __( 'Invalid Twitter Response.', $this->_slug );
605
- }
606
- throw new wpTwitterWidgetException( $widgetOptions['errmsg'] );
607
  } elseif( !empty( $decodedResponse->error ) ) {
608
- if ( empty( $widgetOptions['errmsg'] ) ) {
609
  $widgetOptions['errmsg'] = $decodedResponse->error;
610
- }
611
- throw new wpTwitterWidgetException( $widgetOptions['errmsg'] );
612
  } else {
613
  return $decodedResponse;
614
  }
615
  } else {
616
  // Failed to fetch url;
617
- if ( empty( $widgetOptions['errmsg'] ) ) {
618
  $widgetOptions['errmsg'] = __( 'Could not connect to Twitter', $this->_slug );
619
- }
620
- throw new wpTwitterWidgetException( $widgetOptions['errmsg'] );
621
  }
 
 
622
  }
623
 
624
  /**
@@ -630,9 +657,9 @@ class wpTwitterWidget extends XavisysPlugin {
630
  * @return string - Twitter feed URL
631
  */
632
  private function _getFeedUrl( $widgetOptions, $type = 'json', $count = true ) {
633
- if ( !in_array( $type, array( 'rss', 'json' ) ) ) {
634
  $type = 'json';
635
- }
636
  $req = $this->_api_url . "statuses/user_timeline.{$type}";
637
 
638
  /**
@@ -650,15 +677,15 @@ class wpTwitterWidget extends XavisysPlugin {
650
  */
651
 
652
  $req = add_query_arg( array( 'screen_name' => $widgetOptions['username'] ), $req );
653
- if ( $count ) {
654
  $req = add_query_arg( array( 'count' => $widgetOptions['items'] ), $req );
655
- }
656
- if ( $widgetOptions['hidereplies'] ) {
657
  $req = add_query_arg( array( 'exclude_replies' => 'true' ), $req );
658
- }
659
- if ( $widgetOptions['showretweets'] ) {
660
  $req = add_query_arg( array( 'include_rts' => 'true' ), $req );
661
- }
662
  return $req;
663
  }
664
 
@@ -686,23 +713,22 @@ class wpTwitterWidget extends XavisysPlugin {
686
 
687
  $since = time() - $startTimestamp;
688
 
689
- if ( $max != '-1' && $since >= $max ) {
690
  return date_i18n( $dateFormat, $startTimestamp );
691
- }
692
 
693
  foreach ( $chunks as $key => $seconds ) {
694
  // finding the biggest chunk ( if the chunk fits, break )
695
- if ( ( $count = floor( $since / $seconds ) ) != 0 ) {
696
  break;
697
- }
698
  }
699
 
700
  $messages = array(
701
- 'year' => _n( 'about %s year ago', 'about %s years ago', $count, $this->_slug ),
702
- 'month' => _n( 'about %s month ago', 'about %s months ago', $count, $this->_slug ),
703
- 'week' => _n( 'about %s week ago', 'about %s weeks ago', $count, $this->_slug ),
704
- 'day' => _n( 'about %s day ago', 'about %s days ago', $count, $this->_slug ),
705
- 'hour' => _n( 'about %s hour ago', 'about %s hours ago', $count, $this->_slug ),
706
  'minute' => _n( 'about %s minute ago', 'about %s minutes ago', $count, $this->_slug ),
707
  'second' => _n( 'about %s second ago', 'about %s seconds ago', $count, $this->_slug ),
708
  );
@@ -746,13 +772,14 @@ class wpTwitterWidget extends XavisysPlugin {
746
  'errmsg' => '',
747
  'fetchTimeOut' => '2',
748
  'username' => '',
749
- 'hiderss' => false,
750
- 'hidereplies' => false,
751
- 'showretweets' => true,
752
- 'hidefrom' => false,
 
753
  'avatar' => '',
754
- 'showXavisysLink' => false,
755
- 'targetBlank' => false,
756
  'items' => 10,
757
  'showts' => 60 * 60 * 24,
758
  'dateFormat' => __( 'h:i:s A F d, Y', $this->_slug ),
@@ -779,33 +806,35 @@ class wpTwitterWidget extends XavisysPlugin {
779
  unset( $attr['dateformat'] );
780
  }
781
 
782
- if ( !empty( $content ) && empty( $attr['title'] ) ) {
783
  $attr['title'] = $content;
784
- }
785
 
786
  $attr = shortcode_atts( $defaults, $attr );
787
 
788
- if ( $attr['hiderss'] && $attr['hiderss'] != 'false' && $attr['hiderss'] != '0' ) {
789
- $attr['hiderss'] == true;
790
- }
791
- if ( $attr['hidereplies'] && $attr['hidereplies'] != 'false' && $attr['hidereplies'] != '0' ) {
792
- $attr['hidereplies'] == true;
793
- }
794
- if ( $attr['showretweets'] && $attr['showretweets'] != 'false' && $attr['showretweets'] != '0' ) {
795
- $attr['showretweets'] == true;
796
- }
797
- if ( $attr['hidefrom'] && $attr['hidefrom'] != 'false' && $attr['hidefrom'] != '0' ) {
798
- $attr['hidefrom'] == true;
799
- }
800
- if ( !in_array( $attr['avatar'], array( 'bigger', 'normal', 'mini', 'original', '' ) ) ) {
 
 
 
801
  $attr['avatar'] = 'normal';
802
- }
803
- if ( $attr['showXavisysLink'] && $attr['showXavisysLink'] != 'false' && $attr['showXavisysLink'] != '0' ) {
804
- $attr['showXavisysLink'] == true;
805
- }
806
- if ( $attr['targetBlank'] && $attr['targetBlank'] != 'false' && $attr['targetBlank'] != '0' ) {
807
- $attr['targetBlank'] == true;
808
- }
809
 
810
  return $this->display( $attr );
811
  }
@@ -816,13 +845,14 @@ class wpTwitterWidget extends XavisysPlugin {
816
  'errmsg' => '',
817
  'fetchTimeOut' => '2',
818
  'username' => '',
819
- 'hiderss' => false,
820
- 'hidereplies' => false,
821
- 'showretweets' => true,
822
- 'hidefrom' => false,
 
823
  'avatar' => '',
824
- 'showXavisysLink' => false,
825
- 'targetBlank' => false,
826
  'items' => 10,
827
  'showts' => 60 * 60 * 24,
828
  'dateFormat' => __( 'h:i:s A F d, Y', $this->_slug ),
@@ -836,11 +866,10 @@ class wpTwitterWidget extends XavisysPlugin {
836
  * the old true/false to a size string
837
  */
838
  private function fixAvatar( $settings ) {
839
- if ( false === $settings['avatar'] ) {
840
  $settings['avatar'] = '';
841
- } elseif ( !in_array( $settings['avatar'], array( 'bigger', 'normal', 'mini', 'original', false ) ) ) {
842
  $settings['avatar'] = 'normal';
843
- }
844
 
845
  return $settings;
846
  }
3
  * Plugin Name: Twitter Widget Pro
4
  * Plugin URI: http://xavisys.com/wordpress-plugins/wordpress-twitter-widget/
5
  * Description: A widget that properly handles twitter feeds, including @username, #hashtag, and link parsing. It can even display profile images for the users. Requires PHP5.
6
+ * Version: 2.3.0
7
  * Author: Aaron D. Campbell
8
  * Author URI: http://xavisys.com/
9
  * License: GPLv2 or later
28
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
  */
30
 
31
+ require_once( 'tlc-transients.php' );
32
  require_once( 'xavisys-plugin-framework.php' );
 
33
 
34
  /**
35
  * WP_Widget_Twitter_Pro is the class that handles the main widget.
83
  <label for="<?php echo $this->get_field_id( 'avatar' ); ?>"><?php _e( 'Display profile image?', $this->_slug ); ?></label>
84
  <select id="<?php echo $this->get_field_id( 'avatar' ); ?>" name="<?php echo $this->get_field_name( 'avatar' ); ?>">
85
  <option value=""<?php selected( $instance['avatar'], '' ) ?>>Do not show</option>
86
+ <option value="mini"<?php selected( $instance['avatar'], 'mini' ) ?>>Mini - 24px by 24px</option>
87
+ <option value="normal"<?php selected( $instance['avatar'], 'normal' ) ?>>Normal - 48px by 48px</option>
88
+ <option value="bigger"<?php selected( $instance['avatar'], 'bigger' ) ?>>Bigger - 73px by 73px</option>
89
+ <option value="original"<?php selected( $instance['avatar'], 'original' ) ?>>Original</option>
90
  </select>
91
  </p>
92
  <p>
101
  <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'hidefrom' ); ?>" name="<?php echo $this->get_field_name( 'hidefrom' ); ?>"<?php checked( $instance['hidefrom'], 'true' ); ?> />
102
  <label for="<?php echo $this->get_field_id( 'hidefrom' ); ?>"><?php _e( 'Hide sending applications', $this->_slug ); ?></label>
103
  </p>
104
+ <p>
105
+ <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'showintents' ); ?>" name="<?php echo $this->get_field_name( 'showintents' ); ?>"<?php checked( $instance['showintents'], 'true' ); ?> />
106
+ <label for="<?php echo $this->get_field_id( 'showintents' ); ?>"><?php _e( 'Show Tweet Intents (reply, retweet, favorite)', $this->_slug ); ?></label>
107
+ </p>
108
+ <p>
109
+ <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'showfollow' ); ?>" name="<?php echo $this->get_field_name( 'showfollow' ); ?>"<?php checked( $instance['showfollow'], 'true' ); ?> />
110
+ <label for="<?php echo $this->get_field_id( 'showfollow' ); ?>"><?php _e( 'Show Follow Link', $this->_slug ); ?></label>
111
+ </p>
112
  <p>
113
  <label for="<?php echo $this->get_field_id( 'errmsg' ); ?>"><?php _e( 'What to display when Twitter is down ( optional ):', $this->_slug ); ?></label>
114
  <input class="widefat" id="<?php echo $this->get_field_id( 'errmsg' ); ?>" name="<?php echo $this->get_field_name( 'errmsg' ); ?>" type="text" value="<?php esc_attr_e( $instance['errmsg'] ); ?>" />
133
  <label for="<?php echo $this->get_field_id( 'dateFormat' ); ?>"><?php echo sprintf( __( 'Format to dispaly the date in, uses <a href="%s">PHP date()</a> format:', $this->_slug ), 'http://php.net/date' ); ?></label>
134
  <input class="widefat" id="<?php echo $this->get_field_id( 'dateFormat' ); ?>" name="<?php echo $this->get_field_name( 'dateFormat' ); ?>" type="text" value="<?php esc_attr_e( $instance['dateFormat'] ); ?>" />
135
  </p>
 
 
 
 
136
  <p>
137
  <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'targetBlank' ); ?>" name="<?php echo $this->get_field_name( 'targetBlank' ); ?>"<?php checked( $instance['targetBlank'], 'true' ); ?> />
138
  <label for="<?php echo $this->get_field_id( 'targetBlank' ); ?>"><?php _e( 'Open links in a new window', $this->_slug ); ?></label>
215
  * Function to instantiate our class and make it a singleton
216
  */
217
  public static function getInstance() {
218
+ if ( !self::$instance )
219
  self::$instance = new self;
220
+
221
  return self::$instance;
222
  }
223
 
269
  <td>
270
  <select id="twp_avatar" name="twp[avatar]">
271
  <option value=""<?php selected( $this->_settings['twp']['avatar'], '' ) ?>>Do not show</option>
272
+ <option value="mini"<?php selected( $this->_settings['twp']['avatar'], 'mini' ) ?>>Mini - 24px by 24px</option>
273
+ <option value="normal"<?php selected( $this->_settings['twp']['avatar'], 'normal' ) ?>>Normal - 48px by 48px</option>
274
+ <option value="bigger"<?php selected( $this->_settings['twp']['avatar'], 'bigger' ) ?>>Bigger - 73px by 73px</option>
275
+ <option value="original"<?php selected( $this->_settings['twp']['avatar'], 'original' ) ?>>Original</option>
276
  </select>
277
  </td>
278
  </tr>
330
  <input class="checkbox" type="checkbox" value="true" id="twp_hidefrom" name="twp[hidefrom]"<?php checked( $this->_settings['twp']['hidefrom'], 'true' ); ?> />
331
  <label for="twp_hidefrom"><?php _e( 'Hide sending applications', $this->_slug ); ?></label>
332
  <br />
333
+ <input class="checkbox" type="checkbox" value="true" id="twp_showintents" name="twp[showintents]"<?php checked( $this->_settings['twp']['showintents'], 'true' ); ?> />
334
+ <label for="twp_showintents"><?php _e( 'Show Tweet Intents (reply, retweet, favorite)', $this->_slug ); ?></label>
335
+ <br />
336
+ <input class="checkbox" type="checkbox" value="true" id="twp_showfollow" name="twp[showfollow]"<?php checked( $this->_settings['twp']['showfollow'], 'true' ); ?> />
337
+ <label for="twp_showfollow"><?php _e( 'Show Follow Link', $this->_slug ); ?></label>
338
  <br />
339
  <input class="checkbox" type="checkbox" value="true" id="twp_targetBlank" name="twp[targetBlank]"<?php checked( $this->_settings['twp']['targetBlank'], 'true' ); ?> />
340
  <label for="twp_targetBlank"><?php _e( 'Open links in a new window', $this->_slug ); ?></label>
436
  $attributes = array_filter( wp_parse_args( $attributes ), array( $this, '_notEmpty' ) );
437
  $attributes = apply_filters( 'widget_twitter_link_attributes', $attributes );
438
  $attributes = wp_parse_args( $attributes );
439
+ if ( strtolower( 'www' == substr( $attributes['href'], 0, 3 ) ) )
440
  $attributes['href'] = 'http://' . $attributes['href'];
441
+
442
  $text = apply_filters( 'widget_twitter_link_text', $text );
443
  $link = '<a';
444
  foreach ( $attributes as $name => $value ) {
445
  $link .= ' ' . esc_attr( $name ) . '="' . esc_attr( $value ) . '"';
446
  }
447
  $link .= '>';
448
+ if ( $noFilter )
449
  $link .= $text;
450
+ else
451
  $link .= esc_html( $text );
452
+
453
  $link .= '</a>';
454
  return $link;
455
  }
466
  public function display( $args ) {
467
  $args = wp_parse_args( $args );
468
 
469
+ if ( 'true' == $args['targetBlank'] )
470
  add_filter( 'widget_twitter_link_attributes', array( $this, 'targetBlank' ) );
 
471
 
472
  // Validate our options
473
  $args['items'] = (int) $args['items'];
474
+ if ( $args['items'] < 1 || 20 < $args['items'] )
475
  $args['items'] = 10;
476
+
477
+ if ( !isset( $args['showts'] ) )
478
  $args['showts'] = 86400;
 
479
 
480
+ $tweets = $this->_getTweets( $args );
481
+ if ( false === $tweets )
482
+ return '';
 
 
483
 
484
  $widgetContent = $args['before_widget'] . '<div>';
485
 
486
+ if ( empty( $args['title'] ) )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
487
  $args['title'] = "Twitter: {$args['username']}";
488
+
489
+ $args['title'] = apply_filters( 'twitter-widget-title', $args['title'], $args );
490
+ $args['title'] = "<span class='twitterwidget twitterwidget-title'>{$args['title']}</span>";
 
 
 
 
491
  $widgetContent .= $args['before_title'] . $args['title'] . $args['after_title'];
492
+ if ( !empty( $tweets[0] ) && !empty( $args['avatar'] ) ) {
493
  $widgetContent .= '<div class="twitter-avatar">';
494
  $widgetContent .= $this->_getProfileImage( $tweets[0]->user, $args );
495
  $widgetContent .= '</div>';
496
  }
497
  $widgetContent .= '<ul>';
498
+ if ( count( $tweets ) == 0 ) {
 
 
499
  $widgetContent .= '<li class="wpTwitterWidgetEmpty">' . __( 'No Tweets Available', $this->_slug ) . '</li>';
500
  } else {
501
  $count = 0;
503
  // Set our "ago" string which converts the date to "# ___(s) ago"
504
  $tweet->ago = $this->_timeSince( strtotime( $tweet->created_at ), $args['showts'], $args['dateFormat'] );
505
  $entryContent = apply_filters( 'widget_twitter_content', $tweet->text );
 
506
  $widgetContent .= '<li>';
507
  $widgetContent .= "<span class='entry-content'>{$entryContent}</span>";
508
  $widgetContent .= " <span class='entry-meta'>";
512
  );
513
  $widgetContent .= $this->_buildLink( $tweet->ago, $linkAttrs );
514
  $widgetContent .= '</span>';
515
+
516
+ if ( 'true' != $args['hidefrom'] ) {
517
+ $from = sprintf( __( 'from %s', $this->_slug ), str_replace( '&', '&amp;', $tweet->source ) );
518
  $widgetContent .= " <span class='from-meta'>{$from}</span>";
519
+ }
520
  if ( !empty( $tweet->in_reply_to_screen_name ) ) {
521
  $rtLinkText = sprintf( __( 'in reply to %s', $this->_slug ), $tweet->in_reply_to_screen_name );
522
  $widgetContent .= ' <span class="in-reply-to-meta">';
527
  $widgetContent .= $this->_buildLink( $rtLinkText, $linkAttrs );
528
  $widgetContent .= '</span>';
529
  }
530
+ $widgetContent .= '</span>';
531
 
532
+ if ( 'true' == $args['showintents'] ) {
533
+ $widgetContent .= ' <span class="intent-meta">';
534
+
535
+ $linkText = __( 'Reply', $this->_slug );
536
+ $linkAttrs = array(
537
+ 'href' => "http://twitter.com/intent/tweet?in_reply_to={$tweet->id_str}",
538
+ 'class' => 'in-reply-to',
539
+ 'title' => $linkText,
540
+ );
541
+ $widgetContent .= $this->_buildLink( $linkText, $linkAttrs );
542
+
543
+ $linkText = __( 'Retweet', $this->_slug );
544
+ $linkAttrs = array(
545
+ 'href' => "http://twitter.com/intent/retweet?tweet_id={$tweet->id_str}",
546
+ 'class' => 'retweet',
547
+ 'title' => $linkText,
548
+ );
549
+ $widgetContent .= $this->_buildLink( $linkText, $linkAttrs );
550
+
551
+ $linkText = __( 'Favorite', $this->_slug );
552
+ $linkAttrs = array(
553
+ 'href' => "http://twitter.com/intent/favorite?tweet_id={$tweet->id_str}",
554
+ 'class' => 'favorite',
555
+ 'title' => $linkText,
556
+ );
557
+ $widgetContent .= $this->_buildLink( $linkText, $linkAttrs );
558
+ $widgetContent .= '</span>';
559
  }
560
+ $widgetContent .= '</li>';
561
+
562
+ if ( ++$count >= $args['items'] )
563
+ break;
564
  }
565
  }
566
 
567
+ $widgetContent .= '</ul>';
568
+ if ( 'true' == $args['showfollow'] ) {
569
+ $widgetContent .= '<div class="follow-button">';
570
+ $linkText = "@{$args['username']}";
571
+ $linkAttrs = array(
572
+ 'href' => "http://twitter.com/{$args['username']}",
573
+ 'class' => 'twitter-follow-button',
574
+ 'title' => sprintf( __( 'Follow %s', $this->_slug ), "@{$args['username']}" ),
575
+ );
576
+ $widgetContent .= $this->_buildLink( $linkText, $linkAttrs );
577
+ $widgetContent .= '</div>';
578
+ }
579
+
580
+ if ( 'true' == $args['showXavisysLink'] ) {
581
+ $widgetContent .= '<div class="xavisys-link"><span class="xavisys-link-text">';
582
  $linkAttrs = array(
583
  'href' => 'http://xavisys.com/wordpress-plugins/wordpress-twitter-widget/',
584
+ 'title' => __( 'Brought to you by Xavisys - A WordPress development company', $this->_slug )
585
  );
586
  $widgetContent .= __( 'Powered by', $this->_slug );
587
  $widgetContent .= $this->_buildLink( 'WordPress Twitter Widget Pro', $linkAttrs );
588
+ $widgetContent .= '</span></div>';
589
+ }
590
+ $widgetContent .= '</div>' . $args['after_widget'];
591
+
592
+ if ( 'true' == $args['showintents'] || 'true' == $args['showfollow'] ) {
593
+ wp_enqueue_script( 'twitter-widgets', 'http://platform.twitter.com/widgets.js', array(), '1.0.0', true );
594
+
595
+ if ( ! function_exists( '_wp_footer_scripts' ) ) {
596
+ // This means we can't just enqueue our script (fixes in WP 3.3)
597
+ add_action( 'wp_footer', array( $this, 'add_twitter_js' ) );
598
+ }
599
  }
 
600
  return $widgetContent;
601
  }
602
 
603
+ public function add_twitter_js() {
604
+ wp_print_scripts( 'twitter-widgets' );
605
+ }
606
+
607
  /**
608
  * Gets tweets, from cache if possible
609
  *
611
  * @return array - Array of objects
612
  */
613
  private function _getTweets( $widgetOptions ) {
614
+ $key = 'twp_' . md5( $this->_getFeedUrl( $widgetOptions ) );
615
+ return tlc_transient( $key )
616
+ ->expires_in( 300 ) // cache for 5 minutes
617
+ ->updates_with( array( $this, 'parseFeed' ), array( $widgetOptions ) )
618
+ ->get();
 
 
 
 
 
619
  }
620
 
621
  /**
624
  * @param array $widgetOptions - settings needed to get feed url, etc
625
  * @return array
626
  */
627
+ public function parseFeed( $widgetOptions ) {
628
  $feedUrl = $this->_getFeedUrl( $widgetOptions );
629
  $resp = wp_remote_request( $feedUrl, array( 'timeout' => $widgetOptions['fetchTimeOut'] ) );
630
 
631
  if ( !is_wp_error( $resp ) && $resp['response']['code'] >= 200 && $resp['response']['code'] < 300 ) {
632
  $decodedResponse = json_decode( $resp['body'] );
633
  if ( empty( $decodedResponse ) ) {
634
+ if ( empty( $widgetOptions['errmsg'] ) )
635
  $widgetOptions['errmsg'] = __( 'Invalid Twitter Response.', $this->_slug );
 
 
636
  } elseif( !empty( $decodedResponse->error ) ) {
637
+ if ( empty( $widgetOptions['errmsg'] ) )
638
  $widgetOptions['errmsg'] = $decodedResponse->error;
 
 
639
  } else {
640
  return $decodedResponse;
641
  }
642
  } else {
643
  // Failed to fetch url;
644
+ if ( empty( $widgetOptions['errmsg'] ) )
645
  $widgetOptions['errmsg'] = __( 'Could not connect to Twitter', $this->_slug );
 
 
646
  }
647
+ do_action( 'widget_twitter_parsefeed_error', $resp, $feedUrl, $widgetOptions );
648
+ throw new Exception( $widgetOptions['errmsg'] );
649
  }
650
 
651
  /**
657
  * @return string - Twitter feed URL
658
  */
659
  private function _getFeedUrl( $widgetOptions, $type = 'json', $count = true ) {
660
+ if ( !in_array( $type, array( 'rss', 'json' ) ) )
661
  $type = 'json';
662
+
663
  $req = $this->_api_url . "statuses/user_timeline.{$type}";
664
 
665
  /**
677
  */
678
 
679
  $req = add_query_arg( array( 'screen_name' => $widgetOptions['username'] ), $req );
680
+ if ( $count )
681
  $req = add_query_arg( array( 'count' => $widgetOptions['items'] ), $req );
682
+
683
+ if ( 'true' == $widgetOptions['hidereplies'] )
684
  $req = add_query_arg( array( 'exclude_replies' => 'true' ), $req );
685
+
686
+ if ( 'true' == $widgetOptions['showretweets'] )
687
  $req = add_query_arg( array( 'include_rts' => 'true' ), $req );
688
+
689
  return $req;
690
  }
691
 
713
 
714
  $since = time() - $startTimestamp;
715
 
716
+ if ( $max != '-1' && $since >= $max )
717
  return date_i18n( $dateFormat, $startTimestamp );
718
+
719
 
720
  foreach ( $chunks as $key => $seconds ) {
721
  // finding the biggest chunk ( if the chunk fits, break )
722
+ if ( ( $count = floor( $since / $seconds ) ) != 0 )
723
  break;
 
724
  }
725
 
726
  $messages = array(
727
+ 'year' => _n( 'about %s year ago', 'about %s years ago', $count, $this->_slug ),
728
+ 'month' => _n( 'about %s month ago', 'about %s months ago', $count, $this->_slug ),
729
+ 'week' => _n( 'about %s week ago', 'about %s weeks ago', $count, $this->_slug ),
730
+ 'day' => _n( 'about %s day ago', 'about %s days ago', $count, $this->_slug ),
731
+ 'hour' => _n( 'about %s hour ago', 'about %s hours ago', $count, $this->_slug ),
732
  'minute' => _n( 'about %s minute ago', 'about %s minutes ago', $count, $this->_slug ),
733
  'second' => _n( 'about %s second ago', 'about %s seconds ago', $count, $this->_slug ),
734
  );
772
  'errmsg' => '',
773
  'fetchTimeOut' => '2',
774
  'username' => '',
775
+ 'hidereplies' => 'false',
776
+ 'showretweets' => 'true',
777
+ 'hidefrom' => 'false',
778
+ 'showintents' => 'true',
779
+ 'showfollow' => 'true',
780
  'avatar' => '',
781
+ 'showXavisysLink' => 'false',
782
+ 'targetBlank' => 'false',
783
  'items' => 10,
784
  'showts' => 60 * 60 * 24,
785
  'dateFormat' => __( 'h:i:s A F d, Y', $this->_slug ),
806
  unset( $attr['dateformat'] );
807
  }
808
 
809
+ if ( !empty( $content ) && empty( $attr['title'] ) )
810
  $attr['title'] = $content;
811
+
812
 
813
  $attr = shortcode_atts( $defaults, $attr );
814
 
815
+ if ( $attr['hidereplies'] && $attr['hidereplies'] != 'false' && $attr['hidereplies'] != '0' )
816
+ $attr['hidereplies'] = 'true';
817
+
818
+ if ( $attr['showretweets'] && $attr['showretweets'] != 'false' && $attr['showretweets'] != '0' )
819
+ $attr['showretweets'] = 'true';
820
+
821
+ if ( $attr['hidefrom'] && $attr['hidefrom'] != 'false' && $attr['hidefrom'] != '0' )
822
+ $attr['hidefrom'] = 'true';
823
+
824
+ if ( $attr['showintents'] && $attr['showintents'] != 'true' && $attr['showintents'] != '1' )
825
+ $attr['showintents'] = 'false';
826
+
827
+ if ( $attr['showfollow'] && $attr['showfollow'] != 'true' && $attr['showfollow'] != '1' )
828
+ $attr['showfollow'] = 'false';
829
+
830
+ if ( !in_array( $attr['avatar'], array( 'bigger', 'normal', 'mini', 'original', '' ) ) )
831
  $attr['avatar'] = 'normal';
832
+
833
+ if ( $attr['showXavisysLink'] && $attr['showXavisysLink'] != 'false' && $attr['showXavisysLink'] != '0' )
834
+ $attr['showXavisysLink'] = 'true';
835
+
836
+ if ( $attr['targetBlank'] && $attr['targetBlank'] != 'false' && $attr['targetBlank'] != '0' )
837
+ $attr['targetBlank'] = 'true';
 
838
 
839
  return $this->display( $attr );
840
  }
845
  'errmsg' => '',
846
  'fetchTimeOut' => '2',
847
  'username' => '',
848
+ 'hidereplies' => 'false',
849
+ 'showretweets' => 'true',
850
+ 'hidefrom' => 'false',
851
+ 'showintents' => 'true',
852
+ 'showfollow' => 'true',
853
  'avatar' => '',
854
+ 'showXavisysLink' => 'false',
855
+ 'targetBlank' => 'false',
856
  'items' => 10,
857
  'showts' => 60 * 60 * 24,
858
  'dateFormat' => __( 'h:i:s A F d, Y', $this->_slug ),
866
  * the old true/false to a size string
867
  */
868
  private function fixAvatar( $settings ) {
869
+ if ( false === $settings['avatar'] )
870
  $settings['avatar'] = '';
871
+ elseif ( !in_array( $settings['avatar'], array( 'bigger', 'normal', 'mini', 'original', false ) ) )
872
  $settings['avatar'] = 'normal';
 
873
 
874
  return $settings;
875
  }