Twitter Widget Pro - Version 2.2.1

Version Description

Better SEO by adding the ability to remove the "from" links - Thanks Joost de Valk

=

Download this release

Release Info

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

Code changes from version 2.2.0 to 2.2.1

class-json.php DELETED
@@ -1,860 +0,0 @@
1
- <?php
2
- /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
- /**
4
- * Converts to and from JSON format.
5
- *
6
- * JSON (JavaScript Object Notation) is a lightweight data-interchange
7
- * format. It is easy for humans to read and write. It is easy for machines
8
- * to parse and generate. It is based on a subset of the JavaScript
9
- * Programming Language, Standard ECMA-262 3rd Edition - December 1999.
10
- * This feature can also be found in Python. JSON is a text format that is
11
- * completely language independent but uses conventions that are familiar
12
- * to programmers of the C-family of languages, including C, C++, C#, Java,
13
- * JavaScript, Perl, TCL, and many others. These properties make JSON an
14
- * ideal data-interchange language.
15
- *
16
- * This package provides a simple encoder and decoder for JSON notation. It
17
- * is intended for use with client-side Javascript applications that make
18
- * use of HTTPRequest to perform server communication functions - data can
19
- * be encoded into JSON notation for use in a client-side javascript, or
20
- * decoded from incoming Javascript requests. JSON format is native to
21
- * Javascript, and can be directly eval()'ed with no further parsing
22
- * overhead
23
- *
24
- * All strings should be in ASCII or UTF-8 format!
25
- *
26
- * LICENSE: Redistribution and use in source and binary forms, with or
27
- * without modification, are permitted provided that the following
28
- * conditions are met: Redistributions of source code must retain the
29
- * above copyright notice, this list of conditions and the following
30
- * disclaimer. Redistributions in binary form must reproduce the above
31
- * copyright notice, this list of conditions and the following disclaimer
32
- * in the documentation and/or other materials provided with the
33
- * distribution.
34
- *
35
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
36
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
37
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
38
- * NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
39
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
40
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
41
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
42
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
43
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
44
- * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
45
- * DAMAGE.
46
- *
47
- * @category
48
- * @package Services_JSON
49
- * @author Michal Migurski <mike-json@teczno.com>
50
- * @author Matt Knapp <mdknapp[at]gmail[dot]com>
51
- * @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
52
- * @copyright 2005 Michal Migurski
53
- * @version CVS: $Id: JSON.php,v 1.3 2009/05/22 23:51:00 alan_k Exp $
54
- * @license http://www.opensource.org/licenses/bsd-license.php
55
- * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
56
- */
57
-
58
- /**
59
- * Marker constant for Services_JSON::decode(), used to flag stack state
60
- */
61
- define('SERVICES_JSON_SLICE', 1);
62
-
63
- /**
64
- * Marker constant for Services_JSON::decode(), used to flag stack state
65
- */
66
- define('SERVICES_JSON_IN_STR', 2);
67
-
68
- /**
69
- * Marker constant for Services_JSON::decode(), used to flag stack state
70
- */
71
- define('SERVICES_JSON_IN_ARR', 3);
72
-
73
- /**
74
- * Marker constant for Services_JSON::decode(), used to flag stack state
75
- */
76
- define('SERVICES_JSON_IN_OBJ', 4);
77
-
78
- /**
79
- * Marker constant for Services_JSON::decode(), used to flag stack state
80
- */
81
- define('SERVICES_JSON_IN_CMT', 5);
82
-
83
- /**
84
- * Behavior switch for Services_JSON::decode()
85
- */
86
- define('SERVICES_JSON_LOOSE_TYPE', 16);
87
-
88
- /**
89
- * Behavior switch for Services_JSON::decode()
90
- */
91
- define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
92
-
93
- /**
94
- * Converts to and from JSON format.
95
- *
96
- * Brief example of use:
97
- *
98
- * <code>
99
- * // create a new instance of Services_JSON
100
- * $json = new Services_JSON();
101
- *
102
- * // convert a complexe value to JSON notation, and send it to the browser
103
- * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
104
- * $output = $json->encode($value);
105
- *
106
- * print($output);
107
- * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
108
- *
109
- * // accept incoming POST data, assumed to be in JSON notation
110
- * $input = file_get_contents('php://input', 1000000);
111
- * $value = $json->decode($input);
112
- * </code>
113
- */
114
- class Services_JSON
115
- {
116
- /**
117
- * constructs a new JSON instance
118
- *
119
- * @param int $use object behavior flags; combine with boolean-OR
120
- *
121
- * possible values:
122
- * - SERVICES_JSON_LOOSE_TYPE: loose typing.
123
- * "{...}" syntax creates associative arrays
124
- * instead of objects in decode().
125
- * - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
126
- * Values which can't be encoded (e.g. resources)
127
- * appear as NULL instead of throwing errors.
128
- * By default, a deeply-nested resource will
129
- * bubble up with an error, so all return values
130
- * from encode() should be checked with isError()
131
- */
132
- function Services_JSON($use = 0)
133
- {
134
- $this->use = $use;
135
- }
136
-
137
- /**
138
- * convert a string from one UTF-16 char to one UTF-8 char
139
- *
140
- * Normally should be handled by mb_convert_encoding, but
141
- * provides a slower PHP-only method for installations
142
- * that lack the multibye string extension.
143
- *
144
- * @param string $utf16 UTF-16 character
145
- * @return string UTF-8 character
146
- * @access private
147
- */
148
- function utf162utf8($utf16)
149
- {
150
- // oh please oh please oh please oh please oh please
151
- if(function_exists('mb_convert_encoding')) {
152
- return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
153
- }
154
-
155
- $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
156
-
157
- switch(true) {
158
- case ((0x7F & $bytes) == $bytes):
159
- // this case should never be reached, because we are in ASCII range
160
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
161
- return chr(0x7F & $bytes);
162
-
163
- case (0x07FF & $bytes) == $bytes:
164
- // return a 2-byte UTF-8 character
165
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
166
- return chr(0xC0 | (($bytes >> 6) & 0x1F))
167
- . chr(0x80 | ($bytes & 0x3F));
168
-
169
- case (0xFFFF & $bytes) == $bytes:
170
- // return a 3-byte UTF-8 character
171
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
172
- return chr(0xE0 | (($bytes >> 12) & 0x0F))
173
- . chr(0x80 | (($bytes >> 6) & 0x3F))
174
- . chr(0x80 | ($bytes & 0x3F));
175
- }
176
-
177
- // ignoring UTF-32 for now, sorry
178
- return '';
179
- }
180
-
181
- /**
182
- * convert a string from one UTF-8 char to one UTF-16 char
183
- *
184
- * Normally should be handled by mb_convert_encoding, but
185
- * provides a slower PHP-only method for installations
186
- * that lack the multibye string extension.
187
- *
188
- * @param string $utf8 UTF-8 character
189
- * @return string UTF-16 character
190
- * @access private
191
- */
192
- function utf82utf16($utf8)
193
- {
194
- // oh please oh please oh please oh please oh please
195
- if(function_exists('mb_convert_encoding')) {
196
- return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
197
- }
198
-
199
- switch(strlen($utf8)) {
200
- case 1:
201
- // this case should never be reached, because we are in ASCII range
202
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
203
- return $utf8;
204
-
205
- case 2:
206
- // return a UTF-16 character from a 2-byte UTF-8 char
207
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
208
- return chr(0x07 & (ord($utf8{0}) >> 2))
209
- . chr((0xC0 & (ord($utf8{0}) << 6))
210
- | (0x3F & ord($utf8{1})));
211
-
212
- case 3:
213
- // return a UTF-16 character from a 3-byte UTF-8 char
214
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
215
- return chr((0xF0 & (ord($utf8{0}) << 4))
216
- | (0x0F & (ord($utf8{1}) >> 2)))
217
- . chr((0xC0 & (ord($utf8{1}) << 6))
218
- | (0x7F & ord($utf8{2})));
219
- }
220
-
221
- // ignoring UTF-32 for now, sorry
222
- return '';
223
- }
224
-
225
- /**
226
- * encodes an arbitrary variable into JSON format (and sends JSON Header)
227
- *
228
- * @param mixed $var any number, boolean, string, array, or object to be encoded.
229
- * see argument 1 to Services_JSON() above for array-parsing behavior.
230
- * if var is a strng, note that encode() always expects it
231
- * to be in ASCII or UTF-8 format!
232
- *
233
- * @return mixed JSON string representation of input var or an error if a problem occurs
234
- * @access public
235
- */
236
- function encode($var)
237
- {
238
- header('Content-type: application/x-javascript');
239
- return $this->_encode($var);
240
- }
241
- /**
242
- * encodes an arbitrary variable into JSON format without JSON Header - warning - may allow CSS!!!!)
243
- *
244
- * @param mixed $var any number, boolean, string, array, or object to be encoded.
245
- * see argument 1 to Services_JSON() above for array-parsing behavior.
246
- * if var is a strng, note that encode() always expects it
247
- * to be in ASCII or UTF-8 format!
248
- *
249
- * @return mixed JSON string representation of input var or an error if a problem occurs
250
- * @access public
251
- */
252
- function encodeUnsafe($var)
253
- {
254
- return $this->_encode($var);
255
- }
256
- /**
257
- * PRIVATE CODE that does the work of encodes an arbitrary variable into JSON format
258
- *
259
- * @param mixed $var any number, boolean, string, array, or object to be encoded.
260
- * see argument 1 to Services_JSON() above for array-parsing behavior.
261
- * if var is a strng, note that encode() always expects it
262
- * to be in ASCII or UTF-8 format!
263
- *
264
- * @return mixed JSON string representation of input var or an error if a problem occurs
265
- * @access public
266
- */
267
- function _encode($var)
268
- {
269
-
270
- switch (gettype($var)) {
271
- case 'boolean':
272
- return $var ? 'true' : 'false';
273
-
274
- case 'NULL':
275
- return 'null';
276
-
277
- case 'integer':
278
- return (int) $var;
279
-
280
- case 'double':
281
- case 'float':
282
- return (float) $var;
283
-
284
- case 'string':
285
- // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
286
- $ascii = '';
287
- $strlen_var = strlen($var);
288
-
289
- /*
290
- * Iterate over every character in the string,
291
- * escaping with a slash or encoding to UTF-8 where necessary
292
- */
293
- for ($c = 0; $c < $strlen_var; ++$c) {
294
-
295
- $ord_var_c = ord($var{$c});
296
-
297
- switch (true) {
298
- case $ord_var_c == 0x08:
299
- $ascii .= '\b';
300
- break;
301
- case $ord_var_c == 0x09:
302
- $ascii .= '\t';
303
- break;
304
- case $ord_var_c == 0x0A:
305
- $ascii .= '\n';
306
- break;
307
- case $ord_var_c == 0x0C:
308
- $ascii .= '\f';
309
- break;
310
- case $ord_var_c == 0x0D:
311
- $ascii .= '\r';
312
- break;
313
-
314
- case $ord_var_c == 0x22:
315
- case $ord_var_c == 0x2F:
316
- case $ord_var_c == 0x5C:
317
- // double quote, slash, slosh
318
- $ascii .= '\\'.$var{$c};
319
- break;
320
-
321
- case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
322
- // characters U-00000000 - U-0000007F (same as ASCII)
323
- $ascii .= $var{$c};
324
- break;
325
-
326
- case (($ord_var_c & 0xE0) == 0xC0):
327
- // characters U-00000080 - U-000007FF, mask 110XXXXX
328
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
329
- if ($c+1 >= $strlen_var) {
330
- $c += 1;
331
- $ascii .= '?';
332
- break;
333
- }
334
-
335
- $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
336
- $c += 1;
337
- $utf16 = $this->utf82utf16($char);
338
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
339
- break;
340
-
341
- case (($ord_var_c & 0xF0) == 0xE0):
342
- if ($c+2 >= $strlen_var) {
343
- $c += 2;
344
- $ascii .= '?';
345
- break;
346
- }
347
- // characters U-00000800 - U-0000FFFF, mask 1110XXXX
348
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
349
- $char = pack('C*', $ord_var_c,
350
- @ord($var{$c + 1}),
351
- @ord($var{$c + 2}));
352
- $c += 2;
353
- $utf16 = $this->utf82utf16($char);
354
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
355
- break;
356
-
357
- case (($ord_var_c & 0xF8) == 0xF0):
358
- if ($c+3 >= $strlen_var) {
359
- $c += 3;
360
- $ascii .= '?';
361
- break;
362
- }
363
- // characters U-00010000 - U-001FFFFF, mask 11110XXX
364
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
365
- $char = pack('C*', $ord_var_c,
366
- ord($var{$c + 1}),
367
- ord($var{$c + 2}),
368
- ord($var{$c + 3}));
369
- $c += 3;
370
- $utf16 = $this->utf82utf16($char);
371
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
372
- break;
373
-
374
- case (($ord_var_c & 0xFC) == 0xF8):
375
- // characters U-00200000 - U-03FFFFFF, mask 111110XX
376
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
377
- if ($c+4 >= $strlen_var) {
378
- $c += 4;
379
- $ascii .= '?';
380
- break;
381
- }
382
- $char = pack('C*', $ord_var_c,
383
- ord($var{$c + 1}),
384
- ord($var{$c + 2}),
385
- ord($var{$c + 3}),
386
- ord($var{$c + 4}));
387
- $c += 4;
388
- $utf16 = $this->utf82utf16($char);
389
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
390
- break;
391
-
392
- case (($ord_var_c & 0xFE) == 0xFC):
393
- if ($c+5 >= $strlen_var) {
394
- $c += 5;
395
- $ascii .= '?';
396
- break;
397
- }
398
- // characters U-04000000 - U-7FFFFFFF, mask 1111110X
399
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
400
- $char = pack('C*', $ord_var_c,
401
- ord($var{$c + 1}),
402
- ord($var{$c + 2}),
403
- ord($var{$c + 3}),
404
- ord($var{$c + 4}),
405
- ord($var{$c + 5}));
406
- $c += 5;
407
- $utf16 = $this->utf82utf16($char);
408
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
409
- break;
410
- }
411
- }
412
- return '"'.$ascii.'"';
413
-
414
- case 'array':
415
- /*
416
- * As per JSON spec if any array key is not an integer
417
- * we must treat the the whole array as an object. We
418
- * also try to catch a sparsely populated associative
419
- * array with numeric keys here because some JS engines
420
- * will create an array with empty indexes up to
421
- * max_index which can cause memory issues and because
422
- * the keys, which may be relevant, will be remapped
423
- * otherwise.
424
- *
425
- * As per the ECMA and JSON specification an object may
426
- * have any string as a property. Unfortunately due to
427
- * a hole in the ECMA specification if the key is a
428
- * ECMA reserved word or starts with a digit the
429
- * parameter is only accessible using ECMAScript's
430
- * bracket notation.
431
- */
432
-
433
- // treat as a JSON object
434
- if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
435
- $properties = array_map(array($this, 'name_value'),
436
- array_keys($var),
437
- array_values($var));
438
-
439
- foreach($properties as $property) {
440
- if(Services_JSON::isError($property)) {
441
- return $property;
442
- }
443
- }
444
-
445
- return '{' . join(',', $properties) . '}';
446
- }
447
-
448
- // treat it like a regular array
449
- $elements = array_map(array($this, '_encode'), $var);
450
-
451
- foreach($elements as $element) {
452
- if(Services_JSON::isError($element)) {
453
- return $element;
454
- }
455
- }
456
-
457
- return '[' . join(',', $elements) . ']';
458
-
459
- case 'object':
460
- $vars = get_object_vars($var);
461
-
462
- $properties = array_map(array($this, 'name_value'),
463
- array_keys($vars),
464
- array_values($vars));
465
-
466
- foreach($properties as $property) {
467
- if(Services_JSON::isError($property)) {
468
- return $property;
469
- }
470
- }
471
-
472
- return '{' . join(',', $properties) . '}';
473
-
474
- default:
475
- return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
476
- ? 'null'
477
- : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
478
- }
479
- }
480
-
481
- /**
482
- * array-walking function for use in generating JSON-formatted name-value pairs
483
- *
484
- * @param string $name name of key to use
485
- * @param mixed $value reference to an array element to be encoded
486
- *
487
- * @return string JSON-formatted name-value pair, like '"name":value'
488
- * @access private
489
- */
490
- function name_value($name, $value)
491
- {
492
- $encoded_value = $this->_encode($value);
493
-
494
- if(Services_JSON::isError($encoded_value)) {
495
- return $encoded_value;
496
- }
497
-
498
- return $this->_encode(strval($name)) . ':' . $encoded_value;
499
- }
500
-
501
- /**
502
- * reduce a string by removing leading and trailing comments and whitespace
503
- *
504
- * @param $str string string value to strip of comments and whitespace
505
- *
506
- * @return string string value stripped of comments and whitespace
507
- * @access private
508
- */
509
- function reduce_string($str)
510
- {
511
- $str = preg_replace(array(
512
-
513
- // eliminate single line comments in '// ...' form
514
- '#^\s*//(.+)$#m',
515
-
516
- // eliminate multi-line comments in '/* ... */' form, at start of string
517
- '#^\s*/\*(.+)\*/#Us',
518
-
519
- // eliminate multi-line comments in '/* ... */' form, at end of string
520
- '#/\*(.+)\*/\s*$#Us'
521
-
522
- ), '', $str);
523
-
524
- // eliminate extraneous space
525
- return trim($str);
526
- }
527
-
528
- /**
529
- * decodes a JSON string into appropriate variable
530
- *
531
- * @param string $str JSON-formatted string
532
- *
533
- * @return mixed number, boolean, string, array, or object
534
- * corresponding to given JSON input string.
535
- * See argument 1 to Services_JSON() above for object-output behavior.
536
- * Note that decode() always returns strings
537
- * in ASCII or UTF-8 format!
538
- * @access public
539
- */
540
- function decode($str)
541
- {
542
- $str = $this->reduce_string($str);
543
-
544
- switch (strtolower($str)) {
545
- case 'true':
546
- return true;
547
-
548
- case 'false':
549
- return false;
550
-
551
- case 'null':
552
- return null;
553
-
554
- default:
555
- $m = array();
556
-
557
- if (is_numeric($str)) {
558
- // Lookie-loo, it's a number
559
-
560
- // This would work on its own, but I'm trying to be
561
- // good about returning integers where appropriate:
562
- // return (float)$str;
563
-
564
- // Return float or int, as appropriate
565
- return ((float)$str == (integer)$str)
566
- ? (integer)$str
567
- : (float)$str;
568
-
569
- } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
570
- // STRINGS RETURNED IN UTF-8 FORMAT
571
- $delim = substr($str, 0, 1);
572
- $chrs = substr($str, 1, -1);
573
- $utf8 = '';
574
- $strlen_chrs = strlen($chrs);
575
-
576
- for ($c = 0; $c < $strlen_chrs; ++$c) {
577
-
578
- $substr_chrs_c_2 = substr($chrs, $c, 2);
579
- $ord_chrs_c = ord($chrs{$c});
580
-
581
- switch (true) {
582
- case $substr_chrs_c_2 == '\b':
583
- $utf8 .= chr(0x08);
584
- ++$c;
585
- break;
586
- case $substr_chrs_c_2 == '\t':
587
- $utf8 .= chr(0x09);
588
- ++$c;
589
- break;
590
- case $substr_chrs_c_2 == '\n':
591
- $utf8 .= chr(0x0A);
592
- ++$c;
593
- break;
594
- case $substr_chrs_c_2 == '\f':
595
- $utf8 .= chr(0x0C);
596
- ++$c;
597
- break;
598
- case $substr_chrs_c_2 == '\r':
599
- $utf8 .= chr(0x0D);
600
- ++$c;
601
- break;
602
-
603
- case $substr_chrs_c_2 == '\\"':
604
- case $substr_chrs_c_2 == '\\\'':
605
- case $substr_chrs_c_2 == '\\\\':
606
- case $substr_chrs_c_2 == '\\/':
607
- if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
608
- ($delim == "'" && $substr_chrs_c_2 != '\\"')) {
609
- $utf8 .= $chrs{++$c};
610
- }
611
- break;
612
-
613
- case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
614
- // single, escaped unicode character
615
- $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
616
- . chr(hexdec(substr($chrs, ($c + 4), 2)));
617
- $utf8 .= $this->utf162utf8($utf16);
618
- $c += 5;
619
- break;
620
-
621
- case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
622
- $utf8 .= $chrs{$c};
623
- break;
624
-
625
- case ($ord_chrs_c & 0xE0) == 0xC0:
626
- // characters U-00000080 - U-000007FF, mask 110XXXXX
627
- //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
628
- $utf8 .= substr($chrs, $c, 2);
629
- ++$c;
630
- break;
631
-
632
- case ($ord_chrs_c & 0xF0) == 0xE0:
633
- // characters U-00000800 - U-0000FFFF, mask 1110XXXX
634
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
635
- $utf8 .= substr($chrs, $c, 3);
636
- $c += 2;
637
- break;
638
-
639
- case ($ord_chrs_c & 0xF8) == 0xF0:
640
- // characters U-00010000 - U-001FFFFF, mask 11110XXX
641
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
642
- $utf8 .= substr($chrs, $c, 4);
643
- $c += 3;
644
- break;
645
-
646
- case ($ord_chrs_c & 0xFC) == 0xF8:
647
- // characters U-00200000 - U-03FFFFFF, mask 111110XX
648
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
649
- $utf8 .= substr($chrs, $c, 5);
650
- $c += 4;
651
- break;
652
-
653
- case ($ord_chrs_c & 0xFE) == 0xFC:
654
- // characters U-04000000 - U-7FFFFFFF, mask 1111110X
655
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
656
- $utf8 .= substr($chrs, $c, 6);
657
- $c += 5;
658
- break;
659
-
660
- }
661
-
662
- }
663
-
664
- return $utf8;
665
-
666
- } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
667
- // array, or object notation
668
-
669
- if ($str{0} == '[') {
670
- $stk = array(SERVICES_JSON_IN_ARR);
671
- $arr = array();
672
- } else {
673
- if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
674
- $stk = array(SERVICES_JSON_IN_OBJ);
675
- $obj = array();
676
- } else {
677
- $stk = array(SERVICES_JSON_IN_OBJ);
678
- $obj = new stdClass();
679
- }
680
- }
681
-
682
- array_push($stk, array('what' => SERVICES_JSON_SLICE,
683
- 'where' => 0,
684
- 'delim' => false));
685
-
686
- $chrs = substr($str, 1, -1);
687
- $chrs = $this->reduce_string($chrs);
688
-
689
- if ($chrs == '') {
690
- if (reset($stk) == SERVICES_JSON_IN_ARR) {
691
- return $arr;
692
-
693
- } else {
694
- return $obj;
695
-
696
- }
697
- }
698
-
699
- //print("\nparsing {$chrs}\n");
700
-
701
- $strlen_chrs = strlen($chrs);
702
-
703
- for ($c = 0; $c <= $strlen_chrs; ++$c) {
704
-
705
- $top = end($stk);
706
- $substr_chrs_c_2 = substr($chrs, $c, 2);
707
-
708
- if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
709
- // found a comma that is not inside a string, array, etc.,
710
- // OR we've reached the end of the character list
711
- $slice = substr($chrs, $top['where'], ($c - $top['where']));
712
- array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
713
- //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
714
-
715
- if (reset($stk) == SERVICES_JSON_IN_ARR) {
716
- // we are in an array, so just push an element onto the stack
717
- array_push($arr, $this->decode($slice));
718
-
719
- } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
720
- // we are in an object, so figure
721
- // out the property name and set an
722
- // element in an associative array,
723
- // for now
724
- $parts = array();
725
-
726
- if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
727
- // "name":value pair
728
- $key = $this->decode($parts[1]);
729
- $val = $this->decode($parts[2]);
730
-
731
- if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
732
- $obj[$key] = $val;
733
- } else {
734
- $obj->$key = $val;
735
- }
736
- } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
737
- // name:value pair, where name is unquoted
738
- $key = $parts[1];
739
- $val = $this->decode($parts[2]);
740
-
741
- if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
742
- $obj[$key] = $val;
743
- } else {
744
- $obj->$key = $val;
745
- }
746
- }
747
-
748
- }
749
-
750
- } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
751
- // found a quote, and we are not inside a string
752
- array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
753
- //print("Found start of string at {$c}\n");
754
-
755
- } elseif (($chrs{$c} == $top['delim']) &&
756
- ($top['what'] == SERVICES_JSON_IN_STR) &&
757
- ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
758
- // found a quote, we're in a string, and it's not escaped
759
- // we know that it's not escaped becase there is _not_ an
760
- // odd number of backslashes at the end of the string so far
761
- array_pop($stk);
762
- //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
763
-
764
- } elseif (($chrs{$c} == '[') &&
765
- in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
766
- // found a left-bracket, and we are in an array, object, or slice
767
- array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
768
- //print("Found start of array at {$c}\n");
769
-
770
- } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
771
- // found a right-bracket, and we're in an array
772
- array_pop($stk);
773
- //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
774
-
775
- } elseif (($chrs{$c} == '{') &&
776
- in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
777
- // found a left-brace, and we are in an array, object, or slice
778
- array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
779
- //print("Found start of object at {$c}\n");
780
-
781
- } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
782
- // found a right-brace, and we're in an object
783
- array_pop($stk);
784
- //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
785
-
786
- } elseif (($substr_chrs_c_2 == '/*') &&
787
- in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
788
- // found a comment start, and we are in an array, object, or slice
789
- array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
790
- $c++;
791
- //print("Found start of comment at {$c}\n");
792
-
793
- } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
794
- // found a comment end, and we're in one now
795
- array_pop($stk);
796
- $c++;
797
-
798
- for ($i = $top['where']; $i <= $c; ++$i)
799
- $chrs = substr_replace($chrs, ' ', $i, 1);
800
-
801
- //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
802
-
803
- }
804
-
805
- }
806
-
807
- if (reset($stk) == SERVICES_JSON_IN_ARR) {
808
- return $arr;
809
-
810
- } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
811
- return $obj;
812
-
813
- }
814
-
815
- }
816
- }
817
- }
818
-
819
- /**
820
- * @todo Ultimately, this should just call PEAR::isError()
821
- */
822
- function isError($data, $code = null)
823
- {
824
- if (class_exists('pear')) {
825
- return PEAR::isError($data, $code);
826
- } elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
827
- is_subclass_of($data, 'services_json_error'))) {
828
- return true;
829
- }
830
-
831
- return false;
832
- }
833
- }
834
-
835
- if (class_exists('PEAR_Error')) {
836
-
837
- class Services_JSON_Error extends PEAR_Error
838
- {
839
- function Services_JSON_Error($message = 'unknown error', $code = null,
840
- $mode = null, $options = null, $userinfo = null)
841
- {
842
- parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
843
- }
844
- }
845
-
846
- } else {
847
-
848
- /**
849
- * @todo Ultimately, this class shall be descended from PEAR_Error
850
- */
851
- class Services_JSON_Error
852
- {
853
- function Services_JSON_Error($message = 'unknown error', $code = null,
854
- $mode = null, $options = null, $userinfo = null)
855
- {
856
-
857
- }
858
- }
859
-
860
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/twitter-widget-pro.pot CHANGED
@@ -1,280 +1,242 @@
1
- # Translation of the WordPress plugin by .
2
  # Copyright (C) 2010
3
  # This file is distributed under the same license as the package.
4
- # FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
5
- #
6
- #, fuzzy
7
  msgid ""
8
  msgstr ""
9
  "Project-Id-Version: \n"
10
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/twitter-widget-pro\n"
11
- "POT-Creation-Date: 2010-02-06 16:24+0000\n"
 
 
 
12
  "PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
- "MIME-Version: 1.0\n"
16
- "Content-Type: text/plain; charset=utf-8\n"
17
- "Content-Transfer-Encoding: 8bit\n"
18
- "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
19
 
20
- #: wp-twitter-widget.php:41
21
- msgid "Follow a Twitter Feed"
22
  msgstr ""
23
 
24
- #: wp-twitter-widget.php:48 wp-twitter-widget.php:171
25
- msgid "Twitter Widget Pro"
26
  msgstr ""
27
 
28
- #: wp-twitter-widget.php:63 wp-twitter-widget.php:215
29
- msgid "Twitter username:"
30
  msgstr ""
31
 
32
- #: wp-twitter-widget.php:64
33
- msgid "username"
34
  msgstr ""
35
 
36
- #: wp-twitter-widget.php:67 wp-twitter-widget.php:223
37
- msgid "Give the feed a title (optional):"
38
  msgstr ""
39
 
40
- #: wp-twitter-widget.php:68
41
- msgid "title"
42
  msgstr ""
43
 
44
- #: wp-twitter-widget.php:71 wp-twitter-widget.php:231
45
- msgid "How many items would you like to display?"
46
  msgstr ""
47
 
48
- #: wp-twitter-widget.php:82 wp-twitter-widget.php:289
49
- msgid "Hide @replies"
 
 
 
 
 
 
 
 
50
  msgstr ""
51
 
52
- #: wp-twitter-widget.php:85 wp-twitter-widget.php:245
53
- msgid "What to display when Twitter is down (optional):"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  msgstr ""
55
 
56
- #: wp-twitter-widget.php:86
57
- msgid "errmsg"
58
  msgstr ""
59
 
60
- #: wp-twitter-widget.php:89 wp-twitter-widget.php:253
61
- msgid "Number of seconds to wait for a response from Twitter (default 2):"
62
  msgstr ""
63
 
64
- #: wp-twitter-widget.php:90
65
- msgid "fetchTimeOut"
66
  msgstr ""
67
 
68
- #: wp-twitter-widget.php:93 wp-twitter-widget.php:261
69
- msgid "Show date/time of Tweet (rather than 2 ____ ago):"
70
  msgstr ""
71
 
72
- #: wp-twitter-widget.php:95 wp-twitter-widget.php:265
73
  msgid "Always"
74
  msgstr ""
75
 
76
- #: wp-twitter-widget.php:96 wp-twitter-widget.php:266
77
  msgid "If over an hour old"
78
  msgstr ""
79
 
80
- #: wp-twitter-widget.php:97 wp-twitter-widget.php:267
81
  msgid "If over a day old"
82
  msgstr ""
83
 
84
- #: wp-twitter-widget.php:98 wp-twitter-widget.php:268
85
  msgid "If over a week old"
86
  msgstr ""
87
 
88
- #: wp-twitter-widget.php:99 wp-twitter-widget.php:269
89
  msgid "If over a month old"
90
  msgstr ""
91
 
92
- #: wp-twitter-widget.php:100 wp-twitter-widget.php:270
93
  msgid "If over a year old"
94
  msgstr ""
95
 
96
- #: wp-twitter-widget.php:101 wp-twitter-widget.php:271
97
  msgid "Never"
98
  msgstr ""
99
 
100
- #: wp-twitter-widget.php:105 wp-twitter-widget.php:277
101
- #, php-format
102
  msgid ""
103
  "Format to dispaly the date in, uses <a href=\"%s\">PHP date()</a> format:"
104
  msgstr ""
105
 
106
- #: wp-twitter-widget.php:106
107
- msgid "dateFormat"
108
- msgstr ""
109
-
110
- #: wp-twitter-widget.php:110 wp-twitter-widget.php:292
111
  msgid "Hide RSS Icon and Link"
112
  msgstr ""
113
 
114
- #: wp-twitter-widget.php:114 wp-twitter-widget.php:295
115
  msgid "Open links in a new window"
116
  msgstr ""
117
 
118
- #: wp-twitter-widget.php:118 wp-twitter-widget.php:298
119
  msgid "Show Profile Image"
120
  msgstr ""
121
 
122
- #: wp-twitter-widget.php:122 wp-twitter-widget.php:301
123
  msgid "Show Link to Twitter Widget Pro"
124
  msgstr ""
125
 
126
- #: wp-twitter-widget.php:172
127
  msgid "Twitter Widget"
128
  msgstr ""
129
 
130
- #: wp-twitter-widget.php:207
131
  msgid "General Settings"
132
  msgstr ""
133
 
134
- #: wp-twitter-widget.php:218 wp-twitter-widget.php:226
135
- #: wp-twitter-widget.php:248 wp-twitter-widget.php:256
136
- #: wp-twitter-widget.php:280
137
- msgid "twp"
138
- msgstr ""
139
-
140
- #: wp-twitter-widget.php:285
141
  msgid "Other Setting:"
142
  msgstr ""
143
 
144
- #: wp-twitter-widget.php:472
145
  msgid "Syndicate this content"
146
  msgstr ""
147
 
148
- #: wp-twitter-widget.php:499
149
  msgid "No Tweets Available"
150
  msgstr ""
151
 
152
- #: wp-twitter-widget.php:507
153
- #, php-format
154
  msgid "from %s"
155
  msgstr ""
156
 
157
- #: wp-twitter-widget.php:519
158
- #, php-format
159
  msgid "in reply to %s"
160
  msgstr ""
161
 
162
- #: wp-twitter-widget.php:541
163
  msgid "Get Twitter Widget for your WordPress site"
164
  msgstr ""
165
 
166
- #: wp-twitter-widget.php:543
167
  msgid "Powered by"
168
  msgstr ""
169
 
170
- #: wp-twitter-widget.php:601
171
  msgid "Invalid Twitter Response."
172
  msgstr ""
173
 
174
- #: wp-twitter-widget.php:615
175
  msgid "Could not connect to Twitter"
176
  msgstr ""
177
 
178
- #: wp-twitter-widget.php:678
179
- #, php-format
180
  msgid "about %s year ago"
181
  msgid_plural "about %s years ago"
182
  msgstr[0] ""
183
  msgstr[1] ""
184
 
185
- #: wp-twitter-widget.php:679
186
- #, php-format
187
  msgid "about %s month ago"
188
  msgid_plural "about %s months ago"
189
  msgstr[0] ""
190
  msgstr[1] ""
191
 
192
- #: wp-twitter-widget.php:680
193
- #, php-format
194
  msgid "about %s week ago"
195
  msgid_plural "about %s weeks ago"
196
  msgstr[0] ""
197
  msgstr[1] ""
198
 
199
- #: wp-twitter-widget.php:681
200
- #, php-format
201
  msgid "about %s day ago"
202
  msgid_plural "about %s days ago"
203
  msgstr[0] ""
204
  msgstr[1] ""
205
 
206
- #: wp-twitter-widget.php:682
207
- #, php-format
208
  msgid "about %s hour ago"
209
  msgid_plural "about %s hours ago"
210
  msgstr[0] ""
211
  msgstr[1] ""
212
 
213
- #: wp-twitter-widget.php:683
214
- #, php-format
215
  msgid "about %s minute ago"
216
  msgid_plural "about %s minutes ago"
217
  msgstr[0] ""
218
  msgstr[1] ""
219
 
220
- #: wp-twitter-widget.php:684
221
- #, php-format
222
  msgid "about %s second ago"
223
  msgid_plural "about %s seconds ago"
224
  msgstr[0] ""
225
  msgstr[1] ""
226
 
227
- #: wp-twitter-widget.php:728 wp-twitter-widget.php:789
228
  msgid "h:i:s A F d, Y"
229
  msgstr ""
230
-
231
- #: xavisys-plugin-framework.php:199
232
- msgid "Update Options &raquo;"
233
- msgstr ""
234
-
235
- #: xavisys-plugin-framework.php:236
236
- msgid "Donate"
237
- msgstr ""
238
-
239
- #: xavisys-plugin-framework.php:243
240
- msgid "Support Forum"
241
- msgstr ""
242
-
243
- #: xavisys-plugin-framework.php:251
244
- msgid "Donate to show your appreciation."
245
- msgstr ""
246
-
247
- #: xavisys-plugin-framework.php:262
248
- msgid "Settings"
249
- msgstr ""
250
-
251
- #: xavisys-plugin-framework.php:279
252
- msgid "Like this Plugin?"
253
- msgstr ""
254
-
255
- #: xavisys-plugin-framework.php:280
256
- msgid "Need Support?"
257
- msgstr ""
258
-
259
- #: xavisys-plugin-framework.php:281
260
- msgid "Latest news from Xavisys"
261
- msgstr ""
262
-
263
- #: xavisys-plugin-framework.php:286
264
- msgid "Then please do any or all of the following:"
265
- msgstr ""
266
-
267
- #: xavisys-plugin-framework.php:291
268
- msgid "Link to it so others can find out about it."
269
- msgstr ""
270
-
271
- #: xavisys-plugin-framework.php:296
272
- msgid "Give it a good rating on WordPress.org."
273
- msgstr ""
274
-
275
- #: xavisys-plugin-framework.php:306
276
- #, php-format
277
- msgid ""
278
- "If you have any problems with this plugin or ideas for improvements or "
279
- "enhancements, please use the <a href=\"%s\">Xavisys Support Forums</a>."
280
- msgstr ""
 
1
  # Copyright (C) 2010
2
  # This file is distributed under the same license as the package.
 
 
 
3
  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"
11
  "PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
 
 
 
 
14
 
15
+ #: xavisys-plugin-framework.php:245
16
+ msgid "Update Options &raquo;"
17
  msgstr ""
18
 
19
+ #: xavisys-plugin-framework.php:292
20
+ msgid "Donate"
21
  msgstr ""
22
 
23
+ #: xavisys-plugin-framework.php:299
24
+ msgid "Support Forum"
25
  msgstr ""
26
 
27
+ #: xavisys-plugin-framework.php:307
28
+ msgid "Donate to show your appreciation."
29
  msgstr ""
30
 
31
+ #: xavisys-plugin-framework.php:318
32
+ msgid "Settings"
33
  msgstr ""
34
 
35
+ #: xavisys-plugin-framework.php:336
36
+ msgid "Like this Plugin?"
37
  msgstr ""
38
 
39
+ #: xavisys-plugin-framework.php:339
40
+ msgid "Need Support?"
41
  msgstr ""
42
 
43
+ #: xavisys-plugin-framework.php:342
44
+ msgid "Latest news from Xavisys"
45
+ msgstr ""
46
+
47
+ #: xavisys-plugin-framework.php:348
48
+ msgid "Then please do any or all of the following:"
49
+ msgstr ""
50
+
51
+ #: xavisys-plugin-framework.php:353
52
+ msgid "Link to it so others can find out about it."
53
  msgstr ""
54
 
55
+ #: xavisys-plugin-framework.php:358
56
+ msgid "Give it a good rating on WordPress.org."
57
+ msgstr ""
58
+
59
+ #: xavisys-plugin-framework.php:368
60
+ msgid ""
61
+ "If you have any problems with this plugin or ideas for improvements or "
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 ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: 2.8
6
- Tested up to: 2.9
7
- Stable tag: 2.2.0
8
 
9
  A widget that properly handles twitter feeds, including parsing @username, #hashtags, and URLs into links. Requires PHP5.
10
 
@@ -52,6 +52,7 @@ However, there are more things you can control.
52
  * errmsg - This is the error message that displays if there's a problem connecting to Twitter
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
  * avatar - set to true to display the avatar from the Twitter account (defaults to false)
56
  * targetBlank - set to true to have all links open in a new window (defaults to false)
57
  * 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)
@@ -78,8 +79,17 @@ Aparently the database queries required to display the friends feed was causing
78
  3. This is what the widget looks like in the default theme with no added styles.
79
  4. By using some (X)HTML in the title element and adding a few styles and a background image, you could make it look like this.
80
 
 
 
 
 
 
81
  == Changelog ==
82
 
 
 
 
 
83
  = 2.2.0 =
84
  * Now uses the Xavisys WordPress Plugin Framework - http://xavisys.com/xavisys-wordpress-plugin-framework/
85
  * Added an options page where you can set defaults that apply to widgets, shortcodes, and php calls (everything can be overridden)
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: 2.8
6
+ Tested up to: 3.2.1
7
+ Stable tag: 2.2.1
8
 
9
  A widget that properly handles twitter feeds, including parsing @username, #hashtags, and URLs into links. Requires PHP5.
10
 
52
  * errmsg - This is the error message that displays if there's a problem connecting to Twitter
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)
79
  3. This is what the widget looks like in the default theme with no added styles.
80
  4. By using some (X)HTML in the title element and adding a few styles and a background image, you could make it look like this.
81
 
82
+ == Upgrade Notice ==
83
+
84
+ = 2.2.1 =
85
+ Better SEO by adding the ability to remove the "from" links - Thanks <a href="http://yoast.com/">Joost de Valk</a>
86
+
87
  == Changelog ==
88
 
89
+ = 2.2.1 =
90
+ * Add missing space between "from" and "in reply to"
91
+ * Add the ability to remove the "from" links from displaying - Thanks to <a href="http://yoast.com/">Joost de Valk</a> for the request and the patch!
92
+
93
  = 2.2.0 =
94
  * Now uses the Xavisys WordPress Plugin Framework - http://xavisys.com/xavisys-wordpress-plugin-framework/
95
  * Added an options page where you can set defaults that apply to widgets, shortcodes, and php calls (everything can be overridden)
wp-twitter-widget.php CHANGED
@@ -3,19 +3,20 @@
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.0
7
  * Author: Aaron D. Campbell
8
  * Author URI: http://xavisys.com/
 
9
  * Text Domain: twitter-widget-pro
10
  */
11
 
12
  /*
13
- Copyright 2006-current Aaron D. Campbell (email : wp_plugins@xavisys.com)
14
 
15
  This program is free software; you can redistribute it and/or modify
16
  it under the terms of the GNU General Public License as published by
17
  the Free Software Foundation; either version 2 of the License, or
18
- (at your option) any later version.
19
 
20
  This program is distributed in the hope that it will be useful,
21
  but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -27,7 +28,7 @@
27
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28
  */
29
 
30
- require_once('xavisys-plugin-framework.php');
31
  class wpTwitterWidgetException extends Exception {}
32
 
33
  /**
@@ -47,7 +48,7 @@ class WP_Widget_Twitter_Pro extends WP_Widget {
47
  );
48
  $name = __( 'Twitter Widget Pro', $wpTwitterWidget->get_slug() );
49
 
50
- $this->WP_Widget('twitter', $name, $widget_ops, $control_ops);
51
  }
52
 
53
  private function _getInstanceSettings ( $instance ) {
@@ -60,66 +61,70 @@ class WP_Widget_Twitter_Pro extends WP_Widget {
60
  $wpTwitterWidget = wpTwitterWidget::getInstance();
61
  ?>
62
  <p>
63
- <label for="<?php echo $this->get_field_id('username'); ?>"><?php _e('Twitter username:', $this->_slug); ?></label>
64
- <input class="widefat" id="<?php echo $this->get_field_id('username'); ?>" name="<?php echo $this->get_field_name('username'); ?>" type="text" value="<?php esc_attr_e($instance['username']); ?>" />
65
  </p>
66
  <p>
67
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Give the feed a title (optional):', $this->_slug); ?></label>
68
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php esc_attr_e($instance['title']); ?>" />
69
  </p>
70
  <p>
71
- <label for="<?php echo $this->get_field_id('items'); ?>"><?php _e('How many items would you like to display?', $this->_slug); ?></label>
72
- <select id="<?php echo $this->get_field_id('items'); ?>" name="<?php echo $this->get_field_name('items'); ?>">
73
  <?php
74
  for ( $i = 1; $i <= 20; ++$i ) {
75
- echo "<option value='$i' ". selected($instance['items'], $i, false). ">$i</option>";
76
  }
77
  ?>
78
  </select>
79
  </p>
80
  <p>
81
- <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id('hidereplies'); ?>" name="<?php echo $this->get_field_name('hidereplies'); ?>"<?php checked($instance['hidereplies'], 'true'); ?> />
82
- <label for="<?php echo $this->get_field_id('hidereplies'); ?>"><?php _e('Hide @replies', $this->_slug); ?></label>
83
  </p>
84
  <p>
85
- <label for="<?php echo $this->get_field_id('errmsg'); ?>"><?php _e('What to display when Twitter is down (optional):', $this->_slug); ?></label>
86
- <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']); ?>" />
87
  </p>
88
  <p>
89
- <label for="<?php echo $this->get_field_id('fetchTimeOut'); ?>"><?php _e('Number of seconds to wait for a response from Twitter (default 2):', $this->_slug); ?></label>
90
- <input class="widefat" id="<?php echo $this->get_field_id('fetchTimeOut'); ?>" name="<?php echo $this->get_field_name('fetchTimeOut'); ?>" type="text" value="<?php esc_attr_e($instance['fetchTimeOut']); ?>" />
91
  </p>
92
  <p>
93
- <label for="<?php echo $this->get_field_id('showts'); ?>"><?php _e('Show date/time of Tweet (rather than 2 ____ ago):', $this->_slug); ?></label>
94
- <select id="<?php echo $this->get_field_id('showts'); ?>" name="<?php echo $this->get_field_name('showts'); ?>">
95
- <option value="0" <?php selected($instance['showts'], '0'); ?>><?php _e('Always', $this->_slug);?></option>
96
- <option value="3600" <?php selected($instance['showts'], '3600'); ?>><?php _e('If over an hour old', $this->_slug);?></option>
97
- <option value="86400" <?php selected($instance['showts'], '86400'); ?>><?php _e('If over a day old', $this->_slug);?></option>
98
- <option value="604800" <?php selected($instance['showts'], '604800'); ?>><?php _e('If over a week old', $this->_slug);?></option>
99
- <option value="2592000" <?php selected($instance['showts'], '2592000'); ?>><?php _e('If over a month old', $this->_slug);?></option>
100
- <option value="31536000" <?php selected($instance['showts'], '31536000'); ?>><?php _e('If over a year old', $this->_slug);?></option>
101
- <option value="-1" <?php selected($instance['showts'], '-1'); ?>><?php _e('Never', $this->_slug);?></option>
 
 
 
 
102
  </select>
103
  </p>
104
  <p>
105
- <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>
106
- <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']); ?>" />
107
  </p>
108
  <p>
109
- <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'); ?> />
110
- <label for="<?php echo $this->get_field_id('hiderss'); ?>"><?php _e('Hide RSS Icon and Link', $this->_slug); ?></label>
111
  </p>
112
  <p>
113
- <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'); ?> />
114
- <label for="<?php echo $this->get_field_id('targetBlank'); ?>"><?php _e('Open links in a new window', $this->_slug); ?></label>
115
  </p>
116
  <p>
117
- <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id('avatar'); ?>" name="<?php echo $this->get_field_name('avatar'); ?>"<?php checked($instance['avatar'], 'true'); ?> />
118
- <label for="<?php echo $this->get_field_id('avatar'); ?>"><?php _e('Show Profile Image', $this->_slug); ?></label>
119
  </p>
120
  <p>
121
- <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id('showXavisysLink'); ?>" name="<?php echo $this->get_field_name('showXavisysLink'); ?>"<?php checked($instance['showXavisysLink'], 'true'); ?> />
122
- <label for="<?php echo $this->get_field_id('showXavisysLink'); ?>"><?php _e('Show Link to Twitter Widget Pro', $this->_slug); ?></label>
123
  </p>
124
  <p><?php echo $wpTwitterWidget->getSupportForumLink(); ?></p>
125
  <?php
@@ -130,20 +135,20 @@ class WP_Widget_Twitter_Pro extends WP_Widget {
130
  $instance = $this->_getInstanceSettings( $new_instance );
131
 
132
  // Clean up the free-form areas
133
- $instance['title'] = stripslashes($new_instance['title']);
134
- $instance['errmsg'] = stripslashes($new_instance['errmsg']);
135
 
136
  // If the current user isn't allowed to use unfiltered HTML, filter it
137
- if ( !current_user_can('unfiltered_html') ) {
138
- $instance['title'] = strip_tags($new_instance['title']);
139
- $instance['errmsg'] = strip_tags($new_instance['errmsg']);
140
  }
141
 
142
  return $instance;
143
  }
144
 
145
  public function flush_widget_cache() {
146
- wp_cache_delete('widget_twitter_widget_pro', 'widget');
147
  }
148
 
149
  public function widget( $args, $instance ) {
@@ -172,7 +177,7 @@ class wpTwitterWidget extends XavisysPlugin {
172
  $this->_menuTitle = __( 'Twitter Widget', $this->_slug );
173
  $this->_accessLevel = 'manage_options';
174
  $this->_optionGroup = 'twp-options';
175
- $this->_optionNames = array('twp');
176
  $this->_optionCallbacks = array();
177
  $this->_slug = 'twitter-widget-pro';
178
  $this->_paypalButtonId = '9993090';
@@ -204,7 +209,7 @@ class wpTwitterWidget extends XavisysPlugin {
204
  }
205
 
206
  public function addOptionsMetaBoxes() {
207
- add_meta_box( $this->_slug . '-general-settings', __('General Settings', $this->_slug), array($this, 'generalSettingsMetaBox'), 'xavisys-' . $this->_slug, 'main');
208
  }
209
 
210
  public function generalSettingsMetaBox() {
@@ -212,29 +217,29 @@ class wpTwitterWidget extends XavisysPlugin {
212
  <table class="form-table">
213
  <tr valign="top">
214
  <th scope="row">
215
- <label for="twp_username"><?php _e('Twitter username:', $this->_slug); ?></label>
216
  </th>
217
  <td>
218
- <input id="twp_username" name="twp[username]" type="text" class="regular-text code" value="<?php esc_attr_e($this->_settings['twp']['username']); ?>" size="40" />
219
  </td>
220
  </tr>
221
  <tr valign="top">
222
  <th scope="row">
223
- <label for="twp_title"><?php _e('Give the feed a title (optional):', $this->_slug); ?></label>
224
  </th>
225
  <td>
226
- <input id="twp_title" name="twp[title]" type="text" class="regular-text code" value="<?php esc_attr_e($this->_settings['twp']['title']); ?>" size="40" />
227
  </td>
228
  </tr>
229
  <tr valign="top">
230
  <th scope="row">
231
- <label for="twp_items"><?php _e('How many items would you like to display?', $this->_slug); ?></label>
232
  </th>
233
  <td>
234
  <select id="twp_items" name="twp[items]">
235
  <?php
236
  for ( $i = 1; $i <= 20; ++$i ) {
237
- echo "<option value='$i' ". selected($this->_settings['twp']['items'], $i, false). ">$i</option>";
238
  }
239
  ?>
240
  </select>
@@ -242,100 +247,89 @@ class wpTwitterWidget extends XavisysPlugin {
242
  </tr>
243
  <tr valign="top">
244
  <th scope="row">
245
- <label for="twp_errmsg"><?php _e('What to display when Twitter is down (optional):', $this->_slug); ?></label>
246
  </th>
247
  <td>
248
- <input id="twp_errmsg" name="twp[errmsg]" type="text" class="regular-text code" value="<?php esc_attr_e($this->_settings['twp']['errmsg']); ?>" size="40" />
249
  </td>
250
  </tr>
251
  <tr valign="top">
252
  <th scope="row">
253
- <label for="twp_fetchTimeOut"><?php _e('Number of seconds to wait for a response from Twitter (default 2):', $this->_slug); ?></label>
254
  </th>
255
  <td>
256
- <input id="twp_fetchTimeOut" name="twp[fetchTimeOut]" type="text" class="regular-text code" value="<?php esc_attr_e($this->_settings['twp']['fetchTimeOut']); ?>" size="40" />
257
  </td>
258
  </tr>
259
  <tr valign="top">
260
  <th scope="row">
261
- <label for="twp_showts"><?php _e('Show date/time of Tweet (rather than 2 ____ ago):', $this->_slug); ?></label>
262
  </th>
263
  <td>
264
  <select id="twp_showts" name="twp[showts]">
265
- <option value="0" <?php selected($this->_settings['twp']['showts'], '0'); ?>><?php _e('Always', $this->_slug);?></option>
266
- <option value="3600" <?php selected($this->_settings['twp']['showts'], '3600'); ?>><?php _e('If over an hour old', $this->_slug);?></option>
267
- <option value="86400" <?php selected($this->_settings['twp']['showts'], '86400'); ?>><?php _e('If over a day old', $this->_slug);?></option>
268
- <option value="604800" <?php selected($this->_settings['twp']['showts'], '604800'); ?>><?php _e('If over a week old', $this->_slug);?></option>
269
- <option value="2592000" <?php selected($this->_settings['twp']['showts'], '2592000'); ?>><?php _e('If over a month old', $this->_slug);?></option>
270
- <option value="31536000" <?php selected($this->_settings['twp']['showts'], '31536000'); ?>><?php _e('If over a year old', $this->_slug);?></option>
271
- <option value="-1" <?php selected($this->_settings['twp']['showts'], '-1'); ?>><?php _e('Never', $this->_slug);?></option>
272
  </select>
273
  </td>
274
  </tr>
275
  <tr valign="top">
276
  <th scope="row">
277
- <label for="twp_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>
278
  </th>
279
  <td>
280
- <input id="twp_dateFormat" name="twp[dateFormat]" type="text" class="regular-text code" value="<?php esc_attr_e($this->_settings['twp']['dateFormat']); ?>" size="40" />
281
  </td>
282
  </tr>
283
  <tr valign="top">
284
  <th scope="row">
285
- <?php _e("Other Setting:", $this->_slug);?>
286
  </th>
287
  <td>
288
- <input class="checkbox" type="checkbox" value="true" id="twp_hidereplies" name="twp[hidereplies]"<?php checked($this->_settings['twp']['hidereplies'], 'true'); ?> />
289
- <label for="twp_hidereplies"><?php _e('Hide @replies', $this->_slug); ?></label>
 
 
 
290
  <br />
291
- <input class="checkbox" type="checkbox" value="true" id="twp_hiderss" name="twp[hiderss]"<?php checked($this->_settings['twp']['hiderss'], 'true'); ?> />
292
- <label for="twp_hiderss"><?php _e('Hide RSS Icon and Link', $this->_slug); ?></label>
293
  <br />
294
- <input class="checkbox" type="checkbox" value="true" id="twp_targetBlank" name="twp[targetBlank]"<?php checked($this->_settings['twp']['targetBlank'], 'true'); ?> />
295
- <label for="twp_targetBlank"><?php _e('Open links in a new window', $this->_slug); ?></label>
296
  <br />
297
- <input class="checkbox" type="checkbox" value="true" id="twp_avatar" name="twp[avatar]"<?php checked($this->_settings['twp']['avatar'], 'true'); ?> />
298
- <label for="twp_avatar"><?php _e('Show Profile Image', $this->_slug); ?></label>
299
  <br />
300
- <input class="checkbox" type="checkbox" value="true" id="twp_showXavisysLink" name="twp[showXavisysLink]"<?php checked($this->_settings['twp']['showXavisysLink'], 'true'); ?> />
301
- <label for="twp_showXavisysLink"><?php _e('Show Link to Twitter Widget Pro', $this->_slug); ?></label>
302
  </td>
303
  </tr>
304
  </table>
305
  <?php
306
  }
307
 
308
- /**
309
- * Returns the user's screen name as a link inside strong tags.
310
- *
311
- * @param object $user - Twitter user
312
- * @return string - Username as link (XHTML)
313
- */
314
- private function _getUserName($user) {
315
- $attrs = array(
316
- 'href' => "http://twitter.com/{$user->screen_name}",
317
- 'title' => $user->name
318
- );
319
- return '<strong>' . $this->_buildLink($user->screen_name, $attrs) . '</strong>';
320
- }
321
-
322
  /**
323
  * Replace @username with a link to that twitter user
324
  *
325
  * @param string $text - Tweet text
326
  * @return string - Tweet text with @replies linked
327
  */
328
- public function linkTwitterUsers($text) {
329
  $text = preg_replace_callback('/(^|\s)@(\w+)/i', array($this, '_linkTwitterUsersCallback'), $text);
330
  return $text;
331
  }
332
 
333
- private function _linkTwitterUsersCallback($matches) {
334
  $linkAttrs = array(
335
- 'href' => 'http://twitter.com/' . urlencode($matches[2]),
336
  'class' => 'twitter-user'
337
  );
338
- return $matches[1] . $this->_buildLink('@'.$matches[2], $linkAttrs);
339
  }
340
 
341
  /**
@@ -344,7 +338,7 @@ class wpTwitterWidget extends XavisysPlugin {
344
  * @param string $text - Tweet text
345
  * @return string - Tweet text with #hashtags linked
346
  */
347
- public function linkHashtags($text) {
348
  $text = preg_replace_callback('/(^|\s)(#\w*)/i', array($this, '_hashtagLink'), $text);
349
  return $text;
350
  }
@@ -355,12 +349,12 @@ class wpTwitterWidget extends XavisysPlugin {
355
  * @param array $matches - Tweet text
356
  * @return string - Tweet text with #hashtags linked
357
  */
358
- private function _hashtagLink($matches) {
359
  $linkAttrs = array(
360
- 'href' => 'http://search.twitter.com/search?q=' . urlencode($matches[2]),
361
  'class' => 'twitter-hashtag'
362
  );
363
- return $matches[1] . $this->_buildLink($matches[2], $linkAttrs);
364
  }
365
 
366
  /**
@@ -369,7 +363,7 @@ class wpTwitterWidget extends XavisysPlugin {
369
  * @param string $text - Tweet text
370
  * @return string - Tweet text with URLs repalced with links
371
  */
372
- public function linkUrls($text) {
373
  /**
374
  * match protocol://address/path/file.extension?some=variable&another=asf%
375
  * $1 is a possible space, this keeps us from linking href="[link]" etc
@@ -393,44 +387,44 @@ class wpTwitterWidget extends XavisysPlugin {
393
  return $text;
394
  }
395
 
396
- private function _linkUrlsCallback ($matches) {
397
  $linkAttrs = array(
398
  'href' => $matches[2]
399
  );
400
- return $matches[1] . $this->_buildLink($matches[2], $linkAttrs);
401
  }
402
 
403
  private function _notEmpty( $v ) {
404
- return !(empty($v));
405
  }
406
 
407
  private function _buildLink( $text, $attributes = array(), $noFilter = false ) {
408
- $attributes = array_filter( wp_parse_args( $attributes ), array($this, '_notEmpty' ) );
409
  $attributes = apply_filters( 'widget_twitter_link_attributes', $attributes );
410
  $attributes = wp_parse_args( $attributes );
411
- if ( strtolower( 'www' == substr($attributes['href'], 0, 3) ) ) {
412
  $attributes['href'] = 'http://' . $attributes['href'];
413
  }
414
  $text = apply_filters( 'widget_twitter_link_text', $text );
415
  $link = '<a';
416
  foreach ( $attributes as $name => $value ) {
417
- $link .= ' ' . esc_attr($name) . '="' . esc_attr($value) . '"';
418
  }
419
  $link .= '>';
420
  if ( $noFilter ) {
421
  $link .= $text;
422
  } else {
423
- $link .= esc_html($text);
424
  }
425
  $link .= '</a>';
426
  return $link;
427
  }
428
 
429
  public function register() {
430
- register_widget('WP_Widget_Twitter_Pro');
431
  }
432
 
433
- public function targetBlank($attributes) {
434
  $attributes['target'] = '_blank';
435
  return $attributes;
436
  }
@@ -439,7 +433,7 @@ class wpTwitterWidget extends XavisysPlugin {
439
  $args = wp_parse_args( $args );
440
 
441
  if ( $args['targetBlank'] ) {
442
- add_filter('widget_twitter_link_attributes', array($this, 'targetBlank'));
443
  }
444
 
445
  // Validate our options
@@ -447,13 +441,13 @@ class wpTwitterWidget extends XavisysPlugin {
447
  if ( $args['items'] < 1 || 20 < $args['items'] ) {
448
  $args['items'] = 10;
449
  }
450
- if (!isset($args['showts'])) {
451
  $args['showts'] = 86400;
452
  }
453
 
454
  try {
455
- $tweets = $this->_getTweets($args);
456
- } catch (wpTwitterWidgetException $e) {
457
  $tweets = $e;
458
  }
459
 
@@ -461,23 +455,23 @@ class wpTwitterWidget extends XavisysPlugin {
461
 
462
  // If "hide rss" hasn't been checked, show the linked icon
463
  if ( $args['hiderss'] != 'true' ) {
464
- if ( file_exists(dirname(__FILE__) . '/rss.png') ) {
465
- $icon = str_replace(ABSPATH, get_option('siteurl').'/', dirname(__FILE__)) . '/rss.png';
466
  } else {
467
- $icon = get_option('siteurl').'/wp-includes/images/rss.png';
468
  }
469
- $feedUrl = $this->_getFeedUrl($args, 'rss', false);
470
  $linkAttrs = array(
471
  'class' => 'twitterwidget twitterwidget-rss',
472
- 'title' => __('Syndicate this content', $this->_slug),
473
  'href' => $feedUrl
474
  );
475
 
476
- $args['before_title'] .= $this->_buildLink("<img style='background:orange;color:white;border:none;' width='14' height='14' src='{$icon}' alt='RSS' />", $linkAttrs, true);
477
  }
478
  $twitterLink = 'http://twitter.com/' . $args['username'];
479
 
480
- if (empty($args['title'])) {
481
  $args['title'] = "Twitter: {$args['username']}";
482
  }
483
  $linkAttrs = array(
@@ -485,26 +479,26 @@ class wpTwitterWidget extends XavisysPlugin {
485
  'title' => "Twitter: {$args['username']}",
486
  'href' => $twitterLink
487
  );
488
- $args['title'] = $this->_buildLink($args['title'], $linkAttrs, current_user_can('unfiltered_html'));
489
  $widgetContent .= $args['before_title'] . $args['title'] . $args['after_title'];
490
- if (!is_a($tweets, 'wpTwitterWidgetException') && !empty($tweets[0]) && $args['avatar'] == 'true') {
491
  $widgetContent .= '<div class="twitter-avatar">';
492
- $widgetContent .= $this->_getProfileImage($tweets[0]->user);
493
  $widgetContent .= '</div>';
494
  }
495
  $widgetContent .= '<ul>';
496
- if (is_a($tweets, 'wpTwitterWidgetException')) {
497
  $widgetContent .= '<li class="wpTwitterWidgetError">' . $tweets->getMessage() . '</li>';
498
- } else if (count($tweets) == 0) {
499
- $widgetContent .= '<li class="wpTwitterWidgetEmpty">' . __('No Tweets Available', $this->_slug) . '</li>';
500
  } else {
501
  $count = 0;
502
- foreach ($tweets as $tweet) {
503
- if ( $args['hidereplies'] != 'true' || empty($tweet->in_reply_to_user_id)) {
504
  // Set our "ago" string which converts the date to "# ___(s) ago"
505
- $tweet->ago = $this->_timeSince(strtotime($tweet->created_at), $args['showts'], $args['dateFormat']);
506
  $entryContent = apply_filters( 'widget_twitter_content', $tweet->text );
507
- $from = sprintf(__('from %s', $this->_slug), str_replace('&', '&amp;', $tweet->source));
508
  $widgetContent .= '<li>';
509
  $widgetContent .= "<span class='entry-content'>{$entryContent}</span>";
510
  $widgetContent .= " <span class='entry-meta'>";
@@ -512,22 +506,23 @@ class wpTwitterWidget extends XavisysPlugin {
512
  $linkAttrs = array(
513
  'href' => "http://twitter.com/{$tweet->user->screen_name}/statuses/{$tweet->id}"
514
  );
515
- $widgetContent .= $this->_buildLink($tweet->ago, $linkAttrs);
516
  $widgetContent .= '</span>';
517
- $widgetContent .= " <span class='from-meta'>{$from}</span>";
518
- if ( !empty($tweet->in_reply_to_screen_name) ) {
519
- $rtLinkText = sprintf( __('in reply to %s', $this->_slug), $tweet->in_reply_to_screen_name );
520
- $widgetContent .= '<span class="in-reply-to-meta">';
 
521
  $linkAttrs = array(
522
  'href' => "http://twitter.com/{$tweet->in_reply_to_screen_name}/statuses/{$tweet->in_reply_to_status_id}",
523
  'class' => 'reply-to'
524
  );
525
- $widgetContent .= $this->_buildLink($rtLinkText, $linkAttrs);
526
  $widgetContent .= '</span>';
527
  }
528
  $widgetContent .= '</span></li>';
529
 
530
- if (++$count >= $args['items']) {
531
  break;
532
  }
533
  }
@@ -538,10 +533,10 @@ class wpTwitterWidget extends XavisysPlugin {
538
  $widgetContent .= '<li class="xavisys-link"><span class="xavisys-link-text">';
539
  $linkAttrs = array(
540
  'href' => 'http://xavisys.com/wordpress-plugins/wordpress-twitter-widget/',
541
- 'title' => __('Get Twitter Widget for your WordPress site', $this->_slug)
542
  );
543
- $widgetContent .= __('Powered by', $this->_slug);
544
- $widgetContent .= $this->_buildLink('WordPress Twitter Widget Pro', $linkAttrs);
545
  $widgetContent .= '</span></li>';
546
  }
547
  $widgetContent .= '</ul></div>' . $args['after_widget'];
@@ -554,17 +549,13 @@ class wpTwitterWidget extends XavisysPlugin {
554
  * @param array $widgetOptions - options needed to get feeds
555
  * @return array - Array of objects
556
  */
557
- private function _getTweets($widgetOptions) {
558
- $feedHash = sha1($this->_getFeedUrl($widgetOptions));
559
- $tweets = get_option("wptw-{$feedHash}");
560
- $cacheAge = get_option("wptw-{$feedHash}-time");
561
- //If we don't have cache or it's more than 5 minutes old
562
- if ( empty($tweets) || (time() - $cacheAge) > 300 ) {
563
  try {
564
- $tweets = $this->_parseFeed($widgetOptions);
565
- update_option("wptw-{$feedHash}", $tweets);
566
- update_option("wptw-{$feedHash}-time", time());
567
- } catch (wpTwitterWidgetException $e) {
568
  throw $e;
569
  }
570
  }
@@ -577,44 +568,31 @@ class wpTwitterWidget extends XavisysPlugin {
577
  * @param array $widgetOptions - settings needed to get feed url, etc
578
  * @return array
579
  */
580
- private function _parseFeed($widgetOptions) {
581
- $feedUrl = $this->_getFeedUrl($widgetOptions);
582
- $resp = wp_remote_request($feedUrl, array('timeout' => $widgetOptions['fetchTimeOut']));
583
-
584
- if ( !is_wp_error($resp) && $resp['response']['code'] >= 200 && $resp['response']['code'] < 300 ) {
585
- if (function_exists('json_decode')) {
586
- $decodedResponse = json_decode( $resp['body'] );
587
- } else {
588
- if ( !class_exists('Services_JSON') ) {
589
- require_once( 'class-json.php' );
590
- }
591
-
592
- global $wp_json;
593
- if ( !is_a($wp_json, 'Services_JSON') ) {
594
- $wp_json = new Services_JSON();
595
  }
596
-
597
- $decodedResponse = $wp_json->decode( $resp['body'] );
598
- }
599
- if ( empty($decodedResponse) ) {
600
- if (empty($widgetOptions['errmsg'])) {
601
- $widgetOptions['errmsg'] = __('Invalid Twitter Response.', $this->_slug);
602
- }
603
- throw new wpTwitterWidgetException($widgetOptions['errmsg']);
604
- } elseif( !empty($decodedResponse->error) ) {
605
- if (empty($widgetOptions['errmsg'])) {
606
  $widgetOptions['errmsg'] = $decodedResponse->error;
607
  }
608
- throw new wpTwitterWidgetException($widgetOptions['errmsg']);
609
  } else {
610
  return $decodedResponse;
611
  }
612
  } else {
613
  // Failed to fetch url;
614
- if (empty($widgetOptions['errmsg'])) {
615
- $widgetOptions['errmsg'] = __('Could not connect to Twitter', $this->_slug);
616
  }
617
- throw new wpTwitterWidgetException($widgetOptions['errmsg']);
618
  }
619
  }
620
 
@@ -626,17 +604,17 @@ class wpTwitterWidget extends XavisysPlugin {
626
  * @param bool[optional] $count - If true, it adds the count parameter to the URL
627
  * @return string - Twitter feed URL
628
  */
629
- private function _getFeedUrl($widgetOptions, $type = 'json', $count = true) {
630
- if (!in_array($type, array('rss', 'json'))) {
631
  $type = 'json';
632
  }
633
  if ( $count ) {
634
- $num = ($widgetOptions['hidereplies'])? 100:$widgetOptions['items'];
635
- $count = sprintf('?count=%u', $num);
636
  } else {
637
  $count = '';
638
  }
639
- return sprintf('http://twitter.com/statuses/user_timeline/%1$s.%2$s%3$s', $widgetOptions['username'], $type, $count);
640
  }
641
 
642
  /**
@@ -649,56 +627,56 @@ class wpTwitterWidget extends XavisysPlugin {
649
  * @param int $max - Max number of seconds to conver to "ago" messages. 0 for all, -1 for none
650
  * @return string
651
  */
652
- private function _timeSince($startTimestamp, $max, $dateFormat) {
653
  // array of time period chunks
654
  $chunks = array(
655
- 'year' => 60 * 60 * 24 * 365, // 31,536,000 seconds
656
- 'month' => 60 * 60 * 24 * 30, // 2,592,000 seconds
657
- 'week' => 60 * 60 * 24 * 7, // 604,800 seconds
658
- 'day' => 60 * 60 * 24, // 86,400 seconds
659
- 'hour' => 60 * 60, // 3600 seconds
660
- 'minute' => 60, // 60 seconds
661
- 'second' => 1 // 1 second
662
  );
663
 
664
  $since = time() - $startTimestamp;
665
 
666
- if ($max != '-1' && $since >= $max) {
667
- return date_i18n( $dateFormat, $startTimestamp);
668
  }
669
 
670
  foreach ( $chunks as $key => $seconds ) {
671
- // finding the biggest chunk (if the chunk fits, break)
672
- if (($count = floor($since / $seconds)) != 0) {
673
  break;
674
  }
675
  }
676
 
677
  $messages = array(
678
- 'year' => _n('about %s year ago', 'about %s years ago', $count, $this->_slug),
679
- 'month' => _n('about %s month ago', 'about %s months ago', $count, $this->_slug),
680
- 'week' => _n('about %s week ago', 'about %s weeks ago', $count, $this->_slug),
681
- 'day' => _n('about %s day ago', 'about %s days ago', $count, $this->_slug),
682
- 'hour' => _n('about %s hour ago', 'about %s hours ago', $count, $this->_slug),
683
- 'minute' => _n('about %s minute ago', 'about %s minutes ago', $count, $this->_slug),
684
- 'second' => _n('about %s second ago', 'about %s seconds ago', $count, $this->_slug),
685
  );
686
 
687
- return sprintf($messages[$key], $count);
688
  }
689
 
690
  /**
691
  * Returns the Twitter user's profile image, linked to that user's profile
692
  *
693
  * @param object $user - Twitter User
694
- * @return string - Linked image (XHTML)
695
  */
696
- private function _getProfileImage($user) {
697
  $linkAttrs = array(
698
- 'href' => "http://twitter.com/{$user->screen_name}",
699
- 'title' => $user->name
700
  );
701
- return $this->_buildLink("<img alt='{$user->name}' src='{$user->profile_image_url}' />", $linkAttrs, true);
702
  }
703
 
704
  /**
@@ -708,24 +686,25 @@ class wpTwitterWidget extends XavisysPlugin {
708
  * @param string $content - Content of the shortCode
709
  * @return string - formatted XHTML replacement for the shortCode
710
  */
711
- public function handleShortcodes($attr, $content = '') {
712
  $defaults = array(
713
- 'before_widget' => '',
714
- 'after_widget' => '',
715
- 'before_title' => '<h2>',
716
- 'after_title' => '</h2>',
717
- 'title' => '',
718
- 'errmsg' => '',
719
- 'fetchTimeOut' => '2',
720
- 'username' => '',
721
- 'hiderss' => false,
722
- 'hidereplies' => false,
723
- 'avatar' => false,
724
- 'showXavisysLink' => false,
725
- 'targetBlank' => false,
726
- 'items' => 10,
727
- 'showts' => 60 * 60 * 24,
728
- 'dateFormat' => __('h:i:s A F d, Y', $this->_slug),
 
729
  );
730
 
731
  /**
@@ -734,26 +713,26 @@ class wpTwitterWidget extends XavisysPlugin {
734
  */
735
  if ( array_key_exists( 'fetchtimeout', $attr ) ) {
736
  $attr['fetchTimeOut'] = $attr['fetchtimeout'];
737
- unset($attr['fetchtimeout']);
738
  }
739
  if ( array_key_exists( 'showxavisyslink', $attr ) ) {
740
  $attr['showXavisysLink'] = $attr['showxavisyslink'];
741
- unset($attr['showxavisyslink']);
742
  }
743
  if ( array_key_exists( 'targetblank', $attr ) ) {
744
  $attr['targetBlank'] = $attr['targetblank'];
745
- unset($attr['targetblank']);
746
  }
747
  if ( array_key_exists( 'dateformat', $attr ) ) {
748
  $attr['dateFormat'] = $attr['dateformat'];
749
- unset($attr['dateformat']);
750
  }
751
 
752
- if ( !empty($content) && empty($attr['title']) ) {
753
  $attr['title'] = $content;
754
  }
755
 
756
- $attr = shortcode_atts($defaults, $attr);
757
 
758
  if ( $attr['hiderss'] && $attr['hiderss'] != 'false' && $attr['hiderss'] != '0' ) {
759
  $attr['hiderss'] == true;
@@ -761,6 +740,9 @@ class wpTwitterWidget extends XavisysPlugin {
761
  if ( $attr['hidereplies'] && $attr['hidereplies'] != 'false' && $attr['hidereplies'] != '0' ) {
762
  $attr['hidereplies'] == true;
763
  }
 
 
 
764
  if ( $attr['avatar'] && $attr['avatar'] != 'false' && $attr['avatar'] != '0' ) {
765
  $attr['avatar'] == true;
766
  }
@@ -771,22 +753,24 @@ class wpTwitterWidget extends XavisysPlugin {
771
  $attr['targetBlank'] == true;
772
  }
773
 
774
- return $this->display($attr);
775
  }
776
 
777
- public function filterSettings($settings) {
778
- $defaultArgs = array( 'title' => '',
779
- 'errmsg' => '',
780
- 'fetchTimeOut' => '2',
781
- 'username' => '',
782
- 'hiderss' => false,
783
- 'hidereplies' => false,
784
- 'avatar' => false,
785
- 'showXavisysLink' => false,
786
- 'targetBlank' => false,
787
- 'items' => 10,
788
- 'showts' => 60 * 60 * 24,
789
- 'dateFormat' => __('h:i:s A F d, Y', $this->_slug),
 
 
790
  );
791
 
792
  return wp_parse_args( $settings, $defaultArgs );
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.1
7
  * Author: Aaron D. Campbell
8
  * Author URI: http://xavisys.com/
9
+ * License: GPLv2 or later
10
  * Text Domain: twitter-widget-pro
11
  */
12
 
13
  /*
14
+ Copyright 2006-current Aaron D. Campbell ( email : wp_plugins@xavisys.com )
15
 
16
  This program is free software; you can redistribute it and/or modify
17
  it under the terms of the GNU General Public License as published by
18
  the Free Software Foundation; either version 2 of the License, or
19
+ ( at your option ) any later version.
20
 
21
  This program is distributed in the hope that it will be useful,
22
  but WITHOUT ANY WARRANTY; without even the implied warranty of
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
  /**
48
  );
49
  $name = __( 'Twitter Widget Pro', $wpTwitterWidget->get_slug() );
50
 
51
+ $this->WP_Widget( 'twitter', $name, $widget_ops, $control_ops );
52
  }
53
 
54
  private function _getInstanceSettings ( $instance ) {
61
  $wpTwitterWidget = wpTwitterWidget::getInstance();
62
  ?>
63
  <p>
64
+ <label for="<?php echo $this->get_field_id( 'username' ); ?>"><?php _e( 'Twitter username:', $this->_slug ); ?></label>
65
+ <input class="widefat" id="<?php echo $this->get_field_id( 'username' ); ?>" name="<?php echo $this->get_field_name( 'username' ); ?>" type="text" value="<?php esc_attr_e( $instance['username'] ); ?>" />
66
  </p>
67
  <p>
68
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Give the feed a title ( optional ):', $this->_slug ); ?></label>
69
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php esc_attr_e( $instance['title'] ); ?>" />
70
  </p>
71
  <p>
72
+ <label for="<?php echo $this->get_field_id( 'items' ); ?>"><?php _e( 'How many items would you like to display?', $this->_slug ); ?></label>
73
+ <select id="<?php echo $this->get_field_id( 'items' ); ?>" name="<?php echo $this->get_field_name( 'items' ); ?>">
74
  <?php
75
  for ( $i = 1; $i <= 20; ++$i ) {
76
+ echo "<option value='$i' ". selected( $instance['items'], $i, false ). ">$i</option>";
77
  }
78
  ?>
79
  </select>
80
  </p>
81
  <p>
82
+ <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'hidereplies' ); ?>" name="<?php echo $this->get_field_name( 'hidereplies' ); ?>"<?php checked( $instance['hidereplies'], 'true' ); ?> />
83
+ <label for="<?php echo $this->get_field_id( 'hidereplies' ); ?>"><?php _e( 'Hide @replies', $this->_slug ); ?></label>
84
  </p>
85
  <p>
86
+ <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' ); ?> />
87
+ <label for="<?php echo $this->get_field_id( 'hidefrom' ); ?>"><?php _e( 'Hide sending applications', $this->_slug ); ?></label>
88
  </p>
89
  <p>
90
+ <label for="<?php echo $this->get_field_id( 'errmsg' ); ?>"><?php _e( 'What to display when Twitter is down ( optional ):', $this->_slug ); ?></label>
91
+ <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'] ); ?>" />
92
  </p>
93
  <p>
94
+ <label for="<?php echo $this->get_field_id( 'fetchTimeOut' ); ?>"><?php _e( 'Number of seconds to wait for a response from Twitter ( default 2 ):', $this->_slug ); ?></label>
95
+ <input class="widefat" id="<?php echo $this->get_field_id( 'fetchTimeOut' ); ?>" name="<?php echo $this->get_field_name( 'fetchTimeOut' ); ?>" type="text" value="<?php esc_attr_e( $instance['fetchTimeOut'] ); ?>" />
96
+ </p>
97
+ <p>
98
+ <label for="<?php echo $this->get_field_id( 'showts' ); ?>"><?php _e( 'Show date/time of Tweet ( rather than 2 ____ ago ):', $this->_slug ); ?></label>
99
+ <select id="<?php echo $this->get_field_id( 'showts' ); ?>" name="<?php echo $this->get_field_name( 'showts' ); ?>">
100
+ <option value="0" <?php selected( $instance['showts'], '0' ); ?>><?php _e( 'Always', $this->_slug );?></option>
101
+ <option value="3600" <?php selected( $instance['showts'], '3600' ); ?>><?php _e( 'If over an hour old', $this->_slug );?></option>
102
+ <option value="86400" <?php selected( $instance['showts'], '86400' ); ?>><?php _e( 'If over a day old', $this->_slug );?></option>
103
+ <option value="604800" <?php selected( $instance['showts'], '604800' ); ?>><?php _e( 'If over a week old', $this->_slug );?></option>
104
+ <option value="2592000" <?php selected( $instance['showts'], '2592000' ); ?>><?php _e( 'If over a month old', $this->_slug );?></option>
105
+ <option value="31536000" <?php selected( $instance['showts'], '31536000' ); ?>><?php _e( 'If over a year old', $this->_slug );?></option>
106
+ <option value="-1" <?php selected( $instance['showts'], '-1' ); ?>><?php _e( 'Never', $this->_slug );?></option>
107
  </select>
108
  </p>
109
  <p>
110
+ <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>
111
+ <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'] ); ?>" />
112
  </p>
113
  <p>
114
+ <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' ); ?> />
115
+ <label for="<?php echo $this->get_field_id( 'hiderss' ); ?>"><?php _e( 'Hide RSS Icon and Link', $this->_slug ); ?></label>
116
  </p>
117
  <p>
118
+ <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' ); ?> />
119
+ <label for="<?php echo $this->get_field_id( 'targetBlank' ); ?>"><?php _e( 'Open links in a new window', $this->_slug ); ?></label>
120
  </p>
121
  <p>
122
+ <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'avatar' ); ?>" name="<?php echo $this->get_field_name( 'avatar' ); ?>"<?php checked( $instance['avatar'], 'true' ); ?> />
123
+ <label for="<?php echo $this->get_field_id( 'avatar' ); ?>"><?php _e( 'Show Profile Image', $this->_slug ); ?></label>
124
  </p>
125
  <p>
126
+ <input class="checkbox" type="checkbox" value="true" id="<?php echo $this->get_field_id( 'showXavisysLink' ); ?>" name="<?php echo $this->get_field_name( 'showXavisysLink' ); ?>"<?php checked( $instance['showXavisysLink'], 'true' ); ?> />
127
+ <label for="<?php echo $this->get_field_id( 'showXavisysLink' ); ?>"><?php _e( 'Show Link to Twitter Widget Pro', $this->_slug ); ?></label>
128
  </p>
129
  <p><?php echo $wpTwitterWidget->getSupportForumLink(); ?></p>
130
  <?php
135
  $instance = $this->_getInstanceSettings( $new_instance );
136
 
137
  // Clean up the free-form areas
138
+ $instance['title'] = stripslashes( $new_instance['title'] );
139
+ $instance['errmsg'] = stripslashes( $new_instance['errmsg'] );
140
 
141
  // If the current user isn't allowed to use unfiltered HTML, filter it
142
+ if ( !current_user_can( 'unfiltered_html' ) ) {
143
+ $instance['title'] = strip_tags( $new_instance['title'] );
144
+ $instance['errmsg'] = strip_tags( $new_instance['errmsg'] );
145
  }
146
 
147
  return $instance;
148
  }
149
 
150
  public function flush_widget_cache() {
151
+ wp_cache_delete( 'widget_twitter_widget_pro', 'widget' );
152
  }
153
 
154
  public function widget( $args, $instance ) {
177
  $this->_menuTitle = __( 'Twitter Widget', $this->_slug );
178
  $this->_accessLevel = 'manage_options';
179
  $this->_optionGroup = 'twp-options';
180
+ $this->_optionNames = array( 'twp' );
181
  $this->_optionCallbacks = array();
182
  $this->_slug = 'twitter-widget-pro';
183
  $this->_paypalButtonId = '9993090';
209
  }
210
 
211
  public function addOptionsMetaBoxes() {
212
+ add_meta_box( $this->_slug . '-general-settings', __( 'General Settings', $this->_slug ), array( $this, 'generalSettingsMetaBox' ), 'xavisys-' . $this->_slug, 'main' );
213
  }
214
 
215
  public function generalSettingsMetaBox() {
217
  <table class="form-table">
218
  <tr valign="top">
219
  <th scope="row">
220
+ <label for="twp_username"><?php _e( 'Twitter username:', $this->_slug ); ?></label>
221
  </th>
222
  <td>
223
+ <input id="twp_username" name="twp[username]" type="text" class="regular-text code" value="<?php esc_attr_e( $this->_settings['twp']['username'] ); ?>" size="40" />
224
  </td>
225
  </tr>
226
  <tr valign="top">
227
  <th scope="row">
228
+ <label for="twp_title"><?php _e( 'Give the feed a title ( optional ):', $this->_slug ); ?></label>
229
  </th>
230
  <td>
231
+ <input id="twp_title" name="twp[title]" type="text" class="regular-text code" value="<?php esc_attr_e( $this->_settings['twp']['title'] ); ?>" size="40" />
232
  </td>
233
  </tr>
234
  <tr valign="top">
235
  <th scope="row">
236
+ <label for="twp_items"><?php _e( 'How many items would you like to display?', $this->_slug ); ?></label>
237
  </th>
238
  <td>
239
  <select id="twp_items" name="twp[items]">
240
  <?php
241
  for ( $i = 1; $i <= 20; ++$i ) {
242
+ echo "<option value='$i' ". selected( $this->_settings['twp']['items'], $i, false ). ">$i</option>";
243
  }
244
  ?>
245
  </select>
247
  </tr>
248
  <tr valign="top">
249
  <th scope="row">
250
+ <label for="twp_errmsg"><?php _e( 'What to display when Twitter is down ( optional ):', $this->_slug ); ?></label>
251
  </th>
252
  <td>
253
+ <input id="twp_errmsg" name="twp[errmsg]" type="text" class="regular-text code" value="<?php esc_attr_e( $this->_settings['twp']['errmsg'] ); ?>" size="40" />
254
  </td>
255
  </tr>
256
  <tr valign="top">
257
  <th scope="row">
258
+ <label for="twp_fetchTimeOut"><?php _e( 'Number of seconds to wait for a response from Twitter ( default 2 ):', $this->_slug ); ?></label>
259
  </th>
260
  <td>
261
+ <input id="twp_fetchTimeOut" name="twp[fetchTimeOut]" type="text" class="regular-text code" value="<?php esc_attr_e( $this->_settings['twp']['fetchTimeOut'] ); ?>" size="40" />
262
  </td>
263
  </tr>
264
  <tr valign="top">
265
  <th scope="row">
266
+ <label for="twp_showts"><?php _e( 'Show date/time of Tweet ( rather than 2 ____ ago ):', $this->_slug ); ?></label>
267
  </th>
268
  <td>
269
  <select id="twp_showts" name="twp[showts]">
270
+ <option value="0" <?php selected( $this->_settings['twp']['showts'], '0' ); ?>><?php _e( 'Always', $this->_slug );?></option>
271
+ <option value="3600" <?php selected( $this->_settings['twp']['showts'], '3600' ); ?>><?php _e( 'If over an hour old', $this->_slug );?></option>
272
+ <option value="86400" <?php selected( $this->_settings['twp']['showts'], '86400' ); ?>><?php _e( 'If over a day old', $this->_slug );?></option>
273
+ <option value="604800" <?php selected( $this->_settings['twp']['showts'], '604800' ); ?>><?php _e( 'If over a week old', $this->_slug );?></option>
274
+ <option value="2592000" <?php selected( $this->_settings['twp']['showts'], '2592000' ); ?>><?php _e( 'If over a month old', $this->_slug );?></option>
275
+ <option value="31536000" <?php selected( $this->_settings['twp']['showts'], '31536000' ); ?>><?php _e( 'If over a year old', $this->_slug );?></option>
276
+ <option value="-1" <?php selected( $this->_settings['twp']['showts'], '-1' ); ?>><?php _e( 'Never', $this->_slug );?></option>
277
  </select>
278
  </td>
279
  </tr>
280
  <tr valign="top">
281
  <th scope="row">
282
+ <label for="twp_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>
283
  </th>
284
  <td>
285
+ <input id="twp_dateFormat" name="twp[dateFormat]" type="text" class="regular-text code" value="<?php esc_attr_e( $this->_settings['twp']['dateFormat'] ); ?>" size="40" />
286
  </td>
287
  </tr>
288
  <tr valign="top">
289
  <th scope="row">
290
+ <?php _e( "Other Setting:", $this->_slug );?>
291
  </th>
292
  <td>
293
+ <input class="checkbox" type="checkbox" value="true" id="twp_hidereplies" name="twp[hidereplies]"<?php checked( $this->_settings['twp']['hidereplies'], 'true' ); ?> />
294
+ <label for="twp_hidereplies"><?php _e( 'Hide @replies', $this->_slug ); ?></label>
295
+ <br />
296
+ <input class="checkbox" type="checkbox" value="true" id="twp_hidefrom" name="twp[hidefrom]"<?php checked( $this->_settings['twp']['hidefrom'], 'true' ); ?> />
297
+ <label for="twp_hidefrom"><?php _e( 'Hide sending applications', $this->_slug ); ?></label>
298
  <br />
299
+ <input class="checkbox" type="checkbox" value="true" id="twp_hiderss" name="twp[hiderss]"<?php checked( $this->_settings['twp']['hiderss'], 'true' ); ?> />
300
+ <label for="twp_hiderss"><?php _e( 'Hide RSS Icon and Link', $this->_slug ); ?></label>
301
  <br />
302
+ <input class="checkbox" type="checkbox" value="true" id="twp_targetBlank" name="twp[targetBlank]"<?php checked( $this->_settings['twp']['targetBlank'], 'true' ); ?> />
303
+ <label for="twp_targetBlank"><?php _e( 'Open links in a new window', $this->_slug ); ?></label>
304
  <br />
305
+ <input class="checkbox" type="checkbox" value="true" id="twp_avatar" name="twp[avatar]"<?php checked( $this->_settings['twp']['avatar'], 'true' ); ?> />
306
+ <label for="twp_avatar"><?php _e( 'Show Profile Image', $this->_slug ); ?></label>
307
  <br />
308
+ <input class="checkbox" type="checkbox" value="true" id="twp_showXavisysLink" name="twp[showXavisysLink]"<?php checked( $this->_settings['twp']['showXavisysLink'], 'true' ); ?> />
309
+ <label for="twp_showXavisysLink"><?php _e( 'Show Link to Twitter Widget Pro', $this->_slug ); ?></label>
310
  </td>
311
  </tr>
312
  </table>
313
  <?php
314
  }
315
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  /**
317
  * Replace @username with a link to that twitter user
318
  *
319
  * @param string $text - Tweet text
320
  * @return string - Tweet text with @replies linked
321
  */
322
+ public function linkTwitterUsers( $text ) {
323
  $text = preg_replace_callback('/(^|\s)@(\w+)/i', array($this, '_linkTwitterUsersCallback'), $text);
324
  return $text;
325
  }
326
 
327
+ private function _linkTwitterUsersCallback( $matches ) {
328
  $linkAttrs = array(
329
+ 'href' => 'http://twitter.com/' . urlencode( $matches[2] ),
330
  'class' => 'twitter-user'
331
  );
332
+ return $matches[1] . $this->_buildLink( '@'.$matches[2], $linkAttrs );
333
  }
334
 
335
  /**
338
  * @param string $text - Tweet text
339
  * @return string - Tweet text with #hashtags linked
340
  */
341
+ public function linkHashtags( $text ) {
342
  $text = preg_replace_callback('/(^|\s)(#\w*)/i', array($this, '_hashtagLink'), $text);
343
  return $text;
344
  }
349
  * @param array $matches - Tweet text
350
  * @return string - Tweet text with #hashtags linked
351
  */
352
+ private function _linkHashtagsCallback( $matches ) {
353
  $linkAttrs = array(
354
+ 'href' => 'http://search.twitter.com/search?q=' . urlencode( $matches[2] ),
355
  'class' => 'twitter-hashtag'
356
  );
357
+ return $matches[1] . $this->_buildLink( $matches[2], $linkAttrs );
358
  }
359
 
360
  /**
363
  * @param string $text - Tweet text
364
  * @return string - Tweet text with URLs repalced with links
365
  */
366
+ public function linkUrls( $text ) {
367
  /**
368
  * match protocol://address/path/file.extension?some=variable&another=asf%
369
  * $1 is a possible space, this keeps us from linking href="[link]" etc
387
  return $text;
388
  }
389
 
390
+ private function _linkUrlsCallback ( $matches ) {
391
  $linkAttrs = array(
392
  'href' => $matches[2]
393
  );
394
+ return $matches[1] . $this->_buildLink( $matches[2], $linkAttrs );
395
  }
396
 
397
  private function _notEmpty( $v ) {
398
+ return !( empty( $v ) );
399
  }
400
 
401
  private function _buildLink( $text, $attributes = array(), $noFilter = false ) {
402
+ $attributes = array_filter( wp_parse_args( $attributes ), array( $this, '_notEmpty' ) );
403
  $attributes = apply_filters( 'widget_twitter_link_attributes', $attributes );
404
  $attributes = wp_parse_args( $attributes );
405
+ if ( strtolower( 'www' == substr( $attributes['href'], 0, 3 ) ) ) {
406
  $attributes['href'] = 'http://' . $attributes['href'];
407
  }
408
  $text = apply_filters( 'widget_twitter_link_text', $text );
409
  $link = '<a';
410
  foreach ( $attributes as $name => $value ) {
411
+ $link .= ' ' . esc_attr( $name ) . '="' . esc_attr( $value ) . '"';
412
  }
413
  $link .= '>';
414
  if ( $noFilter ) {
415
  $link .= $text;
416
  } else {
417
+ $link .= esc_html( $text );
418
  }
419
  $link .= '</a>';
420
  return $link;
421
  }
422
 
423
  public function register() {
424
+ register_widget( 'WP_Widget_Twitter_Pro' );
425
  }
426
 
427
+ public function targetBlank( $attributes ) {
428
  $attributes['target'] = '_blank';
429
  return $attributes;
430
  }
433
  $args = wp_parse_args( $args );
434
 
435
  if ( $args['targetBlank'] ) {
436
+ add_filter( 'widget_twitter_link_attributes', array( $this, 'targetBlank' ) );
437
  }
438
 
439
  // Validate our options
441
  if ( $args['items'] < 1 || 20 < $args['items'] ) {
442
  $args['items'] = 10;
443
  }
444
+ if ( !isset( $args['showts'] ) ) {
445
  $args['showts'] = 86400;
446
  }
447
 
448
  try {
449
+ $tweets = $this->_getTweets( $args );
450
+ } catch ( wpTwitterWidgetException $e ) {
451
  $tweets = $e;
452
  }
453
 
455
 
456
  // If "hide rss" hasn't been checked, show the linked icon
457
  if ( $args['hiderss'] != 'true' ) {
458
+ if ( file_exists( dirname( __FILE__ ) . '/rss.png' ) ) {
459
+ $icon = str_replace( ABSPATH, get_option( 'siteurl' ).'/', dirname( __FILE__ ) ) . '/rss.png';
460
  } else {
461
+ $icon = get_option( 'siteurl' ).'/wp-includes/images/rss.png';
462
  }
463
+ $feedUrl = $this->_getFeedUrl( $args, 'rss', false );
464
  $linkAttrs = array(
465
  'class' => 'twitterwidget twitterwidget-rss',
466
+ 'title' => __( 'Syndicate this content', $this->_slug ),
467
  'href' => $feedUrl
468
  );
469
 
470
+ $args['before_title'] .= $this->_buildLink( "<img style='background:orange;color:white;border:none;' width='14' height='14' src='{$icon}' alt='RSS' />", $linkAttrs, true );
471
  }
472
  $twitterLink = 'http://twitter.com/' . $args['username'];
473
 
474
+ if ( empty( $args['title'] ) ) {
475
  $args['title'] = "Twitter: {$args['username']}";
476
  }
477
  $linkAttrs = array(
479
  'title' => "Twitter: {$args['username']}",
480
  'href' => $twitterLink
481
  );
482
+ $args['title'] = $this->_buildLink( $args['title'], $linkAttrs, current_user_can( 'unfiltered_html' ) );
483
  $widgetContent .= $args['before_title'] . $args['title'] . $args['after_title'];
484
+ if ( !is_a( $tweets, 'wpTwitterWidgetException' ) && !empty( $tweets[0] ) && $args['avatar'] == 'true' ) {
485
  $widgetContent .= '<div class="twitter-avatar">';
486
+ $widgetContent .= $this->_getProfileImage( $tweets[0]->user );
487
  $widgetContent .= '</div>';
488
  }
489
  $widgetContent .= '<ul>';
490
+ if ( is_a( $tweets, 'wpTwitterWidgetException' ) ) {
491
  $widgetContent .= '<li class="wpTwitterWidgetError">' . $tweets->getMessage() . '</li>';
492
+ } else if ( count( $tweets ) == 0 ) {
493
+ $widgetContent .= '<li class="wpTwitterWidgetEmpty">' . __( 'No Tweets Available', $this->_slug ) . '</li>';
494
  } else {
495
  $count = 0;
496
+ foreach ( $tweets as $tweet ) {
497
+ if ( $args['hidereplies'] != 'true' || empty( $tweet->in_reply_to_user_id ) ) {
498
  // Set our "ago" string which converts the date to "# ___(s) ago"
499
+ $tweet->ago = $this->_timeSince( strtotime( $tweet->created_at ), $args['showts'], $args['dateFormat'] );
500
  $entryContent = apply_filters( 'widget_twitter_content', $tweet->text );
501
+ $from = sprintf( __( 'from %s', $this->_slug ), str_replace( '&', '&amp;', $tweet->source ) );
502
  $widgetContent .= '<li>';
503
  $widgetContent .= "<span class='entry-content'>{$entryContent}</span>";
504
  $widgetContent .= " <span class='entry-meta'>";
506
  $linkAttrs = array(
507
  'href' => "http://twitter.com/{$tweet->user->screen_name}/statuses/{$tweet->id}"
508
  );
509
+ $widgetContent .= $this->_buildLink( $tweet->ago, $linkAttrs );
510
  $widgetContent .= '</span>';
511
+ if ( 'true' != $args['hidefrom'] )
512
+ $widgetContent .= " <span class='from-meta'>{$from}</span>";
513
+ if ( !empty( $tweet->in_reply_to_screen_name ) ) {
514
+ $rtLinkText = sprintf( __( 'in reply to %s', $this->_slug ), $tweet->in_reply_to_screen_name );
515
+ $widgetContent .= ' <span class="in-reply-to-meta">';
516
  $linkAttrs = array(
517
  'href' => "http://twitter.com/{$tweet->in_reply_to_screen_name}/statuses/{$tweet->in_reply_to_status_id}",
518
  'class' => 'reply-to'
519
  );
520
+ $widgetContent .= $this->_buildLink( $rtLinkText, $linkAttrs );
521
  $widgetContent .= '</span>';
522
  }
523
  $widgetContent .= '</span></li>';
524
 
525
+ if ( ++$count >= $args['items'] ) {
526
  break;
527
  }
528
  }
533
  $widgetContent .= '<li class="xavisys-link"><span class="xavisys-link-text">';
534
  $linkAttrs = array(
535
  'href' => 'http://xavisys.com/wordpress-plugins/wordpress-twitter-widget/',
536
+ 'title' => __( 'Get Twitter Widget for your WordPress site', $this->_slug )
537
  );
538
+ $widgetContent .= __( 'Powered by', $this->_slug );
539
+ $widgetContent .= $this->_buildLink( 'WordPress Twitter Widget Pro', $linkAttrs );
540
  $widgetContent .= '</span></li>';
541
  }
542
  $widgetContent .= '</ul></div>' . $args['after_widget'];
549
  * @param array $widgetOptions - options needed to get feeds
550
  * @return array - Array of objects
551
  */
552
+ private function _getTweets( $widgetOptions ) {
553
+ $key = md5( $this->_getFeedUrl( $widgetOptions ) );
554
+ if ( false === ( $tweets = get_site_transient( 'twp_' . $key ) ) ) {
 
 
 
555
  try {
556
+ $tweets = $this->_parseFeed( $widgetOptions );
557
+ set_site_transient( 'twp_' . $key, $tweets, 300 ); // cache for 5 minutes
558
+ } catch ( wpTwitterWidgetException $e ) {
 
559
  throw $e;
560
  }
561
  }
568
  * @param array $widgetOptions - settings needed to get feed url, etc
569
  * @return array
570
  */
571
+ private function _parseFeed( $widgetOptions ) {
572
+ $feedUrl = $this->_getFeedUrl( $widgetOptions );
573
+ $resp = wp_remote_request( $feedUrl, array( 'timeout' => $widgetOptions['fetchTimeOut'] ) );
574
+
575
+ if ( !is_wp_error( $resp ) && $resp['response']['code'] >= 200 && $resp['response']['code'] < 300 ) {
576
+ $decodedResponse = json_decode( $resp['body'] );
577
+ if ( empty( $decodedResponse ) ) {
578
+ if ( empty( $widgetOptions['errmsg'] ) ) {
579
+ $widgetOptions['errmsg'] = __( 'Invalid Twitter Response.', $this->_slug );
 
 
 
 
 
 
580
  }
581
+ throw new wpTwitterWidgetException( $widgetOptions['errmsg'] );
582
+ } elseif( !empty( $decodedResponse->error ) ) {
583
+ if ( empty( $widgetOptions['errmsg'] ) ) {
 
 
 
 
 
 
 
584
  $widgetOptions['errmsg'] = $decodedResponse->error;
585
  }
586
+ throw new wpTwitterWidgetException( $widgetOptions['errmsg'] );
587
  } else {
588
  return $decodedResponse;
589
  }
590
  } else {
591
  // Failed to fetch url;
592
+ if ( empty( $widgetOptions['errmsg'] ) ) {
593
+ $widgetOptions['errmsg'] = __( 'Could not connect to Twitter', $this->_slug );
594
  }
595
+ throw new wpTwitterWidgetException( $widgetOptions['errmsg'] );
596
  }
597
  }
598
 
604
  * @param bool[optional] $count - If true, it adds the count parameter to the URL
605
  * @return string - Twitter feed URL
606
  */
607
+ private function _getFeedUrl( $widgetOptions, $type = 'json', $count = true ) {
608
+ if ( !in_array( $type, array( 'rss', 'json' ) ) ) {
609
  $type = 'json';
610
  }
611
  if ( $count ) {
612
+ $num = ( $widgetOptions['hidereplies'] )? 100:$widgetOptions['items'];
613
+ $count = sprintf( '?count=%u', $num );
614
  } else {
615
  $count = '';
616
  }
617
+ return sprintf( 'http://twitter.com/statuses/user_timeline/%1$s.%2$s%3$s', $widgetOptions['username'], $type, $count );
618
  }
619
 
620
  /**
627
  * @param int $max - Max number of seconds to conver to "ago" messages. 0 for all, -1 for none
628
  * @return string
629
  */
630
+ private function _timeSince( $startTimestamp, $max, $dateFormat ) {
631
  // array of time period chunks
632
  $chunks = array(
633
+ 'year' => 60 * 60 * 24 * 365, // 31,536,000 seconds
634
+ 'month' => 60 * 60 * 24 * 30, // 2,592,000 seconds
635
+ 'week' => 60 * 60 * 24 * 7, // 604,800 seconds
636
+ 'day' => 60 * 60 * 24, // 86,400 seconds
637
+ 'hour' => 60 * 60, // 3600 seconds
638
+ 'minute' => 60, // 60 seconds
639
+ 'second' => 1 // 1 second
640
  );
641
 
642
  $since = time() - $startTimestamp;
643
 
644
+ if ( $max != '-1' && $since >= $max ) {
645
+ return date_i18n( $dateFormat, $startTimestamp );
646
  }
647
 
648
  foreach ( $chunks as $key => $seconds ) {
649
+ // finding the biggest chunk ( if the chunk fits, break )
650
+ if ( ( $count = floor( $since / $seconds ) ) != 0 ) {
651
  break;
652
  }
653
  }
654
 
655
  $messages = array(
656
+ 'year' => _n( 'about %s year ago', 'about %s years ago', $count, $this->_slug ),
657
+ 'month' => _n( 'about %s month ago', 'about %s months ago', $count, $this->_slug ),
658
+ 'week' => _n( 'about %s week ago', 'about %s weeks ago', $count, $this->_slug ),
659
+ 'day' => _n( 'about %s day ago', 'about %s days ago', $count, $this->_slug ),
660
+ 'hour' => _n( 'about %s hour ago', 'about %s hours ago', $count, $this->_slug ),
661
+ 'minute' => _n( 'about %s minute ago', 'about %s minutes ago', $count, $this->_slug ),
662
+ 'second' => _n( 'about %s second ago', 'about %s seconds ago', $count, $this->_slug ),
663
  );
664
 
665
+ return sprintf( $messages[$key], $count );
666
  }
667
 
668
  /**
669
  * Returns the Twitter user's profile image, linked to that user's profile
670
  *
671
  * @param object $user - Twitter User
672
+ * @return string - Linked image ( XHTML )
673
  */
674
+ private function _getProfileImage( $user ) {
675
  $linkAttrs = array(
676
+ 'href' => "http://twitter.com/{$user->screen_name}",
677
+ 'title' => $user->name
678
  );
679
+ return $this->_buildLink( "<img alt='{$user->name}' src='{$user->profile_image_url}' />", $linkAttrs, true );
680
  }
681
 
682
  /**
686
  * @param string $content - Content of the shortCode
687
  * @return string - formatted XHTML replacement for the shortCode
688
  */
689
+ public function handleShortcodes( $attr, $content = '' ) {
690
  $defaults = array(
691
+ 'before_widget' => '',
692
+ 'after_widget' => '',
693
+ 'before_title' => '<h2>',
694
+ 'after_title' => '</h2>',
695
+ 'title' => '',
696
+ 'errmsg' => '',
697
+ 'fetchTimeOut' => '2',
698
+ 'username' => '',
699
+ 'hiderss' => false,
700
+ 'hidereplies' => false,
701
+ 'hidefrom' => false,
702
+ 'avatar' => false,
703
+ 'showXavisysLink' => false,
704
+ 'targetBlank' => false,
705
+ 'items' => 10,
706
+ 'showts' => 60 * 60 * 24,
707
+ 'dateFormat' => __( 'h:i:s A F d, Y', $this->_slug ),
708
  );
709
 
710
  /**
713
  */
714
  if ( array_key_exists( 'fetchtimeout', $attr ) ) {
715
  $attr['fetchTimeOut'] = $attr['fetchtimeout'];
716
+ unset( $attr['fetchtimeout'] );
717
  }
718
  if ( array_key_exists( 'showxavisyslink', $attr ) ) {
719
  $attr['showXavisysLink'] = $attr['showxavisyslink'];
720
+ unset( $attr['showxavisyslink'] );
721
  }
722
  if ( array_key_exists( 'targetblank', $attr ) ) {
723
  $attr['targetBlank'] = $attr['targetblank'];
724
+ unset( $attr['targetblank'] );
725
  }
726
  if ( array_key_exists( 'dateformat', $attr ) ) {
727
  $attr['dateFormat'] = $attr['dateformat'];
728
+ unset( $attr['dateformat'] );
729
  }
730
 
731
+ if ( !empty( $content ) && empty( $attr['title'] ) ) {
732
  $attr['title'] = $content;
733
  }
734
 
735
+ $attr = shortcode_atts( $defaults, $attr );
736
 
737
  if ( $attr['hiderss'] && $attr['hiderss'] != 'false' && $attr['hiderss'] != '0' ) {
738
  $attr['hiderss'] == true;
740
  if ( $attr['hidereplies'] && $attr['hidereplies'] != 'false' && $attr['hidereplies'] != '0' ) {
741
  $attr['hidereplies'] == true;
742
  }
743
+ if ( $attr['hidefrom'] && $attr['hidefrom'] != 'false' && $attr['hidefrom'] != '0' ) {
744
+ $attr['hidefrom'] == true;
745
+ }
746
  if ( $attr['avatar'] && $attr['avatar'] != 'false' && $attr['avatar'] != '0' ) {
747
  $attr['avatar'] == true;
748
  }
753
  $attr['targetBlank'] == true;
754
  }
755
 
756
+ return $this->display( $attr );
757
  }
758
 
759
+ public function filterSettings( $settings ) {
760
+ $defaultArgs = array(
761
+ 'title' => '',
762
+ 'errmsg' => '',
763
+ 'fetchTimeOut' => '2',
764
+ 'username' => '',
765
+ 'hiderss' => false,
766
+ 'hidereplies' => false,
767
+ 'hidefrom' => false,
768
+ 'avatar' => false,
769
+ 'showXavisysLink' => false,
770
+ 'targetBlank' => false,
771
+ 'items' => 10,
772
+ 'showts' => 60 * 60 * 24,
773
+ 'dateFormat' => __( 'h:i:s A F d, Y', $this->_slug ),
774
  );
775
 
776
  return wp_parse_args( $settings, $defaultArgs );
xavisys-plugin-framework.php CHANGED
@@ -1,10 +1,39 @@
1
  <?php
2
  /**
3
- * Version: 1.0.4
4
  */
5
  /**
6
  * Changelog:
7
  *
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  * 1.0.4:
9
  * - Added donate link to the plugin meta
10
  *
@@ -68,11 +97,19 @@ if (!class_exists('XavisysPlugin')) {
68
  */
69
  protected $_slug = '';
70
 
 
 
 
 
 
 
71
  /**
72
  * @var string - The button ID for the PayPal button, override this generic one with a plugin-specific one
73
  */
74
  protected $_paypalButtonId = '9925248';
75
 
 
 
76
  /**
77
  * This is our constructor, which is private to force the use of getInstance()
78
  * @return void
@@ -157,8 +194,8 @@ if (!class_exists('XavisysPlugin')) {
157
  }
158
 
159
  public function registerOptionsPage() {
160
- if ( is_callable( array( $this, 'options_page' ) ) ) {
161
- add_options_page( $this->_pageTitle, $this->_menuTitle, $this->_accessLevel, $this->_hook, array( $this, 'options_page' ), 'http://cdn.xavisys.com/logos/xavisys-logo-32.png' );
162
  }
163
  }
164
 
@@ -186,25 +223,41 @@ if (!class_exists('XavisysPlugin')) {
186
  $sidebarBoxes = array_filter( $allBoxes, array( $this, '_filterBoxesSidebar' ) );
187
  unset($sidebarBoxes['sidebar']);
188
  sort($sidebarBoxes);
 
 
189
  ?>
190
  <div class="wrap">
191
  <?php $this->screenIconLink(); ?>
192
  <h2><?php echo esc_html($this->_pageTitle); ?></h2>
193
  <div class="metabox-holder">
194
- <div class="postbox-container" style="width:75%;">
195
- <form action="options.php" method="post">
196
- <?php settings_fields( $this->_optionGroup ); ?>
197
- <?php do_meta_boxes( 'xavisys-' . $this->_slug, 'main', '' ); ?>
 
 
 
 
 
 
 
198
  <p class="submit">
199
  <input type="submit" name="Submit" value="<?php esc_attr_e('Update Options &raquo;', $this->_slug); ?>" />
200
  </p>
 
 
 
201
  </form>
202
- <?php
 
203
  foreach( $mainBoxes as $context ) {
204
  do_meta_boxes( 'xavisys-' . $this->_slug, $context, '' );
205
  }
206
- ?>
207
  </div>
 
 
 
208
  <div class="postbox-container" style="width:24%;">
209
  <?php
210
  foreach( $sidebarBoxes as $context ) {
@@ -212,6 +265,9 @@ if (!class_exists('XavisysPlugin')) {
212
  }
213
  ?>
214
  </div>
 
 
 
215
  </div>
216
  </div>
217
  <?php
@@ -276,9 +332,15 @@ if (!class_exists('XavisysPlugin')) {
276
  }
277
 
278
  public function addDefaultOptionsMetaBoxes() {
279
- add_meta_box( $this->_slug . '-like-this', __('Like this Plugin?', $this->_slug), array($this, 'likeThisMetaBox'), 'xavisys-' . $this->_slug, 'sidebar');
280
- add_meta_box( $this->_slug . '-support', __('Need Support?', $this->_slug), array($this, 'supportMetaBox'), 'xavisys-' . $this->_slug, 'sidebar');
281
- add_meta_box( $this->_slug . '-xavisys-feed', __('Latest news from Xavisys', $this->_slug), array($this, 'xavisysFeedMetaBox'), 'xavisys-' . $this->_slug, 'sidebar');
 
 
 
 
 
 
282
  }
283
 
284
  public function likeThisMetaBox() {
@@ -309,7 +371,7 @@ if (!class_exists('XavisysPlugin')) {
309
 
310
  public function xavisysFeedMetaBox() {
311
  $args = array(
312
- 'url' => 'http://xavisys.com/feed/',
313
  'items' => '5',
314
  );
315
  echo '<div class="rss-widget">';
@@ -318,12 +380,14 @@ if (!class_exists('XavisysPlugin')) {
318
  }
319
 
320
  public function addDashboardWidgets() {
321
- wp_add_dashboard_widget( 'dashboardb_xavisys' , 'The Latest News From Xavisys' , array( $this, 'dashboardWidget' ) );
 
 
322
  }
323
 
324
  public function dashboardWidget() {
325
  $args = array(
326
- 'url' => 'http://xavisys.com/feed/',
327
  'items' => '3',
328
  'show_date' => 1,
329
  'show_summary' => 1,
@@ -332,18 +396,24 @@ if (!class_exists('XavisysPlugin')) {
332
  echo '<a href="http://xavisys.com"><img class="alignright" src="http://cdn.xavisys.com/logos/xavisys-logo-small.png" /></a>';
333
  wp_widget_rss_output( $args );
334
  echo '<p style="border-top: 1px solid #CCC; padding-top: 10px; font-weight: bold;">';
335
- echo '<a href="http://xavisys.com/feed/"><img src="'.get_bloginfo('wpurl').'/wp-includes/images/rss.png" alt=""/> Subscribe with RSS</a>';
336
  echo "</p>";
337
  echo "</div>";
338
  }
339
 
340
  public function screenIconLink($name = 'xavisys') {
341
- echo '<a href="http://xavisys.com">';
342
- screen_icon($name);
343
- echo '</a>';
 
 
 
 
 
 
 
344
  }
345
 
346
-
347
  public function optionsPageScripts() {
348
  if (isset($_GET['page']) && $_GET['page'] == $this->_hook) {
349
  wp_enqueue_script('postbox');
1
  <?php
2
  /**
3
+ * Version: 1.0.13
4
  */
5
  /**
6
  * Changelog:
7
  *
8
+ * 1.0.13:
9
+ * - Add the 'xpf-dashboard-widget' filter
10
+ *
11
+ * 1.0.12:
12
+ * - Add the xpf-show-general-settings-submit filter
13
+ *
14
+ * 1.0.11:
15
+ * - Add the xpf-pre-main-metabox action
16
+ *
17
+ * 1.0.10:
18
+ * - Allow the screen icon to be overridden
19
+ *
20
+ * 1.0.9:
21
+ * - Allow removal of Xavisys sidebar boxes
22
+ *
23
+ * 1.0.8:
24
+ * - Allow an auto-created options page that doesn't have a main meta box
25
+ *
26
+ * 1.0.7:
27
+ * - Add the ability to modify the form action on the options page
28
+ * - Add an action in the options page form tag
29
+ *
30
+ * 1.0.6:
31
+ * - Add ability to not have a settings page
32
+ *
33
+ * 1.0.5:
34
+ * - Added XavisysPlugin::_feed_url
35
+ * - Changed feed to the feed burner URL because of a redirect issue with 2.9.x
36
+ *
37
  * 1.0.4:
38
  * - Added donate link to the plugin meta
39
  *
97
  */
98
  protected $_slug = '';
99
 
100
+ /**
101
+ * @var string - The feed URL for Xavisys
102
+ */
103
+ //protected $_feed_url = 'http://xavisys.com/feed/';
104
+ protected $_feed_url = 'http://feeds.feedburner.com/Xavisys';
105
+
106
  /**
107
  * @var string - The button ID for the PayPal button, override this generic one with a plugin-specific one
108
  */
109
  protected $_paypalButtonId = '9925248';
110
 
111
+ protected $_optionsPageAction = 'options.php';
112
+
113
  /**
114
  * This is our constructor, which is private to force the use of getInstance()
115
  * @return void
194
  }
195
 
196
  public function registerOptionsPage() {
197
+ if ( apply_filters( 'xpf-options_page-'.$this->_slug, true ) && is_callable( array( $this, 'options_page' ) ) ) {
198
+ add_options_page( $this->_pageTitle, $this->_menuTitle, $this->_accessLevel, $this->_hook, array( $this, 'options_page' ) );
199
  }
200
  }
201
 
223
  $sidebarBoxes = array_filter( $allBoxes, array( $this, '_filterBoxesSidebar' ) );
224
  unset($sidebarBoxes['sidebar']);
225
  sort($sidebarBoxes);
226
+
227
+ $main_width = empty( $sidebarBoxes )? '100%' : '75%';
228
  ?>
229
  <div class="wrap">
230
  <?php $this->screenIconLink(); ?>
231
  <h2><?php echo esc_html($this->_pageTitle); ?></h2>
232
  <div class="metabox-holder">
233
+ <div class="postbox-container" style="width:<?php echo $main_width; ?>;">
234
+ <?php
235
+ do_action( 'xpf-pre-main-metabox', $main_width );
236
+ if ( in_array( 'main', $allBoxes ) ) {
237
+ ?>
238
+ <form action="<?php esc_attr_e( $this->_optionsPageAction ); ?>" method="post"<?php do_action( 'xpf-options-page-form-tag' ) ?>>
239
+ <?php
240
+ settings_fields( $this->_optionGroup );
241
+ do_meta_boxes( 'xavisys-' . $this->_slug, 'main', '' );
242
+ if ( apply_filters( 'xpf-show-general-settings-submit'.$this->_slug, true ) ) {
243
+ ?>
244
  <p class="submit">
245
  <input type="submit" name="Submit" value="<?php esc_attr_e('Update Options &raquo;', $this->_slug); ?>" />
246
  </p>
247
+ <?php
248
+ }
249
+ ?>
250
  </form>
251
+ <?php
252
+ }
253
  foreach( $mainBoxes as $context ) {
254
  do_meta_boxes( 'xavisys-' . $this->_slug, $context, '' );
255
  }
256
+ ?>
257
  </div>
258
+ <?php
259
+ if ( !empty( $sidebarBoxes ) ) {
260
+ ?>
261
  <div class="postbox-container" style="width:24%;">
262
  <?php
263
  foreach( $sidebarBoxes as $context ) {
265
  }
266
  ?>
267
  </div>
268
+ <?php
269
+ }
270
+ ?>
271
  </div>
272
  </div>
273
  <?php
332
  }
333
 
334
  public function addDefaultOptionsMetaBoxes() {
335
+ if ( apply_filters( 'show-xavisys-like-this', true ) ) {
336
+ add_meta_box( $this->_slug . '-like-this', __('Like this Plugin?', $this->_slug), array($this, 'likeThisMetaBox'), 'xavisys-' . $this->_slug, 'sidebar');
337
+ }
338
+ if ( apply_filters( 'show-xavisys-support', true ) ) {
339
+ add_meta_box( $this->_slug . '-support', __('Need Support?', $this->_slug), array($this, 'supportMetaBox'), 'xavisys-' . $this->_slug, 'sidebar');
340
+ }
341
+ if ( apply_filters( 'show-xavisys-feed', true ) ) {
342
+ add_meta_box( $this->_slug . '-xavisys-feed', __('Latest news from Xavisys', $this->_slug), array($this, 'xavisysFeedMetaBox'), 'xavisys-' . $this->_slug, 'sidebar');
343
+ }
344
  }
345
 
346
  public function likeThisMetaBox() {
371
 
372
  public function xavisysFeedMetaBox() {
373
  $args = array(
374
+ 'url' => $this->_feed_url,
375
  'items' => '5',
376
  );
377
  echo '<div class="rss-widget">';
380
  }
381
 
382
  public function addDashboardWidgets() {
383
+ if ( apply_filters( 'xpf-dashboard-widget', true ) ) {
384
+ wp_add_dashboard_widget( 'dashboardb_xavisys' , 'The Latest News From Xavisys' , array( $this, 'dashboardWidget' ) );
385
+ }
386
  }
387
 
388
  public function dashboardWidget() {
389
  $args = array(
390
+ 'url' => $this->_feed_url,
391
  'items' => '3',
392
  'show_date' => 1,
393
  'show_summary' => 1,
396
  echo '<a href="http://xavisys.com"><img class="alignright" src="http://cdn.xavisys.com/logos/xavisys-logo-small.png" /></a>';
397
  wp_widget_rss_output( $args );
398
  echo '<p style="border-top: 1px solid #CCC; padding-top: 10px; font-weight: bold;">';
399
+ echo '<a href="' . $this->_feed_url . '"><img src="'.get_bloginfo('wpurl').'/wp-includes/images/rss.png" alt=""/> Subscribe with RSS</a>';
400
  echo "</p>";
401
  echo "</div>";
402
  }
403
 
404
  public function screenIconLink($name = 'xavisys') {
405
+ $link = '<a href="http://xavisys.com">';
406
+ if ( function_exists( 'get_screen_icon' ) ) {
407
+ $link .= get_screen_icon( $name );
408
+ } else {
409
+ ob_start();
410
+ screen_icon($name);
411
+ $link .= ob_get_clean();
412
+ }
413
+ $link .= '</a>';
414
+ echo apply_filters('xpf-screenIconLink', $link, $name );
415
  }
416
 
 
417
  public function optionsPageScripts() {
418
  if (isset($_GET['page']) && $_GET['page'] == $this->_hook) {
419
  wp_enqueue_script('postbox');