PowerPress Podcasting plugin by Blubrry - Version 0.8.0

Version Description

Download this release

Release Info

Developer amandato
Plugin Icon 128x128 PowerPress Podcasting plugin by Blubrry
Version 0.8.0
Comparing to
See all releases

Code changes from version 0.7.3 to 0.8.0

3rdparty/JSON.php ADDED
@@ -0,0 +1,806 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
+
4
+ /**
5
+ * Converts to and from JSON format.
6
+ *
7
+ * JSON (JavaScript Object Notation) is a lightweight data-interchange
8
+ * format. It is easy for humans to read and write. It is easy for machines
9
+ * to parse and generate. It is based on a subset of the JavaScript
10
+ * Programming Language, Standard ECMA-262 3rd Edition - December 1999.
11
+ * This feature can also be found in Python. JSON is a text format that is
12
+ * completely language independent but uses conventions that are familiar
13
+ * to programmers of the C-family of languages, including C, C++, C#, Java,
14
+ * JavaScript, Perl, TCL, and many others. These properties make JSON an
15
+ * ideal data-interchange language.
16
+ *
17
+ * This package provides a simple encoder and decoder for JSON notation. It
18
+ * is intended for use with client-side Javascript applications that make
19
+ * use of HTTPRequest to perform server communication functions - data can
20
+ * be encoded into JSON notation for use in a client-side javascript, or
21
+ * decoded from incoming Javascript requests. JSON format is native to
22
+ * Javascript, and can be directly eval()'ed with no further parsing
23
+ * overhead
24
+ *
25
+ * All strings should be in ASCII or UTF-8 format!
26
+ *
27
+ * LICENSE: Redistribution and use in source and binary forms, with or
28
+ * without modification, are permitted provided that the following
29
+ * conditions are met: Redistributions of source code must retain the
30
+ * above copyright notice, this list of conditions and the following
31
+ * disclaimer. Redistributions in binary form must reproduce the above
32
+ * copyright notice, this list of conditions and the following disclaimer
33
+ * in the documentation and/or other materials provided with the
34
+ * distribution.
35
+ *
36
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
37
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
38
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
39
+ * NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
40
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
41
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
42
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
44
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
45
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
46
+ * DAMAGE.
47
+ *
48
+ * @category
49
+ * @package Services_JSON
50
+ * @author Michal Migurski <mike-json@teczno.com>
51
+ * @author Matt Knapp <mdknapp[at]gmail[dot]com>
52
+ * @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
53
+ * @copyright 2005 Michal Migurski
54
+ * @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
55
+ * @license http://www.opensource.org/licenses/bsd-license.php
56
+ * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
57
+ */
58
+
59
+ /**
60
+ * Marker constant for Services_JSON::decode(), used to flag stack state
61
+ */
62
+ define('SERVICES_JSON_SLICE', 1);
63
+
64
+ /**
65
+ * Marker constant for Services_JSON::decode(), used to flag stack state
66
+ */
67
+ define('SERVICES_JSON_IN_STR', 2);
68
+
69
+ /**
70
+ * Marker constant for Services_JSON::decode(), used to flag stack state
71
+ */
72
+ define('SERVICES_JSON_IN_ARR', 3);
73
+
74
+ /**
75
+ * Marker constant for Services_JSON::decode(), used to flag stack state
76
+ */
77
+ define('SERVICES_JSON_IN_OBJ', 4);
78
+
79
+ /**
80
+ * Marker constant for Services_JSON::decode(), used to flag stack state
81
+ */
82
+ define('SERVICES_JSON_IN_CMT', 5);
83
+
84
+ /**
85
+ * Behavior switch for Services_JSON::decode()
86
+ */
87
+ define('SERVICES_JSON_LOOSE_TYPE', 16);
88
+
89
+ /**
90
+ * Behavior switch for Services_JSON::decode()
91
+ */
92
+ define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
93
+
94
+ /**
95
+ * Converts to and from JSON format.
96
+ *
97
+ * Brief example of use:
98
+ *
99
+ * <code>
100
+ * // create a new instance of Services_JSON
101
+ * $json = new Services_JSON();
102
+ *
103
+ * // convert a complexe value to JSON notation, and send it to the browser
104
+ * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
105
+ * $output = $json->encode($value);
106
+ *
107
+ * print($output);
108
+ * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
109
+ *
110
+ * // accept incoming POST data, assumed to be in JSON notation
111
+ * $input = file_get_contents('php://input', 1000000);
112
+ * $value = $json->decode($input);
113
+ * </code>
114
+ */
115
+ class Services_JSON
116
+ {
117
+ /**
118
+ * constructs a new JSON instance
119
+ *
120
+ * @param int $use object behavior flags; combine with boolean-OR
121
+ *
122
+ * possible values:
123
+ * - SERVICES_JSON_LOOSE_TYPE: loose typing.
124
+ * "{...}" syntax creates associative arrays
125
+ * instead of objects in decode().
126
+ * - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
127
+ * Values which can't be encoded (e.g. resources)
128
+ * appear as NULL instead of throwing errors.
129
+ * By default, a deeply-nested resource will
130
+ * bubble up with an error, so all return values
131
+ * from encode() should be checked with isError()
132
+ */
133
+ function Services_JSON($use = 0)
134
+ {
135
+ $this->use = $use;
136
+ }
137
+
138
+ /**
139
+ * convert a string from one UTF-16 char to one UTF-8 char
140
+ *
141
+ * Normally should be handled by mb_convert_encoding, but
142
+ * provides a slower PHP-only method for installations
143
+ * that lack the multibye string extension.
144
+ *
145
+ * @param string $utf16 UTF-16 character
146
+ * @return string UTF-8 character
147
+ * @access private
148
+ */
149
+ function utf162utf8($utf16)
150
+ {
151
+ // oh please oh please oh please oh please oh please
152
+ if(function_exists('mb_convert_encoding')) {
153
+ return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
154
+ }
155
+
156
+ $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
157
+
158
+ switch(true) {
159
+ case ((0x7F & $bytes) == $bytes):
160
+ // this case should never be reached, because we are in ASCII range
161
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
162
+ return chr(0x7F & $bytes);
163
+
164
+ case (0x07FF & $bytes) == $bytes:
165
+ // return a 2-byte UTF-8 character
166
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
167
+ return chr(0xC0 | (($bytes >> 6) & 0x1F))
168
+ . chr(0x80 | ($bytes & 0x3F));
169
+
170
+ case (0xFFFF & $bytes) == $bytes:
171
+ // return a 3-byte UTF-8 character
172
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
173
+ return chr(0xE0 | (($bytes >> 12) & 0x0F))
174
+ . chr(0x80 | (($bytes >> 6) & 0x3F))
175
+ . chr(0x80 | ($bytes & 0x3F));
176
+ }
177
+
178
+ // ignoring UTF-32 for now, sorry
179
+ return '';
180
+ }
181
+
182
+ /**
183
+ * convert a string from one UTF-8 char to one UTF-16 char
184
+ *
185
+ * Normally should be handled by mb_convert_encoding, but
186
+ * provides a slower PHP-only method for installations
187
+ * that lack the multibye string extension.
188
+ *
189
+ * @param string $utf8 UTF-8 character
190
+ * @return string UTF-16 character
191
+ * @access private
192
+ */
193
+ function utf82utf16($utf8)
194
+ {
195
+ // oh please oh please oh please oh please oh please
196
+ if(function_exists('mb_convert_encoding')) {
197
+ return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
198
+ }
199
+
200
+ switch(strlen($utf8)) {
201
+ case 1:
202
+ // this case should never be reached, because we are in ASCII range
203
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
204
+ return $utf8;
205
+
206
+ case 2:
207
+ // return a UTF-16 character from a 2-byte UTF-8 char
208
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
209
+ return chr(0x07 & (ord($utf8{0}) >> 2))
210
+ . chr((0xC0 & (ord($utf8{0}) << 6))
211
+ | (0x3F & ord($utf8{1})));
212
+
213
+ case 3:
214
+ // return a UTF-16 character from a 3-byte UTF-8 char
215
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
216
+ return chr((0xF0 & (ord($utf8{0}) << 4))
217
+ | (0x0F & (ord($utf8{1}) >> 2)))
218
+ . chr((0xC0 & (ord($utf8{1}) << 6))
219
+ | (0x7F & ord($utf8{2})));
220
+ }
221
+
222
+ // ignoring UTF-32 for now, sorry
223
+ return '';
224
+ }
225
+
226
+ /**
227
+ * encodes an arbitrary variable into JSON format
228
+ *
229
+ * @param mixed $var any number, boolean, string, array, or object to be encoded.
230
+ * see argument 1 to Services_JSON() above for array-parsing behavior.
231
+ * if var is a strng, note that encode() always expects it
232
+ * to be in ASCII or UTF-8 format!
233
+ *
234
+ * @return mixed JSON string representation of input var or an error if a problem occurs
235
+ * @access public
236
+ */
237
+ function encode($var)
238
+ {
239
+ switch (gettype($var)) {
240
+ case 'boolean':
241
+ return $var ? 'true' : 'false';
242
+
243
+ case 'NULL':
244
+ return 'null';
245
+
246
+ case 'integer':
247
+ return (int) $var;
248
+
249
+ case 'double':
250
+ case 'float':
251
+ return (float) $var;
252
+
253
+ case 'string':
254
+ // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
255
+ $ascii = '';
256
+ $strlen_var = strlen($var);
257
+
258
+ /*
259
+ * Iterate over every character in the string,
260
+ * escaping with a slash or encoding to UTF-8 where necessary
261
+ */
262
+ for ($c = 0; $c < $strlen_var; ++$c) {
263
+
264
+ $ord_var_c = ord($var{$c});
265
+
266
+ switch (true) {
267
+ case $ord_var_c == 0x08:
268
+ $ascii .= '\b';
269
+ break;
270
+ case $ord_var_c == 0x09:
271
+ $ascii .= '\t';
272
+ break;
273
+ case $ord_var_c == 0x0A:
274
+ $ascii .= '\n';
275
+ break;
276
+ case $ord_var_c == 0x0C:
277
+ $ascii .= '\f';
278
+ break;
279
+ case $ord_var_c == 0x0D:
280
+ $ascii .= '\r';
281
+ break;
282
+
283
+ case $ord_var_c == 0x22:
284
+ case $ord_var_c == 0x2F:
285
+ case $ord_var_c == 0x5C:
286
+ // double quote, slash, slosh
287
+ $ascii .= '\\'.$var{$c};
288
+ break;
289
+
290
+ case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
291
+ // characters U-00000000 - U-0000007F (same as ASCII)
292
+ $ascii .= $var{$c};
293
+ break;
294
+
295
+ case (($ord_var_c & 0xE0) == 0xC0):
296
+ // characters U-00000080 - U-000007FF, mask 110XXXXX
297
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
298
+ $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
299
+ $c += 1;
300
+ $utf16 = $this->utf82utf16($char);
301
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
302
+ break;
303
+
304
+ case (($ord_var_c & 0xF0) == 0xE0):
305
+ // characters U-00000800 - U-0000FFFF, mask 1110XXXX
306
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
307
+ $char = pack('C*', $ord_var_c,
308
+ ord($var{$c + 1}),
309
+ ord($var{$c + 2}));
310
+ $c += 2;
311
+ $utf16 = $this->utf82utf16($char);
312
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
313
+ break;
314
+
315
+ case (($ord_var_c & 0xF8) == 0xF0):
316
+ // characters U-00010000 - U-001FFFFF, mask 11110XXX
317
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
318
+ $char = pack('C*', $ord_var_c,
319
+ ord($var{$c + 1}),
320
+ ord($var{$c + 2}),
321
+ ord($var{$c + 3}));
322
+ $c += 3;
323
+ $utf16 = $this->utf82utf16($char);
324
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
325
+ break;
326
+
327
+ case (($ord_var_c & 0xFC) == 0xF8):
328
+ // characters U-00200000 - U-03FFFFFF, mask 111110XX
329
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
330
+ $char = pack('C*', $ord_var_c,
331
+ ord($var{$c + 1}),
332
+ ord($var{$c + 2}),
333
+ ord($var{$c + 3}),
334
+ ord($var{$c + 4}));
335
+ $c += 4;
336
+ $utf16 = $this->utf82utf16($char);
337
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
338
+ break;
339
+
340
+ case (($ord_var_c & 0xFE) == 0xFC):
341
+ // characters U-04000000 - U-7FFFFFFF, mask 1111110X
342
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
343
+ $char = pack('C*', $ord_var_c,
344
+ ord($var{$c + 1}),
345
+ ord($var{$c + 2}),
346
+ ord($var{$c + 3}),
347
+ ord($var{$c + 4}),
348
+ ord($var{$c + 5}));
349
+ $c += 5;
350
+ $utf16 = $this->utf82utf16($char);
351
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
352
+ break;
353
+ }
354
+ }
355
+
356
+ return '"'.$ascii.'"';
357
+
358
+ case 'array':
359
+ /*
360
+ * As per JSON spec if any array key is not an integer
361
+ * we must treat the the whole array as an object. We
362
+ * also try to catch a sparsely populated associative
363
+ * array with numeric keys here because some JS engines
364
+ * will create an array with empty indexes up to
365
+ * max_index which can cause memory issues and because
366
+ * the keys, which may be relevant, will be remapped
367
+ * otherwise.
368
+ *
369
+ * As per the ECMA and JSON specification an object may
370
+ * have any string as a property. Unfortunately due to
371
+ * a hole in the ECMA specification if the key is a
372
+ * ECMA reserved word or starts with a digit the
373
+ * parameter is only accessible using ECMAScript's
374
+ * bracket notation.
375
+ */
376
+
377
+ // treat as a JSON object
378
+ if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
379
+ $properties = array_map(array($this, 'name_value'),
380
+ array_keys($var),
381
+ array_values($var));
382
+
383
+ foreach($properties as $property) {
384
+ if(Services_JSON::isError($property)) {
385
+ return $property;
386
+ }
387
+ }
388
+
389
+ return '{' . join(',', $properties) . '}';
390
+ }
391
+
392
+ // treat it like a regular array
393
+ $elements = array_map(array($this, 'encode'), $var);
394
+
395
+ foreach($elements as $element) {
396
+ if(Services_JSON::isError($element)) {
397
+ return $element;
398
+ }
399
+ }
400
+
401
+ return '[' . join(',', $elements) . ']';
402
+
403
+ case 'object':
404
+ $vars = get_object_vars($var);
405
+
406
+ $properties = array_map(array($this, 'name_value'),
407
+ array_keys($vars),
408
+ array_values($vars));
409
+
410
+ foreach($properties as $property) {
411
+ if(Services_JSON::isError($property)) {
412
+ return $property;
413
+ }
414
+ }
415
+
416
+ return '{' . join(',', $properties) . '}';
417
+
418
+ default:
419
+ return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
420
+ ? 'null'
421
+ : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
422
+ }
423
+ }
424
+
425
+ /**
426
+ * array-walking function for use in generating JSON-formatted name-value pairs
427
+ *
428
+ * @param string $name name of key to use
429
+ * @param mixed $value reference to an array element to be encoded
430
+ *
431
+ * @return string JSON-formatted name-value pair, like '"name":value'
432
+ * @access private
433
+ */
434
+ function name_value($name, $value)
435
+ {
436
+ $encoded_value = $this->encode($value);
437
+
438
+ if(Services_JSON::isError($encoded_value)) {
439
+ return $encoded_value;
440
+ }
441
+
442
+ return $this->encode(strval($name)) . ':' . $encoded_value;
443
+ }
444
+
445
+ /**
446
+ * reduce a string by removing leading and trailing comments and whitespace
447
+ *
448
+ * @param $str string string value to strip of comments and whitespace
449
+ *
450
+ * @return string string value stripped of comments and whitespace
451
+ * @access private
452
+ */
453
+ function reduce_string($str)
454
+ {
455
+ $str = preg_replace(array(
456
+
457
+ // eliminate single line comments in '// ...' form
458
+ '#^\s*//(.+)$#m',
459
+
460
+ // eliminate multi-line comments in '/* ... */' form, at start of string
461
+ '#^\s*/\*(.+)\*/#Us',
462
+
463
+ // eliminate multi-line comments in '/* ... */' form, at end of string
464
+ '#/\*(.+)\*/\s*$#Us'
465
+
466
+ ), '', $str);
467
+
468
+ // eliminate extraneous space
469
+ return trim($str);
470
+ }
471
+
472
+ /**
473
+ * decodes a JSON string into appropriate variable
474
+ *
475
+ * @param string $str JSON-formatted string
476
+ *
477
+ * @return mixed number, boolean, string, array, or object
478
+ * corresponding to given JSON input string.
479
+ * See argument 1 to Services_JSON() above for object-output behavior.
480
+ * Note that decode() always returns strings
481
+ * in ASCII or UTF-8 format!
482
+ * @access public
483
+ */
484
+ function decode($str)
485
+ {
486
+ $str = $this->reduce_string($str);
487
+
488
+ switch (strtolower($str)) {
489
+ case 'true':
490
+ return true;
491
+
492
+ case 'false':
493
+ return false;
494
+
495
+ case 'null':
496
+ return null;
497
+
498
+ default:
499
+ $m = array();
500
+
501
+ if (is_numeric($str)) {
502
+ // Lookie-loo, it's a number
503
+
504
+ // This would work on its own, but I'm trying to be
505
+ // good about returning integers where appropriate:
506
+ // return (float)$str;
507
+
508
+ // Return float or int, as appropriate
509
+ return ((float)$str == (integer)$str)
510
+ ? (integer)$str
511
+ : (float)$str;
512
+
513
+ } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
514
+ // STRINGS RETURNED IN UTF-8 FORMAT
515
+ $delim = substr($str, 0, 1);
516
+ $chrs = substr($str, 1, -1);
517
+ $utf8 = '';
518
+ $strlen_chrs = strlen($chrs);
519
+
520
+ for ($c = 0; $c < $strlen_chrs; ++$c) {
521
+
522
+ $substr_chrs_c_2 = substr($chrs, $c, 2);
523
+ $ord_chrs_c = ord($chrs{$c});
524
+
525
+ switch (true) {
526
+ case $substr_chrs_c_2 == '\b':
527
+ $utf8 .= chr(0x08);
528
+ ++$c;
529
+ break;
530
+ case $substr_chrs_c_2 == '\t':
531
+ $utf8 .= chr(0x09);
532
+ ++$c;
533
+ break;
534
+ case $substr_chrs_c_2 == '\n':
535
+ $utf8 .= chr(0x0A);
536
+ ++$c;
537
+ break;
538
+ case $substr_chrs_c_2 == '\f':
539
+ $utf8 .= chr(0x0C);
540
+ ++$c;
541
+ break;
542
+ case $substr_chrs_c_2 == '\r':
543
+ $utf8 .= chr(0x0D);
544
+ ++$c;
545
+ break;
546
+
547
+ case $substr_chrs_c_2 == '\\"':
548
+ case $substr_chrs_c_2 == '\\\'':
549
+ case $substr_chrs_c_2 == '\\\\':
550
+ case $substr_chrs_c_2 == '\\/':
551
+ if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
552
+ ($delim == "'" && $substr_chrs_c_2 != '\\"')) {
553
+ $utf8 .= $chrs{++$c};
554
+ }
555
+ break;
556
+
557
+ case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
558
+ // single, escaped unicode character
559
+ $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
560
+ . chr(hexdec(substr($chrs, ($c + 4), 2)));
561
+ $utf8 .= $this->utf162utf8($utf16);
562
+ $c += 5;
563
+ break;
564
+
565
+ case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
566
+ $utf8 .= $chrs{$c};
567
+ break;
568
+
569
+ case ($ord_chrs_c & 0xE0) == 0xC0:
570
+ // characters U-00000080 - U-000007FF, mask 110XXXXX
571
+ //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
572
+ $utf8 .= substr($chrs, $c, 2);
573
+ ++$c;
574
+ break;
575
+
576
+ case ($ord_chrs_c & 0xF0) == 0xE0:
577
+ // characters U-00000800 - U-0000FFFF, mask 1110XXXX
578
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
579
+ $utf8 .= substr($chrs, $c, 3);
580
+ $c += 2;
581
+ break;
582
+
583
+ case ($ord_chrs_c & 0xF8) == 0xF0:
584
+ // characters U-00010000 - U-001FFFFF, mask 11110XXX
585
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
586
+ $utf8 .= substr($chrs, $c, 4);
587
+ $c += 3;
588
+ break;
589
+
590
+ case ($ord_chrs_c & 0xFC) == 0xF8:
591
+ // characters U-00200000 - U-03FFFFFF, mask 111110XX
592
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
593
+ $utf8 .= substr($chrs, $c, 5);
594
+ $c += 4;
595
+ break;
596
+
597
+ case ($ord_chrs_c & 0xFE) == 0xFC:
598
+ // characters U-04000000 - U-7FFFFFFF, mask 1111110X
599
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
600
+ $utf8 .= substr($chrs, $c, 6);
601
+ $c += 5;
602
+ break;
603
+
604
+ }
605
+
606
+ }
607
+
608
+ return $utf8;
609
+
610
+ } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
611
+ // array, or object notation
612
+
613
+ if ($str{0} == '[') {
614
+ $stk = array(SERVICES_JSON_IN_ARR);
615
+ $arr = array();
616
+ } else {
617
+ if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
618
+ $stk = array(SERVICES_JSON_IN_OBJ);
619
+ $obj = array();
620
+ } else {
621
+ $stk = array(SERVICES_JSON_IN_OBJ);
622
+ $obj = new stdClass();
623
+ }
624
+ }
625
+
626
+ array_push($stk, array('what' => SERVICES_JSON_SLICE,
627
+ 'where' => 0,
628
+ 'delim' => false));
629
+
630
+ $chrs = substr($str, 1, -1);
631
+ $chrs = $this->reduce_string($chrs);
632
+
633
+ if ($chrs == '') {
634
+ if (reset($stk) == SERVICES_JSON_IN_ARR) {
635
+ return $arr;
636
+
637
+ } else {
638
+ return $obj;
639
+
640
+ }
641
+ }
642
+
643
+ //print("\nparsing {$chrs}\n");
644
+
645
+ $strlen_chrs = strlen($chrs);
646
+
647
+ for ($c = 0; $c <= $strlen_chrs; ++$c) {
648
+
649
+ $top = end($stk);
650
+ $substr_chrs_c_2 = substr($chrs, $c, 2);
651
+
652
+ if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
653
+ // found a comma that is not inside a string, array, etc.,
654
+ // OR we've reached the end of the character list
655
+ $slice = substr($chrs, $top['where'], ($c - $top['where']));
656
+ array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
657
+ //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
658
+
659
+ if (reset($stk) == SERVICES_JSON_IN_ARR) {
660
+ // we are in an array, so just push an element onto the stack
661
+ array_push($arr, $this->decode($slice));
662
+
663
+ } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
664
+ // we are in an object, so figure
665
+ // out the property name and set an
666
+ // element in an associative array,
667
+ // for now
668
+ $parts = array();
669
+
670
+ if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
671
+ // "name":value pair
672
+ $key = $this->decode($parts[1]);
673
+ $val = $this->decode($parts[2]);
674
+
675
+ if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
676
+ $obj[$key] = $val;
677
+ } else {
678
+ $obj->$key = $val;
679
+ }
680
+ } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
681
+ // name:value pair, where name is unquoted
682
+ $key = $parts[1];
683
+ $val = $this->decode($parts[2]);
684
+
685
+ if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
686
+ $obj[$key] = $val;
687
+ } else {
688
+ $obj->$key = $val;
689
+ }
690
+ }
691
+
692
+ }
693
+
694
+ } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
695
+ // found a quote, and we are not inside a string
696
+ array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
697
+ //print("Found start of string at {$c}\n");
698
+
699
+ } elseif (($chrs{$c} == $top['delim']) &&
700
+ ($top['what'] == SERVICES_JSON_IN_STR) &&
701
+ ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
702
+ // found a quote, we're in a string, and it's not escaped
703
+ // we know that it's not escaped becase there is _not_ an
704
+ // odd number of backslashes at the end of the string so far
705
+ array_pop($stk);
706
+ //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
707
+
708
+ } elseif (($chrs{$c} == '[') &&
709
+ in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
710
+ // found a left-bracket, and we are in an array, object, or slice
711
+ array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
712
+ //print("Found start of array at {$c}\n");
713
+
714
+ } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
715
+ // found a right-bracket, and we're in an array
716
+ array_pop($stk);
717
+ //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
718
+
719
+ } elseif (($chrs{$c} == '{') &&
720
+ in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
721
+ // found a left-brace, and we are in an array, object, or slice
722
+ array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
723
+ //print("Found start of object at {$c}\n");
724
+
725
+ } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
726
+ // found a right-brace, and we're in an object
727
+ array_pop($stk);
728
+ //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
729
+
730
+ } elseif (($substr_chrs_c_2 == '/*') &&
731
+ in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
732
+ // found a comment start, and we are in an array, object, or slice
733
+ array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
734
+ $c++;
735
+ //print("Found start of comment at {$c}\n");
736
+
737
+ } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
738
+ // found a comment end, and we're in one now
739
+ array_pop($stk);
740
+ $c++;
741
+
742
+ for ($i = $top['where']; $i <= $c; ++$i)
743
+ $chrs = substr_replace($chrs, ' ', $i, 1);
744
+
745
+ //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
746
+
747
+ }
748
+
749
+ }
750
+
751
+ if (reset($stk) == SERVICES_JSON_IN_ARR) {
752
+ return $arr;
753
+
754
+ } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
755
+ return $obj;
756
+
757
+ }
758
+
759
+ }
760
+ }
761
+ }
762
+
763
+ /**
764
+ * @todo Ultimately, this should just call PEAR::isError()
765
+ */
766
+ function isError($data, $code = null)
767
+ {
768
+ if (class_exists('pear')) {
769
+ return PEAR::isError($data, $code);
770
+ } elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
771
+ is_subclass_of($data, 'services_json_error'))) {
772
+ return true;
773
+ }
774
+
775
+ return false;
776
+ }
777
+ }
778
+
779
+ if (class_exists('PEAR_Error')) {
780
+
781
+ class Services_JSON_Error extends PEAR_Error
782
+ {
783
+ function Services_JSON_Error($message = 'unknown error', $code = null,
784
+ $mode = null, $options = null, $userinfo = null)
785
+ {
786
+ parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
787
+ }
788
+ }
789
+
790
+ } else {
791
+
792
+ /**
793
+ * @todo Ultimately, this class shall be descended from PEAR_Error
794
+ */
795
+ class Services_JSON_Error
796
+ {
797
+ function Services_JSON_Error($message = 'unknown error', $code = null,
798
+ $mode = null, $options = null, $userinfo = null)
799
+ {
800
+
801
+ }
802
+ }
803
+
804
+ }
805
+
806
+ ?>
css/jquery.css ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* jquery.css */
2
+ body {
3
+ font-family: Arial, Helvetica, sans-serif;
4
+
5
+ /* background-color: #D2E9FF; */
6
+ }
7
+ img {
8
+ border: 0;
9
+ }
10
+ #accountinfo label, h1, h2, h3, h4, h5, a {
11
+ color: #3D517E;
12
+ }
13
+ input[type="button"],
14
+ input[type="submit"] {
15
+ font-family: Geneva, Arial, Helvetica, sans-serif;
16
+ text-decoration: none;
17
+ font-size: 14px !important;
18
+ line-height: 16px;
19
+ cursor: pointer;
20
+ border-width: 1px;
21
+ border-style: solid;
22
+ border-color:#99ADC2;
23
+ -moz-border-radius: 5px;
24
+ -khtml-border-radius: 5px;
25
+ -webkit-border-radius: 5px;
26
+ border-radius: 5px;
27
+ -moz-box-sizing: content-box;
28
+ -webkit-box-sizing: content-box;
29
+ -khtml-box-sizing: content-box;
30
+ box-sizing: content-box;
31
+ background-color: #E8F4FF;
32
+ color: #003366;
33
+ font-weight: bold;
34
+ padding-top: 2px;
35
+ padding-right: 8px;
36
+ padding-bottom: 2px;
37
+ padding-left: 8px;
38
+ }
39
+
40
+ ul.media {
41
+
42
+ }
43
+ ul.media li {
44
+ list-style-type: none;
45
+ }
46
+ ul.media li a {
47
+ font-weight: bold;
48
+ }
49
+
50
+ #accountinfo {
51
+
52
+ }
53
+ #accountinfo p {
54
+ font-size: 90%;
55
+ }
56
+ #accountinfo label {
57
+ float: left;
58
+ width: 240px;
59
+ margin-right: 10px;
60
+ display: block;
61
+ font-weight: bold;
62
+ }
63
+ #accountinfo input[type=text], #accountinfo input[type=password] {
64
+ width: 240px;
65
+ }
66
+ #accountinfo select {
67
+ width: 242px;
68
+ }
69
+ .powerpress-notice {
70
+ border: 1px solid #FFCC00;
71
+ font-size: 12px;
72
+ color: #000000;
73
+ background-color: #FFFFCC;
74
+ font-weight: bold;
75
+ padding: 5px;
76
+ margin: 20px;
77
+ }
78
+
79
+ #media-items-container {
80
+ margin: 10px;
81
+ }
82
+ #media-items {
83
+ border-bottom-color: #dfdfdf;
84
+ border-bottom-width: 1px;
85
+ border-bottom-style: solid;
86
+ min-height: 36px;
87
+ width: 100%;
88
+ }
89
+ .media-item {
90
+
91
+ border-top-color: #dfdfdf;
92
+ border-top-width: 1px;
93
+ border-top-style: solid;
94
+ min-height: 36px;
95
+ width: 100%;
96
+
97
+ border-left-color: #dfdfdf;
98
+ border-left-width: 1px;
99
+ border-left-style: solid;
100
+ border-right-color: #dfdfdf;
101
+ border-right-width: 1px;
102
+ border-right-style: solid;
103
+ position: relative;
104
+
105
+ padding-top: 15px;
106
+
107
+ }
108
+ .media-item .media-name {
109
+ margin-left: 10px;
110
+ }
111
+ .media-item-links {
112
+ position: absolute;
113
+ top: 15px;
114
+ right: 10px;
115
+ text-align: right;
116
+ }
images/folder.png ADDED
Binary file
powerpress.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Blubrry PowerPress
4
  Plugin URI: http://www.blubrry.com/powerpress/
5
  Description: <a href="http://www.blubrry.com/powerpress/" target="_blank">Blubrry PowerPress</a> adds podcasting support to your blog. Features include: media player, 3rd party statistics and iTunes integration.
6
- Version: 0.7.3
7
  Author: Blubrry
8
  Author URI: http://www.blubrry.com/
9
  Change Log:
@@ -29,7 +29,7 @@ License: GPL (http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt)
29
  */
30
 
31
  // WP_PLUGIN_DIR (REMEMBER TO USE THIS DEFINE IF NEEDED)
32
- define('POWERPRESS_VERSION', '0.7.3' );
33
 
34
  /////////////////////////////////////////////////////
35
  // The following define options should be placed in your
@@ -347,22 +347,36 @@ function powerpress_rss2_head()
347
  return; // Not a feed we manage
348
 
349
  $feed_slug = get_query_var( 'feed' );
 
350
 
351
- $Feed = get_option('powerpress_feed');
352
- if( powerpress_is_custom_podcast_feed() )
353
  {
354
- $CustomFeed = get_option('powerpress_feed_'.$feed_slug);
355
  if( $CustomFeed )
356
  $Feed = powerpress_merge_empty_feed_settings($CustomFeed, $Feed);
357
  }
 
 
 
 
 
358
 
359
  if( !isset($Feed['url']) || trim($Feed['url']) == '' )
360
- $Feed['url'] = get_bloginfo('url');
361
-
 
 
 
 
362
 
 
363
  // We made it this far, lets write stuff to the feed!
364
- echo '<!-- podcast_generator="Blubrry PowerPress/'. POWERPRESS_VERSION .'" -->'.PHP_EOL;
365
-
 
 
 
366
  // add the itunes:new-feed-url tag to feed
367
  if( powerpress_is_custom_podcast_feed() )
368
  {
@@ -375,12 +389,12 @@ function powerpress_rss2_head()
375
  }
376
 
377
  if( $Feed['itunes_summary'] )
378
- echo "\t".'<itunes:summary>'. powerpress_format_itunes_value( $Feed['itunes_summary'], 4000 ) .'</itunes:summary>'.PHP_EOL;
379
  else
380
- echo "\t".'<itunes:summary>'. powerpress_format_itunes_value( get_bloginfo('description'), 4000 ) .'</itunes:summary>'.PHP_EOL;
381
 
382
  if( $powerpress_feed['itunes_talent_name'] )
383
- echo "\t\t<itunes:author>" . wp_specialchars($powerpress_feed['itunes_talent_name']) . '</itunes:author>'.PHP_EOL;
384
 
385
  if( $powerpress_feed['explicit'] )
386
  echo "\t".'<itunes:explicit>' . $powerpress_feed['explicit'] . '</itunes:explicit>'.PHP_EOL;
@@ -414,12 +428,12 @@ function powerpress_rss2_head()
414
  }
415
 
416
  if( trim($Feed['itunes_subtitle']) )
417
- echo "\t".'<itunes:subtitle>' . powerpress_format_itunes_value($Feed['itunes_subtitle']) . '</itunes:subtitle>'.PHP_EOL;
418
  else
419
- echo "\t".'<itunes:subtitle>'. powerpress_format_itunes_value( get_bloginfo('description') ) .'</itunes:subtitle>'.PHP_EOL;
420
 
421
  if( trim($Feed['itunes_keywords']) )
422
- echo "\t".'<itunes:keywords>' . powerpress_format_itunes_value($Feed['itunes_keywords']) . '</itunes:keywords>'.PHP_EOL;
423
 
424
  if( $Feed['rss2_image'] )
425
  {
@@ -554,7 +568,7 @@ function powerpress_rss2_item()
554
 
555
  // Check and see if we're working with a podcast episode
556
  $custom_enclosure = false;
557
- if( powerpress_is_custom_podcast_feed() && get_query_var('feed') != 'podcast' )
558
  {
559
  $enclosureData = get_post_meta($post->ID, '_'. get_query_var('feed') .':enclosure', true);
560
  $custom_enclosure = true;
@@ -668,30 +682,31 @@ function powerpress_rss2_item()
668
  }
669
 
670
  if( $keywords )
671
- echo "\t\t<itunes:keywords>" . powerpress_format_itunes_value($keywords) . '</itunes:keywords>'.PHP_EOL;
672
 
673
  // Strip and format the wordpress way, but don't apply any other filters for these itunes tags
674
  $content_no_html = $post->post_content;
675
- if( function_exists('strip_shortcodes') )
676
- $content_no_html = strip_shortcodes( $content_no_html );
677
  $content_no_html = str_replace(']]>', ']]&gt;', $content_no_html);
678
  $content_no_html = strip_tags($content_no_html);
679
 
680
  $excerpt_no_html = strip_tags($post->post_excerpt);
681
 
682
  if( $subtitle )
683
- echo "\t\t<itunes:subtitle>". powerpress_format_itunes_value(powerpress_smart_trim($subtitle, 250, true)) .'</itunes:subtitle>'.PHP_EOL;
684
  else if( $excerpt_no_html )
685
- echo "\t\t<itunes:subtitle>". powerpress_format_itunes_value(powerpress_smart_trim($excerpt_no_html, 250, true)) .'</itunes:subtitle>'.PHP_EOL;
686
  else
687
- echo "\t\t<itunes:subtitle>". powerpress_format_itunes_value(powerpress_smart_trim($content_no_html, 250, true)) .'</itunes:subtitle>'.PHP_EOL;
688
 
689
- if( !isset($powerpress_feed['enhance_itunes_summary']) || $powerpress_feed['enhance_itunes_summary'] )
690
  echo "\t\t<itunes:summary>". powerpress_itunes_summary($post->post_content) .'</itunes:summary>'.PHP_EOL;
691
  else if( $summary )
692
- echo "\t\t<itunes:summary>". powerpress_format_itunes_value(powerpress_smart_trim($summary, 4000), 4000) .'</itunes:summary>'.PHP_EOL;
 
 
693
  else
694
- echo "\t\t<itunes:summary>". powerpress_format_itunes_value(powerpress_smart_trim($content_no_html, 4000), 4000) .'</itunes:summary>'.PHP_EOL;
695
 
696
  if( $author )
697
  echo "\t\t<itunes:author>" . wp_specialchars($author) . '</itunes:author>'.PHP_EOL;
@@ -713,10 +728,8 @@ function powerpress_filter_rss_enclosure($content)
713
  if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) )
714
  return $content; // Another podcasting plugin is enabled...
715
 
716
- if( !powerpress_is_podcast_feed() )
717
- return ''; // All custom podcast feeds we handle directly
718
 
719
- if( powerpress_is_custom_podcast_feed() && get_query_var('feed') != 'podcast' )
720
  return ''; // We will handle this enclosure in the powerpress_rss2_item() function
721
 
722
  $match_count = preg_match('/\surl="([^"]*)"/', $content, $matches);
@@ -727,11 +740,11 @@ function powerpress_filter_rss_enclosure($content)
727
  $OrigURL = $matches[1];
728
 
729
  if( substr($OrigURL, 0, 5) != 'http:' && substr($OrigURL, 0, 6) != 'https:' )
730
- return; // The URL value is invalid
731
 
732
  global $post, $powerpress_rss_enclosure_post_id;
733
  if( @$powerpress_rss_enclosure_post_id == $post->ID )
734
- return; // we've already included one enclosure, lets not allow anymore
735
  $powerpress_rss_enclosure_post_id = $post->ID;
736
 
737
  // Modified Media URL
@@ -750,7 +763,10 @@ function powerpress_bloginfo_rss($content, $field = '')
750
  {
751
  if( powerpress_is_custom_podcast_feed() )
752
  {
753
- $Feed = get_option('powerpress_feed_'.get_query_var('feed') );
 
 
 
754
  //$Feed = true;
755
  if( $Feed )
756
  {
@@ -759,10 +775,18 @@ function powerpress_bloginfo_rss($content, $field = '')
759
  case 'description': {
760
  if( isset($Feed['description']) && $Feed['description'] != '' )
761
  return $Feed['description'];
 
 
 
 
 
 
762
  }; break;
763
  case 'url': {
764
  if( isset($Feed['url']) && $Feed['url'] != '' )
765
  return trim($Feed['url']);
 
 
766
  }; break;
767
  case 'name':
768
  default: {
@@ -780,6 +804,49 @@ function powerpress_bloginfo_rss($content, $field = '')
780
  add_filter('get_bloginfo_rss', 'powerpress_bloginfo_rss', 10, 2);
781
 
782
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
783
  function powerpress_do_podcast_feed($for_comments=false)
784
  {
785
  global $wp_query;
@@ -792,12 +859,13 @@ function powerpress_template_redirect()
792
  if( is_feed() && powerpress_is_custom_podcast_feed() )
793
  {
794
  remove_action('template_redirect', 'ol_feed_redirect'); // Remove this action
795
- $Feed = get_option('powerpress_feed_'.get_query_var('feed') );
796
- if( $Feed && trim(@$Feed['feed_redirect_url']) != '' && !preg_match("/feedburner|feedsqueezer|feedvalidator/i", $_SERVER['HTTP_USER_AGENT'] ) && @$_GET['redirect'] != 'no' )
 
797
  {
798
  if (function_exists('status_header'))
799
  status_header( 302 );
800
- header("Location: " . trim($Feed['feed_redirect_url']));
801
  header("HTTP/1.1 302 Temporary Redirect");
802
  exit();
803
  }
@@ -859,14 +927,38 @@ function powerpress_load_general_feed_settings()
859
 
860
  if( $GeneralSettings )
861
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
862
  $feed_slug = get_query_var('feed');
863
 
864
  if( isset($GeneralSettings['custom_feeds']) && is_array($GeneralSettings['custom_feeds']) && isset($GeneralSettings['custom_feeds'][ $feed_slug ] ))
865
  {
866
  $Feed = get_option('powerpress_feed'); // Get overall feed settings
867
  $FeedCustom = get_option('powerpress_feed_'.$feed_slug); // Get custom feed specific settings
868
- if( $FeedCustom )
869
- $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $Feed);
870
 
871
  $powerpress_feed = array();
872
  $powerpress_feed['is_custom'] = true;
@@ -879,7 +971,10 @@ function powerpress_load_general_feed_settings()
879
  $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
880
  else
881
  $powerpress_feed['itunes_talent_name'] = get_bloginfo_rss('name');
882
- $powerpress_feed['enhance_itunes_summary'] = @$Feed['enhance_itunes_summary'];
 
 
 
883
  $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
884
  }
885
  else
@@ -919,7 +1014,10 @@ function powerpress_load_general_feed_settings()
919
  $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
920
  else
921
  $powerpress_feed['itunes_talent_name'] = get_bloginfo_rss('name');
922
- $powerpress_feed['enhance_itunes_summary'] = @$Feed['enhance_itunes_summary'];
 
 
 
923
  $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
924
  }; break;
925
  // All other cases we let fall through
@@ -958,8 +1056,11 @@ function powerpress_is_custom_podcast_feed()
958
  }
959
 
960
  function powerpress_posts_join($join)
961
- {
962
- if( is_feed() && (powerpress_is_custom_podcast_feed() || get_query_var('feed') == 'podcast' ) )
 
 
 
963
  {
964
  global $wpdb;
965
  $join .= " INNER JOIN {$wpdb->postmeta} ";
@@ -972,12 +1073,15 @@ add_filter('posts_join', 'powerpress_posts_join' );
972
 
973
  function powerpress_posts_where($where)
974
  {
 
 
 
975
  if( is_feed() && (powerpress_is_custom_podcast_feed() || get_query_var('feed') == 'podcast' ) )
976
  {
977
  global $wpdb, $powerpress_feed;
978
  $where .= " AND (";
979
 
980
- if( powerpress_is_custom_podcast_feed() && get_query_var('feed') != 'podcast' )
981
  $where .= " {$wpdb->postmeta}.meta_key = '_". get_query_var('feed') .":enclosure' ";
982
  else
983
  $where .= " {$wpdb->postmeta}.meta_key = 'enclosure' ";
@@ -996,6 +1100,9 @@ add_filter('posts_where', 'powerpress_posts_where' );
996
  // Add the groupby needed for enclosures only
997
  function powerpress_posts_groupby($groupby)
998
  {
 
 
 
999
  if( is_feed() && (powerpress_is_custom_podcast_feed() || get_query_var('feed') == 'podcast' ) )
1000
  {
1001
  global $wpdb;
@@ -1162,12 +1269,11 @@ function powerpress_itunes_summary($html)
1162
  $html = str_replace('<li>', '<li>* ', $html);
1163
 
1164
  // Now do all the other regular conversions...
1165
- if( function_exists('strip_shortcodes') )
1166
- $html = strip_shortcodes( $html );
1167
  $html = str_replace(']]>', ']]&gt;', $html);
1168
  $content_no_html = strip_tags($html);
1169
 
1170
- return powerpress_format_itunes_value(powerpress_smart_trim($content_no_html, 4000), 4000);
1171
  }
1172
 
1173
  function powerpress_itunes_categories($PrefixSubCategories = false)
@@ -1279,21 +1385,74 @@ function powerpress_get_root_url()
1279
  return WP_PLUGIN_URL . '/'. $powerpress_dirname .'/';
1280
  }
1281
 
1282
- function powerpress_format_itunes_value($value, $char_limit = 255, $specialchars = true)
1283
  {
1284
- // Code added to solve issue with KimiliFlashEmbed plugin
1285
- // 99.9% of the time this code will not be necessary
1286
- $value = preg_replace("/\[(kml_(flash|swf)embed)\b(.*?)(?:(\/))?(\]|$)/s", '', $value);
1287
  if( DB_CHARSET != 'utf8' ) // Check if the string is UTF-8
1288
  $value = utf8_encode($value); // If it is not, convert to UTF-8 then decode it...
 
 
 
 
 
1289
  if(version_compare("5", phpversion(), ">"))
1290
- $value = str_replace('&nbsp;', ' ', $value); // Best we can do for PHP4
1291
  else
1292
  $value = @html_entity_decode($value, ENT_COMPAT, 'UTF-8'); // Remove any additional entities such as &nbsp;
 
1293
 
1294
- if( strlen($value) > $char_limit )
1295
- return wp_specialchars(substr($value, 0, $char_limit));
1296
- return wp_specialchars($value);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1297
  }
1298
 
1299
  function powerpress_smart_trim($value, $char_limit = 250, $remove_new_lines = false)
@@ -1380,16 +1539,24 @@ function powerpress_byte_size($ppbytes)
1380
  return $ppsize;
1381
  }
1382
 
1383
- // Merges settings where $S
1384
  function powerpress_merge_empty_feed_settings($CustomFeedSettings, $FeedSettings)
1385
  {
 
 
 
 
 
 
 
 
1386
  while( list($key,$value) = each($CustomFeedSettings) )
1387
  {
1388
- if( $value === '' && $FeedSettings[$key] != $value )
1389
- $CustomFeedSettings[$key] = $FeedSettings[$key];
1390
  }
1391
 
1392
- return $CustomFeedSettings;
1393
  }
1394
 
1395
  function powerpress_readable_duration($duration, $include_hour=false)
3
  Plugin Name: Blubrry PowerPress
4
  Plugin URI: http://www.blubrry.com/powerpress/
5
  Description: <a href="http://www.blubrry.com/powerpress/" target="_blank">Blubrry PowerPress</a> adds podcasting support to your blog. Features include: media player, 3rd party statistics and iTunes integration.
6
+ Version: 0.8.0
7
  Author: Blubrry
8
  Author URI: http://www.blubrry.com/
9
  Change Log:
29
  */
30
 
31
  // WP_PLUGIN_DIR (REMEMBER TO USE THIS DEFINE IF NEEDED)
32
+ define('POWERPRESS_VERSION', '0.8.0' );
33
 
34
  /////////////////////////////////////////////////////
35
  // The following define options should be placed in your
347
  return; // Not a feed we manage
348
 
349
  $feed_slug = get_query_var( 'feed' );
350
+ $cat_ID = get_query_var('cat');
351
 
352
+ $Feed = get_option('powerpress_feed'); // Get the main feed settings
353
+ if( is_category() )
354
  {
355
+ $CustomFeed = get_option('powerpress_cat_feed_'.$cat_ID); // Get the custom podcast feed settings saved in the database
356
  if( $CustomFeed )
357
  $Feed = powerpress_merge_empty_feed_settings($CustomFeed, $Feed);
358
  }
359
+ else if( powerpress_is_custom_podcast_feed() ) // If we're handling a custom podcast feed...
360
+ {
361
+ $CustomFeed = get_option('powerpress_feed_'.$feed_slug); // Get the custom podcast feed settings saved in the database
362
+ $Feed = powerpress_merge_empty_feed_settings($CustomFeed, $Feed);
363
+ }
364
 
365
  if( !isset($Feed['url']) || trim($Feed['url']) == '' )
366
+ {
367
+ if( is_category() )
368
+ $Feed['url'] = get_category_link($cat_ID);
369
+ else
370
+ $Feed['url'] = get_bloginfo('url');
371
+ }
372
 
373
+ $General = get_option('powerpress_general');
374
  // We made it this far, lets write stuff to the feed!
375
+ if( $General['advanced_mode'] == 0 )
376
+ echo '<!-- podcast_generator="Blubrry PowerPress/'. POWERPRESS_VERSION .'" mode="simple" -->'.PHP_EOL;
377
+ else
378
+ echo '<!-- podcast_generator="Blubrry PowerPress/'. POWERPRESS_VERSION .'" mode="advanced" -->'.PHP_EOL;
379
+
380
  // add the itunes:new-feed-url tag to feed
381
  if( powerpress_is_custom_podcast_feed() )
382
  {
389
  }
390
 
391
  if( $Feed['itunes_summary'] )
392
+ echo "\t".'<itunes:summary>'. powerpress_format_itunes_value( $Feed['itunes_summary'], 'summary' ) .'</itunes:summary>'.PHP_EOL;
393
  else
394
+ echo "\t".'<itunes:summary>'. powerpress_format_itunes_value( get_bloginfo('description'), 'summary' ) .'</itunes:summary>'.PHP_EOL;
395
 
396
  if( $powerpress_feed['itunes_talent_name'] )
397
+ echo "\t<itunes:author>" . wp_specialchars($powerpress_feed['itunes_talent_name']) . '</itunes:author>'.PHP_EOL;
398
 
399
  if( $powerpress_feed['explicit'] )
400
  echo "\t".'<itunes:explicit>' . $powerpress_feed['explicit'] . '</itunes:explicit>'.PHP_EOL;
428
  }
429
 
430
  if( trim($Feed['itunes_subtitle']) )
431
+ echo "\t".'<itunes:subtitle>' . powerpress_format_itunes_value($Feed['itunes_subtitle'], 'subtitle', true) . '</itunes:subtitle>'.PHP_EOL;
432
  else
433
+ echo "\t".'<itunes:subtitle>'. powerpress_format_itunes_value( get_bloginfo('description'), 'subtitle', true) .'</itunes:subtitle>'.PHP_EOL;
434
 
435
  if( trim($Feed['itunes_keywords']) )
436
+ echo "\t".'<itunes:keywords>' . powerpress_format_itunes_value($Feed['itunes_keywords'], 'keywords') . '</itunes:keywords>'.PHP_EOL;
437
 
438
  if( $Feed['rss2_image'] )
439
  {
568
 
569
  // Check and see if we're working with a podcast episode
570
  $custom_enclosure = false;
571
+ if( powerpress_is_custom_podcast_feed() && get_query_var('feed') != 'podcast' && !is_category() )
572
  {
573
  $enclosureData = get_post_meta($post->ID, '_'. get_query_var('feed') .':enclosure', true);
574
  $custom_enclosure = true;
682
  }
683
 
684
  if( $keywords )
685
+ echo "\t\t<itunes:keywords>" . powerpress_format_itunes_value($keywords, 'keywords') . '</itunes:keywords>'.PHP_EOL;
686
 
687
  // Strip and format the wordpress way, but don't apply any other filters for these itunes tags
688
  $content_no_html = $post->post_content;
689
+ $content_no_html = strip_shortcodes( $content_no_html );
 
690
  $content_no_html = str_replace(']]>', ']]&gt;', $content_no_html);
691
  $content_no_html = strip_tags($content_no_html);
692
 
693
  $excerpt_no_html = strip_tags($post->post_excerpt);
694
 
695
  if( $subtitle )
696
+ echo "\t\t<itunes:subtitle>". powerpress_format_itunes_value($subtitle, 'subtitle', true) .'</itunes:subtitle>'.PHP_EOL;
697
  else if( $excerpt_no_html )
698
+ echo "\t\t<itunes:subtitle>". powerpress_format_itunes_value($excerpt_no_html, 'subtitle', true) .'</itunes:subtitle>'.PHP_EOL;
699
  else
700
+ echo "\t\t<itunes:subtitle>". powerpress_format_itunes_value($content_no_html, 'subtitle', true) .'</itunes:subtitle>'.PHP_EOL;
701
 
702
+ if( $powerpress_feed['enhance_itunes_summary'] )
703
  echo "\t\t<itunes:summary>". powerpress_itunes_summary($post->post_content) .'</itunes:summary>'.PHP_EOL;
704
  else if( $summary )
705
+ echo "\t\t<itunes:summary>". powerpress_format_itunes_value($summary, 'summary') .'</itunes:summary>'.PHP_EOL;
706
+ else if( $excerpt_no_html )
707
+ echo "\t\t<itunes:summary>". powerpress_format_itunes_value($excerpt_no_html, 'summary') .'</itunes:summary>'.PHP_EOL;
708
  else
709
+ echo "\t\t<itunes:summary>". powerpress_format_itunes_value($content_no_html, 'summary') .'</itunes:summary>'.PHP_EOL;
710
 
711
  if( $author )
712
  echo "\t\t<itunes:author>" . wp_specialchars($author) . '</itunes:author>'.PHP_EOL;
728
  if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) )
729
  return $content; // Another podcasting plugin is enabled...
730
 
 
 
731
 
732
+ if( powerpress_is_custom_podcast_feed() && get_query_var('feed') != 'podcast' && !is_category() )
733
  return ''; // We will handle this enclosure in the powerpress_rss2_item() function
734
 
735
  $match_count = preg_match('/\surl="([^"]*)"/', $content, $matches);
740
  $OrigURL = $matches[1];
741
 
742
  if( substr($OrigURL, 0, 5) != 'http:' && substr($OrigURL, 0, 6) != 'https:' )
743
+ return ''; // The URL value is invalid
744
 
745
  global $post, $powerpress_rss_enclosure_post_id;
746
  if( @$powerpress_rss_enclosure_post_id == $post->ID )
747
+ return ''; // we've already included one enclosure, lets not allow anymore
748
  $powerpress_rss_enclosure_post_id = $post->ID;
749
 
750
  // Modified Media URL
763
  {
764
  if( powerpress_is_custom_podcast_feed() )
765
  {
766
+ if( is_category() )
767
+ $Feed = get_option('powerpress_cat_feed_'.get_query_var('cat') );
768
+ else
769
+ $Feed = get_option('powerpress_feed_'.get_query_var('feed') );
770
  //$Feed = true;
771
  if( $Feed )
772
  {
775
  case 'description': {
776
  if( isset($Feed['description']) && $Feed['description'] != '' )
777
  return $Feed['description'];
778
+ else if( is_category() )
779
+ {
780
+ $category = get_category( get_query_var('cat') );
781
+ if( $category->description )
782
+ return $category->description;
783
+ }
784
  }; break;
785
  case 'url': {
786
  if( isset($Feed['url']) && $Feed['url'] != '' )
787
  return trim($Feed['url']);
788
+ else if( is_category() )
789
+ return get_category_link( get_query_var('cat') );
790
  }; break;
791
  case 'name':
792
  default: {
804
  add_filter('get_bloginfo_rss', 'powerpress_bloginfo_rss', 10, 2);
805
 
806
 
807
+ function powerpress_wp_title_rss($title)
808
+ {
809
+ if( powerpress_is_custom_podcast_feed() )
810
+ {
811
+ if( is_category() )
812
+ {
813
+ $Feed = get_option('powerpress_cat_feed_'.get_query_var('cat') );
814
+ if( $Feed && isset($Feed['title']) && $Feed['title'] != '' )
815
+ return ''; // We alrady did a custom title, lets not add the category to it...
816
+ }
817
+ else
818
+ {
819
+ return ''; // It is not a category, lets not mess with our beautiful title then
820
+ }
821
+ }
822
+ return $title;
823
+ }
824
+
825
+ add_filter('wp_title_rss', 'powerpress_wp_title_rss');
826
+
827
+ function powerpress_rss_language($value)
828
+ {
829
+ if( powerpress_is_custom_podcast_feed() )
830
+ {
831
+ $feed_slug = get_query_var('feed');
832
+ $cat_ID = get_query_var('cat');
833
+
834
+ if( $cat_ID )
835
+ $Feed = get_option('powerpress_cat_feed_'. $cat_ID);
836
+ else if( $feed_slug != 'podcast' )
837
+ $Feed = get_option('powerpress_feed');
838
+ else
839
+ $Feed = get_option('powerpress_feed_'. $feed_slug);
840
+
841
+ if( $Feed && isset($Feed['rss_language']) && $Feed['rss_language'] != '' )
842
+ $value = $Feed['rss_language'];
843
+ }
844
+ return $value;
845
+ }
846
+
847
+ add_filter('option_rss_language', 'powerpress_rss_language');
848
+
849
+
850
  function powerpress_do_podcast_feed($for_comments=false)
851
  {
852
  global $wp_query;
859
  if( is_feed() && powerpress_is_custom_podcast_feed() )
860
  {
861
  remove_action('template_redirect', 'ol_feed_redirect'); // Remove this action
862
+ global $powerpress_feed;
863
+
864
+ if( is_array($powerpress_feed) && trim(@$powerpress_feed['feed_redirect_url']) != '' && !preg_match("/feedburner|feedsqueezer|feedvalidator/i", $_SERVER['HTTP_USER_AGENT'] ) && @$_GET['redirect'] != 'no' )
865
  {
866
  if (function_exists('status_header'))
867
  status_header( 302 );
868
+ header("Location: " . trim($powerpress_feed['feed_redirect_url']));
869
  header("HTTP/1.1 302 Temporary Redirect");
870
  exit();
871
  }
927
 
928
  if( $GeneralSettings )
929
  {
930
+ if( is_category() && in_array( get_query_var('cat'), $GeneralSettings['custom_cat_feeds']) )
931
+ {
932
+ $cat_ID = get_query_var('cat');
933
+ $Feed = get_option('powerpress_feed'); // Get overall feed settings
934
+ $FeedCustom = get_option('powerpress_cat_feed_'.$cat_ID); // Get custom feed specific settings
935
+ $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $Feed);
936
+
937
+ $powerpress_feed = array();
938
+ $powerpress_feed['is_custom'] = true;
939
+ $powerpress_feed['category'] = $cat_ID;
940
+ $powerpress_feed['process_podpress'] = true; // Category feeds could originate from Podpress
941
+ $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/';
942
+ $explicit = array("no", "yes", "clean");
943
+ $powerpress_feed['explicit'] = $explicit[$Feed['itunes_explicit']];
944
+ if( $Feed['itunes_talent_name'] )
945
+ $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
946
+ else
947
+ $powerpress_feed['itunes_talent_name'] = get_bloginfo_rss('name');
948
+ $powerpress_feed['enhance_itunes_summary'] = @$Feed['enhance_itunes_summary'];
949
+ $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
950
+ if( $Feed['feed_redirect_url'] != '' )
951
+ $powerpress_feed['feed_redirect_url'] = $Feed['feed_redirect_url'];
952
+ return;
953
+ }
954
+
955
  $feed_slug = get_query_var('feed');
956
 
957
  if( isset($GeneralSettings['custom_feeds']) && is_array($GeneralSettings['custom_feeds']) && isset($GeneralSettings['custom_feeds'][ $feed_slug ] ))
958
  {
959
  $Feed = get_option('powerpress_feed'); // Get overall feed settings
960
  $FeedCustom = get_option('powerpress_feed_'.$feed_slug); // Get custom feed specific settings
961
+ $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $Feed);
 
962
 
963
  $powerpress_feed = array();
964
  $powerpress_feed['is_custom'] = true;
971
  $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
972
  else
973
  $powerpress_feed['itunes_talent_name'] = get_bloginfo_rss('name');
974
+ if( version_compare( '5', phpversion(), '>=' ) )
975
+ $powerpress_feed['enhance_itunes_summary'] = 0;
976
+ else
977
+ $powerpress_feed['enhance_itunes_summary'] = @$Feed['enhance_itunes_summary'];
978
  $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
979
  }
980
  else
1014
  $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
1015
  else
1016
  $powerpress_feed['itunes_talent_name'] = get_bloginfo_rss('name');
1017
+ if( version_compare( '5', phpversion(), '>=' ) )
1018
+ $powerpress_feed['enhance_itunes_summary'] = 0;
1019
+ else
1020
+ $powerpress_feed['enhance_itunes_summary'] = @$Feed['enhance_itunes_summary'];
1021
  $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
1022
  }; break;
1023
  // All other cases we let fall through
1056
  }
1057
 
1058
  function powerpress_posts_join($join)
1059
+ {
1060
+ if( is_category() )
1061
+ return $join;
1062
+
1063
+ if( is_feed() && (powerpress_is_custom_podcast_feed() || get_query_var('feed') == 'podcast' ) && !is_category() )
1064
  {
1065
  global $wpdb;
1066
  $join .= " INNER JOIN {$wpdb->postmeta} ";
1073
 
1074
  function powerpress_posts_where($where)
1075
  {
1076
+ if( is_category() )
1077
+ return $where;
1078
+
1079
  if( is_feed() && (powerpress_is_custom_podcast_feed() || get_query_var('feed') == 'podcast' ) )
1080
  {
1081
  global $wpdb, $powerpress_feed;
1082
  $where .= " AND (";
1083
 
1084
+ if( powerpress_is_custom_podcast_feed() && get_query_var('feed') != 'podcast' && !is_category() )
1085
  $where .= " {$wpdb->postmeta}.meta_key = '_". get_query_var('feed') .":enclosure' ";
1086
  else
1087
  $where .= " {$wpdb->postmeta}.meta_key = 'enclosure' ";
1100
  // Add the groupby needed for enclosures only
1101
  function powerpress_posts_groupby($groupby)
1102
  {
1103
+ if( is_category() )
1104
+ return $groupby;
1105
+
1106
  if( is_feed() && (powerpress_is_custom_podcast_feed() || get_query_var('feed') == 'podcast' ) )
1107
  {
1108
  global $wpdb;
1269
  $html = str_replace('<li>', '<li>* ', $html);
1270
 
1271
  // Now do all the other regular conversions...
1272
+ $html = strip_shortcodes( $html );
 
1273
  $html = str_replace(']]>', ']]&gt;', $html);
1274
  $content_no_html = strip_tags($html);
1275
 
1276
+ return powerpress_format_itunes_value($content_no_html, 'summary');
1277
  }
1278
 
1279
  function powerpress_itunes_categories($PrefixSubCategories = false)
1385
  return WP_PLUGIN_URL . '/'. $powerpress_dirname .'/';
1386
  }
1387
 
1388
+ function powerpress_format_itunes_value($value, $tag = 255, $remove_new_lines = false)
1389
  {
 
 
 
1390
  if( DB_CHARSET != 'utf8' ) // Check if the string is UTF-8
1391
  $value = utf8_encode($value); // If it is not, convert to UTF-8 then decode it...
1392
+
1393
+ // Code added to solve issue with KimiliFlashEmbed plugin and also remove the shortcode for the WP Audio Player
1394
+ // 99.9% of the time this code will not be necessary
1395
+ $value = preg_replace("/\[(kml_(flash|swf)embed|audio\:)\b(.*?)(?:(\/))?(\]|$)/isu", '', $value);
1396
+
1397
  if(version_compare("5", phpversion(), ">"))
1398
+ $value = preg_replace( '/&nbsp;/ui' , ' ', $value); // Best we can do for PHP4
1399
  else
1400
  $value = @html_entity_decode($value, ENT_COMPAT, 'UTF-8'); // Remove any additional entities such as &nbsp;
1401
+ $value = preg_replace( '/&amp;/ui' , '&', $value); // Best we can do for PHP4. precaution in case it didn't get removed from function above.
1402
 
1403
+ if( $remove_new_lines )
1404
+ $value = preg_replace( array("/\r\n\r\n/u", "/\n/u", "/\r/u", "/\t/u") , array(' - ',' ', '', ' '), $value);
1405
+
1406
+ return wp_specialchars( powerpress_trim_itunes_value($value, $tag) );
1407
+ }
1408
+
1409
+ function powerpress_trim_itunes_value($value, $tag = 'summary')
1410
+ {
1411
+ $length = (function_exists('mb_strlen')?mb_strlen($value):strlen($value) );
1412
+ $trim_at = false;
1413
+ switch($tag)
1414
+ {
1415
+ case 'summary': {
1416
+ // 4000 character limit
1417
+ if( $length > 4000 )
1418
+ $trim_at = 4000;
1419
+ }; break;
1420
+ case 'subtitle':
1421
+ case 'keywords':
1422
+ case 'author':
1423
+ case 'name':
1424
+ default: {
1425
+ // 255 character limit
1426
+ if( $length > 255 )
1427
+ $trim_at = 255;
1428
+ };
1429
+ }
1430
+
1431
+ if( $trim_at )
1432
+ {
1433
+ // Start trimming
1434
+ $value = (function_exists('mb_substr')?mb_substr($value, 0, $trim_at):substr($value, 0, $trim_at) );
1435
+ $clean_break = false;
1436
+ if( preg_match('/(.*[,\n.\?!])[^,\n.\?!]/isu', $value, $matches) ) // pattern modifiers: case (i)nsensitive, entire (s)tring and (u)nicode
1437
+ {
1438
+ if( isset( $matches[1]) )
1439
+ {
1440
+ $detected_eof_pos = (function_exists('mb_strlen')?mb_strlen($matches[1]):strlen($matches[1]) );
1441
+ // Look back at most 50 characters...
1442
+ if( $detected_eof_pos > 3950 || ($detected_eof_pos > 205 && $detected_eof_pos < 255 ) )
1443
+ {
1444
+ $value = $matches[1];
1445
+ $clean_break = true;
1446
+ }
1447
+ // Otherwise we want to continue with the same value we started with...
1448
+ }
1449
+ }
1450
+
1451
+ if( $clean_break == false && $tag = 'subtitle' ) // Subtitle we want to add a ... at the end
1452
+ $value = (function_exists('mb_substr')?mb_substr($value, 0, 252):substr($value, 0, 252) ). '...';
1453
+ }
1454
+
1455
+ return $value;
1456
  }
1457
 
1458
  function powerpress_smart_trim($value, $char_limit = 250, $remove_new_lines = false)
1539
  return $ppsize;
1540
  }
1541
 
1542
+ // Merges settings from feed settings page to empty custom feed settings
1543
  function powerpress_merge_empty_feed_settings($CustomFeedSettings, $FeedSettings)
1544
  {
1545
+ // Remove settings from main $FeedSettings that should not be copied to custom feed.
1546
+ unset($FeedSettings['itunes_new_feed_url']);
1547
+ unset($FeedSettings['apply_to']);
1548
+ unset($FeedSettings['feed_redirect_url']);
1549
+
1550
+ if( !$CustomFeedSettings )
1551
+ return $FeedSettings; // If the $CustomFeedSettings is false
1552
+
1553
  while( list($key,$value) = each($CustomFeedSettings) )
1554
  {
1555
+ if( $value !== '' || !isset($FeedSettings[$key]) )
1556
+ $FeedSettings[$key] = $value;
1557
  }
1558
 
1559
+ return $FeedSettings;
1560
  }
1561
 
1562
  function powerpress_readable_duration($duration, $include_hour=false)