PowerPress Podcasting plugin by Blubrry - Version 0.7.1

Version Description

Download this release

Release Info

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

Code changes from version 0.6.5 to 0.7.1

mp3info.class.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- // mp3info class for use in the Blubrry Powerpress
3
  // Main purpose of this file is to obtain the duration string for the itunes:duration field.
4
  // Library is packaged thin with only basic mp3 support.
5
  // Concept with this library is to get the information without downlaoding the entire file.
@@ -9,7 +9,7 @@
9
  //var $m_DownloadBytesLimit = 1638400; // 200K (200*1024*8) bytes file
10
  var $m_DownloadBytesLimit = 204800; // 25K (25*1024*8) bytes file
11
  var $m_RedirectLimit = 5; // Number of times to do the 302 redirect
12
- var $m_UserAgent = 'Blubrry Powerpress/1.0';
13
  var $m_error = '';
14
  var $m_ContentLength = false;
15
  var $m_RedirectCount = 0;
@@ -216,6 +216,7 @@
216
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
217
  curl_setopt($curl, CURLOPT_MAXREDIRS, $this->m_RedirectLimit);
218
  $Headers = curl_exec($curl);
 
219
  $ContentLength = curl_getinfo($curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
220
  $HttpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
221
 
@@ -235,42 +236,63 @@
235
  return false;
236
  }
237
 
238
- // Next get the first chunk of the file...
239
- curl_setopt($curl, CURLOPT_URL, $url);
240
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
241
- curl_setopt($curl, CURLOPT_HEADER, false); // header will be at output
242
- curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET'); // HTTP request
243
- curl_setopt($curl, CURLOPT_NOBODY, false );
244
- curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
245
- curl_setopt($curl, CURLOPT_MAXREDIRS, $this->m_RedirectLimit);
246
- curl_setopt($curl, CURLOPT_RANGE, "0-{$this->m_DownloadBytesLimit}");
247
- $Content = curl_exec($curl);
248
- curl_close($curl);
249
-
250
- if( $Content )
251
  {
252
- global $TempFile;
253
- if( function_exists('get_temp_dir') ) // If wordpress function is available, lets use it
254
- $TempFile = tempnam(get_temp_dir(), 'wp_powerpress');
255
- else // otherwise use the default path
256
- $TempFile = tempnam('/tmp', 'wp_powerpress');
257
-
258
- if( $TempFile === false )
259
- {
260
- $this->SetError('Unable to save media information to temporary directory.');
261
- return false;
262
- }
263
 
264
- $fp = fopen( $TempFile, 'w' );
265
- fwrite($fp, $Content);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  fclose($fp);
 
 
 
 
 
267
 
268
  if( $ContentLength )
269
  $this->m_ContentLength = $ContentLength;
270
  return $TempFile;
271
  }
 
 
 
 
 
 
 
272
 
273
- $this->SetError('Unable to download media.');
274
  return false;
275
  }
276
 
1
  <?php
2
+ // mp3info class for use in the Blubrry PowerPress
3
  // Main purpose of this file is to obtain the duration string for the itunes:duration field.
4
  // Library is packaged thin with only basic mp3 support.
5
  // Concept with this library is to get the information without downlaoding the entire file.
9
  //var $m_DownloadBytesLimit = 1638400; // 200K (200*1024*8) bytes file
10
  var $m_DownloadBytesLimit = 204800; // 25K (25*1024*8) bytes file
11
  var $m_RedirectLimit = 5; // Number of times to do the 302 redirect
12
+ var $m_UserAgent = 'Blubrry PowerPress/1.0';
13
  var $m_error = '';
14
  var $m_ContentLength = false;
15
  var $m_RedirectCount = 0;
216
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
217
  curl_setopt($curl, CURLOPT_MAXREDIRS, $this->m_RedirectLimit);
218
  $Headers = curl_exec($curl);
219
+
220
  $ContentLength = curl_getinfo($curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
221
  $HttpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
222
 
236
  return false;
237
  }
238
 
239
+ global $TempFile;
240
+ if( function_exists('get_temp_dir') ) // If wordpress function is available, lets use it
241
+ $TempFile = tempnam(get_temp_dir(), 'wp_powerpress');
242
+ else // otherwise use the default path
243
+ $TempFile = tempnam('/tmp', 'wp_powerpress');
244
+ if( $TempFile === false )
 
 
 
 
 
 
 
245
  {
246
+ $this->SetError('Unable to create temporary file for checking media information.');
247
+ return false;
248
+ }
 
 
 
 
 
 
 
 
249
 
250
+ $fp = fopen($TempFile, 'w+b');
251
+ // Next get the first chunk of the file...
252
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, false);
253
+ curl_setopt($curl, CURLOPT_FILE, $fp);
254
+ curl_setopt($curl, CURLOPT_URL, $url);
255
+ curl_setopt($curl, CURLOPT_HEADER, false); // header will be at output
256
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET'); // HTTP request
257
+ curl_setopt($curl, CURLOPT_NOBODY, false );
258
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
259
+ curl_setopt($curl, CURLOPT_MAXREDIRS, $this->m_RedirectLimit);
260
+ curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
261
+ curl_setopt($curl, CURLOPT_HTTPHEADER,array('Range: bytes=0-'.($this->m_DownloadBytesLimit-1) ));
262
+ //curl_setopt($curl, CURLINFO_HEADER_OUT, true); // For debugging
263
+ // Do the download
264
+ $success = curl_exec($curl);
265
+ fclose($fp);
266
+
267
+ //$headers_sent = curl_getinfo($curl, CURLINFO_HEADER_OUT); // For debugging
268
+ //var_dump($headers_sent); // For debugging
269
+
270
+ // Make sure the file is only so big so we don't have memory allocation errors
271
+ $filesize = filesize($TempFile);
272
+ if( $filesize > $this->m_DownloadBytesLimit ) // The web server did not support the Range: request
273
+ {
274
+ $fp = fopen($TempFile, 'w+');
275
+ ftruncate($fp, $this->m_DownloadBytesLimit);
276
  fclose($fp);
277
+ }
278
+
279
+ if( $success )
280
+ {
281
+ curl_close($curl);
282
 
283
  if( $ContentLength )
284
  $this->m_ContentLength = $ContentLength;
285
  return $TempFile;
286
  }
287
+ else
288
+ {
289
+ if( curl_errno($curl) )
290
+ $this->SetError(curl_error($curl) .' ('.curl_errno($curl).')');
291
+ else
292
+ $this->SetError('Unable to download media.');
293
+ }
294
 
295
+ curl_close($curl);
296
  return false;
297
  }
298
 
player.js CHANGED
@@ -1,5 +1,5 @@
1
  /**
2
- * jsMediaPlayer 1.1.1 for Blubrry Powerpress
3
  *
4
  * http://www.blubrry.com/powepress/
5
  *
@@ -8,6 +8,7 @@
8
  * Released under Aoache 2 license:
9
  * http://www.apache.org/licenses/LICENSE-2.0
10
  *
 
11
  * versoin 1.1.1 - 12/22/20008 - Minor change to support Windows Media in Firefox. Includes link to preferred Firefox Windows Media Player plugin.
12
  * versoin 1.1.0 - 11/25/20008 - Major re-write, object now stored in this include file, auto play is no longer a member variable and is determined by function call.
13
  * version 1.0.3 - 11/02/2008 - Added option for playing quicktime files in an intermediate fashion with an image to click to play.
@@ -34,6 +35,26 @@ function powerpress_player_init(PluginURL, QuicktimeImage)
34
  g_bpPlayer.OnePlayerOnly(powerpress_player_init.arguments[2]);
35
  }
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  /**
38
  play media in page function
39
 
@@ -77,6 +98,7 @@ function jsMediaPlayer(FlashSrc) {
77
  this.m_flash_src = FlashSrc;
78
  this.m_width = 320;
79
  this.m_height = 240;
 
80
  this.m_player_div = false;
81
  this.m_player_wnd = false;
82
  this.m_one_player_only = false;
@@ -96,6 +118,10 @@ function jsMediaPlayer(FlashSrc) {
96
  this.m_height = Height;
97
  }
98
 
 
 
 
 
99
  this.OnePlayerOnly=function(Setting) {
100
  this.m_one_player_only = Setting;
101
  }
@@ -306,15 +332,18 @@ function jsMediaPlayer(FlashSrc) {
306
  this._doFlowPlayer = function() {
307
 
308
  var height = this.m_height;
 
309
  var auto_play = false;
310
  if( this._doFlowPlayer.arguments.length > 0 && this._doFlowPlayer.arguments[0] > 0 )
311
  height = this._doFlowPlayer.arguments[0];
312
  if( this._doFlowPlayer.arguments.length > 1 )
313
  auto_play = this._doFlowPlayer.arguments[1];
 
 
314
 
315
  flashembed(
316
  this.m_player_div,
317
- {src: this.m_flash_src, width: this.m_width, height: height },
318
  {config: { autoPlay: auto_play?true:false, autoBuffering: false, initialScale: 'scale', showFullScreenButton: false, showMenu: false, videoFile: this.m_media_url, loop: false, autoRewind: true } }
319
  );
320
 
@@ -326,6 +355,10 @@ function jsMediaPlayer(FlashSrc) {
326
  var height = this.m_height;
327
  if( this._getFlowPlayer.arguments.length > 1 )
328
  height = this._getFlowPlayer.arguments[1];
 
 
 
 
329
 
330
  var auto_play = false;
331
  if( this._getFlowPlayer.arguments.length > 2 )
@@ -334,7 +367,7 @@ function jsMediaPlayer(FlashSrc) {
334
  var Html = '';
335
  Html += "flashembed(\n";
336
  Html += " '"+ destDiv +"', \n";
337
- Html += " {src: '"+ this.m_flash_src +"', width: "+ this.m_width +", height: "+ height +"}, \n";
338
  Html += " {config: { autoPlay: "+ (auto_play?'true':'false') +", duration: 633, autoBuffering: false, initialScale: 'scale', showFullScreenButton: false, showMenu: false, videoFile: '"+ this.m_media_url +"', loop: false, autoRewind: true } } \n";
339
  Html += " ); \n";
340
  return Html;
@@ -484,6 +517,51 @@ function jsMediaPlayer(FlashSrc) {
484
  }
485
  }
486
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
487
  /**
488
  * flashembed 0.31. Adobe Flash embedding script
489
  *
1
  /**
2
+ * jsMediaPlayer 1.1.1 for Blubrry PowerPress
3
  *
4
  * http://www.blubrry.com/powepress/
5
  *
8
  * Released under Aoache 2 license:
9
  * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
+ * versoin 1.1.2 - 03/04/2009 - Added options to set the width for audio, width and height for video.
12
  * versoin 1.1.1 - 12/22/20008 - Minor change to support Windows Media in Firefox. Includes link to preferred Firefox Windows Media Player plugin.
13
  * versoin 1.1.0 - 11/25/20008 - Major re-write, object now stored in this include file, auto play is no longer a member variable and is determined by function call.
14
  * version 1.0.3 - 11/02/2008 - Added option for playing quicktime files in an intermediate fashion with an image to click to play.
35
  g_bpPlayer.OnePlayerOnly(powerpress_player_init.arguments[2]);
36
  }
37
 
38
+ /**
39
+ Initialize function for javascript based player
40
+
41
+ @Width - width of player
42
+ @Height - height of player
43
+ @WidthAudio - width of player (mp3 audio only)
44
+ */
45
+ function powerpress_player_size(Width, Height, WidthAudio)
46
+ {
47
+ if( g_bpPlayer )
48
+ {
49
+ if( Width >= 100 )
50
+ g_bpPlayer.SetWidth(Width);
51
+ if( Height >= 24 )
52
+ g_bpPlayer.SetHeight(Height);
53
+ if( WidthAudio >= 100 )
54
+ g_bpPlayer.SetWidthAudio(WidthAudio);
55
+ }
56
+ }
57
+
58
  /**
59
  play media in page function
60
 
98
  this.m_flash_src = FlashSrc;
99
  this.m_width = 320;
100
  this.m_height = 240;
101
+ this.m_widthAudio = 320;
102
  this.m_player_div = false;
103
  this.m_player_wnd = false;
104
  this.m_one_player_only = false;
118
  this.m_height = Height;
119
  }
120
 
121
+ this.SetWidthAudio=function(Width) {
122
+ this.m_widthAudio = Width;
123
+ }
124
+
125
  this.OnePlayerOnly=function(Setting) {
126
  this.m_one_player_only = Setting;
127
  }
332
  this._doFlowPlayer = function() {
333
 
334
  var height = this.m_height;
335
+ var width = this.m_width;
336
  var auto_play = false;
337
  if( this._doFlowPlayer.arguments.length > 0 && this._doFlowPlayer.arguments[0] > 0 )
338
  height = this._doFlowPlayer.arguments[0];
339
  if( this._doFlowPlayer.arguments.length > 1 )
340
  auto_play = this._doFlowPlayer.arguments[1];
341
+ if( height == 24 )
342
+ width = this.m_widthAudio;
343
 
344
  flashembed(
345
  this.m_player_div,
346
+ {src: this.m_flash_src, width: width, height: height },
347
  {config: { autoPlay: auto_play?true:false, autoBuffering: false, initialScale: 'scale', showFullScreenButton: false, showMenu: false, videoFile: this.m_media_url, loop: false, autoRewind: true } }
348
  );
349
 
355
  var height = this.m_height;
356
  if( this._getFlowPlayer.arguments.length > 1 )
357
  height = this._getFlowPlayer.arguments[1];
358
+
359
+ var width = this.m_width;
360
+ if( height == 24 ) // Player height
361
+ width = this.m_widthAudio;
362
 
363
  var auto_play = false;
364
  if( this._getFlowPlayer.arguments.length > 2 )
367
  var Html = '';
368
  Html += "flashembed(\n";
369
  Html += " '"+ destDiv +"', \n";
370
+ Html += " {src: '"+ this.m_flash_src +"', width: "+ width +", height: "+ height +"}, \n";
371
  Html += " {config: { autoPlay: "+ (auto_play?'true':'false') +", duration: 633, autoBuffering: false, initialScale: 'scale', showFullScreenButton: false, showMenu: false, videoFile: '"+ this.m_media_url +"', loop: false, autoRewind: true } } \n";
372
  Html += " ); \n";
373
  return Html;
517
  }
518
  }
519
 
520
+
521
+ function powerpress_onload()
522
+ {
523
+ if( g_bpLoadDelay )
524
+ setTimeout('powerpress_load_delay()', g_bpLoadDelay);
525
+ else
526
+ powerpress_load_delay();
527
+ }
528
+
529
+ function powerpress_load_delay()
530
+ {
531
+ for( var x = 0; x < g_pbPlayerArray.length; x++ )
532
+ powerpress_play_page( g_pbPlayerArray[x][0], g_pbPlayerArray[x][1] );
533
+ }
534
+
535
+ var g_pbPlayerArray = new Array();
536
+ function powerpress_queue_player(media, div )
537
+ {
538
+ //alert('test');
539
+ var pos = g_pbPlayerArray.length;
540
+ g_pbPlayerArray[pos] = new Array();
541
+ g_pbPlayerArray[pos][0] = media;
542
+ g_pbPlayerArray[pos][1] = div;
543
+ }
544
+
545
+ function powerpress_addLoadEvent(func)
546
+ {
547
+ var oldonload = window.onload;
548
+ if (typeof window.onload != 'function')
549
+ {
550
+ window.onload = func;
551
+ }
552
+ else
553
+ {
554
+ window.onload = function()
555
+ {
556
+ if (oldonload)
557
+ {
558
+ oldonload();
559
+ }
560
+ func();
561
+ }
562
+ }
563
+ }
564
+
565
  /**
566
  * flashembed 0.31. Adobe Flash embedding script
567
  *
powerpress.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /*
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.6.5
7
  Author: Blubrry
8
  Author URI: http://www.blubrry.com/
9
  Change Log:
@@ -28,7 +28,8 @@ License: GPL (http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt)
28
  This project uses source that is GPL licensed.
29
  */
30
 
31
- define('POWERPRESS_VERSION', '0.6.5' );
 
32
 
33
  /////////////////////////////////////////////////////
34
  // The following define options should be placed in your
@@ -36,20 +37,42 @@ define('POWERPRESS_VERSION', '0.6.5' );
36
  // you upgrade the plugin.
37
  /////////////////////////////////////////////////////
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  // Load players in the footer of the page, improves page load times but requires wp_footer() function to be included in WP Theme.
40
  //define('POWERPRESS_USE_FOOTER', true);
41
  // You can also define the delay.
42
- //define('POWERPRESS_USE_FOOTER_DELAY', 500); // Milliseconds delay should occur, e.g. 500 is 1/2 of a second, 2000 is 2 seconds.
43
 
44
- // Display Powerpress player only for previously created Podpress episodes.
45
- //define('POWERPRESS_USE_PLAYER_FOR_PODPRESS_EPISODES', true);
 
 
 
 
 
46
 
47
- // Enhance the itunes:summary for each post by converting web links and imges into direct hotlinks.
48
- //define('POWERPRESS_SMART_ITUNES_SUMMARY', true);
49
 
50
  // Display custom play image for quicktime media. Applies to on page player only.
51
  //define('POWERPRESS_PLAY_IMAGE', 'http://www.blubrry.com/themes/blubrry/images/player/PlayerBadge150x50NoBorder.jpg');
52
 
 
 
 
53
  // Define variables, advanced users could define these in their own wp-config.php so lets not try to re-define
54
  if( !defined('POWERPRESS_LINK_SEPARATOR') )
55
  define('POWERPRESS_LINK_SEPARATOR', '|');
@@ -57,10 +80,15 @@ if( !defined('POWERPRESS_PLAY_IMAGE') )
57
  define('POWERPRESS_PLAY_IMAGE', 'play_video_default.jpg');
58
  if( !defined('PHP_EOL') )
59
  define('PHP_EOL', "\n"); // We need this variable defined for new lines.
 
 
60
 
61
  function powerpress_content($content)
62
  {
63
- global $post;
 
 
 
64
 
65
  if( is_feed() )
66
  return $content; // We don't want to do anything to the feed
@@ -73,7 +101,6 @@ function powerpress_content($content)
73
 
74
  // Problem: If the_excerpt is used instead of the_content, both the_exerpt and the_content will be called here.
75
  // Important to note, get_the_excerpt will be called before the_content is called, so we add a simple little hack
76
- global $g_powerpress_excerpt_post_id;
77
  if( current_filter() == 'get_the_excerpt' )
78
  {
79
  $g_powerpress_excerpt_post_id = $post->ID;
@@ -84,7 +111,7 @@ function powerpress_content($content)
84
  return $content; // We don't want to do anything to this excerpt content in this call either...
85
  }
86
 
87
- // Powerpress settings:
88
  $Powerpress = get_option('powerpress_general');
89
 
90
  if( current_filter() == 'the_excerpt' && !$Powerpress['display_player_excerpt'] )
@@ -94,6 +121,7 @@ function powerpress_content($content)
94
 
95
  // Get the enclosure data
96
  $enclosureData = get_post_meta($post->ID, 'enclosure', true);
 
97
 
98
  if( !$enclosureData )
99
  {
@@ -126,8 +154,14 @@ function powerpress_content($content)
126
  }
127
  else
128
  {
129
- list($EnclosureURL, $EnclosureSize, $EnclosureType) = split("\n", $enclosureData);
130
  $EnclosureURL = trim($EnclosureURL);
 
 
 
 
 
 
131
  }
132
 
133
  // Just in case, if there's no URL lets escape!
@@ -160,20 +194,20 @@ function powerpress_content($content)
160
  switch( $Powerpress['player_function'] )
161
  {
162
  case 1: { // On page and new window
163
- $player_links .= "<a href=\"$EnclosureURL\" target=\"_blank\" title=\"Play in new window\" onclick=\"return powerpress_play_window(this.href);\">Play in new window</a>".PHP_EOL;
164
  }; break;
165
  case 2: { // Play in page only
166
  }; break;
167
  case 3: { //Play in new window only
168
- $player_links .= "<a href=\"$EnclosureURL\" target=\"_blank\" title=\"Play in new window\" onclick=\"return powerpress_play_window(this.href);\">Play in new window</a>".PHP_EOL;
169
  }; break;
170
  case 4: { // Play on page link only
171
- $player_links .= "<a href=\"$EnclosureURL\" title=\"Play on page\" onclick=\"return powerpress_play_page(this.href, 'powerpress_player_{$post->ID}','true');\">Play on page</a>".PHP_EOL;
172
  }; break;
173
  case 5: { //Play on page link and new window
174
- $player_links .= "<a href=\"$EnclosureURL\" title=\"Play on page\" onclick=\"return powerpress_play_page(this.href, 'powerpress_player_{$post->ID}','true');\">Play on page</a>".PHP_EOL;
175
  $player_links .= ' '. POWERPRESS_LINK_SEPARATOR .' ';
176
- $player_links .= "<a href=\"$EnclosureURL\" target=\"_blank\" title=\"Play in new window\" onclick=\"return powerpress_play_window(this.href);\">Play in new window</a>".PHP_EOL;
177
  }; break;
178
  }//end switch
179
 
@@ -181,30 +215,45 @@ function powerpress_content($content)
181
  {
182
  if( $player_links )
183
  $player_links .= ' '. POWERPRESS_LINK_SEPARATOR .' ';
184
- $player_links .= "<a href=\"$EnclosureURL\" title=\"Download\">Download</a>".PHP_EOL;
185
  }
186
  else if( $Powerpress['podcast_link'] == 2 )
187
  {
188
  if( $player_links )
189
  $player_links .= ' '. POWERPRESS_LINK_SEPARATOR .' ';
190
- $player_links .= "<a href=\"$EnclosureURL\" title=\"Download\">Download</a> (".powerpress_byte_size($EnclosureSize).") ".PHP_EOL;
191
  }
192
  else if( $Powerpress['podcast_link'] == 3 )
193
  {
194
- $duration = get_post_meta($post->ID, 'itunes:duration', true);
 
195
  if( $player_links )
196
  $player_links .= ' '. POWERPRESS_LINK_SEPARATOR .' ';
197
  if( $duration && ltrim($duration, '0:') != '' )
198
- $player_links .= "<a href=\"$EnclosureURL\" title=\"Download\">Download</a> (duration: " . ltrim($duration, '0:') ." &#8212; ".powerpress_byte_size($EnclosureSize).")".PHP_EOL;
199
  else
200
- $player_links .= "<a href=\"$EnclosureURL\" title=\"Download\">Download</a> (".powerpress_byte_size($EnclosureSize).")".PHP_EOL;
201
  }
202
 
203
  $new_content = '';
204
  if( $Powerpress['player_function'] == 1 || $Powerpress['player_function'] == 2 ) // We have some kind of on-line player
205
  {
206
  $new_content .= '<div class="powerpress_player" id="powerpress_player_'. $post->ID .'"></div>'.PHP_EOL;
207
- if( defined('POWERPRESS_USE_FOOTER') && POWERPRESS_USE_FOOTER ) // $g_powerpress_footer['player_js']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  {
209
  global $g_powerpress_footer;
210
  $g_powerpress_footer['player_js'] .= "powerpress_play_page('$EnclosureURL', 'powerpress_player_{$post->ID}');\n";
@@ -221,7 +270,7 @@ function powerpress_content($content)
221
  $new_content .= '<div class="powerpress_player" id="powerpress_player_'. $post->ID .'"></div>'.PHP_EOL;
222
  }
223
  if( $player_links )
224
- $new_content .= '<p class="powerpress_links">Podcast: ' . $player_links . '</p>'.PHP_EOL;
225
 
226
  if( $new_content == '' )
227
  return $content;
@@ -235,15 +284,18 @@ function powerpress_content($content)
235
  return $new_content.$content;
236
  }; break;
237
  }
 
238
  }//end function
239
 
240
- add_action('get_the_excerpt', 'powerpress_content', 1);
241
- add_action('the_content', 'powerpress_content');
242
- add_action('the_excerpt', 'powerpress_content');
243
 
244
  function powerpress_header()
245
  {
246
- // Powerpress settings:
 
 
247
  $Powerpress = get_option('powerpress_general');
248
 
249
  $PowerpressPluginURL = powerpress_get_root_url();
@@ -259,6 +311,15 @@ if( $Powerpress['player_function'] == 4 || $Powerpress['player_function'] == 5 )
259
  echo 'powerpress_player_init(\''. $PowerpressPluginURL .'\',\''. $player_image_url .'\',true);'.PHP_EOL;
260
  else
261
  echo 'powerpress_player_init(\''. $PowerpressPluginURL .'\',\''. $player_image_url .'\');'.PHP_EOL;
 
 
 
 
 
 
 
 
 
262
  ?>
263
  </script>
264
  <style type="text/css">
@@ -272,9 +333,10 @@ else
272
 
273
  add_action('wp_head', 'powerpress_header');
274
 
275
- function powerpress_rss2_ns(){
276
- if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) )
277
- return; // Another podcasting plugin is enabled...
 
278
 
279
  // Okay, lets add the namespace
280
  echo 'xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"'."\n";
@@ -282,77 +344,47 @@ function powerpress_rss2_ns(){
282
 
283
  add_action('rss2_ns', 'powerpress_rss2_ns');
284
 
285
-
286
  function powerpress_rss2_head()
287
  {
288
- global $powerpress_feed, $powerpress_itunes_explicit, $powerpress_itunes_talent_name, $powerpress_default_url, $powerpress_process_podpress;
289
- $powerpress_feed = false; // By default, lets not apply the feed settings...
290
-
291
- if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) )
292
- return; // Another podcasting plugin is enabled...
293
 
 
 
294
 
295
  $feed = get_query_var( 'feed' );
296
- if( $feed != 'feed' && $feed != 'podcast' && $feed != 'rss2' )
297
- return; // This is definitely not our kind of feed
298
-
299
- $GeneralSettings = get_option('powerpress_general');
300
- $powerpress_default_url = rtrim($GeneralSettings['default_url'], '/') .'/';
301
- $powerpress_process_podpress = $GeneralSettings['process_podpress'];
302
-
303
- $Feed = get_option('powerpress_feed');
304
 
305
- // First, determine if powerpress should even be rewriting this feed...
306
- if( $Feed['apply_to'] == '0' )
307
- return; // Okay, we're not suppoed to touch this feed, it's bad enough we added the iTunes namespace, escape!!!
 
308
 
309
- if( $Feed['apply_to'] == '3' && $feed != 'podcast' )
310
- return; // This is definitely not our kind of feed
311
 
312
- if( $Feed['apply_to'] == '2' && $feed != 'podcast' )
 
313
  {
314
- // If there's anything else in the query string, then something's going on and we shouldn't touch the feed
315
- if( isset($GLOBALS['wp_query']->query_vars) && count($GLOBALS['wp_query']->query_vars) > 1 )
316
- return;
317
  }
318
-
319
- // if( $Feed['apply_to'] == '1' ) { } // continue...
320
- // Case 1 (default, we apply to all of the rss2 feeds...)
321
-
322
- // We made it this far, lets write stuff to the feed!
323
- $powerpress_feed = true; // Okay, lets continue...
324
- if( $Feed )
325
  {
326
- // while( list($key,$value) = each($Feed) )
327
- // $Feed[$key] = htmlentities($value, ENT_NOQUOTES, 'UTF-8');
328
- // reset($Feed);
329
- }
330
-
331
- echo '<!-- podcast_generator="Blubrry Powerpress/'. POWERPRESS_VERSION .'" -->'.PHP_EOL;
332
-
333
- // add the itunes:new-feed-url tag to feed
334
- if( trim($Feed['itunes_new_feed_url']) && ($feed == 'feed' || $feed == 'rss2') )
335
  echo "\t<itunes:new-feed-url>". $Feed['itunes_new_feed_url'] .'</itunes:new-feed-url>'.PHP_EOL;
336
- else if( trim($Feed['itunes_new_feed_url_podcast']) && $feed == 'podcast' )
337
- echo "\t<itunes:new-feed-url>". $Feed['itunes_new_feed_url_podcast'] .'</itunes:new-feed-url>'.PHP_EOL;
338
 
339
  if( $Feed['itunes_summary'] )
340
  echo "\t".'<itunes:summary>'. powerpress_format_itunes_value( $Feed['itunes_summary'], 4000 ) .'</itunes:summary>'.PHP_EOL;
341
  else
342
  echo "\t".'<itunes:summary>'. powerpress_format_itunes_value( get_bloginfo('description'), 4000 ) .'</itunes:summary>'.PHP_EOL;
343
 
344
- // explicit options:
345
- $explicit = array("no", "yes", "clean");
346
-
347
- $powerpress_itunes_explicit = $explicit[$Feed['itunes_explicit']];
348
- $powerpress_itunes_talent_name = get_bloginfo('name');
349
- if( $Feed['itunes_talent_name'] )
350
- $powerpress_itunes_talent_name = $Feed['itunes_talent_name'];
351
 
352
- echo "\t\t<itunes:author>" . wp_specialchars($powerpress_itunes_talent_name) . '</itunes:author>'.PHP_EOL;
353
-
354
- if( $powerpress_itunes_explicit )
355
- echo "\t".'<itunes:explicit>' . $powerpress_itunes_explicit . '</itunes:explicit>'.PHP_EOL;
 
356
 
357
  if( $Feed['itunes_image'] )
358
  {
@@ -366,10 +398,10 @@ function powerpress_rss2_head()
366
  if( $Feed['email'] )
367
  {
368
  echo "\t".'<itunes:owner>'.PHP_EOL;
369
- echo "\t\t".'<itunes:name>' . wp_specialchars($powerpress_itunes_talent_name) . '</itunes:name>'.PHP_EOL;
370
  echo "\t\t".'<itunes:email>' . wp_specialchars($Feed['email']) . '</itunes:email>'.PHP_EOL;
371
  echo "\t".'</itunes:owner>'.PHP_EOL;
372
- echo "\t".'<managingEditor>'. wp_specialchars($Feed['email'] .' ('. $powerpress_itunes_talent_name .')') .'</managingEditor>'.PHP_EOL;
373
  }
374
 
375
  if( $Feed['copyright'] )
@@ -390,7 +422,7 @@ function powerpress_rss2_head()
390
  if( $Feed['rss2_image'] )
391
  {
392
  echo"\t". '<image>' .PHP_EOL;
393
- echo "\t\t".'<title>' . wp_specialchars(get_bloginfo('name')) . '</title>'.PHP_EOL;
394
  echo "\t\t".'<url>' . wp_specialchars($Feed['rss2_image']) . '</url>'.PHP_EOL;
395
  echo "\t\t".'<link>'. get_bloginfo('url') . '</link>' . PHP_EOL;
396
  echo "\t".'</image>' . PHP_EOL;
@@ -398,12 +430,13 @@ function powerpress_rss2_head()
398
  else // Use the default image
399
  {
400
  echo"\t". '<image>' .PHP_EOL;
401
- echo "\t\t".'<title>' . wp_specialchars(get_bloginfo('name')) . '</title>'.PHP_EOL;
402
  echo "\t\t".'<url>' . powerpress_get_root_url() . 'rss_default.jpg</url>'.PHP_EOL;
403
  echo "\t\t".'<link>'. get_bloginfo('url') . '</link>' . PHP_EOL;
404
  echo "\t".'</image>' . PHP_EOL;
405
  }
406
 
 
407
  $Categories = powerpress_itunes_categories();
408
  $Cat1 = false; $Cat2 = false; $Cat3 = false;
409
  if( $Feed['itunes_cat_1'] != '' )
@@ -497,31 +530,42 @@ function powerpress_rss2_head()
497
  }
498
  }
499
  }
 
500
  }
501
 
502
  add_action('rss2_head', 'powerpress_rss2_head');
503
 
504
  function powerpress_rss2_item()
505
  {
506
- global $powerpress_feed, $powerpress_itunes_explicit, $powerpress_itunes_talent_name, $powerpress_default_url, $powerpress_process_podpress, $post;
507
  $duration = false;
508
 
 
 
 
 
509
  if( function_exists('post_password_required') )
510
  {
511
  if( post_password_required($post) )
512
  return $content;
513
  }
514
-
515
- // are we processing a feed that powerpress should handle
516
- if( $powerpress_feed == false )
517
- return;
518
 
519
  // Check and see if we're working with a podcast episode
520
- $enclosureData = get_post_meta($post->ID, 'enclosure', true);
 
 
 
 
 
 
 
 
 
 
521
  if( !$enclosureData )
522
  {
523
  $EnclosureURL = '';
524
- if( $powerpress_process_podpress )
525
  {
526
  //$Settings = get_option('powerpress_general');
527
  $podPressMedia = get_post_meta($post->ID, 'podPressMedia', true);
@@ -536,7 +580,7 @@ function powerpress_rss2_item()
536
  {
537
  $EnclosureURL = $podPressMedia[0]['URI'];
538
  if( strpos($EnclosureURL, 'http://' ) !== 0 )
539
- $EnclosureURL = $powerpress_default_url . $EnclosureURL;
540
  $EnclosureSize = $podPressMedia[0]['size'];
541
  $duration = $podPressMedia[0]['duration'];
542
  $EnclosureType = false;
@@ -550,7 +594,7 @@ function powerpress_rss2_item()
550
  }
551
 
552
  if( $EnclosureType && $EnclosureSize && $EnclosureURL )
553
- echo "\t\t".'<enclosure url="' . $EnclosureURL . '" length="'. $EnclosureSize .'" type="'. $EnclosureType .'" />'.PHP_EOL;
554
  else
555
  return;
556
  }
@@ -561,20 +605,69 @@ function powerpress_rss2_item()
561
  return;
562
  }
563
 
564
- if( !$duration )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
565
  $duration = get_post_meta($post->ID, 'itunes:duration', true);
566
 
567
- // Get the post tags:
568
- $tagobject = wp_get_post_tags( $post->ID );
569
- if( count($tagobject) )
570
  {
571
- $tags = array();
572
- for($c = 0; $c < count($tagobject) && $c < 12; $c++) // iTunes only accepts up to 12 keywords
573
- $tags[] = $tagobject[$c]->name;
 
 
 
 
574
 
575
- echo "\t\t<itunes:keywords>" . powerpress_format_itunes_value(implode(",", $tags)) . '</itunes:keywords>'.PHP_EOL;
 
 
 
 
 
 
 
 
 
 
 
 
 
576
  }
577
 
 
 
 
578
  // Strip and format the wordpress way, but don't apply any other filters for these itunes tags
579
  $content_no_html = $post->post_content;
580
  if( function_exists('strip_shortcodes') )
@@ -584,30 +677,46 @@ function powerpress_rss2_item()
584
 
585
  $excerpt_no_html = strip_tags($post->post_excerpt);
586
 
587
- if( $excerpt_no_html )
 
 
588
  echo "\t\t<itunes:subtitle>". powerpress_format_itunes_value(powerpress_smart_trim($excerpt_no_html, 250, true)) .'</itunes:subtitle>'.PHP_EOL;
589
  else
590
  echo "\t\t<itunes:subtitle>". powerpress_format_itunes_value(powerpress_smart_trim($content_no_html, 250, true)) .'</itunes:subtitle>'.PHP_EOL;
591
 
592
- if( defined('POWERPRESS_SMART_ITUNES_SUMMARY') && POWERPRESS_SMART_ITUNES_SUMMARY )
593
  echo "\t\t<itunes:summary>". powerpress_itunes_summary($post->post_content) .'</itunes:summary>'.PHP_EOL;
 
 
594
  else
595
  echo "\t\t<itunes:summary>". powerpress_format_itunes_value(powerpress_smart_trim($content_no_html, 4000), 4000) .'</itunes:summary>'.PHP_EOL;
596
 
597
- if( $powerpress_itunes_talent_name )
598
- echo "\t\t<itunes:author>" . wp_specialchars($powerpress_itunes_talent_name) . '</itunes:author>'.PHP_EOL;
599
 
600
- if( $powerpress_itunes_explicit )
601
- echo "\t\t<itunes:explicit>" . $powerpress_itunes_explicit . '</itunes:explicit>'.PHP_EOL;
602
 
603
  if( $duration && preg_match('/^(\d{1,2}:){0,2}\d{1,2}$/i', $duration) ) // Include duration if it is valid
604
  echo "\t\t<itunes:duration>" . ltrim($duration, '0:') . '</itunes:duration>'.PHP_EOL;
 
 
 
605
  }
606
 
607
  add_action('rss2_item', 'powerpress_rss2_item');
608
 
609
  function powerpress_filter_rss_enclosure($content)
610
  {
 
 
 
 
 
 
 
 
 
611
  $match_count = preg_match('/\surl="([^"]*)"/', $content, $matches);
612
  if( count($matches) != 2)
613
  return $content;
@@ -632,24 +741,60 @@ function powerpress_filter_rss_enclosure($content)
632
  return $content;
633
  }
634
 
 
635
  add_filter('rss_enclosure', 'powerpress_filter_rss_enclosure');
636
 
637
- function powerpress_do_podcast_feed()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
638
  {
639
  global $wp_query;
640
  $wp_query->get_posts();
641
- load_template(ABSPATH . WPINC. '/feed-rss2.php');
642
  }
643
 
644
  function powerpress_template_redirect()
645
  {
646
- if( is_feed() && 'podcast' == get_query_var('feed') )
647
  {
648
  remove_action('template_redirect', 'ol_feed_redirect'); // Remove this action
649
- $Feed = get_option('powerpress_feed');
650
- if( trim(@$Feed['feed_redirect_url']) != '' && !preg_match("/feedburner|feedsqueezer|feedvalidator/i", $_SERVER['HTTP_USER_AGENT'] ) )
651
  {
652
- if (function_exists('status_header')) status_header( 302 );
 
653
  header("Location: " . trim($Feed['feed_redirect_url']));
654
  header("HTTP/1.1 302 Temporary Redirect");
655
  exit();
@@ -661,15 +806,119 @@ add_action('template_redirect', 'powerpress_template_redirect', 0);
661
 
662
  function powerpress_init()
663
  {
 
 
 
664
  add_feed('podcast', 'powerpress_do_podcast_feed');
 
 
 
 
 
 
 
 
 
 
665
  }
666
 
667
  add_action('init', 'powerpress_init');
668
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
669
 
670
  function powerpress_posts_join($join)
671
  {
672
- if( is_feed() && get_query_var('feed') == 'podcast' )
673
  {
674
  global $wpdb;
675
  $join .= " INNER JOIN {$wpdb->postmeta} ";
@@ -682,21 +931,21 @@ add_filter('posts_join', 'powerpress_posts_join' );
682
 
683
  function powerpress_posts_where($where)
684
  {
685
- if( is_feed() && get_query_var('feed') == 'podcast' )
686
  {
687
- global $wpdb;
688
  $where .= " AND (";
689
- $where .= " {$wpdb->postmeta}.meta_key = 'enclosure' ";
690
 
691
- // Powerpress settings:
692
- $Powerpress = get_option('powerpress_general');
 
 
693
 
694
  // Include Podpress data if exists...
695
- if( $Powerpress['process_podpress'] )
696
- {
697
  $where .= " OR {$wpdb->postmeta}.meta_key = 'podPressMedia' ";
698
- }
699
- $where .=") ";
700
  }
701
  return $where;
702
  }
@@ -705,17 +954,27 @@ add_filter('posts_where', 'powerpress_posts_where' );
705
 
706
  // Add the groupby needed for enclosures only
707
  function powerpress_posts_groupby($groupby)
708
- {
709
- if( is_feed() && get_query_var('feed') == 'podcast' )
710
  {
711
  global $wpdb;
712
  $groupby = " {$wpdb->posts}.ID ";
713
  }
714
  return $groupby;
715
  }
716
-
717
  add_filter('posts_groupby', 'powerpress_posts_groupby');
718
 
 
 
 
 
 
 
 
 
 
 
 
719
 
720
  function powerpress_wp_footer()
721
  {
@@ -726,12 +985,12 @@ function powerpress_wp_footer()
726
  if( isset($g_powerpress_footer['player_js']) )
727
  {
728
  echo '<script type="text/javascript">'.PHP_EOL;
729
- if( defined('POWERPRESS_USE_FOOTER_DELAY') && POWERPRESS_USE_FOOTER_DELAY && is_numeric(POWERPRESS_USE_FOOTER_DELAY) )
730
  {
731
- echo 'function powerpress_onload() {'.PHP_EOL;
732
  echo $g_powerpress_footer['player_js'];
733
  echo '}'.PHP_EOL;
734
- echo "setTimeout('powerpress_onload()', ".POWERPRESS_USE_FOOTER_DELAY.");\n";
735
  }
736
  else
737
  {
@@ -964,7 +1223,7 @@ function powerpress_add_redirect_url($MediaURL, $GeneralSettings = false)
964
  $key = sprintf('redirect%d', $x);
965
  if( $GeneralSettings[ $key ] )
966
  {
967
- $RedirectClean = str_replace('http://', '', $GeneralSettings[ $key ]);
968
  if( !strstr($NewURL, $RedirectClean) )
969
  $NewURL = 'http://'. $RedirectClean . str_replace('http://', '', $NewURL);
970
  }
@@ -1000,6 +1259,37 @@ function powerpress_byte_size($ppbytes)
1000
  return $ppsize;
1001
  }
1002
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1003
  // For grabbing data from Podpress data stored serialized, the strings for some values can sometimes get corrupted, so we fix it...
1004
  function powerpress_repair_serialize($string)
1005
  {
1
  <?php
2
  /*
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.1
7
  Author: Blubrry
8
  Author URI: http://www.blubrry.com/
9
  Change Log:
28
  This project uses source that is GPL licensed.
29
  */
30
 
31
+ // WP_PLUGIN_DIR (REMEMBER TO USE THIS DEFINE IF NEEDED)
32
+ define('POWERPRESS_VERSION', '0.7.1' );
33
 
34
  /////////////////////////////////////////////////////
35
  // The following define options should be placed in your
37
  // you upgrade the plugin.
38
  /////////////////////////////////////////////////////
39
 
40
+ // Set specific play and download labels for your installation of PowerPress
41
+ if( !defined('POWERPRESS_LINKS_TEXT') )
42
+ define('POWERPRESS_LINKS_TEXT', __('Podcast') );
43
+ if( !defined('POWERPRESS_DURATION_TEXT') )
44
+ define('POWERPRESS_DURATION_TEXT', __('Duration') );
45
+ if( !defined('POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT') )
46
+ define('POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT', __('Play in new window') );
47
+ if( !defined('POWERPRESS_PLAY_ON_PAGE_TEXT') )
48
+ define('POWERPRESS_PLAY_ON_PAGE_TEXT', __('Play on page') );
49
+ if( !defined('POWERPRESS_DOWNLOAD_TEXT') )
50
+ define('POWERPRESS_DOWNLOAD_TEXT', __('Download') );
51
+
52
+
53
+
54
  // Load players in the footer of the page, improves page load times but requires wp_footer() function to be included in WP Theme.
55
  //define('POWERPRESS_USE_FOOTER', true);
56
  // You can also define the delay.
57
+ //define('POWERPRESS_USE_FOOTER_DELAY', 300); // Milliseconds delay should occur, e.g. 500 is 1/2 of a second, 2000 is 2 seconds.
58
 
59
+ // Set whether players should be loaded using the page onload event
60
+ if( !defined('POWERPRESS_USE_ONLOAD') ) // Add define('POWERPRESS_USE_ONLOAD', false); to your wp-config.php to turn this feature off
61
+ define('POWERPRESS_USE_ONLOAD', true);
62
+
63
+ // define how much of a delay should exist when media players are loaded
64
+ if( !defined('POWERPRESS_USE_ONLOAD_DELAY') ) // Add define('POWERPRESS_USE_ONLOAD_DELAY', 1000); to your wp-config.php to set a full 1 second delay.
65
+ define('POWERPRESS_USE_ONLOAD_DELAY', 500);
66
 
67
+ // Display PowerPress player only for previously created Podpress episodes.
68
+ //define('POWERPRESS_USE_PLAYER_FOR_PODPRESS_EPISODES', true);
69
 
70
  // Display custom play image for quicktime media. Applies to on page player only.
71
  //define('POWERPRESS_PLAY_IMAGE', 'http://www.blubrry.com/themes/blubrry/images/player/PlayerBadge150x50NoBorder.jpg');
72
 
73
+ if( !defined('POWWERPRESS_CONTENT_ACTION_PRIORITY') )
74
+ define('POWWERPRESS_CONTENT_ACTION_PRIORITY', 10 );
75
+
76
  // Define variables, advanced users could define these in their own wp-config.php so lets not try to re-define
77
  if( !defined('POWERPRESS_LINK_SEPARATOR') )
78
  define('POWERPRESS_LINK_SEPARATOR', '|');
80
  define('POWERPRESS_PLAY_IMAGE', 'play_video_default.jpg');
81
  if( !defined('PHP_EOL') )
82
  define('PHP_EOL', "\n"); // We need this variable defined for new lines.
83
+
84
+ $powerpress_feed = NULL; // DO NOT CHANGE
85
 
86
  function powerpress_content($content)
87
  {
88
+ global $post, $g_powerpress_excerpt_post_id;
89
+
90
+ if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) )
91
+ return;
92
 
93
  if( is_feed() )
94
  return $content; // We don't want to do anything to the feed
101
 
102
  // Problem: If the_excerpt is used instead of the_content, both the_exerpt and the_content will be called here.
103
  // Important to note, get_the_excerpt will be called before the_content is called, so we add a simple little hack
 
104
  if( current_filter() == 'get_the_excerpt' )
105
  {
106
  $g_powerpress_excerpt_post_id = $post->ID;
111
  return $content; // We don't want to do anything to this excerpt content in this call either...
112
  }
113
 
114
+ // PowerPress settings:
115
  $Powerpress = get_option('powerpress_general');
116
 
117
  if( current_filter() == 'the_excerpt' && !$Powerpress['display_player_excerpt'] )
121
 
122
  // Get the enclosure data
123
  $enclosureData = get_post_meta($post->ID, 'enclosure', true);
124
+ $duration = false;
125
 
126
  if( !$enclosureData )
127
  {
154
  }
155
  else
156
  {
157
+ list($EnclosureURL, $EnclosureSize, $EnclosureType, $Serialized) = split("\n", $enclosureData);
158
  $EnclosureURL = trim($EnclosureURL);
159
+ if( $Serialized )
160
+ {
161
+ $ExtraData = unserialize($Serialized);
162
+ if( isset($ExtraData['duration']) )
163
+ $duration = $ExtraData['duration'];
164
+ }
165
  }
166
 
167
  // Just in case, if there's no URL lets escape!
194
  switch( $Powerpress['player_function'] )
195
  {
196
  case 1: { // On page and new window
197
+ $player_links .= "<a href=\"$EnclosureURL\" class=\"powerpress_link_pinw\" target=\"_blank\" title=\"". POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT ."\" onclick=\"return powerpress_play_window(this.href);\">". POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT ."</a>".PHP_EOL;
198
  }; break;
199
  case 2: { // Play in page only
200
  }; break;
201
  case 3: { //Play in new window only
202
+ $player_links .= "<a href=\"$EnclosureURL\" class=\"powerpress_link_pinw\" target=\"_blank\" title=\"". POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT ."\" onclick=\"return powerpress_play_window(this.href);\">". POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT ."</a>".PHP_EOL;
203
  }; break;
204
  case 4: { // Play on page link only
205
+ $player_links .= "<a href=\"$EnclosureURL\" class=\"powerpress_link_pop\" title=\"". POWERPRESS_PLAY_ON_PAGE_TEXT ."\" onclick=\"return powerpress_play_page(this.href, 'powerpress_player_{$post->ID}','true');\">". POWERPRESS_PLAY_ON_PAGE_TEXT ."</a>".PHP_EOL;
206
  }; break;
207
  case 5: { //Play on page link and new window
208
+ $player_links .= "<a href=\"$EnclosureURL\" class=\"powerpress_link_pop\" title=\"". POWERPRESS_PLAY_ON_PAGE_TEXT ."\" onclick=\"return powerpress_play_page(this.href, 'powerpress_player_{$post->ID}','true');\">". POWERPRESS_PLAY_ON_PAGE_TEXT ."</a>".PHP_EOL;
209
  $player_links .= ' '. POWERPRESS_LINK_SEPARATOR .' ';
210
+ $player_links .= "<a href=\"$EnclosureURL\" class=\"powerpress_link_pinw\" target=\"_blank\" title=\"". POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT ."\" onclick=\"return powerpress_play_window(this.href);\">". POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT ."</a>".PHP_EOL;
211
  }; break;
212
  }//end switch
213
 
215
  {
216
  if( $player_links )
217
  $player_links .= ' '. POWERPRESS_LINK_SEPARATOR .' ';
218
+ $player_links .= "<a href=\"$EnclosureURL\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a>".PHP_EOL;
219
  }
220
  else if( $Powerpress['podcast_link'] == 2 )
221
  {
222
  if( $player_links )
223
  $player_links .= ' '. POWERPRESS_LINK_SEPARATOR .' ';
224
+ $player_links .= "<a href=\"$EnclosureURL\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a> (".powerpress_byte_size($EnclosureSize).") ".PHP_EOL;
225
  }
226
  else if( $Powerpress['podcast_link'] == 3 )
227
  {
228
+ if( $duration == false )
229
+ $duration = get_post_meta($post->ID, 'itunes:duration', true);
230
  if( $player_links )
231
  $player_links .= ' '. POWERPRESS_LINK_SEPARATOR .' ';
232
  if( $duration && ltrim($duration, '0:') != '' )
233
+ $player_links .= "<a href=\"$EnclosureURL\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a> (". htmlspecialchars(POWERPRESS_DURATION_TEXT) .": " . powerpress_readable_duration($duration) ." &#8212; ".powerpress_byte_size($EnclosureSize).")".PHP_EOL;
234
  else
235
+ $player_links .= "<a href=\"$EnclosureURL\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a> (".powerpress_byte_size($EnclosureSize).")".PHP_EOL;
236
  }
237
 
238
  $new_content = '';
239
  if( $Powerpress['player_function'] == 1 || $Powerpress['player_function'] == 2 ) // We have some kind of on-line player
240
  {
241
  $new_content .= '<div class="powerpress_player" id="powerpress_player_'. $post->ID .'"></div>'.PHP_EOL;
242
+ if( defined('POWERPRESS_USE_ONLOAD') && POWERPRESS_USE_ONLOAD )
243
+ {
244
+ if( defined('POWERPRESS_USE_FOOTER') && POWERPRESS_USE_FOOTER )
245
+ {
246
+ global $g_powerpress_footer;
247
+ $g_powerpress_footer['player_js'] .= "powerpress_queue_player('$EnclosureURL', 'powerpress_player_{$post->ID}');\n";
248
+ }
249
+ else
250
+ {
251
+ $new_content .= '<script type="text/javascript">'.PHP_EOL;
252
+ $new_content .= "powerpress_queue_player('$EnclosureURL', 'powerpress_player_{$post->ID}');\n";
253
+ $new_content .= '</script>'.PHP_EOL;
254
+ }
255
+ }
256
+ else if( defined('POWERPRESS_USE_FOOTER') && POWERPRESS_USE_FOOTER ) // $g_powerpress_footer['player_js']
257
  {
258
  global $g_powerpress_footer;
259
  $g_powerpress_footer['player_js'] .= "powerpress_play_page('$EnclosureURL', 'powerpress_player_{$post->ID}');\n";
270
  $new_content .= '<div class="powerpress_player" id="powerpress_player_'. $post->ID .'"></div>'.PHP_EOL;
271
  }
272
  if( $player_links )
273
+ $new_content .= '<p class="powerpress_links">'. htmlspecialchars(POWERPRESS_LINKS_TEXT) .': '. $player_links . '</p>'.PHP_EOL;
274
 
275
  if( $new_content == '' )
276
  return $content;
284
  return $new_content.$content;
285
  }; break;
286
  }
287
+ return $content;
288
  }//end function
289
 
290
+ add_filter('get_the_excerpt', 'powerpress_content', (POWWERPRESS_CONTENT_ACTION_PRIORITY - 1) );
291
+ add_filter('the_content', 'powerpress_content', POWWERPRESS_CONTENT_ACTION_PRIORITY);
292
+ add_filter('the_excerpt', 'powerpress_content', POWWERPRESS_CONTENT_ACTION_PRIORITY);
293
 
294
  function powerpress_header()
295
  {
296
+ if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) )
297
+ return;
298
+ // PowerPress settings:
299
  $Powerpress = get_option('powerpress_general');
300
 
301
  $PowerpressPluginURL = powerpress_get_root_url();
311
  echo 'powerpress_player_init(\''. $PowerpressPluginURL .'\',\''. $player_image_url .'\',true);'.PHP_EOL;
312
  else
313
  echo 'powerpress_player_init(\''. $PowerpressPluginURL .'\',\''. $player_image_url .'\');'.PHP_EOL;
314
+
315
+ if( isset($Powerpress['player_width']) && isset($Powerpress['player_height']) && isset($Powerpress['player_width_audio']) )
316
+ echo 'powerpress_player_size('. (int)trim($Powerpress['player_width']) .','. (int)trim($Powerpress['player_height']) .','. (int)trim($Powerpress['player_width_audio']) .');'.PHP_EOL;
317
+
318
+ if( defined('POWERPRESS_USE_ONLOAD') && POWERPRESS_USE_ONLOAD )
319
+ {
320
+ echo 'powerpress_addLoadEvent(powerpress_onload);'.PHP_EOL;
321
+ echo "var g_bpLoadDelay = ".POWERPRESS_USE_ONLOAD_DELAY.";\n";
322
+ }
323
  ?>
324
  </script>
325
  <style type="text/css">
333
 
334
  add_action('wp_head', 'powerpress_header');
335
 
336
+ function powerpress_rss2_ns()
337
+ {
338
+ if( !powerpress_is_podcast_feed() )
339
+ return;
340
 
341
  // Okay, lets add the namespace
342
  echo 'xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"'."\n";
344
 
345
  add_action('rss2_ns', 'powerpress_rss2_ns');
346
 
 
347
  function powerpress_rss2_head()
348
  {
349
+ global $powerpress_feed;
 
 
 
 
350
 
351
+ if( !powerpress_is_podcast_feed() )
352
+ return; // Not a feed we manage
353
 
354
  $feed = get_query_var( 'feed' );
 
 
 
 
 
 
 
 
355
 
356
+ if( powerpress_is_custom_podcast_feed() )
357
+ $Feed = get_option('powerpress_feed_'.$feed);
358
+ else
359
+ $Feed = get_option('powerpress_feed');
360
 
361
+ // We made it this far, lets write stuff to the feed!
362
+ echo '<!-- podcast_generator="Blubrry PowerPress/'. POWERPRESS_VERSION .'" -->'.PHP_EOL;
363
 
364
+ // add the itunes:new-feed-url tag to feed
365
+ if( powerpress_is_custom_podcast_feed() )
366
  {
367
+ if( trim($Feed['itunes_new_feed_url']) )
368
+ echo "\t<itunes:new-feed-url>". trim($Feed['itunes_new_feed_url']) .'</itunes:new-feed-url>'.PHP_EOL;
 
369
  }
370
+ else if( trim($Feed['itunes_new_feed_url']) && ($feed == 'feed' || $feed == 'rss2') ) // If it is the default feed (We don't wnat to apply this to category or tag feeds
 
 
 
 
 
 
371
  {
 
 
 
 
 
 
 
 
 
372
  echo "\t<itunes:new-feed-url>". $Feed['itunes_new_feed_url'] .'</itunes:new-feed-url>'.PHP_EOL;
373
+ }
 
374
 
375
  if( $Feed['itunes_summary'] )
376
  echo "\t".'<itunes:summary>'. powerpress_format_itunes_value( $Feed['itunes_summary'], 4000 ) .'</itunes:summary>'.PHP_EOL;
377
  else
378
  echo "\t".'<itunes:summary>'. powerpress_format_itunes_value( get_bloginfo('description'), 4000 ) .'</itunes:summary>'.PHP_EOL;
379
 
380
+ if( $powerpress_feed['talent_name'] )
381
+ echo "\t\t<itunes:author>" . wp_specialchars($powerpress_feed['talent_name']) . '</itunes:author>'.PHP_EOL;
 
 
 
 
 
382
 
383
+ if( $powerpress_feed['explicit'] )
384
+ echo "\t".'<itunes:explicit>' . $powerpress_feed['explicit'] . '</itunes:explicit>'.PHP_EOL;
385
+
386
+ if( $powerpress_feed['block'] && $powerpress_feed['block'] == 'yes' )
387
+ echo "\t\t<itunes:block>yes</itunes:block>\n";
388
 
389
  if( $Feed['itunes_image'] )
390
  {
398
  if( $Feed['email'] )
399
  {
400
  echo "\t".'<itunes:owner>'.PHP_EOL;
401
+ echo "\t\t".'<itunes:name>' . wp_specialchars($powerpress_feed['talent_name']) . '</itunes:name>'.PHP_EOL;
402
  echo "\t\t".'<itunes:email>' . wp_specialchars($Feed['email']) . '</itunes:email>'.PHP_EOL;
403
  echo "\t".'</itunes:owner>'.PHP_EOL;
404
+ echo "\t".'<managingEditor>'. wp_specialchars($Feed['email'] .' ('. $powerpress_feed['talent_name'] .')') .'</managingEditor>'.PHP_EOL;
405
  }
406
 
407
  if( $Feed['copyright'] )
422
  if( $Feed['rss2_image'] )
423
  {
424
  echo"\t". '<image>' .PHP_EOL;
425
+ echo "\t\t".'<title>' . wp_specialchars( get_bloginfo_rss('name') . get_wp_title_rss() ) . '</title>'.PHP_EOL;
426
  echo "\t\t".'<url>' . wp_specialchars($Feed['rss2_image']) . '</url>'.PHP_EOL;
427
  echo "\t\t".'<link>'. get_bloginfo('url') . '</link>' . PHP_EOL;
428
  echo "\t".'</image>' . PHP_EOL;
430
  else // Use the default image
431
  {
432
  echo"\t". '<image>' .PHP_EOL;
433
+ echo "\t\t".'<title>' . wp_specialchars( get_bloginfo_rss('name') . get_wp_title_rss() ) . '</title>'.PHP_EOL;
434
  echo "\t\t".'<url>' . powerpress_get_root_url() . 'rss_default.jpg</url>'.PHP_EOL;
435
  echo "\t\t".'<link>'. get_bloginfo('url') . '</link>' . PHP_EOL;
436
  echo "\t".'</image>' . PHP_EOL;
437
  }
438
 
439
+ // Handle iTunes categories
440
  $Categories = powerpress_itunes_categories();
441
  $Cat1 = false; $Cat2 = false; $Cat3 = false;
442
  if( $Feed['itunes_cat_1'] != '' )
530
  }
531
  }
532
  }
533
+ // End Handle iTunes categories
534
  }
535
 
536
  add_action('rss2_head', 'powerpress_rss2_head');
537
 
538
  function powerpress_rss2_item()
539
  {
540
+ global $post, $powerpress_feed;
541
  $duration = false;
542
 
543
+ // are we processing a feed that powerpress should handle
544
+ if( !powerpress_is_podcast_feed() )
545
+ return;
546
+
547
  if( function_exists('post_password_required') )
548
  {
549
  if( post_password_required($post) )
550
  return $content;
551
  }
 
 
 
 
552
 
553
  // Check and see if we're working with a podcast episode
554
+ $custom_enclosure = false;
555
+ if( powerpress_is_custom_podcast_feed() && get_query_var('feed') != 'podcast' )
556
+ {
557
+ $enclosureData = get_post_meta($post->ID, '_'. get_query_var('feed') .':enclosure', true);
558
+ $custom_enclosure = true;
559
+ }
560
+ else
561
+ {
562
+ $enclosureData = get_post_meta($post->ID, 'enclosure', true);
563
+ }
564
+
565
  if( !$enclosureData )
566
  {
567
  $EnclosureURL = '';
568
+ if( $powerpress_feed['process_podpress'] )
569
  {
570
  //$Settings = get_option('powerpress_general');
571
  $podPressMedia = get_post_meta($post->ID, 'podPressMedia', true);
580
  {
581
  $EnclosureURL = $podPressMedia[0]['URI'];
582
  if( strpos($EnclosureURL, 'http://' ) !== 0 )
583
+ $EnclosureURL = $powerpress_feed['default_url'] . $EnclosureURL;
584
  $EnclosureSize = $podPressMedia[0]['size'];
585
  $duration = $podPressMedia[0]['duration'];
586
  $EnclosureType = false;
594
  }
595
 
596
  if( $EnclosureType && $EnclosureSize && $EnclosureURL )
597
+ echo "\t\t".'<enclosure url="' . trim(htmlspecialchars($EnclosureURL)) . '" length="'. $EnclosureSize .'" type="'. $EnclosureType .'" />'.PHP_EOL;
598
  else
599
  return;
600
  }
605
  return;
606
  }
607
 
608
+ // Split the episode information into parts...
609
+ list($EnclosureURL, $EnclosureSize, $EnclosureType, $Serialized) = split("\n", $enclosureData);
610
+ $EnclosureURL = trim($EnclosureURL);
611
+ $EnclosureType = trim($EnclosureType);
612
+ $EnclosureSize = trim($EnclosureSize);
613
+ $author = $powerpress_feed['talent_name'];
614
+ $explicit = $powerpress_feed['explicit'];
615
+ $summary = false;
616
+ $subtitle = false;
617
+ $keywords = false;
618
+ $block = $powerpress_feed['block'];
619
+
620
+ if( $Serialized )
621
+ {
622
+ $EpisodeData = unserialize($Serialized);
623
+ if( isset( $EpisodeData['duration'] ) )
624
+ $duration = $EpisodeData['duration'];
625
+ if( isset( $EpisodeData['author'] ) )
626
+ $author = $EpisodeData['author'];
627
+ if( isset( $EpisodeData['explicit'] ) )
628
+ $explicit = $EpisodeData['explicit'];
629
+ if( isset( $EpisodeData['summary'] ) )
630
+ $summary = $EpisodeData['summary'];
631
+ if( isset( $EpisodeData['subtitle'] ) )
632
+ $subtitle = $EpisodeData['subtitle'];
633
+ if( isset( $EpisodeData['keywords'] ) )
634
+ $keywords = $EpisodeData['keywords'];
635
+ if( isset( $EpisodeData['block'] ) )
636
+ $block = $EpisodeData['block'];
637
+ }
638
+
639
+ if( !$duration && !$custom_enclosure )
640
  $duration = get_post_meta($post->ID, 'itunes:duration', true);
641
 
642
+ if( $custom_enclosure ) // We need to add the enclosure tag here...
 
 
643
  {
644
+ $ModifiedURL = powerpress_add_redirect_url($EnclosureURL);
645
+ echo "\t". sprintf('<enclosure url="%s" length="%d" type="%s" />%s',
646
+ $ModifiedURL,
647
+ $EnclosureSize,
648
+ $EnclosureType,
649
+ PHP_EOL);
650
+ }
651
 
652
+ // Get the post tags:
653
+ if( !$keywords )
654
+ {
655
+ // Lets try to use the page tags...
656
+ $tagobject = wp_get_post_tags( $post->ID );
657
+ if( count($tagobject) )
658
+ {
659
+ $tags = array();
660
+ for($c = 0; $c < count($tagobject) && $c < 12; $c++) // iTunes only accepts up to 12 keywords
661
+ $tags[] = $tagobject[$c]->name;
662
+
663
+ if( count($tags) > 0 )
664
+ $keywords = implode(",", $tags);
665
+ }
666
  }
667
 
668
+ if( $keywords )
669
+ echo "\t\t<itunes:keywords>" . powerpress_format_itunes_value($keywords) . '</itunes:keywords>'.PHP_EOL;
670
+
671
  // Strip and format the wordpress way, but don't apply any other filters for these itunes tags
672
  $content_no_html = $post->post_content;
673
  if( function_exists('strip_shortcodes') )
677
 
678
  $excerpt_no_html = strip_tags($post->post_excerpt);
679
 
680
+ if( $subtitle )
681
+ echo "\t\t<itunes:subtitle>". powerpress_format_itunes_value(powerpress_smart_trim($subtitle, 250, true)) .'</itunes:subtitle>'.PHP_EOL;
682
+ else if( $excerpt_no_html )
683
  echo "\t\t<itunes:subtitle>". powerpress_format_itunes_value(powerpress_smart_trim($excerpt_no_html, 250, true)) .'</itunes:subtitle>'.PHP_EOL;
684
  else
685
  echo "\t\t<itunes:subtitle>". powerpress_format_itunes_value(powerpress_smart_trim($content_no_html, 250, true)) .'</itunes:subtitle>'.PHP_EOL;
686
 
687
+ if( $powerpress_feed['enhance_itunes_summary'] )
688
  echo "\t\t<itunes:summary>". powerpress_itunes_summary($post->post_content) .'</itunes:summary>'.PHP_EOL;
689
+ else if( $summary )
690
+ echo "\t\t<itunes:summary>". powerpress_format_itunes_value(powerpress_smart_trim($summary, 4000), 4000) .'</itunes:summary>'.PHP_EOL;
691
  else
692
  echo "\t\t<itunes:summary>". powerpress_format_itunes_value(powerpress_smart_trim($content_no_html, 4000), 4000) .'</itunes:summary>'.PHP_EOL;
693
 
694
+ if( $author )
695
+ echo "\t\t<itunes:author>" . wp_specialchars($author) . '</itunes:author>'.PHP_EOL;
696
 
697
+ if( $explicit )
698
+ echo "\t\t<itunes:explicit>" . $explicit . '</itunes:explicit>'.PHP_EOL;
699
 
700
  if( $duration && preg_match('/^(\d{1,2}:){0,2}\d{1,2}$/i', $duration) ) // Include duration if it is valid
701
  echo "\t\t<itunes:duration>" . ltrim($duration, '0:') . '</itunes:duration>'.PHP_EOL;
702
+
703
+ if( $block && $block == 'yes' )
704
+ echo "\t\t<itunes:block>yes</itunes:block>\n";
705
  }
706
 
707
  add_action('rss2_item', 'powerpress_rss2_item');
708
 
709
  function powerpress_filter_rss_enclosure($content)
710
  {
711
+ if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) )
712
+ return $content; // Another podcasting plugin is enabled...
713
+
714
+ if( !powerpress_is_podcast_feed() )
715
+ return ''; // All custom podcast feeds we handle directly
716
+
717
+ if( powerpress_is_custom_podcast_feed() && get_query_var('feed') != 'podcast' )
718
+ return ''; // We will handle this enclosure in the powerpress_rss2_item() function
719
+
720
  $match_count = preg_match('/\surl="([^"]*)"/', $content, $matches);
721
  if( count($matches) != 2)
722
  return $content;
741
  return $content;
742
  }
743
 
744
+
745
  add_filter('rss_enclosure', 'powerpress_filter_rss_enclosure');
746
 
747
+ function powerpress_bloginfo_rss($content, $field)
748
+ {
749
+ if( powerpress_is_custom_podcast_feed() )
750
+ {
751
+ $Feed = get_option('powerpress_feed_'.get_query_var('feed') );
752
+ //$Feed = true;
753
+ if( $Feed )
754
+ {
755
+ switch( $field )
756
+ {
757
+ case 'description': {
758
+ if( isset($Feed['description']) && $Feed['description'] != '' )
759
+ return $Feed['description'];
760
+ }; break;
761
+ case 'url': {
762
+ if( isset($Feed['url']) && $Feed['url'] != '' )
763
+ return trim($Feed['url']);
764
+ }; break;
765
+ case 'name':
766
+ default: {
767
+ if( isset($Feed['title']) && $Feed['title'] != '' )
768
+ return $Feed['title'];
769
+ }; break;
770
+
771
+ }
772
+ }
773
+ }
774
+
775
+ return $content;
776
+ }
777
+
778
+ add_filter('get_bloginfo_rss', 'powerpress_bloginfo_rss', 10, 2);
779
+
780
+
781
+ function powerpress_do_podcast_feed($for_comments=false)
782
  {
783
  global $wp_query;
784
  $wp_query->get_posts();
785
+ do_feed_rss2($for_comments);
786
  }
787
 
788
  function powerpress_template_redirect()
789
  {
790
+ if( is_feed() && powerpress_is_custom_podcast_feed() )
791
  {
792
  remove_action('template_redirect', 'ol_feed_redirect'); // Remove this action
793
+ $Feed = get_option('powerpress_feed_'.get_query_var('feed') );
794
+ if( $Feed && trim(@$Feed['feed_redirect_url']) != '' && !preg_match("/feedburner|feedsqueezer|feedvalidator/i", $_SERVER['HTTP_USER_AGENT'] ) && @$_GET['redirect'] != 'no' )
795
  {
796
+ if (function_exists('status_header'))
797
+ status_header( 302 );
798
  header("Location: " . trim($Feed['feed_redirect_url']));
799
  header("HTTP/1.1 302 Temporary Redirect");
800
  exit();
806
 
807
  function powerpress_init()
808
  {
809
+ if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) )
810
+ return false; // Another podcasting plugin is enabled...
811
+
812
  add_feed('podcast', 'powerpress_do_podcast_feed');
813
+
814
+ $GeneralSettings = get_option('powerpress_general');
815
+ if( $GeneralSettings && isset($GeneralSettings['custom_feeds']) && is_array($GeneralSettings['custom_feeds']) )
816
+ {
817
+ while( list($feed_slug,$feed_title) = each($GeneralSettings['custom_feeds']) )
818
+ {
819
+ if( $feed_slug != 'podcast' )
820
+ add_feed($feed_slug, 'powerpress_do_podcast_feed');
821
+ }
822
+ }
823
  }
824
 
825
  add_action('init', 'powerpress_init');
826
 
827
+ // Load the general feed settings for feeds handled by powerpress
828
+ function powerpress_load_general_feed_settings()
829
+ {
830
+ global $powerpress_feed;
831
+ if( $powerpress_feed !== false )
832
+ {
833
+ $powerpress_feed = false;
834
+
835
+ // Get the powerpress settings
836
+ $GeneralSettings = get_option('powerpress_general');
837
+ if( $GeneralSettings )
838
+ {
839
+ $feed_slug = get_query_var('feed');
840
+
841
+ if( isset($GeneralSettings['custom_feeds']) && is_array($GeneralSettings['custom_feeds']) && isset($GeneralSettings['custom_feeds'][ $feed_slug ] ))
842
+ {
843
+ $Feed = get_option('powerpress_feed_'.$feed_slug);
844
+ $powerpress_feed = array();
845
+ $powerpress_feed['is_custom'] = true;
846
+ $powerpress_feed['feed-slug'] = $feed_slug;
847
+ $powerpress_feed['process_podpress'] = false; // We don't touch podpress data for custom feeds
848
+ $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/';
849
+ $explicit = array("no", "yes", "clean");
850
+ $powerpress_feed['explicit'] = $explicit[$Feed['itunes_explicit']];
851
+ if( $Feed['talent_name'] )
852
+ $powerpress_feed['talent_name'] = $Feed['talent_name'];
853
+ else
854
+ $powerpress_feed['talent_name'] = get_bloginfo_rss('name');
855
+ $powerpress_feed['enhance_itunes_summary'] = @$Feed['enhance_itunes_summary'];
856
+ $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
857
+ }
858
+ else
859
+ {
860
+ // One last check, we may still want to manage this feed, it's just not a custom feed...
861
+ $Feed = get_option('powerpress_feed');
862
+ // First, determine if powerpress should even be rewriting this feed...
863
+ switch( $Feed['apply_to'] )
864
+ {
865
+ case 2: // RSS2 feed only
866
+ if( $feed_slug != 'podcast' && isset($GLOBALS['wp_query']->query_vars) && count($GLOBALS['wp_query']->query_vars) > 1 )
867
+ break; // This is not just an RSS2 feed...
868
+ case 1: // All other feeds
869
+ {
870
+ $powerpress_feed = array();
871
+ $powerpress_feed['is_custom'] = false; // ($feed_slug == 'podcast'?true:false);
872
+ $powerpress_feed['feed-slug'] = $feed_slug;
873
+ $powerpress_feed['process_podpress'] = $GeneralSettings['process_podpress']; // We don't touch podpress data for custom feeds
874
+ $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/';
875
+ $explicit = array("no", "yes", "clean");
876
+ $powerpress_feed['explicit'] = $explicit[$Feed['itunes_explicit']];
877
+ if( $Feed['talent_name'] )
878
+ $powerpress_feed['talent_name'] = $Feed['talent_name'];
879
+ else
880
+ $powerpress_feed['talent_name'] = get_bloginfo_rss('name');
881
+ $powerpress_feed['enhance_itunes_summary'] = @$Feed['enhance_itunes_summary'];
882
+ $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
883
+ }; break;
884
+ // All other cases we let fall through
885
+ }
886
+ }
887
+ }
888
+ }
889
+ }
890
+
891
+ // Returns true of the feed should be treated as a podcast feed
892
+ function powerpress_is_podcast_feed()
893
+ {
894
+ if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) )
895
+ return false; // Another podcasting plugin is enabled...
896
+
897
+ global $powerpress_feed;
898
+ if( $powerpress_feed !== false && !is_array($powerpress_feed) )
899
+ powerpress_load_general_feed_settings();
900
+ if( $powerpress_feed === false )
901
+ return false;
902
+ return true;
903
+ }
904
+
905
+ // Returns true if the feed is a custom feed added by PowerPress
906
+ function powerpress_is_custom_podcast_feed()
907
+ {
908
+ if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) )
909
+ return false; // Another podcasting plugin is enabled...
910
+
911
+ global $powerpress_feed;
912
+ if( $powerpress_feed !== false && !is_array($powerpress_feed) )
913
+ powerpress_load_general_feed_settings();
914
+ if( $powerpress_feed === false )
915
+ return false;
916
+ return $powerpress_feed['is_custom'];
917
+ }
918
 
919
  function powerpress_posts_join($join)
920
  {
921
+ if( is_feed() && (powerpress_is_custom_podcast_feed() || get_query_var('feed') == 'podcast' ) )
922
  {
923
  global $wpdb;
924
  $join .= " INNER JOIN {$wpdb->postmeta} ";
931
 
932
  function powerpress_posts_where($where)
933
  {
934
+ if( is_feed() && (powerpress_is_custom_podcast_feed() || get_query_var('feed') == 'podcast' ) )
935
  {
936
+ global $wpdb, $powerpress_feed;
937
  $where .= " AND (";
 
938
 
939
+ if( powerpress_is_custom_podcast_feed() && get_query_var('feed') != 'podcast' )
940
+ $where .= " {$wpdb->postmeta}.meta_key = '_". get_query_var('feed') .":enclosure' ";
941
+ else
942
+ $where .= " {$wpdb->postmeta}.meta_key = 'enclosure' ";
943
 
944
  // Include Podpress data if exists...
945
+ if( $powerpress_feed['process_podpress'] && get_query_var('feed') == 'podcast' )
 
946
  $where .= " OR {$wpdb->postmeta}.meta_key = 'podPressMedia' ";
947
+
948
+ $where .= ") ";
949
  }
950
  return $where;
951
  }
954
 
955
  // Add the groupby needed for enclosures only
956
  function powerpress_posts_groupby($groupby)
957
+ {
958
+ if( is_feed() && (powerpress_is_custom_podcast_feed() || get_query_var('feed') == 'podcast' ) )
959
  {
960
  global $wpdb;
961
  $groupby = " {$wpdb->posts}.ID ";
962
  }
963
  return $groupby;
964
  }
 
965
  add_filter('posts_groupby', 'powerpress_posts_groupby');
966
 
967
+ function powerpress_post_limits($limits)
968
+ {
969
+ if( is_feed() && powerpress_is_custom_podcast_feed() )
970
+ {
971
+ global $powerpress_feed;
972
+ if( $powerpress_feed['posts_per_rss'] && preg_match('/^(\d)+$/', trim($powerpress_feed['posts_per_rss'])) )
973
+ $limits = "LIMIT 0, {$powerpress_feed['posts_per_rss']}";
974
+ }
975
+ return $limits;
976
+ }
977
+ add_filter('post_limits', 'powerpress_post_limits');
978
 
979
  function powerpress_wp_footer()
980
  {
985
  if( isset($g_powerpress_footer['player_js']) )
986
  {
987
  echo '<script type="text/javascript">'.PHP_EOL;
988
+ if( POWERPRESS_USE_ONLOAD == false && defined('POWERPRESS_USE_FOOTER_DELAY') && POWERPRESS_USE_FOOTER_DELAY && is_numeric(POWERPRESS_USE_FOOTER_DELAY) )
989
  {
990
+ echo 'function powerpress_onload_delay() {'.PHP_EOL;
991
  echo $g_powerpress_footer['player_js'];
992
  echo '}'.PHP_EOL;
993
+ echo "setTimeout('powerpress_onload_delay()', ".POWERPRESS_USE_FOOTER_DELAY.");\n";
994
  }
995
  else
996
  {
1223
  $key = sprintf('redirect%d', $x);
1224
  if( $GeneralSettings[ $key ] )
1225
  {
1226
+ $RedirectClean = str_replace('http://', '', trim($GeneralSettings[ $key ]) );
1227
  if( !strstr($NewURL, $RedirectClean) )
1228
  $NewURL = 'http://'. $RedirectClean . str_replace('http://', '', $NewURL);
1229
  }
1259
  return $ppsize;
1260
  }
1261
 
1262
+ function powerpress_readable_duration($duration, $include_hour=false)
1263
+ {
1264
+ $seconds = 0;
1265
+ $parts = split(':', $duration);
1266
+ if( count($parts) == 3 )
1267
+ $seconds = $parts[2] + ($parts[1]*60) + ($parts[0]*60*60);
1268
+ else if ( count($parts) == 2 )
1269
+ $seconds = $parts[1] + ($parts[0]*60);
1270
+ else
1271
+ $seconds = $parts[0];
1272
+
1273
+ $hours = 0;
1274
+ $minutes = 0;
1275
+ if( $seconds > (60*60) )
1276
+ {
1277
+ $hours = floor( $seconds /(60*60) );
1278
+ $seconds -= (60*60*$hours);
1279
+ }
1280
+ if( $seconds > (60) )
1281
+ {
1282
+ $minutes = floor( $seconds /(60) );
1283
+ $seconds -= (60*$minutes);
1284
+ }
1285
+
1286
+ if( $hours || $include_hour ) // X:XX:XX (readable)
1287
+ return sprintf('%d:%02d:%02d', $hours, $minutes, $seconds);
1288
+
1289
+ return sprintf('%d:%02d', $minutes, $seconds); // X:XX or 0:XX (readable)
1290
+ }
1291
+
1292
+
1293
  // For grabbing data from Podpress data stored serialized, the strings for some values can sometimes get corrupted, so we fix it...
1294
  function powerpress_repair_serialize($string)
1295
  {
powerpress_ico.png ADDED
Binary file
powerpressadmin-appearance.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // powerpressadmin-presentation.php
3
+
4
+ function powerpressadmin_appearance()
5
+ {
6
+ $General = powerpress_get_settings('powerpress_general');
7
+ ?>
8
+ <h2><?php echo __("Appearance Settings"); ?></h2>
9
+
10
+ <p style="margin-bottom: 0;">Configure how your media will be found on your blog.</p>
11
+
12
+
13
+ <table class="form-table">
14
+ <tr valign="top">
15
+ <th scope="row"><?php echo __("Media Presentation"); ?></th>
16
+ <td><select name="General[display_player]" class="bpp_input_sm">
17
+ <?php
18
+ $displayoptions = array(1=>"Below Post", 2=>"Above Post", 0=>"None");
19
+
20
+ while( list($value,$desc) = each($displayoptions) )
21
+ echo "\t<option value=\"$value\"". ($General['display_player']==$value?' selected':''). ">$desc</option>\n";
22
+
23
+ ?>
24
+ </select> (where player and/or links will be displayed)
25
+ <p><input name="General[display_player_excerpt]" type="checkbox" value="1" <?php if($General['display_player_excerpt']) echo 'checked '; ?>/> Display player / links in <a href="http://codex.wordpress.org/Template_Tags/the_excerpt" title="Explanation of an excerpt in Wordpress" target="_blank">excerpts</a> (e.g. search results)</p>
26
+ </td>
27
+ </tr>
28
+
29
+ <tr valign="top">
30
+ <th scope="row">
31
+ <?php _e("Player Function"); ?></th>
32
+ <td><select name="General[player_function]" class="bpp_input_med">
33
+ <?php
34
+ $playeroptions = array(1=>'On Page & New Window', 2=>'On Page Only', 3=>'New Window Only', 4=>'On Page Link', 5=>'On Page Link & New Window', 0=>'Disable');
35
+
36
+ while( list($value,$desc) = each($playeroptions) )
37
+ echo "\t<option value=\"$value\"". ($General['player_function']==$value?' selected':''). ">".htmlspecialchars($desc)."</option>\n";
38
+
39
+ ?>
40
+ </select>
41
+ <p style="margin-top: 0;">
42
+ Note: "On Page Link" is a link to "play on page", the player is not displayed until link is clicked.
43
+ </p>
44
+ <?php
45
+ global $wp_version;
46
+ if( version_compare($wp_version, '2.7') < 0 ) // Wordpress before version 2.7
47
+ {
48
+ ?>
49
+ <p><input name="CheckSWF" type="checkbox" value="1" /> Verify flash player</p>
50
+ <?php
51
+ }
52
+ ?>
53
+ </td>
54
+ </tr>
55
+
56
+ <tr valign="top">
57
+ <th scope="row">
58
+
59
+ <?php _e("Download Link"); ?></th>
60
+ <td>
61
+ <select name="General[podcast_link]" class="bpp_input_med">
62
+ <?php
63
+ $linkoptions = array(1=>"Display", 2=>"Display with file size", 3=>"Display with file size and duration", 0=>"Disable");
64
+
65
+ while( list($value,$desc) = each($linkoptions) )
66
+ echo "\t<option value=\"$value\"". ($General['podcast_link']==$value?' selected':''). ">$desc</option>\n";
67
+
68
+ ?>
69
+ </select>
70
+ </td>
71
+ </tr>
72
+
73
+ <tr valign="top">
74
+ <th scope="row">
75
+ <?php echo __("Player Width"); ?>
76
+ </th>
77
+ <td>
78
+ <input type="text" name="General[player_width]" style="width: 50px;" onkeyup="javascript:this.value=this.value.replace(/[^0-9]/g, '');" value="<?php echo $General['player_width']; ?>" maxlength="4" />
79
+ Width of player (leave blank for 320 default)
80
+ </td>
81
+ </tr>
82
+
83
+ <tr valign="top">
84
+ <th scope="row">
85
+ <?php echo __("Player Height"); ?>
86
+ </th>
87
+ <td>
88
+ <input type="text" name="General[player_height]" style="width: 50px;" onkeyup="javascript:this.value=this.value.replace(/[^0-9]/g, '');" value="<?php echo $General['player_height']; ?>" maxlength="4" />
89
+ Height of player (leave blank for 240 default)
90
+ </td>
91
+ </tr>
92
+
93
+ <tr valign="top">
94
+ <th scope="row">
95
+ <?php echo __("Player Width Audio"); ?>
96
+ </th>
97
+ <td>
98
+ <input type="text" name="General[player_width_audio]" style="width: 50px;" onkeyup="javascript:this.value=this.value.replace(/[^0-9]/g, '');" value="<?php echo $General['player_width_audio']; ?>" maxlength="4" />
99
+ Width of Audio mp3 player (leave blank for 320 default)
100
+ </td>
101
+ </tr>
102
+
103
+ </table>
104
+ <p>
105
+ Looking for a better Audio Player? Check out the <a href="http://wpaudioplayer.com" target="_blank" title="WP Audio Player 2.0">WP Audio Player 2.0</a>.
106
+ The WP Audio Player 2.0 options include
107
+ theme colors, initial volume, player width and more.
108
+ </p>
109
+ <br />
110
+ <?php
111
+ } // End powerpress_admin_appearance()
112
+
113
+ ?>
powerpressadmin-basic.php ADDED
@@ -0,0 +1,296 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function powerpress_admin_basic()
4
+ {
5
+ $General = powerpress_get_settings('powerpress_general');
6
+ $AdvancedMode = $General['advanced_mode'];
7
+ ?>
8
+ <h2><?php echo __("Basic Settings"); ?></h2>
9
+
10
+ <table class="form-table">
11
+
12
+
13
+ <tr valign="top">
14
+ <th scope="row">
15
+
16
+ <?php echo __("Mode"); ?></th>
17
+ <td><input type="hidden" name="General[advanced_mode]" id="powerpress_advanced_mode" value="<?php echo $General['advanced_mode']; ?>" />
18
+ <?php
19
+ if( $General['advanced_mode'] == 0 )
20
+ {
21
+ ?>
22
+ <p style="margin-top: 5px;">Simple Mode (<strong><a href="#" onclick="return powerpress_changemode(1);">Switch to Advanced Mode</a></strong>)</p>
23
+ <?php
24
+ }
25
+ else
26
+ {
27
+ ?>
28
+ <p style="margin-top: 5px;">Advanced Mode (<strong><a href="#" onclick="return powerpress_changemode(0);">Switch to Simple Mode</a></strong>)</p>
29
+ <?php
30
+ }
31
+ ?>
32
+ </td>
33
+ </tr>
34
+
35
+
36
+ <?php if( $AdvancedMode ) { ?>
37
+ <tr valign="top">
38
+ <th scope="row"><?php _e("Default Media URL"); ?></th>
39
+ <td>
40
+ <input type="text" style="width: 80%;" name="General[default_url]" value="<?php echo $General['default_url']; ?>" maxlength="250" />
41
+ <p>URL above will prefix entered file names that do not start with 'http://'. URL above must end with a trailing slash.
42
+ You may leave blank if you always enter the complete URL to your media when creating podcast episodes.
43
+ </p>
44
+ <p>e.g. http://example.com/mediafolder/</p>
45
+ </td>
46
+ </tr>
47
+ <?php } ?>
48
+
49
+ <?php
50
+ if( $General['process_podpress'] || powerpress_podpress_episodes_exist() )
51
+ {
52
+ ?>
53
+ <tr valign="top">
54
+ <th scope="row">
55
+
56
+ <?php _e("PodPress Episodes"); ?></th>
57
+ <td>
58
+ <select name="General[process_podpress]" class="bpp_input_med">
59
+ <?php
60
+ $options = array(0=>'Ignore', 1=>'Include in Posts and Feeds');
61
+
62
+ while( list($value,$desc) = each($options) )
63
+ echo "\t<option value=\"$value\"". ($General['process_podpress']==$value?' selected':''). ">$desc</option>\n";
64
+
65
+ ?>
66
+ </select> (includes podcast episodes previously created in PodPress)
67
+ </td>
68
+ </tr>
69
+ <?php } ?>
70
+
71
+ <?php if( $AdvancedMode ) { ?>
72
+
73
+
74
+ <tr valign="top">
75
+ <th scope="row"><?php _e("iTunes URL"); ?></th>
76
+ <td>
77
+ <input type="text" style="width: 80%;" name="General[itunes_url]" value="<?php echo $General['itunes_url']; ?>" maxlength="250" />
78
+ <p>Click the following link to <a href="https://phobos.apple.com/WebObjects/MZFinance.woa/wa/publishPodcast" target="_blank" title="Publish a Podcast on iTunes">Publish a Podcast on iTunes</a>.
79
+ Once your podcast is listed on iTunes, enter your one-click subscription URL above.
80
+ </p>
81
+ <p>e.g. http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=000000000</p>
82
+ </td>
83
+ </tr>
84
+
85
+ <?php
86
+ $OpenSSLSupport = extension_loaded('openssl');
87
+ ?>
88
+ <tr valign="top">
89
+ <th scope="row">
90
+
91
+ <?php _e("Ping iTunes"); ?></th>
92
+ <td>
93
+ <select name="General[ping_itunes]"<?php if( $OpenSSLSupport == false ) echo ' disabled'; ?> class="bpp_input_sm">
94
+ <?php
95
+ $options = array(0=>'No ', 1=>'Yes ');
96
+
97
+ if( $OpenSSLSupport == false )
98
+ $value = 0;
99
+
100
+ while( list($value,$desc) = each($options) )
101
+ echo "\t<option value=\"$value\"". ($General['ping_itunes']==$value?' selected':''). ">$desc</option>\n";
102
+
103
+ ?>
104
+ </select> (Notify iTunes when you publish a new episode.)
105
+ <p><input name="TestiTunesPing" type="checkbox" value="1"<?php if( $OpenSSLSupport == false ) echo ' disabled'; ?> /> Test iTunes Ping (recommended)</p>
106
+ <?php if( $General['itunes_url'] ) {
107
+
108
+ $ping_url = str_replace(
109
+ array( 'https://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=',
110
+ 'http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=',
111
+ 'https://www.itunes.com/podcast?id=',
112
+ 'http://www.itunes.com/podcast?id='),
113
+ 'https://phobos.apple.com/WebObjects/MZFinance.woa/wa/pingPodcast?id=', $General['itunes_url']);
114
+ ?>
11