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
+ ?>
115
+ <p>You may also ping iTunes by using the following link: <a href="#" onclick="javascript: window.open('<?php echo $ping_url; ?>'); return false;" title="Ping iTunes in New Window">Ping iTunes in New Window</a></p>
116
+ <?php } ?>
117
+ </td>
118
+ </tr>
119
+ <?php } // End if $AdvancedMode ?>
120
+ </table>
121
+ <?php if( $OpenSSLSupport == false && $AdvancedMode ) { ?>
122
+ <div class="error powerpress-error">Ping iTunes requires OpenSSL in PHP. Please refer to your php.ini to enable the php_openssl module.</div>
123
+ <?php } // End if !$OpenSSLSupport ?>
124
+
125
+
126
+ <h2><?php _e("Edit Post Settings"); ?></h2>
127
+ <p style="margin-bottom: 0;">Configure how the Podcast Episode entry boxes function when editing blog posts.</p>
128
+ <table class="form-table">
129
+ <tr valign="top">
130
+ <th scope="row">
131
+
132
+ <?php _e("Podcast Entry Box"); ?></th>
133
+ <td>
134
+
135
+ <ul>
136
+ <li><label><input type="radio" name="General[episode_box_mode]" value="0" <?php if( $General['episode_box_mode'] == 0 ) echo 'checked'; ?> onclick="javascript:document.getElementById('episode_entry_settings').style.display='block';" /> Normal Mode</label> (default)</li>
137
+ <li>
138
+ <ul>
139
+ <li>Episode entry box includes Media URL, File Size and Duration fields.</li>
140
+ </ul>
141
+ </li>
142
+ <li><label><input type="radio" name="General[episode_box_mode]" value="1" <?php if( $General['episode_box_mode'] == 1 ) echo 'checked'; ?> onclick="javascript:document.getElementById('episode_entry_settings').style.display='none';" /> Simple Mode</label></li>
143
+ <li>
144
+ <ul>
145
+ <li>Episode entry box includes Media URL field only. File Size and Duration will be auto detected.</li>
146
+ </ul>
147
+ </li>
148
+ </ul>
149
+
150
+ </td>
151
+ </tr>
152
+ </table>
153
+ <div id="episode_entry_settings" style="<?php if( $General['episode_box_mode'] == 1 ) echo 'display:none;'; ?>">
154
+ <?php if( $AdvancedMode ) { ?>
155
+ <table class="form-table">
156
+ <tr valign="top">
157
+ <th scope="row">
158
+
159
+ <?php _e("File Size Default"); ?></th>
160
+ <td>
161
+ <select name="General[set_size]" class="bpp_input_med">
162
+ <?php
163
+ $options = array(0=>'Auto detect file size', 1=>'User specify');
164
+
165
+ while( list($value,$desc) = each($options) )
166
+ echo "\t<option value=\"$value\"". ($General['set_size']==$value?' selected':''). ">$desc</option>\n";
167
+
168
+ ?>
169
+ </select> (specify default file size option when creating a new episode)
170
+ </td>
171
+ </tr>
172
+
173
+ <tr valign="top">
174
+ <th scope="row">
175
+ <?php _e("Duration Default"); ?></th>
176
+ <td>
177
+ <select name="General[set_duration]" class="bpp_input_med">
178
+ <?php
179
+ $options = array(0=>'Auto detect duration (mp3\'s only)', 1=>'User specify', -1=>'Not specified (not recommended)');
180
+
181
+ while( list($value,$desc) = each($options) )
182
+ echo "\t<option value=\"$value\"". ($General['set_duration']==$value?' selected':''). ">$desc</option>\n";
183
+
184
+ ?>
185
+ </select> (specify default duration option when creating a new episode)
186
+ </td>
187
+ </tr>
188
+ </table>
189
+ <br />
190
+ <?php
191
+ }
192
+ ?>
193
+ </div>
194
+
195
+
196
+ <h2><?php _e("Media Statistics"); ?></h2>
197
+ <p>
198
+ Enter your Redirect URL issued by your media statistics service provider below.
199
+ </p>
200
+
201
+ <div style="position: relative;">
202
+ <table class="form-table">
203
+ <tr valign="top">
204
+ <th scope="row">
205
+ <?php _e("Redirect URL 1"); ?>
206
+ </th>
207
+ <td>
208
+ <input type="text" style="width: 60%;" name="General[redirect1]" value="<?php echo $General['redirect1']; ?>" maxlength="250" />
209
+ <!-- <div style="margin-left: 2px;margin-top: 0;">Enter your issued Blubrry Statistics Redirect URL above.</div> -->
210
+ </td>
211
+ </tr>
212
+ </table>
213
+ <?php if( $General['redirect2'] == '' && $General['redirect3'] == '' ) { ?>
214
+ <div style="position: absolute;bottom: 0px;right: 10px;font-size: 85%;" id="powerpress_redirect2_showlink">
215
+ <a href="javascript:void();" onclick="javascript:document.getElementById('powerpress_redirect2_table').style.display='block';document.getElementById('powerpress_redirect2_showlink').style.display='none';return false;">Add Another Redirect</a>
216
+ </div>
217
+ <?php } ?>
218
+ </div>
219
+
220
+ <div id="powerpress_redirect2_table" style="position: relative;<?php if( $General['redirect2'] == '' && $General['redirect3'] == '' ) echo 'display:none;'; ?>">
221
+ <table class="form-table">
222
+ <tr valign="top">
223
+ <th scope="row">
224
+ <?php _e("Redirect URL 2"); ?>
225
+ </th>
226
+ <td>
227
+ <input type="text" style="width: 60%;" name="General[redirect2]" value="<?php echo $General['redirect2']; ?>" maxlength="250" />
228
+ </td>
229
+ </tr>
230
+ </table>
231
+ <?php if( $General['redirect3'] == '' ) { ?>
232
+ <div style="position: absolute;bottom: 0px;right: 10px;font-size: 85%;" id="powerpress_redirect3_showlink">
233
+ <a href="javascript:void();" onclick="javascript:document.getElementById('powerpress_redirect3_table').style.display='block';document.getElementById('powerpress_redirect3_showlink').style.display='none';return false;">Add Another Redirect</a>
234
+ </div>
235
+ <?php } ?>
236
+ </div>
237
+
238
+ <div id="powerpress_redirect3_table" style="<?php if( $General['redirect3'] == '' ) echo 'display:none;'; ?>">
239
+ <table class="form-table">
240
+ <tr valign="top">
241
+ <th scope="row">
242
+ <?php _e("Redirect URL 3"); ?>
243
+ </th>
244
+ <td>
245
+ <input type="text" style="width: 60%;" name="General[redirect3]" value="<?php echo $General['redirect3']; ?>" maxlength="250" />
246
+ </td>
247
+ </tr>
248
+ </table>
249
+ </div>
250
+
251
+ <input type="hidden" id="hide_free_stats" name="General[hide_free_stats]" value="<?php echo $General['hide_free_stats']; ?>" />
252
+
253
+ <div id="blubrry_stats_box" style="<?php if( $General['hide_free_stats'] == 1 ) echo 'display:none;'; ?>">
254
+ <div style="font-family: Arial, Helvetica, sans-serif; border: solid 1px #3D517E; background-color:#D2E9FF;padding:10px; margin-left:10px;margin-right:10px;margin-top:10px;">
255
+ <div style="color: #3D517E; font-weight: bold; font-size: 18px;">Free Access to the Best Media Statistics!</div>
256
+ <div style="font-size: 14px;margin-top: 10px; margin-bottom: 10px;">
257
+ Get <span style="color: #990000; font-weight: bold;">Free</span> Media Statistics by taking a few minutes and adding your podcast to Blubrry.com. What's the catch? Nothing!
258
+ For many, our free service is all you will need. But if you're looking to further your abilities with media download information, we hope you consider upgrading to our paid Premium Statistics service.
259
+ </div>
260
+ <div style="text-align: center; font-size: 16px; font-weight: bold;"><a href="http://www.blubrry.com/addpodcast.php?feed=<?php echo urlencode(get_feed_link('podcast')); ?>" target="_blank" style="color: #3D517E;">Sign Up For Free Media Statistics Now</a></div>
261
+ </div>
262
+ <div style="font-size: 10px;margin-left: 10px;">
263
+ <a href="javascript:void();" onclick="javascript:document.getElementById('blubrry_stats_box').style.display='none';document.getElementById('hide_free_stats').value=1;document.getElementById('show_free_stats').style.display='block';return false;">hide</a>
264
+ </div>
265
+ </div>
266
+
267
+ <div id="show_free_stats" style="<?php if( $General['hide_free_stats'] != 1 ) echo 'display:none;'; ?>">
268
+ <table class="form-table">
269
+ <tr valign="top">
270
+ <th scope="row">
271
+ &nbsp;
272
+ </th>
273
+ <td>
274
+ <p style="margin: 0;"><a href="javascript:void();" onclick="javascript:document.getElementById('blubrry_stats_box').style.display='block';document.getElementById('hide_free_stats').value=0;document.getElementById('show_free_stats').style.display='none';return false;">Learn About Free Blubrry Statistics</a></p>
275
+ </td>
276
+ </tr>
277
+ </table>
278
+ </div>
279
+
280
+
281
+ <!--
282
+ <p>
283
+ The services above must support redirects that do
284
+ not include nested 'http://' within the URL. Statistics services such as
285
+ <a href="http://www.podtrac.com" target="_blank" title="PodTrac">PodTrac.com</a>,
286
+ <a href="http://www.blubrry.com/podcast_statistics/" target="_blank" title="Blubrry Statistics">Blubrry.com</a>,
287
+ <a href="http://www.techpodcasts.com/podcast_statistics/" target="_blank" title="TechPodcasts Statistics">TechPodcasts.com</a>,
288
+ <a href="http://www.rawvoice.com/products/statistics/" target="_blank" title="RawVoice Statistics">RawVoice.com</a>
289
+ are supported.
290
+ </p>
291
+ -->
292
+
293
+
294
+ <?php
295
+ }
296
+ ?>
powerpressadmin-customfeeds.php ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ function powerpress_admin_customfeeds_columns($data=array())
5
+ {
6
+ $data['name'] = 'Name';
7
+ $data['feed-slug'] = 'Slug';
8
+ $data['episode-count'] = 'Episodes';
9
+ $data['url'] = 'URL';
10
+ return $data;
11
+ }
12
+
13
+ add_filter('manage_powerpressadmin_customfeeds_columns', 'powerpress_admin_customfeeds_columns');
14
+
15
+ function powerpress_admin_customfeeds()
16
+ {
17
+ $General = powerpress_get_settings('powerpress_general');
18
+
19
+
20
+ ?>
21
+ <h2><?php echo __("Custom Podcast Feeds"); ?></h2>
22
+ <p style="">
23
+ Custom podcast feeds allow you to associate multiple media files and/or formats to one blog post. Note that additional custom feeds
24
+ will not appear in the online player or in download links.
25
+ </p>
26
+
27
+ <style type="text/css">
28
+
29
+ .column-url {
30
+ width: 40%;
31
+ }
32
+ .column-name {
33
+ width: 30%;
34
+ }
35
+ .column-feed-slug {
36
+ width: 15%;
37
+ }
38
+ .column-episode-count {
39
+ width: 15%;
40
+ }
41
+ </style>
42
+ <div id="col-container">
43
+
44
+ <div id="col-right">
45
+ <table class="widefat fixed" cellspacing="0">
46
+ <thead>
47
+ <tr>
48
+ <?php print_column_headers('powerpressadmin_customfeeds'); ?>
49
+ </tr>
50
+ </thead>
51
+
52
+ <tfoot>
53
+ <tr>
54
+ <?php print_column_headers('powerpressadmin_customfeeds', false); ?>
55
+ </tr>
56
+ </tfoot>
57
+ <tbody>
58
+ <?php
59
+
60
+
61
+ $Feeds = array('podcast'=>'Podcast Feed');
62
+ if( isset($General['custom_feeds']['podcast']) )
63
+ $Feeds = $General['custom_feeds'];
64
+ else if( is_array($General['custom_feeds']) )
65
+ $Feeds += $General['custom_feeds'];
66
+
67
+ asort($Feeds, SORT_STRING); // Sort feeds
68
+
69
+ $count = 0;
70
+ while( list($feed_slug, $feed_title) = each($Feeds ) )
71
+ {
72
+ $episode_total = powerpress_admin_episodes_per_feed($feed_slug);
73
+ $columns = powerpress_admin_customfeeds_columns();
74
+ $hidden = array();
75
+ if( $feed_slug == 'podcast' )
76
+ $feed_title = 'Podcast Feed (default)';
77
+ $feed_title = wp_specialchars($feed_title);
78
+ if( $count % 2 == 0 )
79
+ echo '<tr valign="middle" class="alternate">';
80
+ else
81
+ echo '<tr valign="middle">';
82
+
83
+ foreach($columns as $column_name=>$column_display_name) {
84
+ $class = "class=\"column-$column_name\"";
85
+
86
+ $edit_link = admin_url('admin.php?page=powerpress/powerpressadmin_customfeeds.php&amp;action=powerpress-editfeed&amp;feed_slug=') . $feed_slug;
87
+
88
+ $url = get_feed_link($feed_slug);
89
+ $short_url = str_replace('http://', '', $url);
90
+ $short_url = str_replace('www.', '', $short_url);
91
+ //if ('/' == substr($short_url, -1))
92
+ // $short_url = substr($short_url, 0, -1);
93
+ if (strlen($short_url) > 35)
94
+ $short_url = substr($short_url, 0, 32).'...';
95
+
96
+ //$short_url = '';
97
+
98
+ switch($column_name) {
99
+ case 'feed-slug': {
100
+
101
+ echo "<td $class>$feed_slug";
102
+ echo "</td>";
103
+
104
+ }; break;
105
+ case 'name': {
106
+
107
+ echo '<td '.$class.'><strong><a class="row-title" href="'.$edit_link.'" title="' . attribute_escape(sprintf(__('Edit "%s"'), $feed_title)) . '">'.$feed_title.'</a></strong><br />';
108
+ $actions = array();
109
+ $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
110
+ $actions['delete'] = "<a class='submitdelete' href='". admin_url() . wp_nonce_url("admin.php?page=powerpress/powerpressadmin_customfeeds.php&amp;action=powerpress-delete-feed&amp;feed_slug=$feed_slug", 'powerpress-delete-feed-' . $feed_slug) . "' onclick=\"if ( confirm('" . js_escape(sprintf( __("You are about to delete feed '%s'\n 'Cancel' to stop, 'OK' to delete."), $feed_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
111
+ $action_count = count($actions);
112
+ $i = 0;
113
+ echo '<div class="row-actions">';
114
+ foreach ( $actions as $action => $linkaction ) {
115
+ ++$i;
116
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
117
+ echo '<span class="'.$action.'">'.$linkaction.$sep .'</span>';
118
+ }
119
+ echo '</div>';
120
+ echo '</td>';
121
+
122
+ }; break;
123
+
124
+ case 'url': {
125
+
126
+ echo "<td $class><a href='$url' title='". attribute_escape(sprintf(__('Visit %s'), $feed_title))."' target=\"_blank\">$short_url</a>";
127
+ echo '<div class="row-actions">';
128
+ echo '<span class="'.$action .'"><a href="http://www.feedvalidator.org/check.cgi?url='. urlencode($url) .'" target="_blank">' . __('Validate Feed') . '</a></span>';
129
+ echo '</div>';
130
+ echo "</td>";
131
+
132
+ }; break;
133
+
134
+ case 'episode-count': {
135
+
136
+ echo "<td $class>$episode_total";
137
+ echo "</td>";
138
+
139
+ }; break;
140
+ default: {
141
+
142
+ }; break;
143
+ }
144
+ }
145
+ echo "\n </tr>\n";
146
+ $count++;
147
+ }
148
+ ?>
149
+ </tbody>
150
+ </table>
151
+ </div> <!-- col-right -->
152
+
153
+ <div id="col-left">
154
+ <div class="col-wrap">
155
+ <div class="form-wrap">
156
+ <h3><?php _e('Add Podcast Feed'); ?></h3>
157
+ <div id="ajax-response"></div>
158
+ <input type="hidden" name="action" value="powerpress-addfeed" />
159
+ <?php
160
+ //wp_original_referer_field(true, 'previous');
161
+ //wp_nonce_field('powerpress-add-feed');
162
+ ?>
163
+
164
+ <div class="form-field form-required">
165
+ <label for="feed_name"><?php _e('Feed Name') ?></label>
166
+ <input name="feed_name" id="feed_name" type="text" value="" size="40" />
167
+ <p><?php _e('The name is used for use within the administration area only.'); ?></p>
168
+ </div>
169
+
170
+ <div class="form-field">
171
+ <label for="feed_slug"><?php _e('Feed Slug') ?></label>
172
+ <input name="feed_slug" id="feed_slug" type="text" value="" size="40" />
173
+ <p><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
174
+ </div>
175
+
176
+ <p class="submit"><input type="submit" class="button" name="submit" value="<?php _e('Add Podcast Feed'); ?>" /></p>
177
+
178
+ </div>
179
+ </div>
180
+
181
+ </div> <!-- col-left -->
182
+
183
+ </div> <!-- col-container -->
184
+
185
+ <h3>Example Usage</h3>
186
+ <p>
187
+ Example 1: You want to distribute both an mp3 and an ogg version of your podcast. Use the default podcast feed for your mp3
188
+ media and create a custom feed for your ogg media.
189
+ </p>
190
+ <p>
191
+ Example 2: You have a video podcast with multiple file formats. Use the default podcast feed for the main media that you
192
+ want to appear on your blog (e.g. m4v). Create additional feeds for the remaining formats (e.g. wmv, mov, mpeg).
193
+ </p>
194
+ <p>
195
+ Example 3: You create two versions of your podcast, a 20 minute summary and a full 2 hour episode. Use the default feed for
196
+ your 20 minute summary episodes and create a new custom feed for your full length episodes.
197
+ </p>
198
+
199
+ <?php
200
+ }
201
+ ?>
powerpressadmin-editfeed.php ADDED
@@ -0,0 +1,388 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // powerpressadmin_editfeed.php
3
+ function powerpress_admin_editfeed($feed_slug=false)
4
+ {
5
+ $UploadArray = wp_upload_dir();
6
+ $upload_path = rtrim( substr($UploadArray['path'], 0, 0 - strlen($UploadArray['subdir']) ), '\\/').'/powerpress/';
7
+
8
+ if( !file_exists($upload_path) )
9
+ $SupportUploads = @mkdir($upload_path, 0777);
10
+ else
11
+ $SupportUploads = true;
12
+
13
+ $General = powerpress_get_settings('powerpress_general');
14
+ if( $feed_slug )
15
+ {
16
+ $FeedSettings = powerpress_get_settings('powerpress_feed_'.$feed_slug);
17
+ if( !$FeedSettings )
18
+ {
19
+ $FeedSettings = array();
20
+ $FeedSettings['title'] = $General['custom_feeds'][$feed_slug];
21
+ }
22
+ }
23
+ else
24
+ {
25
+ $FeedSettings = powerpress_get_settings('powerpress_feed');
26
+ }
27
+
28
+ $FeedTitle = __('Feed Settings');
29
+ if( $feed_slug )
30
+ {
31
+ $FeedTitle = sprintf( '%s: %s', $FeedTitle, $General['custom_feeds'][$feed_slug]) ;
32
+ echo sprintf('<input type="hidden" name="feed_slug" value="%s" />', $feed_slug);
33
+ }
34
+ $AdvancedMode = $General['advanced_mode'];
35
+ ?>
36
+ <h2><?php echo $FeedTitle; ?></h2>
37
+ <?php if( $feed_slug ) { ?>
38
+ <p style="margin-bottom: 0;">
39
+ <?php _e('Configure your custom podcast feed.'); ?>
40
+ </p>
41
+ <?php } else { ?>
42
+ <p style="margin-bottom: 0;">
43
+ <?php _e('Configure your feeds to support podcasting.'); ?>
44
+ </p>
45
+ <?php } ?>
46
+ <table class="form-table">
47
+ <?php if( !$feed_slug ) { ?>
48
+ <?php if( $AdvancedMode ) { ?>
49
+ <tr valign="top">
50
+ <th scope="row">
51
+
52
+ <?php echo __('Enhance Feeds'); ?></th>
53
+ <td>
54
+ <ul>
55
+ <li><label><input type="radio" name="Feed[apply_to]" value="1" <?php if( $FeedSettings['apply_to'] == 1 ) echo 'checked'; ?> /> Enhance All Feeds</label> (Recommended)</li>
56
+ <li>
57
+ <ul>
58
+ <li>Adds podcasting support to all feeds</li>
59
+ <li>Allows for Category Casting (Visitors may subscribe to your categories as a podcast)</li>
60
+ <li>Allows for Tag/Keyword Casting (Visitors may subscribe to your tags as a podcast)</li>
61
+ </ul>
62
+ </li>
63
+ <li><label><input type="radio" name="Feed[apply_to]" value="2" <?php if( $FeedSettings['apply_to'] == 2 ) echo 'checked'; ?> /> Enhance Main Feed Only</label></li>
64
+ <li>
65
+ <ul>
66
+ <li>Adds podcasting support to your main feed only</li>
67
+ </ul>
68
+ </li>
69
+ <li><label><input type="radio" name="Feed[apply_to]" value="0" <?php if( $FeedSettings['apply_to'] == 0 ) echo 'checked'; ?> /> Do Not Enhance Feeds</label></li>
70
+ <li>
71
+ <ul>
72
+ <li>Feed Settings below will only apply to your podcast only feeds</li>
73
+ </ul>
74
+ </li>
75
+ </ul>
76
+
77
+ <?php /* ?>
78
+ <select name="Feed[apply_to]" class="bpp_input_large" style="width: 60%;">
79
+ <?php
80
+ $applyoptions = array(1=>'All RSS2 Feeds (category / tag specific podcast feeds)', 2=>'Main RSS2 Feed only', 0=>'Disable (settings below ignored)');
81
+
82
+ while( list($value,$desc) = each($applyoptions) )
83
+ echo "\t<option value=\"$value\"". ($FeedSettings['apply_to']==$value?' selected':''). ">$desc</option>\n";
84
+
85
+ ?>
86
+ </select>
87
+ <p>Select 'All RSS Feeds' to include podcast episodes in all feeds such as category and tag feeds.</p>
88
+ <p>Select 'Main RSS2 Feed only' to include podcast episodes only in your primary RSS2 feed.</p>
89
+ <p>Select 'Disable' to prevent Blubrry PowerPress from adding podcast episodes to any feeds.</p>
90
+ <?php */ ?>
91
+ </td>
92
+ </tr>
93
+ <?php } // End AdvancedMode ?>
94
+
95
+ <tr valign="top">
96
+ <th scope="row">
97
+
98
+ <?php _e("Important Feeds"); ?></th>
99
+ <td>
100
+ <p style="margin-top: 5px;">Main RSS2 Feed: <a href="<?php echo get_bloginfo('rss2_url'); ?>" title="Main RSS 2 Feed" target="_blank"><?php echo get_bloginfo('rss2_url'); ?></a> | <a href="http://www.feedvalidator.org/check.cgi?url=<?php echo urlencode(get_bloginfo('rss2_url')); ?>" title="Validate Feed" target="_blank">validate</a></p>
101
+ <p>Special Podcast only Feed: <a href="<?php echo get_feed_link('podcast'); ?>" title="Podcast Feed" target="_blank"><?php echo get_feed_link('podcast'); ?></a> | <a href="http://www.feedvalidator.org/check.cgi?url=<?php echo urlencode(get_feed_link('podcast')); ?>" title="Validate Feed" target="_blank">validate</a></p>
102
+
103
+ </td>
104
+ </tr>
105
+ <?php } else { // Else if( $feed_slug) ?>
106
+
107
+ <tr valign="top">
108
+ <th scope="row">
109
+ <?php _e("Feed URL"); ?> <br />
110
+ </th>
111
+ <td>
112
+ <p style="margin-top: 0;"><a href="<?php echo get_feed_link($feed_slug); ?>" target="_blank"><?php echo get_feed_link($feed_slug); ?></a> | <a href="http://www.feedvalidator.org/check.cgi?url=<?php echo urlencode(get_feed_link($feed_slug)); ?>" target="_blank"><?php _e('validate'); ?></a></p>
113
+ </td>
114
+ </tr>
115
+
116
+ <tr valign="top">
117
+ <th scope="row">
118
+ <?php _e("Feed Title"); ?>
119
+ </th>
120
+ <td>
121
+ <input type="text" name="Feed[title]"style="width: 60%;" value="<?php echo $FeedSettings['title']; ?>" maxlength="250" /> (leave blank to use blog title)
122
+ </td>
123
+ </tr>
124
+ <tr valign="top">
125
+ <th scope="row">
126
+ <?php _e("Feed Description"); ?>
127
+ </th>
128
+ <td>
129
+ <input type="text" name="Feed[description]"style="width: 60%;" value="<?php echo $FeedSettings['description']; ?>" maxlength="1000" /> (leave blank to use blog description)
130
+ </td>
131
+ </tr>
132
+
133
+ <tr valign="top">
134
+ <th scope="row">
135
+ <?php _e("Feed Landing Page"); ?> <br />
136
+ </th>
137
+ <td>
138
+ <input type="text" name="Feed[url]"style="width: 60%;" value="<?php echo $FeedSettings['url']; ?>" maxlength="250" /> (optional)
139
+ <p>e.g. <?php echo get_bloginfo('home'); ?>/custom-page/</p>
140
+ </td>
141
+ </tr>
142
+
143
+ <tr valign="top">
144
+ <th scope="row">
145
+ <?php _e("Show the most recent"); ?>
146
+ </th>
147
+ <td>
148
+ <input type="text" name="Feed[posts_per_rss]"style="width: 50px;" value="<?php echo $FeedSettings['posts_per_rss']; ?>" maxlength="5" /> episodes (leave blank to use blog default: <?php form_option('posts_per_rss'); ?>)
149
+ </td>
150
+ </tr>
151
+
152
+ <tr valign="top">
153
+ <th scope="row">
154
+ <?php _e("Redirect Feed URL"); ?>
155
+ </th>
156
+ <td>
157
+ <input type="text" name="Feed[feed_redirect_url]"style="width: 60%;" value="<?php echo $FeedSettings['feed_redirect_url']; ?>" maxlength="100" /> (leave blank to use current feed)
158
+ <p>Use this option to redirect this feed to a hosted feed service such as <a href="http://www.feedburner.com/" target="_blank">FeedBurner</a>.</p>
159
+ <?php
160
+ $link = get_feed_link($feed_slug);
161
+ if( strstr($link, '?') )
162
+ $link .= "&redirect=no";
163
+ else
164
+ $link .= "?redirect=no";
165
+ ?>
166
+ <p>Bypass Redirect URL: <a href="<?php echo $link; ?>" target="_blank"><?php echo $link; ?></a></p>
167
+ </td>
168
+ </tr>
169
+
170
+ <?php } // End $feed_slug ?>
171
+
172
+ <?php if( $AdvancedMode ) { ?>
173
+ <tr valign="top">
174
+ <th scope="row" >
175
+
176
+ <?php _e("iTunes New Feed URL"); ?></th>
177
+ <td>
178
+ <div id="new_feed_url_step_1" style="display: <?php echo ($FeedSettings['itunes_new_feed_url'] || $FeedSettings['itunes_new_feed_url_podcast'] ?'none':'block'); ?>;">
179
+ <p style="margin-top: 5px;"><a href="#" onclick="return powerpress_new_feed_url_prompt();">Click here</a> if you need to change the Feed URL for iTunes subscribers.</p>
180
+ </div>
181
+ <div id="new_feed_url_step_2" style="display: <?php echo ($FeedSettings['itunes_new_feed_url'] || $FeedSettings['itunes_new_feed_url_podcast'] ?'block':'none'); ?>;">
182
+ <p style="margin-top: 5px;"><strong>WARNING: Changes made here are permanent. If the New Feed URL entered is incorrect, you will lose subscribers and will no longer be able to update your listing in the iTunes Store.</strong></p>
183
+ <p><strong>DO NOT MODIFY THIS SETTING UNLESS YOU ABSOLUTELY KNOW WHAT YOU ARE DOING.</strong></p>
184
+ <p>
185
+ Apple recommends you maintain the &lt;itunes:new-feed-url&gt; tag in your feed for at least two weeks to ensure that most subscribers will receive the new New Feed URL.
186
+ </p>
187
+ <p>
188
+ Example URL: <?php echo get_feed_link( ($feed_slug?$feed_slug:'podcast') ); ?>
189
+ </p>
190
+ <p style="margin-bottom: 0;">
191
+ <label style="width: 25%; float:left; display:block; font-weight: bold;">New Feed URL</label>
192
+ <input type="text" name="Feed[itunes_new_feed_url]"style="width: 55%;" value="<?php echo $FeedSettings['itunes_new_feed_url']; ?>" maxlength="250" />
193
+ </p>
194
+ <p style="margin-left: 25%;margin-top: 0;font-size: 90%;">(Leave blank for no New Feed URL)</p>
195
+ <p>More information regarding the iTunes New Feed URL is available <a href="http://www.apple.com/itunes/whatson/podcasts/specs.html#changing" target="_blank" title="Apple iTunes Podcasting Specificiations">here</a>.</p>
196
+ </div>
197
+ </td>
198
+ </tr>
199
+
200
+
201
+ <tr valign="top">
202
+ <th scope="row">
203
+
204
+ <?php _e("iTunes Summary"); ?></th>
205
+ <td>
206
+ <p style="margin-top: 5px;">Your summary may not contain HTML and cannot exceed 4,000 characters in length.</p>
207
+
208
+ <textarea name="Feed[itunes_summary]" rows="5" style="width:80%;" ><?php echo $FeedSettings['itunes_summary']; ?></textarea>
209
+ <div><input type="checkbox" name="Feed[enhance_itunes_summary]" value="1" <?php echo ($FeedSettings['enhance_itunes_summary']?'checked ':''); ?>/> Enhance iTunes Summary from Blog Posts (<a href="http://help.blubrry.com/blubrry-powerpress/settings/enhanced-itunes-summary/" target="_blank">What's this</a>)</div>
210
+ </td>
211
+ </tr>
212
+
213
+ <tr valign="top">
214
+ <th scope="row">
215
+ <?php _e("iTunes Program Subtitle"); ?> <br />
216
+ </th>
217
+ <td>
218
+ <input type="text" name="Feed[itunes_subtitle]"style="width: 60%;" value="<?php echo $FeedSettings['itunes_subtitle']; ?>" maxlength="250" />
219
+ </td>
220
+ </tr>
221
+ <?php } // End AdvancedMode ?>
222
+
223
+ <tr valign="top">
224
+ <th scope="row">
225
+ <?php _e("iTunes Program Keywords"); ?> <br />
226
+ </th>
227
+ <td>
228
+ <input type="text" name="Feed[itunes_keywords]" style="width: 60%;" value="<?php echo $FeedSettings['itunes_keywords']; ?>" maxlength="250" />
229
+ <p>Enter up to 12 keywords separated by commas.</p>
230
+ </td>
231
+ </tr>
232
+
233
+ <tr valign="top">
234
+ <th scope="row">
235
+ <?php _e("iTunes Category"); ?>
236
+ </th>
237
+ <td>
238
+ <select name="Feed[itunes_cat_1]" style="width: 60%;">
239
+ <?php
240
+ $linkoptions = array("On page", "Disable");
241
+
242
+ $Categories = powerpress_itunes_categories(true);
243
+
244
+ echo '<option value="">Select Category</option>';
245
+
246
+ while( list($value,$desc) = each($Categories) )
247
+ echo "\t<option value=\"$value\"". ($FeedSettings['itunes_cat_1']==$value?' selected':''). ">".htmlspecialchars($desc)."</option>\n";
248
+
249
+ reset($Categories);
250
+ ?>
251
+ </select>
252
+ </td>
253
+ </tr>
254
+
255
+ <?php if( $AdvancedMode ) { ?>
256
+ <tr valign="top">
257
+ <th scope="row">
258
+ <?php _e("iTunes Category 2"); ?>
259
+ </th>
260
+ <td>
261
+ <select name="Feed[itunes_cat_2]" style="width: 60%;">
262
+ <?php
263
+ $linkoptions = array("On page", "Disable");
264
+
265
+ echo '<option value="">Select Category</option>';
266
+
267
+ while( list($value,$desc) = each($Categories) )
268
+ echo "\t<option value=\"$value\"". ($FeedSettings['itunes_cat_2']==$value?' selected':''). ">".htmlspecialchars($desc)."</option>\n";
269
+
270
+ reset($Categories);
271
+
272
+ ?>
273
+ </select>
274
+ </td>
275
+ </tr>
276
+
277
+ <tr valign="top">
278
+ <th scope="row">
279
+ <?php _e("iTunes Category 3"); ?>
280
+ </th>
281
+ <td>
282
+ <select name="Feed[itunes_cat_3]" style="width: 60%;">
283
+ <?php
284
+ $linkoptions = array("On page", "Disable");
285
+
286
+ echo '<option value="">Select Category</option>';
287
+
288
+ while( list($value,$desc) = each($Categories) )
289
+ echo "\t<option value=\"$value\"". ($FeedSettings['itunes_cat_3']==$value?' selected':''). ">".htmlspecialchars($desc)."</option>\n";
290
+
291
+ reset($Categories);
292
+ ?>
293
+ </select>
294
+ </td>
295
+ </tr>
296
+ <?php } // End AdvancedMode ?>
297
+
298
+ <tr valign="top">
299
+ <th scope="row">
300
+ <?php _e("iTunes Explicit"); ?>
301
+ </th>
302
+ <td>
303
+ <select name="Feed[itunes_explicit]" class="bpp_input_med">
304
+ <?php
305
+ $explicit = array(0=>"no - display nothing", 1=>"yes - explicit content", 2=>"clean - no explicit content");
306
+
307
+ while( list($value,$desc) = each($explicit) )
308
+ echo "\t<option value=\"$value\"". ($FeedSettings['itunes_explicit']==$value?' selected':''). ">$desc</option>\n";
309
+
310
+ ?>
311
+ </select>
312
+ </td>
313
+ </tr>
314
+
315
+ <tr valign="top">
316
+ <th scope="row">
317
+ <?php _e("iTunes Image"); ?>
318
+ </th>
319
+ <td>
320
+ <input type="text" id="itunes_image" name="Feed[itunes_image]" style="width: 60%;" value="<?php echo $FeedSettings['itunes_image']; ?>" maxlength="250" />
321
+ <a href="#" onclick="javascript: window.open( document.getElementById('itunes_image').value ); return false;">preview</a>
322
+
323
+ <p>Place the URL to the iTunes image above. e.g. http://mysite.com/images/itunes.jpg<br /><br />iTunes prefers square .jpg or .png images that are at 600 x 600 pixels (prevously 300 x 300), which is different than what is specified for the standard RSS image.</p>
324
+
325
+ <?php if( $SupportUploads ) { ?>
326
+ <p><input name="itunes_image_checkbox" type="checkbox" onchange="powerpress_show_field('itunes_image_upload', this.checked)" value="1" /> Upload new image </p>
327
+ <div style="display:none" id="itunes_image_upload">
328
+ <label for="itunes_image">Choose file:</label><input type="file" name="itunes_image_file" />
329
+ </div>
330
+ <?php } ?>
331
+ </td>
332
+ </tr>
333
+
334
+ <tr valign="top">
335
+ <th scope="row">
336
+ <?php _e("RSS2 Image"); ?> <br />
337
+ </th>
338
+ <td>
339
+ <input type="text" id="rss2_image" name="Feed[rss2_image]" style="width: 60%;" value="<?php echo $FeedSettings['rss2_image']; ?>" maxlength="250" />
340
+ <a href="#" onclick="javascript: window.open( document.getElementById('rss2_image').value ); return false;">preview</a>
341
+
342
+ <p>Place the URL to the RSS image above. e.g. http://mysite.com/images/rss.jpg</p>
343
+ <p>RSS image should be at least 88 and at most 144 pixels wide and at least 31 and at most 400 pixels high in either .gif, .jpg and .png format. A square 144 x 144 pixel image is recommended.</p>
344
+
345
+ <?php if( $SupportUploads ) { ?>
346
+ <p><input name="rss2_image_checkbox" type="checkbox" onchange="powerpress_show_field('rss_image_upload', this.checked)" value="1" /> Upload new image</p>
347
+ <div style="display:none" id="rss_image_upload">
348
+ <label for="rss2_image">Choose file:</label><input type="file" name="rss2_image_file" />
349
+ </div>
350
+ <?php } ?>
351
+ </td>
352
+ </tr>
353
+
354
+ <?php if( $AdvancedMode ) { ?>
355
+ <tr valign="top">
356
+ <th scope="row">
357
+ <?php _e("Talent Name"); ?> <br />
358
+ </th>
359
+ <td>
360
+ <input type="text" name="Feed[itunes_talent_name]"style="width: 60%;" value="<?php echo $FeedSettings['itunes_talent_name']; ?>" maxlength="250" />
361
+ </td>
362
+ </tr>
363
+ <?php } // End AdvancedMode ?>
364
+
365
+ <tr valign="top">
366
+ <th scope="row">
367
+ <?php _e("Email"); ?>
368
+ </th>
369
+ <td>
370
+ <input type="text" name="Feed[email]" style="width: 60%;" value="<?php echo $FeedSettings['email']; ?>" maxlength="250" />
371
+ </td>
372
+ </tr>
373
+
374
+ <?php if( $AdvancedMode ) { ?>
375
+ <tr valign="top">
376
+ <th scope="row">
377
+ <?php _e("Copyright"); ?>
378
+ </th>
379
+ <td>
380
+ <input type="text" name="Feed[copyright]" style="width: 60%;" value="<?php echo $FeedSettings['copyright']; ?>" maxlength="250" />
381
+ </td>
382
+ </tr>
383
+ <?php } // End AdvancedMode ?>
384
+ </table>
385
+ <?php
386
+ }
387
+
388
+ ?>
powerpressadmin-metabox.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // powerpressadmin-metabox.php
3
+
4
+
5
+ function powerpress_meta_box($object, $box)
6
+ {
7
+ $FeedSlug = str_replace('powerpress-', '', $box['id']);
8
+
9
+ $DurationHH = '';
10
+ $DurationMM = '';
11
+ $DurationSS = '';
12
+ $EnclosureURL = '';
13
+ $EnclosureLength = '';
14
+ $GeneralSettings = get_option('powerpress_general');
15
+ if( !isset($GeneralSettings['set_size']) )
16
+ $GeneralSettings['set_size'] = 0;
17
+ if( !isset($GeneralSettings['set_duration']) )
18
+ $GeneralSettings['set_duration'] = 0;
19
+
20
+ if( $object->ID )
21
+ {
22
+ if( $FeedSlug == 'podcast' )
23
+ $enclosureArray = get_post_meta($object->ID, 'enclosure', true);
24
+ else
25
+ $enclosureArray = get_post_meta($object->ID, '_'.$FeedSlug.':enclosure', true);
26
+
27
+ list($EnclosureURL, $EnclosureLength, $EnclosureType, $EnclosureSerialized) = explode("\n", $enclosureArray);
28
+ if( $EnclosureSerialized )
29
+ {
30
+ $ExtraData = @unserialize($EnclosureSerialized);
31
+ if( $ExtraData && isset($ExtraData['duration']) )
32
+ $iTunesDuration = $ExtraData['duration'];
33
+ }
34
+
35
+ if( $FeedSlug == 'podcast' && !$iTunesDuration )
36
+ $iTunesDuration = get_post_meta($object->ID, 'itunes:duration', true);
37
+
38
+ if( $iTunesDuration )
39
+ {
40
+ $iTunesDuration = powerpress_readable_duration($iTunesDuration, true);
41
+ list($DurationHH, $DurationMM, $DurationSS) = explode(':', $iTunesDuration);
42
+ if( ltrim($DurationHH, '0') == 0 )
43
+ $DurationHH = '';
44
+ if( $DurationHH == '' && ltrim($DurationMM, '0') == 0 )
45
+ $DurationMM = '';
46
+ if( $DurationHH == '' && $DurationMM == '' && ltrim($DurationSS, '0') == 0 )
47
+ $DurationSS = '';
48
+ }
49
+ }
50
+
51
+ if( $EnclosureURL )
52
+ {
53
+ ?>
54
+ <div>
55
+ <input type="checkbox" name="Powerpress[<?php echo $FeedSlug; ?>][change_podcast]" id="powerpress_change" value="1" onchange="javascript:document.getElementById('powerpress_podcast_box_<?php echo $FeedSlug; ?>').style.display=(this.checked?'block':'none');" /> Modify existing podcast episode
56
+ </div>
57
+ <?php
58
+ }
59
+ else
60
+ {
61
+ echo '<input type="hidden" name="Powerpress['. $FeedSlug .'][new_podcast]" value="1" />'.PHP_EOL;
62
+ }
63
+ ?>
64
+
65
+ <div class="powerpress_podcast_box" id="powerpress_podcast_box_<?php echo $FeedSlug; ?>"<?php if( $EnclosureURL ) echo ' style="display:none;"'; ?>>
66
+ <?php
67
+ if( $EnclosureURL )
68
+ {
69
+ ?>
70
+ <div class="powerpress_row">
71
+ <label>Remove</label>
72
+ <div class="powerpress_row_content">
73
+ <input type="checkbox" name="Powerpress[<?php echo $FeedSlug; ?>][remove_podcast]" id="powerpress_remove" value="1" onchange="javascript:document.getElementById('powerpress_podcast_edit_<?php echo $FeedSlug; ?>').style.display=(this.checked?'none':'block');" />
74
+ Podcast episode will be removed from this post upon save
75
+ </div>
76
+ </div>
77
+ <?php
78
+ }
79
+ ?>
80
+ <div id="powerpress_podcast_edit_<?php echo $FeedSlug; ?>">
81
+ <div class="error below-h2" id="powerpress_warning_<?php echo $FeedSlug; ?>" style="display:none;">None</div>
82
+ <div class="powerpress_row">
83
+ <label for "Powerpress[<?php echo $FeedSlug; ?>][url]">Media URL</label>
84
+ <div class="powerpress_row_content">
85
+ <input id="powerpress_url_<?php echo $FeedSlug; ?>" name="Powerpress[<?php echo $FeedSlug; ?>][url]" value="<?php echo $EnclosureURL; ?>" onblur="powerpress_check_url(this.value,'powerpress_warning_<?php echo $FeedSlug; ?>')" style="width: 70%; font-size: 90%;" />
86
+ </div>
87
+ </div>
88
+ <?php
89
+ if( $GeneralSettings['episode_box_mode'] != 1 )
90
+ {
91
+ ?>
92
+ <div class="powerpress_row">
93
+ <label for "size">File Size</label>
94
+ <div class="powerpress_row_content">
95
+ <div style="margin-bottom: 4px;">
96
+ <input id="powerpress_set_size_<?php echo $FeedSlug; ?>" name="Powerpress[<?php echo $FeedSlug; ?>][set_size]" value="0" type="radio" <?php echo ($GeneralSettings['set_size']==0?'checked':''); ?> /> Auto detect file size
97
+ </div>
98
+ <div>
99
+ <input id="powerpress_set_size_<?php echo $FeedSlug; ?>" name="Powerpress[<?php echo $FeedSlug; ?>][set_size]" value="1" type="radio" <?php echo ($GeneralSettings['set_size']==1?'checked':''); ?> /> Specify:
100
+ <input id="powerpress_size_<?php echo $FeedSlug; ?>" name="Powerpress[<?php echo $FeedSlug; ?>][size]" value="<?php echo $EnclosureLength; ?>" style="width: 110px; font-size: 90%;" /> in bytes
101
+ </div>
102
+ </div>
103
+ </div>
104
+ <div class="powerpress_row">
105
+ <label for "size">Duration</label>
106
+ <div class="powerpress_row_content">
107
+ <div style="margin-bottom: 4px;">
108
+ <input id="powerpress_set_duration_<?php echo $FeedSlug; ?>" name="Powerpress[<?php echo $FeedSlug; ?>][set_duration]" value="0" type="radio" <?php echo ($GeneralSettings['set_duration']==0?'checked':''); ?> /> Auto detect duration (mp3's only)
109
+ </div>
110
+ <div style="margin-bottom: 4px;">
111
+ <input id="powerpress_set_duration_<?php echo $FeedSlug; ?>" name="Powerpress[<?php echo $FeedSlug; ?>][set_duration]" value="1" type="radio" <?php echo ($GeneralSettings['set_duration']==1?'checked':''); ?> /> Specify:
112
+ <input id="powerpress_duration_hh" name="Powerpress[<?php echo $FeedSlug; ?>][duration_hh]" maxlength="2" value="<?php echo $DurationHH; ?>" style="width: 24px; font-size: 90%; text-align: right;" /><strong>:</strong>
113
+ <input id="powerpress_duration_mm" name="Powerpress[<?php echo $FeedSlug; ?>][duration_mm]" maxlength="2" value="<?php echo $DurationMM; ?>" style="width: 24px; font-size: 90%; text-align: right;" /><strong>:</strong>
114
+ <input id="powerpress_duration_ss" name="Powerpress[<?php echo $FeedSlug; ?>][duration_ss]" maxlength="10" value="<?php echo $DurationSS; ?>" style="width: 24px; font-size: 90%; text-align: right;" /> HH:MM:SS
115
+ </div>
116
+ <div>
117
+ <input id="powerpress_set_duration" name="Powerpress[<?php echo $FeedSlug; ?>][set_duration]" value="-1" type="radio" <?php echo ($GeneralSettings['set_duration']==-1?'checked':''); ?> /> Not specified
118
+ </div>
119
+ </div>
120
+ </div>
121
+ <?php
122
+ }
123
+ else
124
+ {
125
+ ?>
126
+ <input id="powerpress_set_size_<?php echo $FeedSlug; ?>" name="Powerpress[<?php echo $FeedSlug; ?>][set_size]" value="0" type="hidden" />
127
+ <input id="powerpress_set_duration_<?php echo $FeedSlug; ?>" name="Powerpress[<?php echo $FeedSlug; ?>][set_duration]" value="0" type="hidden" />
128
+ <?php
129
+ }
130
+ ?>
131
+ </div>
132
+ </div>
133
+ <?php
134
+ }
135
+
136
+ ?>
powerpressadmin-podpress.php ADDED
@@ -0,0 +1,598 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // powerpressadmin-podpress.php
3
+
4
+ function powerpress_get_podpress_episodes()
5
+ {
6
+ global $wpdb;
7
+
8
+ $PodpressSettings = get_option('podPress_config');
9
+ if( !$PodpressSettings )
10
+ return false;
11
+ $media_url = $PodpressSettings['mediaWebPath'];
12
+ if( $media_url && substr($media_url, 0, -1) != '/' )
13
+ $media_url .= '/'; // Make sure the URL has a trailing slash
14
+
15
+
16
+ $return = array();
17
+ $return['feeds_required'] = 0;
18
+ $query = "SELECT p.ID, p.post_title, p.post_date, pm.meta_value ";
19
+ $query .= "FROM {$wpdb->posts} AS p ";
20
+ $query .= "INNER JOIN {$wpdb->postmeta} AS pm ON p.ID = pm.post_id ";
21
+ $query .= "WHERE pm.meta_key = 'podPressMedia' ";
22
+ $query .= "GROUP BY p.ID ";
23
+ $query .= "ORDER BY p.post_date DESC ";
24
+
25
+ $results_data = $wpdb->get_results($query, ARRAY_A);
26
+ if( $results_data )
27
+ {
28
+
29
+ while( list($null,$row) = each($results_data) )
30
+ {
31
+ //$return = $row;
32
+ $podpress_data = unserialize($row['meta_value']);
33
+ if( !$podpress_data )
34
+ {
35
+ $podpress_data_serialized = powerpress_repair_serialize($row['meta_value']);
36
+ $podpress_data = @unserialize($podpress_data_serialized);
37
+ }
38
+
39
+ if( $podpress_data )
40
+ {
41
+ $clean_data = array();
42
+ while( list($episode_index,$episode_data) = each($podpress_data) )
43
+ {
44
+ if( trim($episode_data['URI']) != '' )
45
+ {
46
+ $clean_data[ $episode_index ] = array();
47
+ if( strtolower(substr($episode_data['URI'], 0, 4)) == 'http' )
48
+ $clean_data[ $episode_index ]['url'] = $episode_data['URI'];
49
+ else
50
+ $clean_data[ $episode_index ]['url'] = $media_url . $episode_data['URI'];
51
+ $clean_data[ $episode_index ]['size'] = $episode_data['size'];
52
+ if( trim($episode_data['duration']) && $episode_data['duration'] != 'UNKNOWN' )
53
+ $clean_data[ $episode_index ]['duration'] = powerpress_readable_duration($episode_data['duration'], true);
54
+ $FileType = wp_check_filetype( $episode_data['URI'] );
55
+ if( $FileType )
56
+ $clean_data[ $episode_index ]['type'] = $FileType['type'];
57
+ }
58
+ }
59
+
60
+ if( count($clean_data) == 0 )
61
+ continue; // Go to the next record...
62
+
63
+
64
+ if( $return['feeds_required'] < count( $clean_data ) )
65
+ $return['feeds_required'] = count( $clean_data );
66
+ $return[ $row['ID'] ] = array();
67
+ $return[ $row['ID'] ]['podpress_data'] = $clean_data;
68
+ $return[ $row['ID'] ]['post_title'] = $row['post_title'];
69
+ $return[ $row['ID'] ]['post_date'] = $row['post_date'];
70
+
71
+ // Check that there is no other enclosure...
72
+ $enclosure_data = get_post_meta($row['ID'], 'enclosure', true);
73
+ if( $enclosure_data )
74
+ {
75
+ $Included = false;
76
+ list($EnclosureURL,$null) = split("\n", $enclosure_data);
77
+ $return[ $row['ID'] ]['enclosure'] = $enclosure_data;
78
+
79
+ while( list($episode_index_temp,$episode_data_temp) = each($clean_data) )
80
+ {
81
+ if( $EnclosureURL == $episode_data_temp['url'] )
82
+ {
83
+ $Included = true;
84
+ break; // We found the media already.
85
+ }
86
+ }
87
+ reset($clean_data);
88
+
89
+ if( $Included == false && $return['feeds_required'] < (count( $clean_data )+1) )
90
+ {
91
+ $return['feeds_required'] = count( $clean_data )+1; // We can't remove this enclosure
92
+ }
93
+ }
94
+
95
+ // Check for additional itunes data in the database..
96
+ if( false ) // Possibly for future verions, but seems unnecessary at this point
97
+ {
98
+ $itunes_data = get_post_meta($row['ID'], 'podPressPostSpecific', true);
99
+ if( $itunes_data && is_array($itunes_data) )
100
+ {
101
+ $return[ $row['ID'] ]['itunes'] = array();
102
+
103
+ // Add iTunes stuff...
104
+ if( $itunes_data['itunes:subtitle'] != '##PostExcerpt##' && $itunes_data['itunes:subtitle'] != '' )
105
+ $return[ $row['ID'] ]['itunes']['subtitle'] = $itunes_data['itunes:subtitle'];
106
+
107
+ if( $itunes_data['itunes:summary'] != '##PostExcerpt##' && $itunes_data['itunes:summary'] != '##Global##' && $itunes_data['itunes:summary'] != '' )
108
+ $return[ $row['ID'] ]['itunes']['summary'] = $itunes_data['itunes:summary'];
109
+
110
+ if( $itunes_data['itunes:keywords'] != '##WordPressCats##' && $itunes_data['itunes:keywords'] != '##Global##' && $itunes_data['itunes:keywords'] != '' )
111
+ $return[ $row['ID'] ]['itunes']['keywords'] = $itunes_data['itunes:keywords'];
112
+
113
+ if( $itunes_data['itunes:author'] != '##Global##' && $itunes_data['itunes:author'] != '' )
114
+ $return[ $row['ID'] ]['itunes']['author'] = $itunes_data['itunes:author'];
115
+
116
+ if( strtolower($itunes_data['itunes:explicit']) == 'yes' )
117
+ $return[ $row['ID'] ]['itunes']['explicit'] = 'yes';
118
+
119
+ if( strtolower($itunes_data['itunes:block']) == 'yes' )
120
+ $return[ $row['ID'] ]['itunes']['block'] = 'yes';
121
+
122
+ if( count($return[ $row['ID'] ]['itunes']) == 0 )
123
+ unset($return[ $row['ID'] ]['itunes']);
124
+ }
125
+ }
126
+ }
127
+ }
128
+ }
129
+ return $return;
130
+ }
131
+
132
+ function powerpressadmin_podpress_delete_data()
133
+ {
134
+ global $wpdb;
135
+ // Delete podpress data from database...
136
+ $query = "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE 'podPress%'";
137
+ $deleted_count = $wpdb->query($query);
138
+ powerpress_page_message_add_notice( sprintf(__('PodPress data deleted from database successfully. (%d database records removed)'), $deleted_count) );
139
+ }
140
+
141
+ function powerpressadmin_podpress_do_import()
142
+ {
143
+ $Import = $_POST['Import'];
144
+ $PodPressData = powerpress_get_podpress_episodes();
145
+
146
+ while( list($post_id, $podpress_episode_feeds) = each($Import) )
147
+ {
148
+ while( list($podpress_index, $feed_slug) = each($podpress_episode_feeds) )
149
+ {
150
+ if( $feed_slug )
151
+ {
152
+ $EpisodeData = $PodPressData[ $post_id ]['podpress_data'][ $podpress_index ];
153
+
154
+ if( $EpisodeData['size'] == '' || $EpisodeData['size'] == 'UNKNOWN' ) // Get the content length
155
+ {
156
+ $headers = wp_get_http_headers($EpisodeData['url']);
157
+ if( $headers && $headers['content-length'] )
158
+ $EpisodeData['size'] = (int) $headers['content-length'];
159
+ }
160
+ $EnclosureData = $EpisodeData['url'] . "\n" . $EpisodeData['size'] . "\n". $EpisodeData['type'];
161
+ if( $EpisodeData['duration'] )
162
+ $EnclosureData .= "\n".serialize( array('duration'=>$EpisodeData['duration']) );
163
+
164
+ if( $feed_slug == 'podcast' )
165
+ add_post_meta($post_id, 'enclosure', $EnclosureData, true);
166
+ else
167
+ add_post_meta($post_id, '_'. $feed_slug .':enclosure', $EnclosureData, true);
168
+
169
+ powerpressadmin_podpress_import_log($PodPressData[ $post_id ]['post_title'], $EpisodeData['url'], $feed_slug);
170
+ }
171
+ }
172
+ }
173
+ }
174
+
175
+ function powerpressadmin_podpress_import_log($post_title, $episode_url, $feed_slug)
176
+ {
177
+ global $g_podpress_import_log, $g_podpress_import_count;
178
+ $filename = substr($episode_url, strrpos($episode_url, '/')+1);
179
+ $g_podpress_import_log .= '<p style="font-weight: normal; margin-top: 2px; margin-bottom: 2px; margin-left: 20px;">';
180
+ $g_podpress_import_log .= 'Podpress Episode "'. htmlspecialchars($filename) .'" for blog post "'. htmlspecialchars($post_title) .'" imported to feed "'. $feed_slug ."\".\n";
181
+
182
+ $g_podpress_import_log .= '</p>';
183
+
184
+ if( $g_podpress_import_count )
185
+ $g_podpress_import_count++;
186
+ else
187
+ $g_podpress_import_count = 1;
188
+ }
189
+
190
+ function powerpressadmin_podpress_import_print_log()
191
+ {
192
+ global $g_podpress_import_log, $g_podpress_import_count;
193
+ if( !$g_podpress_import_log )
194
+ return;
195
+ echo '<div style="" class="updated powerpress-notice">';
196
+ echo '<h3 style="margin-top: 2px; margin-bottom: 2px;">PodPress Import Log</h3>';
197
+ echo $g_podpress_import_log;
198
+ $g_podpress_import_log='';
199
+ echo "<p style=\"font-weight: normal;\">Imported $g_podpress_import_count PodPress episode(s).</p>";
200
+ echo '</div>';
201
+ }
202
+
203
+ function powerpressadmin_importpodpress_columns($data=array())
204
+ {
205
+ $Settings = powerpress_get_settings('powerpress_general', false);
206
+ $data['post-title'] = 'Episode Title';
207
+ $data['post-date'] = 'Date';
208
+
209
+ $data['feed-podcast'] = 'Feed: (podcast)';
210
+
211
+ if( is_array($Settings['custom_feeds']) )
212
+ {
213
+ while( list($feed_slug,$value) = each($Settings['custom_feeds']) )
214
+ {
215
+ if( $feed_slug != 'podcast' )
216
+ $data['feed-'.$feed_slug] = 'Feed: ('.$feed_slug.')';
217
+ }
218
+ }
219
+ $data['exclude'] = 'No Import';
220
+
221
+ return $data;
222
+ }
223
+
224
+ add_filter('manage_powerpressadmin_importpodpress_columns', 'powerpressadmin_importpodpress_columns');
225
+
226
+ function powerpress_admin_podpress()
227
+ {
228
+ $results = powerpress_get_podpress_episodes();
229
+ $Settings = powerpress_get_settings('powerpress_general', false);
230
+ if( !isset($Settings['custom_feeds']['podcast']) )
231
+ $Settings['custom_feeds']['podcast'] = 'Podcast Feed (default)';
232
+
233
+ $AllowImport = false;
234
+ $AllowCleanup = true;
235
+
236
+ if( $results )
237
+ {
238
+ if( $results['feeds_required'] > count($Settings['custom_feeds']) )
239
+ {
240
+ powerpress_page_message_add_error( sprintf(__('You will need %d Custom Podcast Feeds to continue.'), $results['feeds_required']) );
241
+ powerpress_page_message_print();
242
+ }
243
+ else
244
+ {
245
+ $AllowImport = true;
246
+ }
247
+ }
248
+
249
+ powerpressadmin_podpress_import_print_log();
250
+
251
+ ?>
252
+ <style>
253
+ .column-exclude {
254
+ width: 80px;
255
+ }
256
+ .column-post-date {
257
+ width: 80px;
258
+ }
259
+ </style>
260
+ <script language="javascript">
261
+
262
+ function check_radio_selection(obj, PostID, FileIndex)
263
+ {
264
+ if( obj.value == '' ) // Users can select the no feed option as much as they want
265
+ return true;
266
+
267
+ var Field = obj.id;
268
+ while( Field.charAt( Field.length-1 ) >= "0" && Field.charAt( Field.length-1 ) <= "9" ) // ( chr < "0" ) || ( chr > "9" )
269
+ {
270
+ Field = Field.substring(0, Field.length-1);
271
+ }
272
+
273
+ var Pos = 0;
274
+ var CheckObj = document.getElementsByName( "Import["+PostID+"]["+Pos+"]" );
275
+ while( CheckObj )
276
+ {
277
+ if( CheckObj.length == 0 )
278
+ break;
279
+
280
+ if( Pos != FileIndex )
281
+ {
282
+ for (var i = 0; i < CheckObj.length; i++)
283
+ {
284
+ if (CheckObj[i].type == 'radio' && CheckObj[i].checked && CheckObj[i].value == obj.value )
285
+ {
286
+ alert("Sorry, you may only select one media file per post per feed. ");
287
+ return false;
288
+ }
289
+ }
290
+ }
291
+ Pos++;
292
+ var CheckObj = document.getElementsByName( "Import["+PostID+"]["+Pos+"]" );
293
+ }
294
+
295
+ return true;
296
+ }
297
+
298
+ </script>
299
+ <h2><?php echo __("Import PodPress Episodes"); ?></h2>
300
+ <?php
301
+
302
+ //echo "<pre id=\"podpress_debug_info\" style=\"display: none;\">";
303
+ //print_r($results);
304
+ //echo "</pre>";
305
+ //echo '<p><a href="javascript:void();" onclick="javascript:document.getElementById(\'podpress_debug_info\').style.display=\'block\';this.style.display=\'none\';return false;">Show Debug Info</a></p>';
306
+
307
+ if( count($results) == 0 || count($results) == 1 )
308
+ {
309
+ ?>
310
+ <p>No PodPress episodes found to import.</p>
311
+ <?php
312
+ }
313
+ else
314
+ {
315
+ ?>
316
+ <input type="hidden" name="action" value="powerpress-importpodpress" />
317
+ <p>Select the media file under each feed for each episode you wish to import.</p>
318
+ <table class="widefat fixed" cellspacing="0">
319
+ <thead>
320
+ <tr>
321
+ <?php print_column_headers('powerpressadmin_importpodpress'); ?>
322
+ </tr>
323
+ </thead>
324
+
325
+ <tfoot>
326
+ <tr>
327
+ <?php print_column_headers('powerpressadmin_importpodpress', false); ?>
328
+ </tr>
329
+ </tfoot>
330
+ <tbody>
331
+ <?php
332
+
333
+ $StrandedEpisodes = 0;
334
+ $ImportableEpisodes = 0;
335
+
336
+ $count = 0;
337
+ while( list($post_id, $import_data) = each($results ) )
338
+ {
339
+ $edit_link = get_edit_post_link( $post_id );
340
+ if( $post_id == 'feeds_required' )
341
+ continue;
342
+
343
+ $columns = powerpressadmin_importpodpress_columns();
344
+
345
+ $CurrentEnclosures = array();
346
+
347
+ if( is_array($Settings['custom_feeds']) )
348
+ {
349
+ while( list($feed_slug,$value) = each($Settings['custom_feeds']) )
350
+ {
351
+ if( $feed_slug == 'podcast' )
352
+ $enclosure_data = get_post_meta($post_id, 'enclosure', true);
353
+ else
354
+ $enclosure_data = get_post_meta($post_id, '_'. $feed_slug .':enclosure', true);
355
+ if( !$enclosure_data )
356
+ continue;
357
+
358
+ list($EnclosureURL, $EnclosureSize, $EnclosureType, $Serialized) = split("\n", $enclosure_data);
359
+ if( $EnclosureURL )
360
+ {
361
+ $CurrentEnclosures[ $feed_slug ] = array();
362
+ $CurrentEnclosures[ $feed_slug ]['url'] = trim($EnclosureURL);
363
+ $CurrentEnclosures[ $feed_slug ]['imported'] = false;
364
+ }
365
+
366
+ $found = false;
367
+ while( list($episode_index,$episode_data) = each($import_data['podpress_data']) )
368
+ {
369
+ if( $episode_data['url'] == $CurrentEnclosures[ $feed_slug ]['url'] )
370
+ {
371
+ $import_data['podpress_data'][$episode_index]['imported'] = true;
372
+ $CurrentEnclosures[ $feed_slug ]['imported'] = true;
373
+ $found = true;
374
+ break;
375
+ }
376
+ }
377
+ reset($import_data['podpress_data']);
378
+ if( $found == false )
379
+ {
380
+ // Add it to the media file list, prepend it...
381
+ $not_podpress_data = array();
382
+ $not_podpress_data['url'] = $CurrentEnclosures[ $feed_slug ]['url'];
383
+ $not_podpress_data['imported'] = true;
384
+ $not_podpress_data['not_podpress'] = true;
385
+
386
+ array_push($import_data['podpress_data'], $not_podpress_data);
387
+ $CurrentEnclosures[ $feed_slug ]['imported'] = true;
388
+ $CurrentEnclosures[ $feed_slug ]['present'] = true;
389
+ }
390
+ }
391
+ reset($Settings['custom_feeds']);
392
+ }
393
+
394
+ if( $feed_slug == 'podcast' )
395
+ $feed_title = 'Podcast Feed (default)';
396
+ $feed_title = wp_specialchars($feed_title);
397
+ if( $count % 2 == 0 )
398
+ echo '<tr valign="middle" class="alternate">';
399
+ else
400
+ echo '<tr valign="middle">';
401
+
402
+ $CheckedEpisodes = array(); // key = file_index, value = feed-slug
403
+
404
+ $feed_index = 0;
405
+ foreach($columns as $column_name=>$column_display_name)
406
+ {
407
+ $class = "class=\"column-$column_name\"";
408
+
409
+ switch($column_name)
410
+ {
411
+ case 'post-title': {
412
+
413
+ echo '<td '.$class.'><strong>';
414
+ if ( current_user_can( 'edit_post', $post_id ) )
415
+ {
416
+ ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $import_data['post_title'])); ?>"><?php echo $import_data['post_title'] ?></a><?php
417
+ }
418
+ else
419
+ {
420
+ echo $import_data['post_title'];
421
+ }
422
+
423
+ echo '</strong><br />';
424
+ echo '<div style="margin-left: 10px;">';
425
+ $index = 1;
426
+ while( list($episode_index,$episode_data) = each($import_data['podpress_data']) )
427
+ {
428
+ $Parts = parse_url($episode_data['url']);
429
+ $filename = substr($Parts['path'], strrpos($Parts['path'], '/')+1 );
430
+ echo "File&nbsp;$index:&nbsp;";
431
+
432
+ if( !$episode_data['not_podpress'] && !$episode_data['imported'] )
433
+ {
434
+ echo '<span style="color: #CC0000; font-weight: bold; cursor:pointer;" onclick="alert(\'File: '. $filename .'\nURL: '. $episode_data['url'] .'\')">';
435
+ $AllowCleanup = false;
436
+ $StrandedEpisodes++;
437
+ }
438
+ else if( !$episode_data['not_podpress'] && $episode_data['imported'] )
439
+ echo '<span style="color: green; font-weight: bold; cursor:pointer;" onclick="alert(\'File: '. $filename .'\nURL: '. $episode_data['url'] .'\')">';
440
+
441
+ if( !$episode_data['not_podpress'] && !$episode_data['imported'] )
442
+ echo '*';
443
+ echo $filename;
444
+ if( !$episode_data['not_podpress'] )
445
+ echo '</span>';
446
+
447
+ echo '<br/>';
448
+ $index++;
449
+ }
450
+ reset($import_data['podpress_data']);
451
+
452
+ echo '</div>';
453
+ echo '</td>';
454
+
455
+ }; break;
456
+ case 'post-date': {
457
+ echo "<td $class>";
458
+ $timestamp = strtotime($import_data['post_date']);
459
+ echo date('Y/m/d', $timestamp);
460
+ echo "</td>";
461
+ }; break;
462
+ case 'feed-slug': {
463
+
464
+ echo "<td $class>$feed_slug";
465
+ echo "</td>";
466
+
467
+ }; break;
468
+
469
+ default: {
470
+
471
+ echo "<td $class>";
472
+ $feed_slug = substr($column_name, 5);
473
+ if( $column_name == 'exclude' )
474
+ $feed_slug = '';
475
+ $enclosure_data = false;
476
+ $EnclosureURL = '';
477
+
478
+ echo '<div class="">&nbsp;<br />';
479
+ if( isset($CurrentEnclosures[$feed_slug]) && $CurrentEnclosures[$feed_slug]['imported'] )
480
+ {
481
+ $index = 1;
482
+ while( list($episode_index,$episode_data) = each($import_data['podpress_data']) )
483
+ {
484
+ echo "File $index: ";
485
+ if( $CurrentEnclosures[$feed_slug]['url'] == $episode_data['url'] )
486
+ {
487
+ if( $CurrentEnclosures[$feed_slug]['present'] )
488
+ echo '<strong style="color: green;">present</strong>';
489
+ else
490
+ echo '<strong style="color: green;">imported</strong>';
491
+ }
492
+ else
493
+ echo 'X';
494
+ echo "<br/>\n";
495
+ $index++;
496
+ }
497
+ reset($import_data['podpress_data']);
498
+ }
499
+ else
500
+ {
501
+ $index = 1;
502
+ while( list($episode_index,$episode_data) = each($import_data['podpress_data']) )
503
+ {
504
+ echo "File&nbsp;$index:&nbsp;";
505
+ if( @$episode_data['imported'] )
506
+ {
507
+ echo '&nbsp;X';
508
+ }
509
+ else
510
+ {
511
+ $checked = '';
512
+ if( !isset($CheckedEpisodes[ $episode_index ]) && !in_array($feed_slug, $CheckedEpisodes) )
513
+ {
514
+ $checked = 'checked';
515
+ $CheckedEpisodes[ $episode_index ] = $feed_slug;
516
+ }
517
+ if( !isset($CheckedEpisodes[ $episode_index ]) && $feed_slug == '' )
518
+ {
519
+ $checked = 'checked';
520
+ }
521
+
522
+
523
+ echo '<input type="radio" id="import_'. $post_id .'_'. $episode_index .'" name="Import['.$post_id.']['.$episode_index.']" value="'.$feed_slug.'" '. $checked .' onclick="return check_radio_selection(this, '.$post_id.', '.$episode_index.')" />';
524
+ }
525
+ echo '<br/>';
526
+ $index++;
527
+ }
528
+ reset($import_data['podpress_data']);
529
+ }
530
+
531
+ echo '</div>';
532
+
533
+
534
+ echo "</td>";
535
+ $feed_index++;
536
+ }; break;
537
+ }
538
+ }
539
+ echo "\n </tr>\n";
540
+ $count++;
541
+ }
542
+ ?>
543
+ </tbody>
544
+ </table>
545
+ <p>Importable PodPress episodes highlighted in <span style="color: #CC0000; font-weight: bold;">red</span> with asterisks *.</p>
546
+
547
+ <?php
548
+ }
549
+
550
+ if( $StrandedEpisodes )
551
+ {
552
+ ?>
553
+ <p>
554
+ There are <?php echo $StrandedEpisodes; ?> PodPress media files that can be imported.
555
+ </p>
556
+ <?php
557
+ }
558
+
559
+ if( $AllowImport )
560
+ {
561
+ if( count($results) > 1 && $StrandedEpisodes > 0 )
562
+ {
563
+ ?>
564
+ <p class="submit">
565
+ <input type="submit" name="Submit" id="powerpress_import_button" class="button-primary" value="Import Episodes" />
566
+ </p>
567
+ <?php
568
+ }
569
+
570
+ if( $AllowCleanup )
571
+ {
572
+ ?>
573
+ </form>
574
+ <form enctype="multipart/form-data" method="post" action="<?php echo admin_url('admin.php?page=powerpress/powerpressadmin_tools.php') ?>">
575
+ <?php wp_nonce_field('powerpress-delete-podpress-data'); ?>
576
+ <input type="hidden" name="action" value="deletepodpressdata" />
577
+ <p class="submit">
578
+ <input type="submit" name="Submit" id="powerpress_delete_button" class="button-primary" value="Delete PodPress Data from Database" onclick="return confirm('Delete old PodPress data from database, are you sure?\n\nAll PodPress episode data will be permanently deleted.');" />
579
+ <br /> There is no need to delete PodPress data, but if you prefer to clean up your database then please feel free to use this option.
580
+ </p>
581
+ <?php
582
+ }
583
+ else
584
+ {
585
+ ?>
586
+
587
+ <p class="submit">
588
+ <input type="button" name="Submit" id="powerpress_delete_button" class="button-primary" value="Delete PodPress Data from Database" onclick="alert('This option will be enabled once all PodPress episodes have been imported.');" />
589
+ </p>
590
+ <?php
591
+ }
592
+ }
593
+ ?>
594
+ <!-- start footer -->
595
+ <?php
596
+ }
597
+
598
+ ?>
powerpressadmin-tools.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // powerpressadmin-tools.php
3
+
4
+ function powerpress_admin_tools()
5
+ {
6
+ $General = get_option('powerpress_general');
7
+ ?>
8
+ <h2><?php echo __("PowerPress Tools"); ?></h2>
9
+
10
+ <p style="margin-bottom: 0;">Useful utilities and tools for PowerPress.</p>
11
+
12
+
13
+ <table class="form-table">
14
+ <tr valign="top">
15
+ <th scope="row"><?php echo __("Import Settings"); ?></th>
16
+ <td>
17
+ <p style="margin-top: 5px;"><strong><a href="<?php echo admin_url() . wp_nonce_url("admin.php?page=powerpress/powerpressadmin_tools.php&amp;action=powerpress-podpress-settings", 'powerpress-podpress-settings'); ?>" onclick="return confirm('Import PodPress settings, are you sure?\n\nExisting settings will be overwritten.');">Import PodPress Settings</a></strong></p>
18
+ </td>
19
+ </tr>
20
+
21
+ <tr valign="top">
22
+ <th scope="row"><?php echo __("Import Episodes"); ?></th>
23
+ <td>
24
+ <p style="margin-top: 5px;"><strong><a href="<?php echo admin_url("admin.php?page=powerpress/powerpressadmin_tools.php&amp;action=powerpress-podpress-epiosdes"); ?>">Import PodPress Episodes</a></strong></p>
25
+ <p>Import PodPress created episodes to PowerPress specific podcast feeds.</p>
26
+ </td>
27
+ </tr>
28
+
29
+ <!-- use_caps -->
30
+ <tr valign="top">
31
+ <th scope="row"><?php echo __("User Capabilities"); ?></th>
32
+ <td>
33
+ <?php
34
+ if( $General['use_caps'] )
35
+ {
36
+ ?>
37
+ <p style="margin-top: 5px;"><strong><a href="<?php echo admin_url() . wp_nonce_url("admin.php?page=powerpress/powerpressadmin_tools.php&amp;action=powerpress-remove-caps", 'powerpress-remove-caps'); ?>"><?php _e('Remove Edit Podcast Capability for User Role Management'); ?></a></strong></p>
38
+ <p>
39
+ Removing Edit Podcast capability will allow anyone who can edit posts the ability to create and edit podcast episodes.
40
+ </p>
41
+ <p>You will most likely need either the <a href="http://www.im-web-gefunden.de/wordpress-plugins/role-manager/" target="_blank">Role Manager</a> or <a href="http://agapetry.net/category/plugins/role-scoper/" target="_blank">Role Scoper</a> plugin to manage the Edit Podcast capability.
42
+ The Edit Podcast capability feature comes with no support. Please do not contact Blubrry.com for help with this feature.
43
+ </p>
44
+ <?php
45
+ }
46
+ else
47
+ {
48
+ ?>
49
+ <p style="margin-top: 5px;"><strong><a href="<?php echo admin_url() . wp_nonce_url("admin.php?page=powerpress/powerpressadmin_tools.php&amp;action=powerpress-add-caps", 'powerpress-add-caps'); ?>"><?php _e('Add Edit Podcast Capability for User Role Management'); ?></a></strong></p>
50
+ <p>
51
+ Currently anyone who can edit posts on this blog may also edit podcast episodes.
52
+ </p>
53
+ <p>
54
+ Adding Edit Podcast capability will configure Administrators, Editors and Authors with access to create and edit podcast episodes. Contributors, Subscribers and other custom user roles will not be able to create and edit podcast episodes.
55
+ </p>
56
+ <?php
57
+ }
58
+ ?>
59
+ <p>The WordPress <a href="http://codex.wordpress.org/Roles_and_Capabilities" target="_blank">Roles and Capabilities</a> feature is designed to give the blog owner the ability to control and assign what users can and cannot do in the blog.
60
+ By adding the Edit Podcast capability to your blog, you will be able to use the Roles and Capabilities in Wordpress to manage which users can create and edit podcast episodes.
61
+ </p>
62
+
63
+ </td>
64
+ </tr>
65
+
66
+ </table>
67
+ <?php
68
+
69
+ }
70
+
71
+ ?>
powerpressadmin.php CHANGED
@@ -1,392 +1,66 @@
1
  <?php
2
 
3
- function powerpress_admin_menu() {
4
- if( function_exists('add_meta_box') ) { // Otherwise we're using a version of wordpress that is not supported.
5
- add_meta_box('id', 'Podcast Episode', 'powerpress_meta_box', 'post', 'normal');
6
- add_meta_box('id', 'Podcast Episode', 'powerpress_meta_box', 'page', 'normal');
7
- }
8
- add_options_page('Blubrry Powerpress Settings', 'Blubrry Powerpress', 8, 'powerpress/powerpress.php', 'powerpress_admin_page');
9
- }
10
-
11
- add_action('admin_menu', 'powerpress_admin_menu');
12
-
13
- function powerpress_meta_box($object, $box)
14
- {
15
- $DurationHH = '';
16
- $DurationMM = '';
17
- $DurationSS = '';
18
- $EnclosureURL = '';
19
- $EnclosureLength = '';
20
- $GeneralSettings = get_option('powerpress_general');
21
- if( !isset($GeneralSettings['set_size']) )
22
- $GeneralSettings['set_size'] = 0;
23
- if( !isset($GeneralSettings['set_duration']) )
24
- $GeneralSettings['set_duration'] = 0;
25
-
26
- if( $object->ID )
27
- {
28
- $enclosureArray = get_post_meta($object->ID, 'enclosure', true);
29
- list($EnclosureURL, $EnclosureLength, $EnclosureType) = explode("\n", $enclosureArray);
30
- $iTunesDuration = get_post_meta($object->ID, 'itunes:duration', true);
31
- list($DurationHH, $DurationMM, $DurationSS) = explode(':', $iTunesDuration);
32
- }
33
-
34
- if( $EnclosureURL )
35
- {
36
- ?>
37
- <div>
38
- <input type="checkbox" name="Powerpress[change_podcast]" id="powerpress_change" value="1" onchange="javascript:document.getElementById('powerpress_podcast_box').style.display=(this.checked?'block':'none');" /> Modify existing podcast episode
39
- </div>
40
- <?php
41
- }
42
- else
43
- {
44
- echo '<input type="hidden" name="Powerpress[new_podcast]" value="1" />'.PHP_EOL;
45
- }
46
- ?>
47
- <style type="text/css">
48
- #powerpress_podcast_box {
49
-
50
- }
51
- #powerpress_podcast_box label {
52
- width: 120px;
53
- font-weight: bold;
54
- font-size: 110%;
55
- display: inline;
56
- position: absolute;
57
- top: 0;
58
- left: 0;
59
- }
60
- #powerpress_podcast_box .powerpress_row {
61
- margin-top: 10px;
62
- margin-bottom: 10px;
63
- position: relative;
64
- }
65
- #powerpress_podcast_box .powerpress_row_content {
66
- margin-left: 120px;
67
- }
68
- #powerpress_podcast_box .error {
69
- margin-top: 10px;
70
- margin-bottom: 10px;
71
- padding: 5px;
72
- font-size: 12px;
73
- text-align: center;
74
- border-width: 1px;
75
- border-style: solid;
76
- font-weight: bold;
77
- }
78
- </style>
79
- <script language="javascript">
80
- function powerpress_check_url(url)
81
  {
82
- var validChars = ':0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-_.';
83
-
84
- for( var x = 0; x < url.length; x++ )
85
- {
86
- if( validChars.indexOf( url.charAt(x) ) == -1 )
87
- {
88
- document.getElementById('powerpress_warning').innerHTML = 'Media URL contains characters that may cause problems for some clients. For maximum compatibility, only use letters, numbers, dash - and underscore _ characters only.';
89
- document.getElementById('powerpress_warning').style.display = 'block';
90
- return;
91
- }
92
-
93
- if( x == 5 )
94
- validChars = validChars.substring(1); // remove the colon, should no longer appear in URLs
95
- }
96
-
97
- document.getElementById('powerpress_warning').style.display = 'none';
98
  }
99
 
100
- </script>
101
- <div id="powerpress_podcast_box"<?php if( $EnclosureURL ) echo ' style="display:none;"'; ?>>
102
- <?php
103
- if( $EnclosureURL )
104
- {
105
- ?>
106
- <div class="powerpress_row">
107
- <label>Remove</label>
108
- <div class="powerpress_row_content">
109
- <input type="checkbox" name="Powerpress[remove_podcast]" id="powerpress_remove" value="1" onchange="javascript:document.getElementById('powerpress_podcast_edit').style.display=(this.checked?'none':'block');" />
110
- Podcast episode will be removed from this post upon save
111
- </div>
112
- </div>
113
- <?php
114
- }
115
- ?>
116
- <div id="powerpress_podcast_edit">
117
- <div class="error" id="powerpress_warning" style="display:none;">None</div>
118
- <div class="powerpress_row">
119
- <label for "Powerpress[url]">Media URL</label>
120
- <div class="powerpress_row_content">
121
- <input id="powerpress_url" name="Powerpress[url]" value="<?php echo $EnclosureURL; ?>" onblur="powerpress_check_url(this.value)" style="width: 70%; font-size: 90%;" />
122
- </div>
123
- </div>
124
- <div class="powerpress_row">
125
- <label for "size">File Size</label>
126
- <div class="powerpress_row_content">
127
- <div style="margin-bottom: 4px;">
128
- <input id="powerpress_set_size" name="Powerpress[set_size]" value="0" type="radio" <?php echo ($GeneralSettings['set_size']==0?'checked':''); ?> /> Auto detect file size
129
- </div>
130
- <div>
131
- <input id="powerpress_set_size" name="Powerpress[set_size]" value="1" type="radio" <?php echo ($GeneralSettings['set_size']==1?'checked':''); ?> /> Specify:
132
- <input id="powerpress_size" name="Powerpress[size]" value="<?php echo $EnclosureLength; ?>" style="width: 110px; font-size: 90%;" /> in bytes
133
- </div>
134
- </div>
135
- </div>
136
- <div class="powerpress_row">
137
- <label for "size">Duration</label>
138
- <div class="powerpress_row_content">
139
- <div style="margin-bottom: 4px;">
140
- <input id="powerpress_set_duration" name="Powerpress[set_duration]" value="0" type="radio" <?php echo ($GeneralSettings['set_duration']==0?'checked':''); ?> /> Auto detect duration (mp3's only)
141
- </div>
142
- <div style="margin-bottom: 4px;">
143
- <input id="powerpress_set_duration" name="Powerpress[set_duration]" value="1" type="radio" <?php echo ($GeneralSettings['set_duration']==1?'checked':''); ?> /> Specify:
144
- <input id="powerpress_duration_hh" name="Powerpress[duration_hh]" maxlength="2" value="<?php echo $DurationHH; ?>" style="width: 24px; font-size: 90%; text-align: right;" /><strong>:</strong>
145
- <input id="powerpress_duration_mm" name="Powerpress[duration_mm]" maxlength="2" value="<?php echo $DurationMM; ?>" style="width: 24px; font-size: 90%; text-align: right;" /><strong>:</strong>
146
- <input id="powerpress_duration_ss" name="Powerpress[duration_ss]" maxlength="2" value="<?php echo $DurationSS; ?>" style="width: 24px; font-size: 90%; text-align: right;" /> HH:MM:SS
147
- </div>
148
- <div>
149
- <input id="powerpress_set_duration" name="Powerpress[set_duration]" value="-1" type="radio" <?php echo ($GeneralSettings['set_duration']==-1?'checked':''); ?> /> Not specified
150
- </div>
151
- </div>
152
- </div>
153
- </div>
154
- </div>
155
- <?php
156
  }
157
 
158
 
159
- function powerpress_edit_post($post_ID) {
160
-
161
- $Powerpress = $_POST['Powerpress'];
162
-
163
- if( $Powerpress['remove_podcast'] == 1 )
164
- {
165
- delete_post_meta( $post_ID, 'enclosure');
166
- delete_post_meta( $post_ID, 'itunes:duration');
167
- }
168
- else if( @$Powerpress['change_podcast'] == 1 || @$Powerpress['new_podcast'] == 1 )
169
- {
170
- // No URL specified, then it's not really a podcast to save
171
- if( $Powerpress['url'] == '' )
172
- return;
173
-
174
- // Initialize the important variables:
175
- $MediaURL = $Powerpress['url'];
176
- if( strpos($MediaURL, 'http://') !== 0 ) // If the url entered does not start with a http://
177
- {
178
- $Settings = get_option('powerpress_general');
179
- $MediaURL = rtrim(@$Settings['default_url'], '/') .'/'. $MediaURL;
180
- }
181
-
182
- $FileSize = '';
183
- $ContentType = '';
184
- $Duration = false;
185
-
186
- // Get the content type based on the file extension, first we have to remove query string if it exists
187
- $UrlParts = parse_url($Powerpress['url']);
188
- if( $UrlParts['path'] )
189
- {
190
- // using functions that already exist in Wordpress when possible:
191
- $FileType = wp_check_filetype($UrlParts['path']);
192
- if( $FileType )
193
- $ContentType = $FileType['type'];
194
-
195
- /*
196
- $FileParts = pathinfo($UrlParts['path']);
197
- if( $FileParts )
198
- {
199
-
200
- $ContentType = powerpress_mimetypes($FileParts['extension']);
201
- }
202
- */
203
- }
204
-
205
- //Set the duration specified by the user
206
- if( $Powerpress['set_duration'] == 1 ) // specify duration
207
- {
208
- $Duration = sprintf('%02d:%02d:%02d', $Powerpress['duration_hh'], $Powerpress['duration_mm'], $Powerpress['duration_ss'] );
209
- }
210
-
211
- //Set the file size specified by the user
212
- if( $Powerpress['set_size'] == 1 ) // specify file size
213
- {
214
- $FileSize = $Powerpress['size'];
215
- }
216
-
217
- if( $Powerpress['set_size'] == 0 || $Powerpress['set_duration'] == 0 )
218
- {
219
- // Lets use the mp3info class:
220
- require_once('mp3info.class.php');
221
-
222
- $Mp3Info = new Mp3Info();
223
- if( $ContentType == 'audio/mpeg' && $Powerpress['set_duration'] == 0 )
224
- {
225
- $Mp3Data = $Mp3Info->GetMp3Info($MediaURL);
226
- if( $Mp3Data )
227
- {
228
- if( @$Powerpress['set_size'] == 0 )
229
- $FileSize = $Mp3Info->GetContentLength();
230
- $Duration = $Mp3Data['playtime_string'];
231
- if( substr_count($Duration, ':' ) == 0 )
232
- {
233
- if( $Duration < 60 )
234
- $Duration = '00:00:'.$Duration;
235
- }
236
- else if( substr_count($Duration, ':' ) == 1 )
237
- {
238
- $Duration = '00:'.$Duration;
239
- }
240
- }
241
- }
242
- else // Just get the file size
243
- {
244
- $Headers = wp_get_http_headers($MediaURL);
245
- if( $headers && $headers['content-length'] )
246
- {
247
- $FileSize = (int) $headers['content-length'];
248
- }
249
- }
250
- }
251
-
252
- $EnclosureData = $MediaURL . "\n" . $FileSize . "\n". $ContentType;
253
-
254
- if( @$Powerpress['new_podcast'] )
255
- {
256
- add_post_meta($post_ID, 'enclosure', $EnclosureData, true);
257
- if( $Duration !== false )
258
- add_post_meta($post_ID, 'itunes:duration', $Duration, true);
259
- }
260
- else
261
- {
262
- update_post_meta($post_ID, 'enclosure', $EnclosureData);
263
- if( $Duration !== false )
264
- {
265
- if( !update_post_meta($post_ID, 'itunes:duration', $Duration) )
266
- add_post_meta($post_ID, 'itunes:duration', $Duration, true); // If we can't update it, lets try to add it
267
- }
268
- if( $Powerpress['set_duration'] == -1 ) // Special case, lets remove the duration since they set Not specified
269
- {
270
- delete_post_meta( $post_ID, 'itunes:duration');
271
- }
272
- }
273
- }
274
-
275
- // If we're moving from draft to published, maybe we should ping iTunes?
276
- if($_POST['prev_status'] == 'draft' && $_POST['publish'] == 'Publish' )
277
- {
278
- // Next double check we're looking at a podcast episode...
279
- $Enclosure = get_post_meta($post_ID, 'enclosure', true);
280
- if( $Enclosure )
281
- {
282
- $Settings = get_option('powerpress_general');
283
- if( $Settings['ping_itunes'] && $Settings['itunes_url'] )
284
- {
285
- $PingResults = powerpress_ping_itunes($Settings['itunes_url']);
286
- //mail( 'email@host.com', 'Ping iTunes Results', implode("\n", $PingResults) ); // Let me know how the ping went.
287
- }
288
- }
289
- }
290
-
291
- // And we're done!
292
  }
293
 
294
- add_action('edit_post', 'powerpress_edit_post');
295
-
296
-
297
- function powerpress_admin_head()
298
  {
299
- if( strstr($_GET['page'], 'powerpress.php' ) )
 
 
300
  {
301
- ?>
302
- <script type="text/javascript">
303
- function powerpress_show_field(id, show) {
304
- if( document.getElementById(id).nodeName == "SPAN" )
305
- document.getElementById(id).style.display = (show?"inline":"none");
306
- else
307
- document.getElementById(id).style.display = (show?"block":"none");
308
- }
309
- function powerpress_new_feed_url_prompt() {
310
- var Msg = 'WARNING: Changes made here are permanent. If the New Feed URL entered is incorrect, you will lose subscribers and will no longer be able to update your listing in the iTunes Store.\n\nDO NOT MODIFY THIS SETTING UNLESS YOU ABSOLUTELY KNOW WHAT YOU ARE DOING.\n\nAre you sure you want to continue?';
311
- if( confirm(Msg) ) {
312
- powerpress_show_field('new_feed_url_step_1', false);
313
- powerpress_show_field('new_feed_url_step_2', true);
314
- }
315
- return false;
316
- }
317
- </script>
318
- <style type="text/css">
319
- .powerpress-notice {
320
- margin-top: 10px;
321
- margin-bottom: 10px;
322
- line-height: 29px;
323
- font-size: 12px;
324
- border-width: 1px;
325
- border-style: solid;
326
- font-weight: bold;
327
- }
328
- .powerpress-error {
329
- margin-top: 10px;
330
- margin-bottom: 10px;
331
- line-height: 29px;
332
- font-size: 12px;
333
- border-width: 1px;
334
- border-style: solid;
335
- font-weight: bold;
336
- }
337
- #powerpress_settings {
338
- background-image:url(http://images.blubrry.com/powerpress/blubrry.png);
339
- background-repeat: no-repeat;
340
- background-position: bottom right;
341
- }
342
- .bpp_input_sm {
343
- width: 120px;
344
- }
345
- .bpp_input_med {
346
- width: 250px;
347
- }
348
- </style>
349
- <?php
350
  }
351
- }
352
-
353
- add_action('admin_head', 'powerpress_admin_head');
354
-
355
- function powerpress_admin_page()
356
- {
357
- global $wp_version, $wp_rewrite;
358
 
359
- if( isset($_POST['CheckSWF']) )
360
  {
361
  $md5 = md5_file( dirname(__FILE__).'/FlowPlayerClassic.swf' );
362
  if( $md5 == '051ed574774436e228e5dafd97d0f5f0' )
363
- echo '<div class="updated powerpress-notice">Flash player verified successfully.</div>';
364
  else
365
- echo '<div class="error powerpress-error">FlowPlayerClassic.swf is corrupt, please re-upload.</div>';
366
  }
 
 
 
 
367
 
 
368
  $VersionDiff = version_compare($wp_version, 2.5);
369
  if( $VersionDiff < 0 )
370
- echo '<div class="error powerpress-error">Blubrry Powerpress requires Wordpress version 2.5 or greater.</div>';
371
-
372
-
373
- $UploadArray = wp_upload_dir();
374
- $upload_path = rtrim( substr($UploadArray['path'], 0, 0 - strlen($UploadArray['subdir']) ), '\\/').'/powerpress/';
375
-
376
- if( !file_exists($upload_path) )
377
- $SupportUploads = @mkdir($upload_path, 0777);
378
- else
379
- $SupportUploads = true;
380
-
381
 
382
-
383
- if( isset($_POST[ 'Submit' ]) )
384
  {
 
 
 
385
  $urlImages = rtrim( substr($UploadArray['url'], 0, 0 - strlen($UploadArray['subdir']) ), '/').'/powerpress/';
386
 
387
  // Save the posted value in the database
388
  $Feed = $_POST['Feed'];
389
  $General = $_POST['General'];
 
390
 
391
  // New iTunes image
392
  if( @$_POST['itunes_image_checkbox'] == 1 )
@@ -412,7 +86,7 @@ function powerpress_admin_page()
412
  }
413
  else
414
  {
415
- echo '<div class="error powerpress-error">Invalid iTunes image ' . htmlspecialchars($_FILES['itunes_image_file']['name']) . '</div>';
416
  }
417
  }
418
 
@@ -438,707 +112,959 @@ function powerpress_admin_page()
438
  }
439
  else
440
  {
441
- echo '<div class="error powerpress-error">Invalid RSS image: ' . htmlspecialchars($_FILES['rss2_image_file']['name']) . '</div>';
442
  }
443
  }
444
 
445
- // Wordpress adds slashes to everything, but since we're storing everything serialized, lets remove them...
446
- while( list($key,$value) = each($General) )
447
- $General[$key] = stripslashes($value);
448
- reset($General);
449
- while( list($key,$value) = each($Feed) )
450
- $Feed[$key] = stripslashes($value);
451
- reset($Feed);
 
 
 
 
 
452
 
453
  // Update the settings in the database:
454
- update_option( 'powerpress_general', $General);
455
- update_option( 'powerpress_feed', $Feed );
 
 
 
 
 
 
 
 
 
 
 
 
456
 
457
  // Anytime settings are saved lets flush the rewrite rules
458
  $wp_rewrite->flush_rules();
459
-
460
- ?>
461
- <div class="updated powerpress-notice"><?php _e('Blubrry Powerpress settings saved.'); ?></div>
462
- <?php
 
 
463
 
464
  if( @$_POST['TestiTunesPing'] == 1 )
465
  {
466
  $PingResults = powerpress_ping_itunes($General['itunes_url']);
467
  if( @$PingResults['success'] )
468
  {
469
- ?>
470
- <div class="updated powerpress-notice">iTunes Ping Successful. Podcast Feed URL: <?php echo $PingResults['feed_url']; ?>
471
- </div>
472
- <?php
473
  }
474
  else
475
  {
476
- echo '<div class="error powerpress-error">' . htmlspecialchars($PingResults['content']) . '</div>';
477
  }
478
  }
479
-
480
- }
481
-
482
- // Get the general settings
483
- $General = get_option('powerpress_general');
484
-
485
- // Get previous podpress settings if no general settings set
486
- if( !$General )
487
- $PodpressData = get_option('podPress_config');
488
 
489
- if( !$General ) // If no general settings, lets pre-populate or copy from podpress
 
490
  {
491
- $General = array();
492
- $General['process_podpress'] = 1;
493
- $General['display_player'] = 1;
494
- $General['player_function'] = 1;
495
- $General['podcast_link'] = 1;
496
- $General['ping_itunes'] = 1;
497
- $PodpressData = get_option('podPress_config');
498
- if( $PodpressData ) // If no general settings, lets set defaults or copy from podpress.
499
  {
500
- ?>
501
- <div class="updated powerpress-notice"><?php _e('Podpress settings detected. Please click \'Save Changes\' to apply detected settings.'); ?></div>
502
- <?php
503
- // Lets try to copy settings from podpress
504
- $General['default_url'] = $PodpressData['mediaWebPath'];
505
- if( substr($General['default_url'], 0, -1) != '/' )
506
- $General['default_url'] .= '/'; // Add the trailing slash, donno it's not there...
507
-
508
- // Insert the blubrry redirect
509
- if( isset($PodpressData['statBluBrryProgramKeyword']) && strlen($PodpressData['statBluBrryProgramKeyword']) > 2 )
510
- {
511
- $General['redirect1'] = 'http://media.blubrry.com/'.$PodpressData['statBluBrryProgramKeyword'].'/';
512
- }
513
-
514
- // Insert the Podtrac redirect
515
- if( $PodpressData['enable3rdPartyStats'] == 'PodTrac' )
516
- {
517
- if( $General['redirect1'] )
518
- $General['redirect2'] = 'http://www.podtrac.com/pts/redirect.mp3/';
 
 
519
  else
520
- $General['redirect1'] = 'http://www.podtrac.com/pts/redirect.mp3/';
521
- }
522
-
523
- if( $PodpressData['contentDownload'] == 'enabled' )
524
- $General['podcast_link'] = 1;
525
- else
526
- $General['podcast_link'] = 0;
527
-
528
- if( $PodpressData['contentPlayer'] == 'both' )
529
- $General['player_function'] = 1;
530
- else if( $PodpressData['contentPlayer'] == 'inline' )
531
- $General['player_function'] = 2;
532
- else if( $PodpressData['contentPlayer'] == 'popup' )
533
- $General['player_function'] = 3;
534
- else
535
- $General['player_function'] = 0;
536
 
537
- if( $PodpressData['contentPlayer'] == 'start' )
538
- $General['display_player'] = 2;
539
- else
540
- $General['display_player'] = 1;
541
 
542
- $General['itunes_url'] = 'http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id='. $PodpressData['iTunes']['FeedID'];
 
 
 
 
 
 
 
 
543
  }
544
  }
545
- // Format the data for printing in html
546
- while( list($key,$value) = each($General) )
547
- $General[$key] = htmlspecialchars($value);
548
- reset($General);
549
 
550
- // Load feed settings
551
- $FeedSettings = get_option('powerpress_feed');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
552
 
553
- if( !$FeedSettings ) // If no feed settings, lets set defaults or copy from podpress.
 
 
 
554
  {
555
- $FeedSettings = array();
556
- $FeedSettings['apply_to'] = 1; // Default, apply to all the rss2 feeds
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
557
 
558
- if( $PodpressData )
 
 
 
559
  {
560
- $FeedSettings['itunes_image'] = $PodpressData['iTunes']['image'];
561
- if( strstr($FeedSettings['itunes_image'], 'powered_by_podpress') )
562
- $FeedSettings['itunes_image'] = ''; // We're not using podpress anymore
563
-
564
- $FeedSettings['itunes_summary'] = $PodpressData['iTunes']['summary'];
565
- $FeedSettings['itunes_talent_name'] = $PodpressData['iTunes']['author'];
566
- $FeedSettings['itunes_subtitle'] = $PodpressData['iTunes']['subtitle'];
567
- $FeedSettings['itunes_keywords'] = $PodpressData['iTunes']['keywords'];
568
- $FeedSettings['copyright'] = $PodpressData['rss_copyright'];
569
- // Categories are tricky...
570
- $iTunesCategories = powerpress_itunes_categories(true);
571
- for( $x = 0; $x < 3; $x++ )
572
  {
573
- $CatDesc = str_replace(':', ' > ', $PodpressData['iTunes']['category'][$x]);
574
- $CatKey = array_search($CatDesc, $iTunesCategories);
575
- if( $CatKey )
576
- $FeedSettings['itunes_cat_'.($x+1)] = $CatKey;
 
 
 
577
  }
578
 
579
- if( $PodpressData['iTunes']['explicit'] == 'No' )
580
- $FeedSettings['itunes_explicit'] = 0;
581
- else if( $PodpressData['iTunes']['explicit'] == 'Yes' )
582
- $FeedSettings['itunes_explicit'] = 1;
583
- else if( $PodpressData['iTunes']['explicit'] == 'Clean' )
584
- $FeedSettings['itunes_explicit'] = 2;
 
 
 
 
585
  }
586
-
587
- // Lastly, lets try to get the RSS image from the database
588
- $RSSImage = get_option('rss_image');
589
- if( $RSSImage )
590
- $FeedSettings['rss2_image'] = $RSSImage;
591
- if( strstr($FeedSettings['rss2_image'], 'powered_by_podpress') )
592
- $FeedSettings['rss2_image'] = ''; // We're not using podpress anymore
593
- $AdminEmail = get_option('admin_email');
594
- if( $AdminEmail )
595
- $FeedSettings['email'] = $AdminEmail;
596
-
597
- //var_dump($FeedSettings);
598
- //var_dump($PodpressData);
599
- //exit;
600
  }
601
- // Format the data for printing in html
602
- while( list($key,$value) = each($FeedSettings) )
603
- $FeedSettings[$key] = htmlspecialchars($value);
604
- reset($FeedSettings);
605
 
606
- // Now display the options editing screen
607
- ?>
608
- <div class="wrap" id="powerpress_settings">
609
-
610
- <form enctype="multipart/form-data" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
611
-
612
-
613
- <?php wp_nonce_field('update-options'); ?>
 
 
 
 
 
 
 
 
 
614
 
615
- <h2><?php _e("Basic Settings"); ?></h2>
616
 
617
- <table class="form-table">
618
- <tr valign="top">
619
- <th scope="row"><?php _e("Default Media URL"); ?></th>
620
- <td>
621
- <input type="text" style="width: 80%;" name="General[default_url]" value="<?php echo $General['default_url']; ?>" maxlength="250" />
622
- <p>URL above will prefix entered file names that do not start with 'http://'. URL above must end with a trailing slash.
623
- You may leave blank if you always enter the complete URL to your media when creating podcast episodes.
624
- </p>
625
- <p>e.g. http://example.com/mediafolder/</p>
626
- </td>
627
- </tr>
628
 
629
- <tr valign="top">
630
- <th scope="row">
631
 
632
- <?php _e("Podpress Episodes"); ?></th>
633
- <td>
634
- <select name="General[process_podpress]" class="bpp_input_med">
635
- <?php
636
- $options = array(0=>'Ignore', 1=>'Include in Posts and Feeds');
637
 
638
- while( list($value,$desc) = each($options) )
639
- echo "\t<option value=\"$value\"". ($General['process_podpress']==$value?' selected':''). ">$desc</option>\n";
 
 
 
 
 
640
 
641
- ?>
642
- </select> (includes podcast episodes previously created in Podpress)
643
- </td>
644
- </tr>
645
-
646
- <tr valign="top">
647
- <th scope="row">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
648
 
649
- <?php _e("File Size Default"); ?></th>
650
- <td>
651
- <select name="General[set_size]" class="bpp_input_med">
652
- <?php
653
- $options = array(0=>'Auto detect file size', 1=>'User specify');
 
 
 
 
 
 
 
 
 
 
 
 
 
654
 
655
- while( list($value,$desc) = each($options) )
656
- echo "\t<option value=\"$value\"". ($General['set_size']==$value?' selected':''). ">$desc</option>\n";
657
-
658
- ?>
659
- </select> (specify default file size option when creating a new episode)
660
- </td>
661
- </tr>
662
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
663
 
664
- <tr valign="top">
665
- <th scope="row">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
666
 
667
- <?php _e("Duration Default"); ?></th>
668
- <td>
669
- <select name="General[set_duration]" class="bpp_input_med">
670
- <?php
671
- $options = array(0=>'Auto detect duration (mp3\'s only)', 1=>'User specify', -1=>'Not specified (not recommended)');
672
 
673
- while( list($value,$desc) = each($options) )
674
- echo "\t<option value=\"$value\"". ($General['set_duration']==$value?' selected':''). ">$desc</option>\n";
675
-
 
 
676
  ?>
677
- </select> (specify default duration option when creating a new episode)
678
- </td>
679
- </tr>
680
-
681
- <tr valign="top">
682
- <th scope="row"><?php _e("iTunes URL"); ?></th>
683
- <td>
684
- <input type="text" style="width: 80%;" name="General[itunes_url]" value="<?php echo $General['itunes_url']; ?>" maxlength="250" />
685
- <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>.
686
- Once your podcast is listed on iTunes, enter your one click subscription URL above.
687
- </p>
688
- <p>e.g. http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=000000000</p>
689
- </td>
690
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
691
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
692
  <?php
693
- $OpenSSLSupport = extension_loaded('openssl');
 
 
694
  ?>
695
- <tr valign="top">
696
- <th scope="row">
697
-
698
- <?php _e("Ping iTunes"); ?></th>
699
- <td>
700
- <select name="General[ping_itunes]"<?php if( $OpenSSLSupport == false ) echo ' disabled'; ?> class="bpp_input_sm">
701
- <?php
702
- $options = array(0=>'No ', 1=>'Yes ');
703
-
704
- if( $OpenSSLSupport == false )
705
- $value = 0;
706
 
707
- while( list($value,$desc) = each($options) )
708
- echo "\t<option value=\"$value\"". ($General['ping_itunes']==$value?' selected':''). ">$desc</option>\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
709
 
710
- ?>
711
- </select> (Notify iTunes when you publish a new episode.)
712
- <p><input name="TestiTunesPing" type="checkbox" value="1"<?php if( $OpenSSLSupport == false ) echo ' disabled'; ?> /> Test iTunes Ping (recommended)</p>
713
- <?php if( $General['itunes_url'] ) {
714
-
715
- $ping_url = str_replace(
716
- array( 'https://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=',
717
- 'http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=',
718
- 'https://www.itunes.com/podcast?id=',
719
- 'http://www.itunes.com/podcast?id='),
720
- 'https://phobos.apple.com/WebObjects/MZFinance.woa/wa/pingPodcast?id=', $General['itunes_url']);
721
- ?>
722
- <p>You may also ping iTunes by using the following link: <a href="#" onclick="javascript: window.open('<?php echo $ping_url; ?>'); return false;" title="Ping iTunes in New Window">Ping iTunes in New Window</a></p>
723
- <?php } ?>
724
- </td>
725
- </tr>
726
-
727
- </table>
728
- <?php if( $OpenSSLSupport == false ) { ?>
729
- <div class="error powerpress-error">Ping iTunes requires OpenSSL in PHP. Please refer to your php.ini to enable the php_openssl module.</div>
730
- <?php } ?>
731
- <br />
732
-
733
-
734
- <h2><?php _e("Presentation Settings"); ?></h2>
735
-
736
- <p style="margin-bottom: 0;">Configure how your media will be found on your blog.</p>
737
-
738
-
739
- <table class="form-table">
740
- <tr valign="top">
741
- <th scope="row"><?php _e("Display Player"); ?></th>
742
- <td><select name="General[display_player]" class="bpp_input_sm">
743
- <?php
744
- $displayoptions = array(1=>"Below Post", 2=>"Above Post", 0=>"None");
745
-
746
- while( list($value,$desc) = each($displayoptions) )
747
- echo "\t<option value=\"$value\"". ($General['display_player']==$value?' selected':''). ">$desc</option>\n";
748
-
749
- ?>
750
- </select>
751
- <p><input name="General[display_player_excerpt]" type="checkbox" value="1" <?php if($General['display_player_excerpt']) echo 'checked '; ?>/> Display player 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>
752
- </td>
753
- </tr>
754
-
755
- <tr valign="top">
756
- <th scope="row">
757
- <?php _e("Player Function"); ?></th>
758
- <td><select name="General[player_function]" class="bpp_input_med">
759
- <?php
760
- $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');
761
-
762
- while( list($value,$desc) = each($playeroptions) )
763
- echo "\t<option value=\"$value\"". ($General['player_function']==$value?' selected':''). ">".htmlspecialchars($desc)."</option>\n";
764
 
765
- ?>
766
- </select>
767
- <p style="margin-top: 0;">
768
- Note: "On Page Link" is a link to "play on page", the player is not displayed until link is clicked.
769
- </p>
770
- <?php
771
- global $wp_version;
772
- if( version_compare($wp_version, '2.7') < 0 ) // Wordpress before version 2.7
773
  {
774
- ?>
775
- <p><input name="CheckSWF" type="checkbox" value="1" /> Verify flash player</p>
776
- <?php
777
  }
778
- ?>
779
- </td>
780
- </tr>
781
-
782
- <tr valign="top">
783
- <th scope="row">
784
-
785
- <?php _e("Download Link"); ?></th>
786
- <td>
787
- <select name="General[podcast_link]" class="bpp_input_med">
788
- <?php
789
- $linkoptions = array(1=>"Display", 2=>"Display with file size", 3=>"Display with file size and duration", 0=>"Disable");
790
-
791
- while( list($value,$desc) = each($linkoptions) )
792
- echo "\t<option value=\"$value\"". ($General['podcast_link']==$value?' selected':''). ">$desc</option>\n";
793
-
794
- ?>
795
- </select>
796
- </td>
797
- </tr>
798
- </table>
799
- <p>
800
- 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>.
801
- The WP Audio Player 2.0 options include
802
- theme colors, initial volume, player width and more.
803
- </p>
804
- <br />
805
- <h2><?php _e("Media Statistics"); ?></h2>
806
- <p style="margin-bottom: 0;">Configure 3rd party statistics services to measure your media. (optional)</p>
807
-
808
- <table class="form-table">
809
- <tr valign="top">
810
- <th scope="row">
811
- <?php _e("Redirect URL 1"); ?>
812
- </th>
813
- <td>
814
- <input type="text" style="width: 60%;" name="General[redirect1]" value="<?php echo $General['redirect1']; ?>" maxlength="250" />
815
- </td>
816
- </tr>
817
-
818
- <tr valign="top">
819
- <th scope="row">
820
- <?php _e("Redirect URL 2"); ?>
821
- </th>
822
- <td>
823
- <input type="text" style="width: 60%;" name="General[redirect2]" value="<?php echo $General['redirect2']; ?>" maxlength="250" />
824
- </td>
825
- </tr>
826
-
827
- <tr valign="top">
828
- <th scope="row">
829
- <?php _e("Redirect URL 3"); ?>
830
- </th>
831
- <td>
832
- <input type="text" style="width: 60%;" name="General[redirect3]" value="<?php echo $General['redirect3']; ?>" maxlength="250" />
833
- </td>
834
- </tr>
835
- </table>
836
- <p>
837
- The services above must support redirects that do
838
- not include nested 'http://' within the URL. Statistics services such as
839
- <a href="http://www.podtrac.com" target="_blank" title="PodTrac">PodTrac.com</a>,
840
- <a href="http://www.blubrry.com/podcast_statistics/" target="_blank" title="Blubrry Statistics">Blubrry.com</a>,
841
- <a href="http://www.techpodcasts.com/podcast_statistics/" target="_blank" title="TechPodcasts Statistics">TechPodcasts.com</a>,
842
- <a href="http://www.rawvoice.com/products/statistics/" target="_blank" title="RawVoice Statistics">RawVoice.com</a>
843
- are supported.
844
- </p>
845
- <br />
846
- <h2><?php _e("Feed Settings"); ?></h2>
847
- <p style="margin-bottom: 0;">
848
- Configure your feeds to support podcasting.
849
- </p>
850
- <table class="form-table">
851
-
852
- <tr valign="top">
853
- <th scope="row">
854
-
855
- <?php _e("Apply Settings To"); ?></th>
856
- <td>
857
- <select name="Feed[apply_to]" class="bpp_input_med">
858
- <?php
859
- $applyoptions = array(1=>'All RSS2 Feeds', 2=>'Main RSS2 Feed only', 0=>'Disable (settings below ignored)');
860
-
861
- while( list($value,$desc) = each($applyoptions) )
862
- echo "\t<option value=\"$value\"". ($FeedSettings['apply_to']==$value?' selected':''). ">$desc</option>\n";
863
 
864
- ?>
865
- </select>
866
- <p>Select 'All RSS Feeds' to include podcast episodes in all feeds such as category and tag feeds.</p>
867
- <p>Select 'Main RSS2 Feed only' to include podcast episodes only in your primary RSS2 feed.</p>
868
- <p>Select 'Disable' to prevent Blubrry Powerpress from adding podcast episodes to any feeds.</p>
869
- </td>
870
- </tr>
871
-
872
- <tr valign="top">
873
- <th scope="row">
874
-
875
- <?php _e("Important Feeds"); ?></th>
876
- <td>
877
- <p>Main RSS2 Feed: <a href="<?php echo get_bloginfo('rss2_url'); ?>" title="Main RSS 2 Feed" target="_blank"><?php echo get_bloginfo('rss2_url'); ?></a> | <a href="http://www.feedvalidator.org/check.cgi?url=<?php echo urlencode(get_bloginfo('rss2_url')); ?>" title="Validate Feed" target="_blank">validate</a></p>
878
- <p>Special Podcast only Feed: <a href="<?php echo get_feed_link('podcast'); ?>" title="Podcast Feed" target="_blank"><?php echo get_feed_link('podcast'); ?></a> | <a href="http://www.feedvalidator.org/check.cgi?url=<?php echo urlencode(get_feed_link('podcast')); ?>" title="Validate Feed" target="_blank">validate</a></p>
879
-
880
- </td>
881
- </tr>
882
-
883
- <tr valign="top">
884
- <th scope="row" >
885
-
886
- <?php _e("iTunes New Feed URL"); ?></th>
887
- <td>
888
- <div id="new_feed_url_step_1" style="display: <?php echo ($FeedSettings['itunes_new_feed_url'] || $FeedSettings['itunes_new_feed_url_podcast'] ?'none':'block'); ?>;">
889
- <p><a href="#" onclick="return powerpress_new_feed_url_prompt();">Click here</a> if you need to change the Feed URL for iTunes subscribers.</p>
890
- </div>
891
- <div id="new_feed_url_step_2" style="display: <?php echo ($FeedSettings['itunes_new_feed_url'] || $FeedSettings['itunes_new_feed_url_podcast'] ?'block':'none'); ?>;">
892
- <p><strong>WARNING: Changes made here are permanent. If the New Feed URL entered is incorrect, you will lose subscribers and will no longer be able to update your listing in the iTunes Store.</strong></p>
893
- <p><strong>DO NOT MODIFY THIS SETTING UNLESS YOU ABSOLUTELY KNOW WHAT YOU ARE DOING.</strong></p>
894
- <p>
895
- Apple recommends you maintain the &lt;itunes:new-feed-url&gt; tag in your feed for at least two weeks to ensure that most subscribers will receive the new New Feed URL.
896
- </p>
897
- <p>
898
- Example URL: <?php echo get_feed_link('podcast'); ?>
899
- </p>
900
- <p style="margin-bottom: 0;">
901
- <label style="width: 25%; float:left; display:block; font-weight: bold;">Main RSS2 Feed</label>
902
- <input type="text" name="Feed[itunes_new_feed_url]"style="width: 55%;" value="<?php echo $FeedSettings['itunes_new_feed_url']; ?>" maxlength="250" />
903
- </p>
904
- <p style="margin-left: 25%;margin-top: 0;font-size: 90%;">(Leave blank for no New Feed URL)</p>
905
- <p style="margin-bottom: 0;">
906
- <label style="width: 25%; float:left; display:block; font-weight: bold;">Podcast Feed</label>
907
- <input type="text" name="Feed[itunes_new_feed_url_podcast]"style="width: 55%;" value="<?php echo $FeedSettings['itunes_new_feed_url_podcast']; ?>" maxlength="250" />
908
- </p>
909
- <p style="margin-left: 25%;margin-top: 0;font-size: 90%;">(Leave blank for no New Feed URL)</p>
910
- <p>More information regarding the iTunes New Feed URL is available <a href="http://www.apple.com/itunes/whatson/podcasts/specs.html#changing" target="_blank" title="Apple iTunes Podcasting Specificiations">here</a>.</p>
911
- </div>
912
- </td>
913
- </tr>
914
-
915
- <tr valign="top">
916
- <th scope="row">
917
-
918
- <?php _e("iTunes Summary"); ?></th>
919
- <td>
920
- <p>Your summary may not contain HTML and cannot exceed 4,000 characters in length.</p>
921
-
922
- <textarea name="Feed[itunes_summary]" rows="5" style="width:80%;" ><?php echo $FeedSettings['itunes_summary']; ?></textarea>
923
- </td>
924
- </tr>
925
-
926
- <tr valign="top">
927
- <th scope="row">
928
- <?php _e("iTunes Program Subtitle"); ?> <br />
929
- </th>
930
- <td>
931
- <input type="text" name="Feed[itunes_subtitle]"style="width: 60%;" value="<?php echo $FeedSettings['itunes_subtitle']; ?>" maxlength="250" />
932
- </td>
933
- </tr>
934
-
935
- <tr valign="top">
936
- <th scope="row">
937
- <?php _e("iTunes Program Keywords"); ?> <br />
938
- </th>
939
- <td>
940
- <input type="text" name="Feed[itunes_keywords]" style="width: 60%;" value="<?php echo $FeedSettings['itunes_keywords']; ?>" maxlength="250" />
941
- <p>Enter up to 12 keywords separated by commas.</p>
942
- </td>
943
- </tr>
944
-
945
- <tr valign="top">
946
- <th scope="row">
947
- <?php _e("iTunes Category 1"); ?>
948
- </th>
949
- <td>
950
- <select name="Feed[itunes_cat_1]" style="width: 60%;">
951
- <?php
952
- $linkoptions = array("On page", "Disable");
953
-
954
- $Categories = powerpress_itunes_categories(true);
955
-
956
- echo '<option value="">Select Category</option>';
957
-
958
- while( list($value,$desc) = each($Categories) )
959
- echo "\t<option value=\"$value\"". ($FeedSettings['itunes_cat_1']==$value?' selected':''). ">".htmlspecialchars($desc)."</option>\n";
960
-
961
- reset($Categories);
962
- ?>
963
- </select>
964
- </td>
965
- </tr>
966
-
967
- <tr valign="top">
968
- <th scope="row">
969
- <?php _e("iTunes Category 2"); ?>
970
- </th>
971
- <td>
972
- <select name="Feed[itunes_cat_2]" style="width: 60%;">
973
- <?php
974
- $linkoptions = array("On page", "Disable");
975
-
976
- echo '<option value="">Select Category</option>';
977
-
978
- while( list($value,$desc) = each($Categories) )
979
- echo "\t<option value=\"$value\"". ($FeedSettings['itunes_cat_2']==$value?' selected':''). ">".htmlspecialchars($desc)."</option>\n";
980
-
981
- reset($Categories);
982
 
983
- ?>
984
- </select>
985
- </td>
986
- </tr>
987
 
988
- <tr valign="top">
989
- <th scope="row">
990
- <?php _e("iTunes Category 3"); ?>
991
- </th>
992
- <td>
993
- <select name="Feed[itunes_cat_3]" style="width: 60%;">
994
  <?php
995
- $linkoptions = array("On page", "Disable");
996
-
997
- echo '<option value="">Select Category</option>';
998
 
999
- while( list($value,$desc) = each($Categories) )
1000
- echo "\t<option value=\"$value\"". ($FeedSettings['itunes_cat_3']==$value?' selected':''). ">".htmlspecialchars($desc)."</option>\n";
1001
 
1002
- reset($Categories);
 
 
 
 
1003
  ?>
1004
- </select>
1005
- </td>
1006
- </tr>
1007
-
1008
- <tr valign="top">
1009
- <th scope="row">
1010
- <?php _e("iTunes Explicit"); ?>
1011
- </th>
1012
- <td>
1013
- <select name="Feed[itunes_explicit]" class="bpp_input_med">
1014
  <?php
1015
- $explicit = array(0=>"no - display nothing", 1=>"yes - explicit content", 2=>"clean - no explicit content");
 
 
 
 
1016
 
1017
- while( list($value,$desc) = each($explicit) )
1018
- echo "\t<option value=\"$value\"". ($FeedSettings['itunes_explicit']==$value?' selected':''). ">$desc</option>\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1019
 
1020
- ?>
1021
- </select>
1022
- </td>
1023
- </tr>
 
 
 
 
1024
 
1025
- <tr valign="top">
1026
- <th scope="row">
1027
- <?php _e("iTunes Image"); ?>
1028
- </th>
1029
- <td>
1030
- <input type="text" id="itunes_image" name="Feed[itunes_image]" style="width: 60%;" value="<?php echo $FeedSettings['itunes_image']; ?>" maxlength="250" />
1031
- <a href="#" onclick="javascript: window.open( document.getElementById('itunes_image').value ); return false;">preview</a>
 
1032
 
1033
- <p>Place the URL to the iTunes image above. e.g. http://mysite.com/images/itunes.jpg<br /><br />iTunes prefers square .jpg or .png images that are at 600 x 600 pixels (prevously 300 x 300), which is different than what is specified for the standard RSS image.</p>
 
 
 
 
 
 
 
1034
 
1035
- <?php if( $SupportUploads ) { ?>
1036
- <p><input name="itunes_image_checkbox" type="checkbox" onchange="powerpress_show_field('itunes_image_upload', this.checked)" value="1" /> Upload new image: </p>
1037
- <div style="display:none" id="itunes_image_upload">
1038
- <label for="itunes_image">Choose file:</label><input type="file" name="itunes_image_file" />
1039
- </div>
1040
- <?php } ?>
1041
- </td>
1042
- </tr>
 
 
 
 
 
 
 
 
 
 
 
1043
 
1044
- <tr valign="top">
1045
- <th scope="row">
1046
- <?php _e("RSS2 Image"); ?> <br />
1047
- </th>
1048
- <td>
1049
- <input type="text" id="rss2_image" name="Feed[rss2_image]" style="width: 60%;" value="<?php echo $FeedSettings['rss2_image']; ?>" maxlength="250" />
1050
- <a href="#" onclick="javascript: window.open( document.getElementById('rss2_image').value ); return false;">preview</a>
 
 
 
 
 
 
 
 
 
 
 
 
1051
 
1052
- <p>Place the URL to the RSS image above. e.g. http://mysite.com/images/rss.jpg</p>
1053
- <p>RSS image should be at least 88 and at most 144 pixels wide and at least 31 and at most 400 pixels high in either .gif, .jpg and .png format. A square 144 x 144 pixel image is recommended.</p>
 
 
 
 
 
 
 
 
 
 
1054
 
1055
- <?php if( $SupportUploads ) { ?>
1056
- <p><input name="rss2_image_checkbox" type="checkbox" onchange="powerpress_show_field('rss_image_upload', this.checked)" value="1" /> Upload new image</p>
1057
- <div style="display:none" id="rss_image_upload">
1058
- <label for="rss2_image">Choose file:</label><input type="file" name="rss2_image_file" />
1059
- </div>
1060
- <?php } ?>
1061
- </td>
1062
- </tr>
1063
 
1064
- <tr valign="top">
1065
- <th scope="row">
1066
- <?php _e("Talent Name"); ?> <br />
1067
- </th>
1068
- <td>
1069
- <input type="text" name="Feed[itunes_talent_name]"style="width: 60%;" value="<?php echo $FeedSettings['itunes_talent_name']; ?>" maxlength="250" />
1070
- </td>
1071
- </tr>
1072
 
1073
- <tr valign="top">
1074
- <th scope="row">
1075
- <?php _e("Email"); ?>
1076
- </th>
1077
- <td>
1078
- <input type="text" name="Feed[email]" style="width: 60%;" value="<?php echo $FeedSettings['email']; ?>" maxlength="250" />
1079
- </td>
1080
- </tr>
1081
 
1082
- <tr valign="top">
1083
- <th scope="row">
1084
- <?php _e("Copyright"); ?>
1085
- </th>
1086
- <td>
1087
- <input type="text" name="Feed[copyright]" style="width: 60%;" value="<?php echo $FeedSettings['copyright']; ?>" maxlength="250" />
1088
- </td>
1089
- </tr>
1090
- </table>
1091
- <p style="font-size: 85%; text-align: center;">
1092
- <a href="http://www.blubrry.com/powerpress/" title="Blubrry Powerpress" target="_blank">Blubrry Powerpress</a> <?php echo POWERPRESS_VERSION; ?>
1093
- &#8212; <a href="http://help.blubrry.com/blubrry-powerpress/" target="_blank" title="Blubrry Powerpress Documentation">Documentation</a> | <a href="http://twitter.com/blubrry" target="_blank" title="Follow Blubrry on Twitter">Follow Blubrry on Twitter</a>
1094
- </p>
1095
- <p class="submit">
1096
- <input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes' ) ?>" />
1097
- </p>
1098
 
1099
- </form>
1100
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1101
 
1102
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1103
  }
1104
 
1105
- function powerpress_shutdown()
 
1106
  {
1107
- global $wpdb;
1108
- $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE meta_key = '_encloseme' ");
 
 
1109
  }
1110
 
1111
- add_action('shutdown','powerpress_shutdown'); // disable the auto enclosure process
 
 
 
1112
 
1113
- /*
1114
- // Helper functions:
1115
- */
1116
- function powerpress_ping_itunes($iTunes_url)
1117
- {
1118
- if( strpos($iTunes_url, 'phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=' ) === false )
1119
- return array('error'=>true, 'content'=>'iTunes URL required to ping iTunes.');
1120
-
1121
- // convert: https://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=
1122
- // to: https://phobos.apple.com/WebObjects/MZFinance.woa/wa/pingPodcast?id=
1123
- $ping_url = str_replace(
1124
- array( 'https://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=',
1125
- 'http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=',
1126
- 'https://www.itunes.com/podcast?id=',
1127
- 'http://www.itunes.com/podcast?id='),
1128
- 'https://phobos.apple.com/WebObjects/MZFinance.woa/wa/pingPodcast?id=', $iTunes_url);
1129
-
1130
- $tempdata = wp_remote_fopen($ping_url);
1131
 
1132
- if( $tempdata == false )
1133
- return array('error'=>true, 'content'=>'Unable to connect to iTunes ping server.');
 
 
 
 
 
 
 
 
 
 
 
 
 
1134
 
1135
- if( stristr($tempdata, 'No Podcast Found') )
1136
- return array('error'=>true, 'content'=>'No Podcast Found from iTunes ping request');
1137
-
1138
- // Parse the data into something readable
1139
- $results = trim( str_replace('Podcast Ping Received', '', strip_tags($tempdata) ) );
1140
- list($null, $FeedURL, $null, $null, $null, $PodcastID) = split("\n", $results );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1141
 
1142
- return array('success'=>true, 'content'=>$tempdata, 'feed_url'=>trim($FeedURL), 'podcast_id'=>trim($PodcastID) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1143
  }
 
 
1144
  ?>
1
  <?php
2
 
3
+ function powerpress_page_message_add_error($msg)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  {
5
+ global $g_powerpress_page_message;
6
+ $g_powerpress_page_message .= '<div class="error powerpress-error">'. $msg . '</div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  }
8
 
9
+ function powerpress_page_message_add_notice($msg)
10
+ {
11
+ global $g_powerpress_page_message;
12
+ $g_powerpress_page_message .= '<div class="updated fade powerpress-notice">'. $msg . '</div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  }
14
 
15
 
16
+ function powerpress_page_message_print()
17
+ {
18
+ global $g_powerpress_page_message;
19
+ if( $g_powerpress_page_message )
20
+ echo $g_powerpress_page_message;
21
+ $g_powerpress_page_message = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  }
23
 
24
+ function powerpress_admin_init()
 
 
 
25
  {
26
+ global $wp_rewrite;
27
+
28
+ if( !current_user_can('manage_options') )
29
  {
30
+ powerpress_page_message_add_error( __('You do not have sufficient permission to manage options.') );
31
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
 
 
 
 
 
 
 
33
 
34
+ if( isset($_POST['CheckSWF']) ) // Leave until we no longer support Wordpress 2.6.x
35
  {
36
  $md5 = md5_file( dirname(__FILE__).'/FlowPlayerClassic.swf' );
37
  if( $md5 == '051ed574774436e228e5dafd97d0f5f0' )
38
+ powerpress_page_message_add_notice( __('Flash player verified successfully.') );
39
  else
40
+ powerpress_page_message_add_error( __('FlowPlayerClassic.swf is corrupt, please re-upload.') );
41
  }
42
+
43
+ // Check for other podcasting plugin
44
+ if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) )
45
+ powerpress_page_message_add_error( __('Another podcasting plugin has been detected, PowerPress is currently disabled.') );
46
 
47
+ global $wp_version;
48
  $VersionDiff = version_compare($wp_version, 2.5);
49
  if( $VersionDiff < 0 )
50
+ powerpress_page_message_add_error( __('Blubrry PowerPress requires Wordpress version 2.5 or greater.') );
 
 
 
 
 
 
 
 
 
 
51
 
52
+ // Save settings here
53
+ if( isset($_POST[ 'Feed' ]) || isset($_POST[ 'General' ]) )
54
  {
55
+ check_admin_referer('powerpress-edit');
56
+ $UploadArray = wp_upload_dir();
57
+ $upload_path = rtrim( substr($UploadArray['path'], 0, 0 - strlen($UploadArray['subdir']) ), '\\/').'/powerpress/';
58
  $urlImages = rtrim( substr($UploadArray['url'], 0, 0 - strlen($UploadArray['subdir']) ), '/').'/powerpress/';
59
 
60
  // Save the posted value in the database
61
  $Feed = $_POST['Feed'];
62
  $General = $_POST['General'];
63
+ $FeedSlug = (isset($_POST['feed_slug'])?$_POST['feed_slug']:false);
64
 
65
  // New iTunes image
66
  if( @$_POST['itunes_image_checkbox'] == 1 )
86
  }
87
  else
88
  {
89
+ powerpress_page_message_add_error( 'Invalid iTunes image ' . htmlspecialchars($_FILES['itunes_image_file']['name']) );
90
  }
91
  }
92
 
112
  }
113
  else
114
  {
115
+ powerpress_page_message_add_error( 'Invalid RSS image: ' . htmlspecialchars($_FILES['rss2_image_file']['name']) );
116
  }
117
  }
118
 
119
+ // Check to see if we need to update the feed title
120
+ if( $FeedSlug )
121
+ {
122
+ $GeneralSettingsTemp = powerpress_get_settings('powerpress_general', false);
123
+ if( $GeneralSettingsTemp['custom_feeds'][$FeedSlug] != $Feed['title'] )
124
+ {
125
+ if( !$General )
126
+ $General = array();
127
+ $General['custom_feeds'] = $GeneralSettingsTemp['custom_feeds'];
128
+ $General['custom_feeds'][$FeedSlug] = $Feed['title'];
129
+ }
130
+ }
131
 
132
  // Update the settings in the database:
133
+ if( $General )
134
+ {
135
+ // Wordpress adds slashes to everything, but since we're storing everything serialized, lets remove them...
136
+ $General = powerpress_stripslashes($General);
137
+ powerpress_save_settings($General);
138
+ }
139
+
140
+ if( $Feed )
141
+ {
142
+ if( !isset($Feed['enhance_itunes_summary']) )
143
+ $Feed['enhance_itunes_summary'] = false;
144
+ $Feed = powerpress_stripslashes($Feed);
145
+ powerpress_save_settings($Feed, 'powerpress_feed'.($FeedSlug?'_'.$FeedSlug:'') );
146
+ }
147
 
148
  // Anytime settings are saved lets flush the rewrite rules
149
  $wp_rewrite->flush_rules();
150
+
151
+ // Settings saved successfully
152
+ if( $FeedSlug )
153
+ powerpress_page_message_add_notice( __('Blubrry PowerPress settings saved.') );
154
+ else
155
+ powerpress_page_message_add_notice( __('Blubrry PowerPress feed settings saved.') );
156
 
157
  if( @$_POST['TestiTunesPing'] == 1 )
158
  {
159
  $PingResults = powerpress_ping_itunes($General['itunes_url']);
160
  if( @$PingResults['success'] )
161
  {
162
+ powerpress_page_message_add_notice( 'iTunes Ping Successful. Podcast Feed URL:'. $PingResults['feed_url'] );
 
 
 
163
  }
164
  else
165
  {
166
+ powerpress_page_message_add_error( htmlspecialchars($PingResults['content']) );
167
  }
168
  }
169
+ }
 
 
 
 
 
 
 
 
170
 
171
+ // Handle POST actions...
172
+ if( isset($_POST['action'] ) )
173
  {
174
+ switch($_POST['action'])
 
 
 
 
 
 
 
175
  {
176
+ case 'powerpress-addfeed': {
177
+ check_admin_referer('powerpress-add-feed');
178
+
179
+ $Settings = get_option('powerpress_general');
180
+ $key = sanitize_title($_POST['feed_slug']);
181
+ $value = $_POST['feed_name'];
182
+ $value = powerpress_stripslashes($value);
183
+
184
+ /*
185
+ if( isset($Settings['custom_feeds'][ $key ]) && @$_POST['overwrite'] != 1 )
186
+ {
187
+ powerpress_page_message_add_error( sprintf(__('Feed slug "%s" already exists.'), $key) );
188
+ } else */
189
+ if( $key == '' )
190
+ {
191
+ powerpress_page_message_add_error( sprintf(__('Feed slug "%s" is not valid.'), $_POST['feed_slug']) );
192
+ }
193
+ else if( in_array($key, $wp_rewrite->feeds) && !isset($Settings['custom_feeds'][ $key ]) ) // If it is a system feed or feed created by something else
194
+ {
195
+ powerpress_page_message_add_error( sprintf(__('Feed slug "%s" is not available.'), $key) );
196
+ }
197
  else
198
+ {
199
+ $Settings['custom_feeds'][ $key ] = $value;
200
+ powerpress_save_settings($Settings);
201
+
202
+ add_feed($key, 'powerpress_do_podcast_feed'); // Before we flush the rewrite rules we need to add the new custom feed...
203
+ $wp_rewrite->flush_rules();
204
+
205
+ powerpress_page_message_add_notice( sprintf(__('Podcast Feed "%s" added, please configure your new feed now.'), $value) );
206
+ $_GET['action'] = 'powerpress-editfeed';
207
+ $_GET['feed_slug'] = $key;
208
+ }
209
+ }; break;
210
+ case 'powerpress-importpodpress': {
211
+ check_admin_referer('powerpress-import-podpress');
 
 
212
 
213
+ require_once( dirname(__FILE__) . '/powerpressadmin-podpress.php');
214
+ powerpressadmin_podpress_do_import();
 
 
215
 
216
+ $_GET['action'] = 'powerpress-podpress-epiosdes';
217
+ }; break;
218
+ case 'deletepodpressdata': {
219
+ check_admin_referer('powerpress-delete-podpress-data');
220
+
221
+ require_once( dirname(__FILE__) . '/powerpressadmin-podpress.php');
222
+ powerpressadmin_podpress_delete_data();
223
+
224
+ }; break;
225
  }
226
  }
 
 
 
 
227
 
228
+ // Handle GET actions...
229
+ if( isset($_GET['action'] ) )
230
+ {
231
+ switch( $_GET['action'] )
232
+ {
233
+ case 'powerpress-delete-feed': {
234
+ $delete_slug = $_GET['feed_slug'];
235
+ check_admin_referer('powerpress-delete-feed-'.$delete_slug);
236
+
237
+ $Episodes = powerpress_admin_episodes_per_feed($delete_slug);
238
+
239
+ if( $delete_slug == 'podcast' )
240
+ {
241
+ powerpress_page_message_add_error( __('Cannot delete default podcast feed.') );
242
+ }
243
+ else if( $Episodes > 0 )
244
+ {
245
+ powerpress_page_message_add_error( sprintf(__('Cannot delete feed. Feed contains %d episode(s).'), $Episodes) );
246
+ }
247
+ else
248
+ {
249
+ $Settings = get_option('powerpress_general');
250
+ unset($Settings['custom_feeds'][ $delete_slug ]);
251
+ powerpress_save_settings($Settings); // Delete the feed from the general settings
252
+ delete_option('powerpress_feed_'.$delete_slug); // Delete the actual feed settings
253
+
254
+ // Now we need to update the rewrite cso the cached rules are up to date
255
+ if ( in_array($delete_slug, $wp_rewrite->feeds))
256
+ {
257
+ $index = array_search($delete_slug, $wp_rewrite->feeds);
258
+ if( $index !== false )
259
+ unset($wp_rewrite->feeds[$index]); // Remove the old feed
260
+ }
261
+
262
+ // Remove feed function hook
263
+ $hook = 'do_feed_' . $delete_slug;
264
+ remove_action($hook, $hook, 10, 1); // This may not be necessary
265
+ $wp_rewrite->flush_rules(); // This is definitely necessary
266
+
267
+ powerpress_page_message_add_notice( 'Feed deleted successfully.' );
268
+ }
269
+ }; break;
270
+ case 'powerpress-podpress-settings': {
271
+ check_admin_referer('powerpress-podpress-settings');
272
+
273
+ // Import settings here..
274
+ if( powerpress_admin_import_podpress_settings() )
275
+ powerpress_page_message_add_notice( __('Podpress settings imported successfully.') );
276
+ else
277
+ powerpress_page_message_add_error( __('No Podpress settings found.') );
278
+
279
+ }; break;
280
+ case 'powerpress-add-caps': {
281
+ check_admin_referer('powerpress-add-caps');
282
+
283
+ $users = array('administrator','editor', 'author'); // , 'contributor', 'subscriber');
284
+ while( list($null,$user) = each($users) )
285
+ {
286
+ $role = get_role($user);
287
+ if( !$role->has_cap('edit_podcast') )
288
+ $role->add_cap('edit_podcast');
289
+ }
290
+ $General = array('use_caps'=>true);
291
+ powerpress_save_settings($General);
292
+ powerpress_page_message_add_notice( __('Edit Podcast Capability added successfully.') );
293
+
294
+ }; break;
295
+ case 'powerpress-remove-caps': {
296
+ check_admin_referer('powerpress-remove-caps');
297
+
298
+ $users = array('administrator','editor', 'author', 'contributor', 'subscriber');
299
+ while( list($null,$user) = each($users) )
300
+ {
301
+ $role = get_role($user);
302
+ if( $role->has_cap('edit_podcast') )
303
+ $role->remove_cap('edit_podcast');
304
+ }
305
+ $General = array('use_caps'=>false);
306
+ powerpress_save_settings($General);
307
+ powerpress_page_message_add_notice( __('Edit Podcast Capability removed successfully.') );
308
+
309
+ }; break;
310
+ }
311
+ }
312
+ }
313
+
314
+ add_action('init', 'powerpress_admin_init');
315
+
316
+ function powerpress_save_settings($SettingsNew=false, $field = 'powerpress_general' )
317
+ {
318
+ // Save general settings
319
+ if( $SettingsNew )
320
+ {
321
+ $Settings = get_option($field);
322
+ if( !is_array($Settings) )
323
+ $Settings = array();
324
+ while( list($key,$value) = each($SettingsNew) )
325
+ $Settings[$key] = $value;
326
+ update_option($field, $Settings);
327
+ }
328
+ }
329
+
330
+ function powerpress_get_settings($field, $for_editing=true)
331
+ {
332
+ $Settings = get_option($field);
333
+ if( $for_editing )
334
+ $Settings = powerpress_htmlspecialchars($Settings);
335
+ return $Settings;
336
+ }
337
+
338
+ function powerpress_htmlspecialchars($data)
339
+ {
340
+ if( !$data )
341
+ return $data;
342
+ if( is_array($value) )
343
+ {
344
+ while( list($key,$value) = each($data) )
345
+ {
346
+ if( is_array($value) )
347
+ $data[$key] = powerpress_htmlspecialchars($value);
348
+ else
349
+ $data[$key] = htmlspecialchars($value);
350
+ }
351
+ reset($data);
352
+ }
353
+ return $data;
354
+ }
355
+
356
+ function powerpress_stripslashes($data)
357
+ {
358
+ if( !$data )
359
+ return $data;
360
 
361
+ if( !is_array($data) )
362
+ return stripslashes($data);
363
+
364
+ while( list($key,$value) = each($data) )
365
  {
366
+ if( is_array($value) )
367
+ $data[$key] = powerpress_stripslashes($value);
368
+ else
369
+ $data[$key] = stripslashes($value);
370
+ }
371
+ reset($data);
372
+ return $data;
373
+ }
374
+
375
+ function powerpress_admin_menu()
376
+ {
377
+ $Powerpress = get_option('powerpress_general');
378
+
379
+ if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) )
380
+ {
381
+ // CRAP
382
+ }
383
+ else if( function_exists('add_meta_box') && (!@$Powerpress['use_caps'] || current_user_can('edit_podcast') ) )
384
+ { // Otherwise we're using a version of wordpress that is not supported.
385
 
386
+ require_once( dirname(__FILE__).'/powerpressadmin-metabox.php');
387
+ add_meta_box('powerpress-podcast', 'Podcast Episode', 'powerpress_meta_box', 'page', 'normal');
388
+
389
+ if( isset($Powerpress['custom_feeds']) )
390
  {
391
+ if( !isset($Powerpress['custom_feeds']['podcast'] ) )
 
 
 
 
 
 
 
 
 
 
 
392
  {
393
+ add_meta_box('powerpress-podcast', 'Podcast Episode (default)', 'powerpress_meta_box', 'post', 'normal');
394
+
395
+ }
396
+ else
397
+ {
398
+ //add_meta_box('powerpress-podcast', 'Podcast Episode for: '.$Powerpress['custom_feeds']['podcast'].' (default)', 'powerpress_meta_box', 'post', 'normal');
399
+ add_meta_box('powerpress-podcast', 'Podcast Episode (default)', 'powerpress_meta_box', 'post', 'normal');
400
  }
401
 
402
+ while( list($feed_slug, $feed_title) = each($Powerpress['custom_feeds']) )
403
+ {
404
+ if( $feed_slug == 'podcast' )
405
+ continue;
406
+ add_meta_box('powerpress-'.$feed_slug, 'Podcast Episode for Custom Feed: '.$feed_title, 'powerpress_meta_box', 'post', 'normal');
407
+ }
408
+ }
409
+ else
410
+ {
411
+ add_meta_box('powerpress-podcast', 'Podcast Episode', 'powerpress_meta_box', 'post', 'normal');
412
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
413
  }
 
 
 
 
414
 
415
+ if( current_user_can('manage_options') )
416
+ {
417
+ if( $Powerpress['advanced_mode'] )
418
+ {
419
+ add_menu_page(__('PowerPress'), __('PowerPress'), 1, 'powerpress/powerpressadmin_basic.php', 'powerpress_admin_page_basic', powerpress_get_root_url() . 'powerpress_ico.png');
420
+ add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Basic Settings'), __('Basic Settings'), 1, 'powerpress/powerpressadmin_basic.php', 'powerpress_admin_page_basic' );
421
+ add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Appearance Settings'), __('Appearance'), 1, 'powerpress/powerpressadmin_appearance.php', 'powerpress_admin_page_appearance' );
422
+ add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Feed Settings'), __('Feed Settings'), 1, 'powerpress/powerpressadmin_feedsettings.php', 'powerpress_admin_page_feedsettings');
423
+ add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Custom Feeds'), __('Custom Feeds'), 1, 'powerpress/powerpressadmin_customfeeds.php', 'powerpress_admin_page_customfeeds');
424
+ add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Tools'), __('Tools'), 1, 'powerpress/powerpressadmin_tools.php', 'powerpress_admin_page_tools');
425
+ }
426
+ else
427
+ {
428
+ add_options_page('Blubrry PowerPress Settings', 'Blubrry PowerPress', 1, 'powerpress/powerpressadmin_basic.php', 'powerpress_admin_page');
429
+ }
430
+ }
431
+ }
432
 
 
433
 
434
+ add_action('admin_menu', 'powerpress_admin_menu');
 
 
 
 
 
 
 
 
 
 
435
 
 
 
436
 
 
 
 
 
 
437
 
438
+ // Save episode information
439
+ function powerpress_edit_post($post_ID, $post)
440
+ {
441
+ if ( !current_user_can('edit_post', $post_ID) )
442
+ return $postID;
443
+
444
+ $Episodes = $_POST['Powerpress'];
445
 
446
+ if( $Episodes )
447
+ {
448
+ while( list($feed_slug,$Powerpress) = each($Episodes) )
449
+ {
450
+ $field = 'enclosure';
451
+ if( $feed_slug != 'podcast' )
452
+ $field = '_'.$feed_slug.':enclosure';
453
+
454
+ if( $Powerpress['remove_podcast'] == 1 )
455
+ {
456
+ delete_post_meta( $post_ID, $field);
457
+
458
+ if( $feed_slug == 'podcast' ) // Clean up the old data
459
+ delete_post_meta( $post_ID, 'itunes:duration');
460
+ }
461
+ else if( @$Powerpress['change_podcast'] == 1 || @$Powerpress['new_podcast'] == 1 )
462
+ {
463
+ // No URL specified, then it's not really a podcast to save
464
+ if( $Powerpress['url'] == '' )
465
+ continue; // go to the next media file
466
+
467
+ // Initialize the important variables:
468
+ $MediaURL = $Powerpress['url'];
469
+ if( strpos($MediaURL, 'http://') !== 0 ) // If the url entered does not start with a http://
470
+ {
471
+ $Settings = get_option('powerpress_general');
472
+ $MediaURL = rtrim(@$Settings['default_url'], '/') .'/'. $MediaURL;
473
+ }
474
+
475
+ $FileSize = '';
476
+ $ContentType = '';
477
+ $Duration = false;
478
 
479
+ // Get the content type based on the file extension, first we have to remove query string if it exists
480
+ $UrlParts = parse_url($Powerpress['url']);
481
+ if( $UrlParts['path'] )
482
+ {
483
+ // using functions that already exist in Wordpress when possible:
484
+ $FileType = wp_check_filetype($UrlParts['path']);
485
+ if( $FileType )
486
+ $ContentType = $FileType['type'];
487
+
488
+ /*
489
+ $FileParts = pathinfo($UrlParts['path']);
490
+ if( $FileParts )
491
+ {
492
+
493
+ $ContentType = powerpress_mimetypes($FileParts['extension']);
494
+ }
495
+ */
496
+ }
497
 
498
+ //Set the duration specified by the user
499
+ if( $Powerpress['set_duration'] == 1 ) // specify duration
500
+ {
501
+ $Duration = sprintf('%02d:%02d:%02d', $Powerpress['duration_hh'], $Powerpress['duration_mm'], $Powerpress['duration_ss'] );
502
+ }
503
+
504
+ //Set the file size specified by the user
505
+ if( $Powerpress['set_size'] == 1 ) // specify file size
506
+ {
507
+ $FileSize = $Powerpress['size'];
508
+ }
509
+
510
+ if( $Powerpress['set_size'] == 0 || $Powerpress['set_duration'] == 0 )
511
+ {
512
+ // Lets use the mp3info class:
513
+ require_once('mp3info.class.php');
514
+
515
+ $Mp3Info = new Mp3Info();
516
+ if( $Powerpress['set_duration'] == 0 && $ContentType == 'audio/mpeg' )
517
+ {
518
+ $Mp3Data = $Mp3Info->GetMp3Info($MediaURL);
519
+ if( $Mp3Data )
520
+ {
521
+ if( @$Powerpress['set_size'] == 0 )
522
+ $FileSize = $Mp3Info->GetContentLength();
523
+ $Duration = $Mp3Data['playtime_string'];
524
+ if( substr_count($Duration, ':' ) == 0 )
525
+ {
526
+ if( $Duration < 60 )
527
+ $Duration = '00:00:'.$Duration;
528
+ }
529
+ else if( substr_count($Duration, ':' ) == 1 )
530
+ {
531
+ $Duration = '00:'.$Duration;
532
+ }
533
+ $Duration = powerpress_readable_duration($Duration, true); // Fix so it looks better when viewed for editing
534
+ }
535
+ }
536
+
537
+ // Just get the file size
538
+ if( $Powerpress['set_size'] == 0 && $FileSize == '' )
539
+ {
540
+ $headers = wp_get_http_headers($MediaURL);
541
+ if( $headers && $headers['content-length'] )
542
+ {
543
+ $FileSize = (int) $headers['content-length'];
544
+ }
545
+ }
546
+ }
547
+
548
+ $EnclosureData = $MediaURL . "\n" . $FileSize . "\n". $ContentType;
549
+ $ToSerialize = array();
550
+ // iTunes duration
551
+ if( $Duration )
552
+ $ToSerialize['duration'] = $Duration; // regular expression '/^(\d{1,2}\:)?\d{1,2}\:\d\d$/i' (examples: 1:23, 12:34, 1:23:45, 12:34:56)
553
+ // iTunes Subtitle (FUTURE USE)
554
+ if( isset($Powerpress['subtitle']) && trim($Powerpress['subtitle']) != '' )
555
+ $ToSerialize['subtitle'] = $Powerpress['subtitle'];
556
+ // iTunes Summary (FUTURE USE)
557
+ if( isset($Powerpress['summary']) && trim($Powerpress['summary']) != '' )
558
+ $ToSerialize['summary'] = $Powerpress['summary'];
559
+ // iTunes keywords (FUTURE USE)
560
+ if( isset($Powerpress['keywords']) && trim($Powerpress['keywords']) != '' )
561
+ $ToSerialize['keywords'] = $Powerpress['keywords'];
562
+ // iTunes Author (FUTURE USE)
563
+ if( isset($Powerpress['author']) && trim($Powerpress['author']) != '' )
564
+ $ToSerialize['author'] = $Powerpress['author'];
565
+ // iTunes Explicit (FUTURE USE)
566
+ if( isset($Powerpress['explicit']) && trim($Powerpress['explicit']) != '' )
567
+ $ToSerialize['explicit'] = $Powerpress['explicit'];
568
+ // iTunes Block (FUTURE USE)
569
+ if( isset($Powerpress['block']) && (trim($Powerpress['block']) == 'yes' || trim($Powerpress['block']) == 'no') )
570
+ $ToSerialize['block'] = ($Powerpress['block']=='yes'?'yes':'');
571
+ // Player Embed (FUTURE USE)
572
+ if( isset($Powerpress['player_embed']) && trim($Powerpress['player_embed']) != '' )
573
+ $ToSerialize['player_embed'] = $Powerpress['player_embed'];
574
+ if( $Powerpress['set_duration'] == -1 )
575
+ unset($ToSerialize['duration']);
576
+ if( count($ToSerialize) > 0 ) // Lets add the serialized data
577
+ $EnclosureData .= "\n".serialize( $ToSerialize );
578
+
579
+ if( @$Powerpress['new_podcast'] )
580
+ {
581
+ add_post_meta($post_ID, $field, $EnclosureData, true);
582
+ }
583
+ else
584
+ {
585
+ update_post_meta($post_ID, $field, $EnclosureData);
586
+ if( $feed_slug == 'podcast' )
587
+ delete_post_meta( $post_ID, 'itunes:duration'); // Simple cleanup, we're storing the duration in the enclosure as serialized value
588
+ }
589
+ }
590
+
591
+ // If we're moving from draft to published, maybe we should ping iTunes?
592
+ if($_POST['prev_status'] == 'draft' && $_POST['publish'] == 'Publish' )
593
+ {
594
+ // Next double check we're looking at a podcast episode...
595
+ $Enclosure = get_post_meta($post_ID, $field, true);
596
+ if( $Enclosure )
597
+ {
598
+ $Settings = get_option('powerpress_feed_'.$feed_slug);
599
+ if( $Settings['ping_itunes'] && $Settings['itunes_url'] )
600
+ {
601
+ $PingResults = powerpress_ping_itunes($Settings['itunes_url']);
602
+ //mail( 'email@host.com', 'Ping iTunes Results', implode("\n", $PingResults) ); // Let me know how the ping went.
603
+ }
604
+ }
605
+ }
606
+ } // Loop through posted episodes...
607
+ }
608
 
609
+ // If we're moving from draft to published, maybe we should ping iTunes?
610
+ if($_POST['prev_status'] == 'draft' && $_POST['publish'] == 'Publish' )
611
+ {
612
+ // Next double check we're looking at a podcast episode...
613
+ $Enclosure = get_post_meta($post_ID, 'enclosure', true);
614
+ if( $Enclosure )
615
+ {
616
+ $Settings = get_option('powerpress_general');
617
+ if( $Settings['ping_itunes'] && $Settings['itunes_url'] )
618
+ {
619
+ $PingResults = powerpress_ping_itunes($Settings['itunes_url']);
620
+ //mail( 'email@host.com', 'Ping iTunes Results', implode("\n", $PingResults) ); // Let me know how the ping went.
621
+ }
622
+ }
623
+ }
624
+
625
+ // And we're done!
626
+ }
627
 
628
+ add_action('edit_post', 'powerpress_edit_post', 10, 2);
 
 
 
 
629
 
630
+ // Admin page, html meta header
631
+ function powerpress_admin_head()
632
+ {
633
+ if( strstr($_GET['page'], 'powerpress' ) )
634
+ {
635
  ?>
636
+ <script type="text/javascript">
637
+ function powerpress_show_field(id, show) {
638
+ if( document.getElementById(id).nodeName == "SPAN" )
639
+ document.getElementById(id).style.display = (show?"inline":"none");
640
+ else
641
+ document.getElementById(id).style.display = (show?"block":"none");
642
+ }
643
+ function powerpress_new_feed_url_prompt() {
644
+ var Msg = 'WARNING: Changes made here are permanent. If the New Feed URL entered is incorrect, you will lose subscribers and will no longer be able to update your listing in the iTunes Store.\n\nDO NOT MODIFY THIS SETTING UNLESS YOU ABSOLUTELY KNOW WHAT YOU ARE DOING.\n\nAre you sure you want to continue?';
645
+ if( confirm(Msg) ) {
646
+ powerpress_show_field('new_feed_url_step_1', false);
647
+ powerpress_show_field('new_feed_url_step_2', true);
648
+ }
649
+ return false;
650
+ }
651
+ function powerpress_changemode(Mode)
652
+ {
653
+ if( Mode )
654
+ {
655
+ if( !confirm("Are you sure you want to switch to Advanced Mode?\n\nAdvanced Mode provides:\n * Advanced Settings\n * Presentation Settings\n * Extensive Feed Settings \n * Custom Feeds \n * Useful Tools") )
656
+ return false;
657
+ }
658
+ else
659
+ {
660
+ if( !confirm("Are you sure you want to switch to Simple Mode?\n\nSimple Mode provides:\n * Only the bare essential settings\n * All settings on one page") )
661
+ return false;
662
+ }
663
+ document.getElementById('powerpress_advanced_mode').value = Mode;
664
+ document.forms[0].submit();
665
+ return false;
666
+ }
667
+ </script>
668
+ <style type="text/css">
669
+ .powerpress-notice {
670
+ margin-top: 10px;
671
+ margin-bottom: 10px;
672
+ line-height: 29px;
673
+ font-size: 12px;
674
+ border-width: 1px;
675
+ border-style: solid;
676
+ font-weight: bold;
677
+ }
678
+ .powerpress-error {
679
+ margin-top: 10px;
680
+ margin-bottom: 10px;
681
+ line-height: 29px;
682
+ font-size: 12px;
683
+ border-width: 1px;
684
+ border-style: solid;
685
+ font-weight: bold;
686
+ }
687
+ #powerpress_settings {
688
+ background-image:url(http://images.blubrry.com/powerpress/blubrry_logo.png);
689
+ background-repeat: no-repeat;
690
+ background-position: bottom right;
691
+ }
692
 
693
+ #powerpress_settings ul li ul {
694
+ list-style: disc;
695
+ }
696
+ #powerpress_settings ul li ul li {
697
+ margin-left: 50px;
698
+ font-size: 90%;
699
+ }
700
+ #powerpress_settings label {
701
+ font-size: 120%;
702
+ }
703
+ .bpp_input_sm {
704
+ width: 120px;
705
+ }
706
+ .bpp_input_med {
707
+ width: 250px;
708
+ }
709
+ </style>
710
  <?php
711
+ }
712
+ else
713
+ {
714
  ?>
715
+ <style type="text/css">
716
+ .powerpress_podcast_box {
 
 
 
 
 
 
 
 
 
717
 
718
+ }
719
+ .powerpress_podcast_box label {
720
+ width: 120px;
721
+ font-weight: bold;
722
+ font-size: 110%;
723
+ display: inline;
724
+ position: absolute;
725
+ top: 0;
726
+ left: 0;
727
+ }
728
+ .powerpress_podcast_box .powerpress_row {
729
+ margin-top: 10px;
730
+ margin-bottom: 10px;
731
+ position: relative;
732
+ }
733
+ .powerpress_podcast_box .powerpress_row_content {
734
+ margin-left: 120px;
735
+ }
736
+ .powerpress_podcast_box .error {
737
+ margin-top: 10px;
738
+ margin-bottom: 10px;
739
+ padding: 5px;
740
+ font-size: 12px;
741
+ text-align: center;
742
+ border-width: 1px;
743
+ border-style: solid;
744
+ font-weight: bold;
745
+ }
746
+ </style>
747
+ <script language="javascript">
748
+ function powerpress_check_url(url)
749
+ {
750
+ var DestDiv = 'powerpress_warning';
751
+ if( powerpress_check_url.arguments.length > 1 )
752
+ DestDiv = powerpress_check_url.arguments[1];
753
 
754
+ var validChars = ':0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-_.';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
755
 
756
+ for( var x = 0; x < url.length; x++ )
757
+ {
758
+ if( validChars.indexOf( url.charAt(x) ) == -1 )
 
 
 
 
 
759
  {
760
+ document.getElementById(DestDiv).innerHTML = 'Media URL contains characters that may cause problems for some clients. For maximum compatibility, only use letters, numbers, dash - and underscore _ characters only.';
761
+ document.getElementById(DestDiv).style.display = 'block';
762
+ return;
763
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
764
 
765
+ if( x == 5 )
766
+ validChars = validChars.substring(1); // remove the colon, should no longer appear in URLs
767
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
768
 
769
+ document.getElementById(DestDiv).style.display = 'none';
770
+ }
 
 
771
 
772
+ </script>
 
 
 
 
 
773
  <?php
774
+ }
775
+ }
 
776
 
777
+ add_action('admin_head', 'powerpress_admin_head');
 
778
 
779
+ // Admin page, header
780
+ function powerpress_admin_page_header($page=false, $nonce_field = 'powerpress-edit')
781
+ {
782
+ if( !$page )
783
+ $page = 'powerpress/powerpressadmin_basic.php';
784
  ?>
785
+ <div class="wrap" id="powerpress_settings">
786
+ <form enctype="multipart/form-data" method="post" action="<?php echo admin_url('admin.php?page='.$page) ?>">
 
 
 
 
 
 
 
 
787
  <?php
788
+ if( $nonce_field )
789
+ wp_nonce_field($nonce_field);
790
+
791
+ powerpress_page_message_print();
792
+ }
793
 
794
+ // Admin page, footer
795
+ function powerpress_admin_page_footer($SaveButton=true)
796
+ {
797
+ if( $SaveButton ) { ?>
798
+ <p class="submit">
799
+ <input type="submit" name="Submit" id="powerpress_save_button" class="button-primary" value="<?php _e('Save Changes' ) ?>" />
800
+ </p>
801
+ <?php } ?>
802
+ <p style="font-size: 85%; text-align: center; padding-bottom: 25px;">
803
+ <a href="http://www.blubrry.com/powerpress/" title="Blubrry PowerPress" target="_blank">Blubrry PowerPress</a> <?php echo POWERPRESS_VERSION; ?>
804
+ &#8212; <a href="http://help.blubrry.com/blubrry-powerpress/" target="_blank" title="Blubrry PowerPress Documentation">Documentation</a> | <a href="http://twitter.com/blubrry" target="_blank" title="Follow Blubrry on Twitter">Follow Blubrry on Twitter</a>
805
+ </p>
806
+ </form>
807
+ </div>
808
+ <?php
809
+ }
810
 
811
+ // Admin page, advanced mode: basic settings
812
+ function powerpress_admin_page_basic()
813
+ {
814
+ powerpress_admin_page_header();
815
+ require_once( dirname(__FILE__).'/powerpressadmin-basic.php');
816
+ powerpress_admin_basic();
817
+ powerpress_admin_page_footer(true, true);
818
+ }
819
 
820
+ // Admin page, advanced mode: appearance settings
821
+ function powerpress_admin_page_appearance()
822
+ {
823
+ powerpress_admin_page_header('powerpress/powerpressadmin_appearance.php');
824
+ require_once( dirname(__FILE__).'/powerpressadmin-appearance.php');
825
+ powerpressadmin_appearance();
826
+ powerpress_admin_page_footer();
827
+ }
828
 
829
+ // Admin page, advanced mode: feed settings
830
+ function powerpress_admin_page_feedsettings()
831
+ {
832
+ powerpress_admin_page_header('powerpress/powerpressadmin_feedsettings.php');
833
+ require_once( dirname(__FILE__).'/powerpressadmin-editfeed.php');
834
+ powerpress_admin_editfeed();
835
+ powerpress_admin_page_footer();
836
+ }
837
 
838
+ // Admin page, advanced mode: custom feeds
839
+ function powerpress_admin_page_customfeeds()
840
+ {
841
+ switch( @$_GET['action'] )
842
+ {
843
+ case 'powerpress-editfeed' : {
844
+ powerpress_admin_page_header('powerpress/powerpressadmin_customfeeds.php');
845
+ require_once( dirname(__FILE__).'/powerpressadmin-editfeed.php');
846
+ powerpress_admin_editfeed($_GET['feed_slug']);
847
+ powerpress_admin_page_footer();
848
+ }; break;
849
+ default: {
850
+ powerpress_admin_page_header('powerpress/powerpressadmin_customfeeds.php', 'powerpress-add-feed');
851
+ require_once( dirname(__FILE__).'/powerpressadmin-customfeeds.php');
852
+ powerpress_admin_customfeeds();
853
+ powerpress_admin_page_footer(false);
854
+ };
855
+ }
856
+ }
857
 
858
+ // Admin page, advanced mode: tools
859
+ function powerpress_admin_page_tools()
860
+ {
861
+ switch( @$_GET['action'] )
862
+ {
863
+ case 'powerpress-podpress-epiosdes' : {
864
+ powerpress_admin_page_header('powerpress/powerpressadmin_tools.php', 'powerpress-import-podpress');
865
+ require_once( dirname(__FILE__).'/powerpressadmin-podpress.php');
866
+ powerpress_admin_podpress();
867
+ powerpress_admin_page_footer(false);
868
+ }; break;
869
+ default: {
870
+ powerpress_admin_page_header('powerpress/powerpressadmin_tools.php');
871
+ require_once( dirname(__FILE__).'/powerpressadmin-tools.php');
872
+ powerpress_admin_tools();
873
+ powerpress_admin_page_footer(false);
874
+ };
875
+ }
876
+ }
877
 
878
+ function powerpress_podpress_episodes_exist()
879
+ {
880
+ global $wpdb;
881
+ $query = "SELECT post_id ";
882
+ $query .= "FROM {$wpdb->postmeta} ";
883
+ $query .= "WHERE meta_key = 'podPressMedia' ";
884
+ $query .= "LIMIT 0, 1";
885
+ $results = $wpdb->get_results($query, ARRAY_A);
886
+ if( count($results) )
887
+ return true;
888
+ return false;
889
+ }
890
 
891
+ // Admin page, simple mode
892
+ function powerpress_admin_page()
893
+ {
894
+ powerpress_admin_page_header();
 
 
 
 
895
 
896
+ require_once( dirname(__FILE__).'/powerpressadmin-basic.php');
897
+ powerpress_admin_basic();
 
 
 
 
 
 
898
 
899
+ require_once( dirname(__FILE__).'/powerpressadmin-editfeed.php');
900
+ powerpress_admin_editfeed();
 
 
 
 
 
 
901
 
902
+ powerpress_admin_page_footer(true, true);
903
+ }
904
+
905
+ function powerpress_shutdown()
906
+ {
907
+ global $wpdb;
908
+ $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE meta_key = '_encloseme' ");
909
+ }
 
 
 
 
 
 
 
 
910
 
911
+ add_action('shutdown','powerpress_shutdown'); // disable the auto enclosure process
912
+
913
+ /*
914
+ // Helper functions:
915
+ */
916
+ function powerpress_ping_itunes($iTunes_url)
917
+ {
918
+ if( strpos($iTunes_url, 'phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=' ) === false )
919
+ return array('error'=>true, 'content'=>'iTunes URL required to ping iTunes.');
920
+
921
+ // convert: https://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=
922
+ // to: https://phobos.apple.com/WebObjects/MZFinance.woa/wa/pingPodcast?id=
923
+ $ping_url = str_replace(
924
+ array( 'https://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=',
925
+ 'http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=',
926
+ 'https://www.itunes.com/podcast?id=',
927
+ 'http://www.itunes.com/podcast?id='),
928
+ 'https://phobos.apple.com/WebObjects/MZFinance.woa/wa/pingPodcast?id=', $iTunes_url);
929
+
930
+ $tempdata = wp_remote_fopen($ping_url);
931
+
932
+ if( $tempdata == false )
933
+ return array('error'=>true, 'content'=>'Unable to connect to iTunes ping server.');
934
+
935
+ if( stristr($tempdata, 'No Podcast Found') )
936
+ return array('error'=>true, 'content'=>'No Podcast Found from iTunes ping request');
937
+
938
+ // Parse the data into something readable
939
+ $results = trim( str_replace('Podcast Ping Received', '', strip_tags($tempdata) ) );
940
+ list($null, $FeedURL, $null, $null, $null, $PodcastID) = split("\n", $results );
941
+
942
+ return array('success'=>true, 'content'=>$tempdata, 'feed_url'=>trim($FeedURL), 'podcast_id'=>trim($PodcastID) );
943
+ }
944
 
945
+ // Import podpress settings
946
+ function powerpress_admin_import_podpress_settings()
947
+ {
948
+ // First pull in the Podpress settings
949
+ $PodpressData = get_option('podPress_config');
950
+ if( !$PodpressData )
951
+ return false;
952
+
953
+ $General = get_option('powerpress_general');
954
+ if( !$General)
955
+ $General = array();
956
+ $General['process_podpress'] = 1;
957
+ $General['display_player'] = 1;
958
+ $General['player_function'] = 1;
959
+ $General['podcast_link'] = 1;
960
+ $General['ping_itunes'] = 1;
961
+ // Lets try to copy settings from podpress
962
+ $General['default_url'] = $PodpressData['mediaWebPath'];
963
+ if( substr($General['default_url'], 0, -1) != '/' )
964
+ $General['default_url'] .= '/'; // Add the trailing slash, donno it's not there...
965
+
966
+ // Insert the blubrry redirect
967
+ if( isset($PodpressData['statBluBrryProgramKeyword']) && strlen($PodpressData['statBluBrryProgramKeyword']) > 2 )
968
+ {
969
+ $General['redirect1'] = 'http://media.blubrry.com/'.$PodpressData['statBluBrryProgramKeyword'].'/';
970
  }
971
 
972
+ // Insert the Podtrac redirect
973
+ if( $PodpressData['enable3rdPartyStats'] == 'PodTrac' )
974
  {
975
+ if( $General['redirect1'] )
976
+ $General['redirect2'] = 'http://www.podtrac.com/pts/redirect.mp3/';
977
+ else
978
+ $General['redirect1'] = 'http://www.podtrac.com/pts/redirect.mp3/';
979
  }
980
 
981
+ if( $PodpressData['contentDownload'] == 'enabled' )
982
+ $General['podcast_link'] = 1;
983
+ else
984
+ $General['podcast_link'] = 0;
985
 
986
+ if( $PodpressData['contentPlayer'] == 'both' )
987
+ $General['player_function'] = 1;
988
+ else if( $PodpressData['contentPlayer'] == 'inline' )
989
+ $General['player_function'] = 2;
990
+ else if( $PodpressData['contentPlayer'] == 'popup' )
991
+ $General['player_function'] = 3;
992
+ else
993
+ $General['player_function'] = 0;
 
 
 
 
 
 
 
 
 
 
994
 
995
+ if( $PodpressData['contentPlayer'] == 'start' )
996
+ $General['display_player'] = 2;
997
+ else
998
+ $General['display_player'] = 1;
999
+
1000
+ if( $PodpressData['iTunes']['FeedID'] )
1001
+ $General['itunes_url'] = 'http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id='. $PodpressData['iTunes']['FeedID'];
1002
+
1003
+ // save these imported general settings
1004
+ powerpress_save_settings($General, 'powerpress_general');
1005
+
1006
+ $FeedSettings = get_option('powerpress_feed');
1007
+
1008
+ if( !$FeedSettings ) // If no feed settings, lets set defaults or copy from podpress.
1009
+ $FeedSettings = array();
1010
 
1011
+ $FeedSettings['apply_to'] = 1; // Default, apply to all the rss2 feeds
1012
+
1013
+ $FeedSettings['itunes_image'] = $PodpressData['iTunes']['image'];
1014
+ if( strstr($FeedSettings['itunes_image'], 'powered_by_podpress') )
1015
+ $FeedSettings['itunes_image'] = ''; // We're not using podpress anymore
1016
+
1017
+ $FeedSettings['itunes_summary'] = $PodpressData['iTunes']['summary'];
1018
+ $FeedSettings['itunes_talent_name'] = $PodpressData['iTunes']['author'];
1019
+ $FeedSettings['itunes_subtitle'] = $PodpressData['iTunes']['subtitle'];
1020
+ $FeedSettings['itunes_keywords'] = $PodpressData['iTunes']['keywords'];
1021
+ $FeedSettings['copyright'] = $PodpressData['rss_copyright'];
1022
+ // Categories are tricky...
1023
+ $iTunesCategories = powerpress_itunes_categories(true);
1024
+ for( $x = 0; $x < 3; $x++ )
1025
+ {
1026
+ $CatDesc = str_replace(':', ' > ', $PodpressData['iTunes']['category'][$x]);
1027
+ $CatKey = array_search($CatDesc, $iTunesCategories);
1028
+ if( $CatKey )
1029
+ $FeedSettings['itunes_cat_'.($x+1)] = $CatKey;
1030
+ }
1031
+
1032
+ if( $PodpressData['iTunes']['explicit'] == 'No' )
1033
+ $FeedSettings['itunes_explicit'] = 0;
1034
+ else if( $PodpressData['iTunes']['explicit'] == 'Yes' )
1035
+ $FeedSettings['itunes_explicit'] = 1;
1036
+ else if( $PodpressData['iTunes']['explicit'] == 'Clean' )
1037
+ $FeedSettings['itunes_explicit'] = 2;
1038
+
1039
+ // Lastly, lets try to get the RSS image from the database
1040
+ $RSSImage = get_option('rss_image');
1041
+ if( $RSSImage )
1042
+ $FeedSettings['rss2_image'] = $RSSImage;
1043
+ if( strstr($FeedSettings['rss2_image'], 'powered_by_podpress') )
1044
+ $FeedSettings['rss2_image'] = ''; // We're not using podpress anymore
1045
+ $AdminEmail = get_option('admin_email');
1046
+ if( $AdminEmail )
1047
+ $FeedSettings['email'] = $AdminEmail;
1048
 
1049
+ // save these imported feed settings
1050
+ powerpress_save_settings($FeedSettings, 'powerpress_feed');
1051
+ return true;
1052
+ }
1053
+
1054
+ function powerpress_admin_episodes_per_feed($feed_slug)
1055
+ {
1056
+ $field = 'enclosure';
1057
+ if( $feed_slug != 'podcast' )
1058
+ $field = '_'. $feed_slug .':enclosure';
1059
+ global $wpdb;
1060
+ if ( $results = $wpdb->get_results("SELECT COUNT(post_id) AS episodes_total FROM $wpdb->postmeta WHERE meta_key = '$field'", ARRAY_A) ) {
1061
+ if( count($results) )
1062
+ {
1063
+ list($key,$row) = each($results);
1064
+ if( $row['episodes_total'] )
1065
+ return $row['episodes_total'];
1066
+ }
1067
  }
1068
+ return 0;
1069
+ }
1070
  ?>
readme.txt CHANGED
@@ -1,28 +1,37 @@
1
- === Blubrry Powerpress Podcasting plugin ===
2
  Contributors: Angelo Mandato, Blubrry.com
3
  Tags: podcast, podcasting, itunes, enclosure, zune, iphone, audio, video, rss2, feed, player, media, rss
4
  Requires at least: 2.5.0
5
  Tested up to: 2.7.1
6
- Stable tag: 0.6.5
7
 
8
  Add podcasting support to your blog.
9
 
10
  == Description ==
11
- The Blubrry Powerpress Podcast Plugin has all of the essential features needed to provide podcasting support in a Wordpress blog.
12
 
13
- The Blubrry Powerpress interface allows you to easily add/modify/remove podcast episodes from blog posts and includes a simple on-line media player, iTunes compatibile RSS feed tags, ability to upload cover art images, ping iTunes, detect media size, detect time duration (mp3's only) and add 3rd party media statistics.
14
 
15
  Features:
16
 
17
  * Easily add/modify/remove podcast episodes from blog posts and pages
18
- * Integrated media player
 
 
19
  * iTunes RSS tags
 
20
  * iTunes album/cover art
21
  * Upload new iTunes/RSS cover art
22
  * Ping iTunes
23
  * Media size detection
24
  * Duration detection (mp3 only)
25
  * 3rd party statistics integration
 
 
 
 
 
 
26
 
27
  For the latest information visit the website.
28
 
@@ -34,29 +43,29 @@ http://help.blubrry.com/blubrry-powerpress/
34
 
35
  == Frequently Asked Questions ==
36
 
37
- = Why doesn't Blubrry Powerpress support multiple enclosures? =
38
- Blubrry Powerpress does not support multiple enclosures in one blog post. This is because each podcatching application handles multiple enclosures differently. iTunes will download the first enclosure that it sees in the feed ignoring the rest. Other podcatchers and podcasting directories either pick up the first enclosure or the last in each post item. This inconsistency combined with the fact that [Dave Winer does not recommend multiple enclosures](http://www.reallysimplesyndication.com/2004/12/21) and the [FeedValidator.org recommendation against it](http://www.feedvalidator.org/docs/warning/DuplicateEnclosure.html) is why the Blubrry Powerpress does not support them.
39
 
40
- = Why doesn't Blubrry Powerpress include media statistics? =
41
- Blubrry Powerpress does not include media statistics. This is not because Blubrry has its own statistics service, although that's a good reason by itself. Maintaining and calculating statistics is a resource and server intensive task that would add bloat to an otherwise lightweight Wordpress podcasting plugin. We recommend you use your media hosting's statistics and you're more than welcome to use the [Blubrry Statistics service](http://www.blubrry.com/podcast_statistics/) as well.
42
 
43
  = Looking for a better Audio Player? =
44
  Check out the <a href="http://wpaudioplayer.com" target="_blank" title="WP Audio Player 2.0">WP Audio Player 2.0</a>. The WP Audio Player 2.0 options include theme colors, initial volume, player width and more.
45
 
46
  == Installation ==
47
  1. Copy the entire directory from the downloaded zip file into the /wp-content/plugins/ folder.
48
- 2. Activate the "Blubrry Powerpress" plugin in the Plugin Management page.
49
- 3. Configure your Blubrry Powerpress by going to the **Settings** > **Blubrry Powerpress** page.
50
 
51
  == Screenshots ==
52
  1. Add podcast episode, found within the edit post screen
53
- 2. Cross section of Blubrry Powerpress settings page (Feed settings).
54
- 3. Cross section of Blubrry Powerpress settings page (Basic settings).
55
 
56
  == Changelog ==
57
 
58
  0.2 released on 08/11/2008
59
- Initial release of Blubrry Powerpress
60
 
61
  0.2.1 released on 09/17/2008
62
  Fixed bugs: itunes:subtitle bug, itunes:summary is now enabled by default, add ending trailing slash to media url if missing, and copy blubrry keyword from podpress fix.
@@ -106,6 +115,13 @@ Fixed bug where post_password_required() function does not exist, bug only affec
106
  0.6.5 released on 02/20/2009
107
  Fixed warning from being printed when v0.6.3/v0.6.4 used with PHP4. Bug only affected users using PHP4.
108
 
 
 
 
 
 
 
 
109
  == Contributors ==
110
  Angelo Mandato, CIO [RawVoice](http://www.rawvoice.com) - Plugin founder, architect and lead developer
111
 
1
+ === Blubrry PowerPress Podcasting plugin ===
2
  Contributors: Angelo Mandato, Blubrry.com
3
  Tags: podcast, podcasting, itunes, enclosure, zune, iphone, audio, video, rss2, feed, player, media, rss
4
  Requires at least: 2.5.0
5
  Tested up to: 2.7.1
6
+ Stable tag: 0.7.1
7
 
8
  Add podcasting support to your blog.
9
 
10
  == Description ==
11
+ The Blubrry PowerPress Podcast Plugin has all of the essential features needed to provide podcasting support in a Wordpress blog.
12
 
13
+ The Blubrry PowerPress interface allows you to easily add/modify/remove podcast episodes from blog posts and includes a simple on-line media player, iTunes compatibile RSS feed tags, ability to upload cover art images, ping iTunes, detect media size, detect time duration (mp3's only) and add 3rd party media statistics.
14
 
15
  Features:
16
 
17
  * Easily add/modify/remove podcast episodes from blog posts and pages
18
+ * Integrated audio/video media player
19
+ * Podcast Only Feed
20
+ * Custom Podcast Feeds (no limit)
21
  * iTunes RSS tags
22
+ * Enhanced iTunes summaries from blog posts option
23
  * iTunes album/cover art
24
  * Upload new iTunes/RSS cover art
25
  * Ping iTunes
26
  * Media size detection
27
  * Duration detection (mp3 only)
28
  * 3rd party statistics integration
29
+ * Import PodPress settings and media episodes
30
+ * Category Podcast Feeds (Category Casting)
31
+ * Tag/Keyword Podcast Feeds (Tag Casting)
32
+ * Hosted Feed Support (FeedBurner.com)
33
+ * User Role Management (Control which users on blog can Podcast)
34
+
35
 
36
  For the latest information visit the website.
37
 
43
 
44
  == Frequently Asked Questions ==
45
 
46
+ = Why doesn't Blubrry PowerPress support multiple enclosures? =
47
+ Blubrry PowerPress does not support multiple enclosures in one blog post. This is because each podcatching application handles multiple enclosures differently. iTunes will download the first enclosure that it sees in the feed ignoring the rest. Other podcatchers and podcasting directories either pick up the first enclosure or the last in each post item. This inconsistency combined with the fact that [Dave Winer does not recommend multiple enclosures](http://www.reallysimplesyndication.com/2004/12/21) and the [FeedValidator.org recommendation against it](http://www.feedvalidator.org/docs/warning/DuplicateEnclosure.html) is why the Blubrry PowerPress does not support them.
48
 
49
+ = Why doesn't Blubrry PowerPress include media statistics? =
50
+ Blubrry PowerPress does not include media statistics. This is not because Blubrry has its own statistics service, although that's a good reason by itself. Maintaining and calculating statistics is a resource and server intensive task that would add bloat to an otherwise lightweight Wordpress podcasting plugin. We recommend you use your media hosting's statistics and you're more than welcome to use the [Blubrry Statistics service](http://www.blubrry.com/podcast_statistics/) as well.
51
 
52
  = Looking for a better Audio Player? =
53
  Check out the <a href="http://wpaudioplayer.com" target="_blank" title="WP Audio Player 2.0">WP Audio Player 2.0</a>. The WP Audio Player 2.0 options include theme colors, initial volume, player width and more.
54
 
55
  == Installation ==
56
  1. Copy the entire directory from the downloaded zip file into the /wp-content/plugins/ folder.
57
+ 2. Activate the "Blubrry PowerPress" plugin in the Plugin Management page.
58
+ 3. Configure your Blubrry PowerPress by going to the **Settings** > **Blubrry PowerPress** page.
59
 
60
  == Screenshots ==
61
  1. Add podcast episode, found within the edit post screen
62
+ 2. Cross section of Blubrry PowerPress settings page (Feed settings).
63
+ 3. Cross section of Blubrry PowerPress settings page (Basic settings).
64
 
65
  == Changelog ==
66
 
67
  0.2 released on 08/11/2008
68
+ Initial release of Blubrry PowerPress
69
 
70
  0.2.1 released on 09/17/2008
71
  Fixed bugs: itunes:subtitle bug, itunes:summary is now enabled by default, add ending trailing slash to media url if missing, and copy blubrry keyword from podpress fix.
115
  0.6.5 released on 02/20/2009
116
  Fixed warning from being printed when v0.6.3/v0.6.4 used with PHP4. Bug only affected users using PHP4.
117
 
118
+ 0.7.0 released on 03/10/2009
119
+ Beta release only intended for a handfull of beta testers. For full list of changes, please refer to version 0.7.1
120
+
121
+ 0.7.1 released on 03/11/2009
122
+ Bugs: Improved flash player loading on pages with multiple podcast episodes, Detecting file size when specifying duration bug fixed. Fixed bug where duration would sometimes save minutes over 60 rather than rolling over one hour.
123
+ Features: Added new Simple and Advanced Modes. Advance mode adds 5 new pages (Basic, Appearance, Feed Settings, Custom Feeds and Tools). New Edit Post settings section added which allows user to toggle between a simple and normal edit episode boxes. The simple mode displays only the Media URL field. Users can now set the width of the audio player as well as the width and height of the video player. New language added to the Feed Settings page to better explain the apply settings to setting which is now renamed "Enhance Feeds" setting. Added new Enhance iTunes Summary from Blog Posts option, which intelligently takes web links and links to images in your regular blog post into a readable and clickable format for the iTunes summary. Custom feeds including the default podcast feed include additional options such as setting the number of most recent posts in the feed, customizing the feed title, description and landing web link, as well as full support for redirecting feed to a hosted feed service such as FeedBurner.com. The new Custom Feeds section allows user to create an endless number of podcast specific feeds either for separating long and sort formats and/or media types such as ogg, wma and mp3. New Tools section allows users to re-import PodPress settings (typically imported automatically upon first install), Import PodPress episodes with a detailed table of media files with options to specify which media files go to which feeds. Tools page also includes an option to add Edit Podcast Capability for User Role Management. Added Nonces support to all edit and delete transactions to admin pages. Added simple mode for podcast episode boxes in the edit post screen.
124
+
125
  == Contributors ==
126
  Angelo Mandato, CIO [RawVoice](http://www.rawvoice.com) - Plugin founder, architect and lead developer
127