PowerPress Podcasting plugin by Blubrry - Version 0.9.6

Version Description

  • Released on 8/31/2009
  • Added Auto Add Media option, auto adds first/last media link found in post content. (default is off)
  • Added option in Appearance settings to disable player per custom podcast feed basis.
  • Added option to Episode Entry Box Custom Mode to select iTunes Explicit setting on a per episode basis.
  • Added note when in simple mode if there are advanced mode settings that take precedence.
  • Fixed bug with language setting not getting applied to the default PowerPress custom podcast feed in some cases.
  • Fixed a bug in the getid3 library where it would occasionally not detect the media duration.
  • Detecting mp3 duration change, increased the amount of the file downloaded from 25k to 40k for users who have a lot of tags in their mp3 files.
  • Consolidated duplicate code for detecting media information.
  • Display error message when PowerPress cannot detect media file content type.
  • Display error message when PowerPress cannot detect media file size and duration information.
  • Display error message when PowerPress encounters an error with Blubrry Services.
  • Stream lined code for loading PowerPress general and feed settings.
  • Added more agressive code to prevent WordPress from deleting enclosures when scheduling blog posts.
  • Improved the look of the AJAX windows for selecting media/configuring services.
  • Fixed bug where 'more' link for statistics would fail if user was not a blog admin.
  • Added code to admin_head() function so css/js only included on appropriate pages (Thanks @Frumph!).
  • Made Default Podcast Episode first media player listed when displaying multiple players on page.
  • Blubrry Media Hosting list of uploaded media screen enhanced with new in-page media upload option and monthly quota information.
  • Fixed bug with Podcast Category feed links to FeedValidator (thanks Darcy Fiander).
  • Fixed bug with Podcast Category feed title not matching the feed image title FeedValidator (thanks Darcy Fiander).
  • Fixed Windows Media embed issue with Firefox 3.x+ and re-added note to use the Firefox Windows Media addon.
Download this release

Release Info

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

Code changes from version 0.9.5 to 0.9.6

css/jquery.css CHANGED
@@ -1,9 +1,6 @@
1
  /* jquery.css */
2
- body {
3
- font-family: Arial, Helvetica, sans-serif;
4
 
5
- /* background-color: #D2E9FF; */
6
- }
7
  img {
8
  border: 0;
9
  }
@@ -37,6 +34,11 @@ input[type="submit"] {
37
  padding-left: 8px;
38
  }
39
 
 
 
 
 
 
40
  ul.media {
41
 
42
  }
@@ -46,7 +48,9 @@ ul.media li {
46
  ul.media li a {
47
  font-weight: bold;
48
  }
49
-
 
 
50
  #accountinfo {
51
 
52
  }
@@ -77,21 +81,23 @@ ul.media li a {
77
  }
78
 
79
  #media-items-container {
80
- margin: 10px;
81
  }
82
  #media-items {
83
  border-bottom-color: #dfdfdf;
84
  border-bottom-width: 1px;
85
  border-bottom-style: solid;
86
- min-height: 36px;
87
  width: 100%;
 
 
88
  }
89
  .media-item {
90
 
91
  border-top-color: #dfdfdf;
92
  border-top-width: 1px;
93
  border-top-style: solid;
94
- min-height: 36px;
95
  width: 100%;
96
 
97
  border-left-color: #dfdfdf;
@@ -102,7 +108,7 @@ ul.media li a {
102
  border-right-style: solid;
103
  position: relative;
104
 
105
- padding-top: 15px;
106
 
107
  }
108
  .media-item .media-name {
@@ -110,7 +116,25 @@ ul.media li a {
110
  }
111
  .media-item-links {
112
  position: absolute;
113
- top: 15px;
114
  right: 10px;
115
  text-align: right;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
1
  /* jquery.css */
 
 
2
 
3
+
 
4
  img {
5
  border: 0;
6
  }
34
  padding-left: 8px;
35
  }
36
 
37
+ /* Fix what WordPress breaks for Thickbox: */
38
+ html,
39
+ body {
40
+ height: auto;
41
+ }
42
  ul.media {
43
 
44
  }
48
  ul.media li a {
49
  font-weight: bold;
50
  }
51
+ #container {
52
+ margin: 0px 15px;
53
+ }
54
  #accountinfo {
55
 
56
  }
81
  }
82
 
83
  #media-items-container {
84
+ margin: 0;
85
  }
86
  #media-items {
87
  border-bottom-color: #dfdfdf;
88
  border-bottom-width: 1px;
89
  border-bottom-style: solid;
90
+ min-height: 26px;
91
  width: 100%;
92
+ padding-top: 0px;
93
+ margin-top: 0px;
94
  }
95
  .media-item {
96
 
97
  border-top-color: #dfdfdf;
98
  border-top-width: 1px;
99
  border-top-style: solid;
100
+ min-height: 26px;
101
  width: 100%;
102
 
103
  border-left-color: #dfdfdf;
108
  border-right-style: solid;
109
  position: relative;
110
 
111
+ padding-top: 5px;
112
 
113
  }
114
  .media-item .media-name {
116
  }
117
  .media-item-links {
118
  position: absolute;
119
+ top: 5px;
120
  right: 10px;
121
  text-align: right;
122
+ }
123
+ #media-header {
124
+ position: relative;
125
+ margin: 0 0 5px 0;
126
+ }
127
+ #media-footer {
128
+ position: relative;
129
+ margin: 5px 0 0 0;
130
+ height: 12px;
131
+ }
132
+ #media-header p, #media-footer p {
133
+ margin: 8px 0;
134
+ }
135
+ .media-upload-link {
136
+ position: absolute;
137
+ bottom: 0;
138
+ right: 0;
139
+ margin: 0;
140
  }
getid3/getid3.php CHANGED
@@ -151,7 +151,7 @@ class getID3
151
 
152
 
153
  // public: analyze file - replaces GetAllFileInfo() and GetTagOnly()
154
- function analyze($filename, $filesize=false) {
155
 
156
  if (!empty($this->startup_error)) {
157
  return $this->error($this->startup_error);
@@ -293,7 +293,7 @@ class getID3
293
  $formattest = fread($fp, 32774);
294
 
295
  // determine format
296
- $determined_format = $this->GetFileFormat($formattest, $filename);
297
 
298
  // unable to determine file format
299
  if (!$determined_format) {
151
 
152
 
153
  // public: analyze file - replaces GetAllFileInfo() and GetTagOnly()
154
+ function analyze($filename, $filesize=false, $orig_filename='file.mp3') {
155
 
156
  if (!empty($this->startup_error)) {
157
  return $this->error($this->startup_error);
293
  $formattest = fread($fp, 32774);
294
 
295
  // determine format
296
+ $determined_format = $this->GetFileFormat($formattest, $orig_filename);
297
 
298
  // unable to determine file format
299
  if (!$determined_format) {
mp3info.class.php CHANGED
@@ -7,7 +7,8 @@
7
 
8
  class Mp3Info {
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 = '';
@@ -87,7 +88,7 @@
87
  return false;
88
  }
89
 
90
- if( ini_get( 'curl_init' ) )
91
  return $this->DownloadCurl($url);
92
 
93
  // The following code relies on fopen_url capability.
@@ -122,6 +123,7 @@
122
  $RedirectURL = false;
123
  $ContentLength = false;
124
  $ContentType = false;
 
125
  // Loop through the headers
126
  while( !feof($fp) )
127
  {
@@ -137,7 +139,16 @@
137
  $key = trim($key);
138
  $value = trim($value);
139
 
140
- if( stristr($line, '301 Moved Permanently') || stristr($line, '302 Found') || stristr($line, '307 Temporary Redirect') )
 
 
 
 
 
 
 
 
 
141
  {
142
  $Redirect = true; // We are dealing with a redirect, lets handle it
143
  }
@@ -214,6 +225,7 @@
214
  curl_setopt($curl, CURLOPT_HEADER, true); // header will be at output
215
  curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'HEAD'); // HTTP request
216
  curl_setopt($curl, CURLOPT_NOBODY, true );
 
217
  if ( !ini_get('safe_mode') && !ini_get('open_basedir') )
218
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
219
  curl_setopt($curl, CURLOPT_MAXREDIRS, $this->m_RedirectLimit);
@@ -221,8 +233,10 @@
221
 
222
  $ContentLength = curl_getinfo($curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
223
  $HttpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
 
 
224
 
225
- if( $HttpCode != 200 )
226
  {
227
  switch( $HttpCode )
228
  {
@@ -232,12 +246,18 @@
232
  $this->SetError( 'Download exceeded redirect limit of '.$this->m_RedirectLimit .'.' );
233
  }; break;
234
  default: {
235
- $this->SetError( 'HTTP error '. $HttpCode .'.' );
236
  }; break;
237
  }
238
  return false;
239
  }
240
 
 
 
 
 
 
 
241
  global $TempFile;
242
  if( function_exists('get_temp_dir') ) // If wordpress function is available, lets use it
243
  $TempFile = tempnam(get_temp_dir(), 'wp_powerpress');
@@ -262,7 +282,7 @@
262
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
263
  curl_setopt($curl, CURLOPT_MAXREDIRS, $this->m_RedirectLimit);
264
  curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
265
- curl_setopt($curl, CURLOPT_HTTPHEADER,array('Range: bytes=0-'.($this->m_DownloadBytesLimit-1) ));
266
  //curl_setopt($curl, CURLINFO_HEADER_OUT, true); // For debugging
267
  // Do the download
268
  $success = curl_exec($curl);
@@ -346,9 +366,9 @@
346
 
347
  /*
348
  // Example usage:
349
-
350
  $Mp3Info = new Mp3Info();
351
- if( $Data = $Mp3Info->GetMp3Info('http://www.podcampohio.com/podpress_trac/web/177/0/TS-107667.mp3') )
 
352
  {
353
  echo 'Success: ';
354
  echo print_r( $Data );
@@ -364,5 +384,4 @@
364
  }
365
  */
366
 
367
-
368
  ?>
7
 
8
  class Mp3Info {
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_DownloadBytesLimit = 327680; // 40K (40*1024*8) bytes file
12
  var $m_RedirectLimit = 5; // Number of times to do the 302 redirect
13
  var $m_UserAgent = 'Blubrry PowerPress/1.0';
14
  var $m_error = '';
88
  return false;
89
  }
90
 
91
+ if( function_exists( 'curl_init' ) )
92
  return $this->DownloadCurl($url);
93
 
94
  // The following code relies on fopen_url capability.
123
  $RedirectURL = false;
124
  $ContentLength = false;
125
  $ContentType = false;
126
+ $ReturnCode = 0;
127
  // Loop through the headers
128
  while( !feof($fp) )
129
  {
139
  $key = trim($key);
140
  $value = trim($value);
141
 
142
+ if( preg_match('/^HTTPS?\/\d\.\d (\d{3})(.*)/i', $line, $matches) )
143
+ {
144
+ $ReturnCode = $matches[1];
145
+ if( $ReturnCode < 200 || $ReturnCode > 250 )
146
+ {
147
+ $this->SetError('HTTP '.$ReturnCode.$matches[2]);
148
+ return false;
149
+ }
150
+ }
151
+ else if( stristr($line, '301 Moved Permanently') || stristr($line, '302 Found') || stristr($line, '307 Temporary Redirect') )
152
  {
153
  $Redirect = true; // We are dealing with a redirect, lets handle it
154
  }
225
  curl_setopt($curl, CURLOPT_HEADER, true); // header will be at output
226
  curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'HEAD'); // HTTP request
227
  curl_setopt($curl, CURLOPT_NOBODY, true );
228
+ curl_setopt($curl, CURLOPT_FAILONERROR, true);
229
  if ( !ini_get('safe_mode') && !ini_get('open_basedir') )
230
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
231
  curl_setopt($curl, CURLOPT_MAXREDIRS, $this->m_RedirectLimit);
233
 
234
  $ContentLength = curl_getinfo($curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
235
  $HttpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
236
+ $ContentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE);
237
+ $ErrorMsg = curl_error($curl);
238
 
239
+ if( $HttpCode < 200 || $HttpCode > 250 )
240
  {
241
  switch( $HttpCode )
242
  {
246
  $this->SetError( 'Download exceeded redirect limit of '.$this->m_RedirectLimit .'.' );
247
  }; break;
248
  default: {
249
+ $this->SetError( curl_error($curl) );
250
  }; break;
251
  }
252
  return false;
253
  }
254
 
255
+ if( stristr($ContentType, 'text') )
256
+ {
257
+ $this->SetError( 'Invalid content type returned.' );
258
+ return false;
259
+ }
260
+
261
  global $TempFile;
262
  if( function_exists('get_temp_dir') ) // If wordpress function is available, lets use it
263
  $TempFile = tempnam(get_temp_dir(), 'wp_powerpress');
282
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
283
  curl_setopt($curl, CURLOPT_MAXREDIRS, $this->m_RedirectLimit);
284
  curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
285
+ curl_setopt($curl, CURLOPT_HTTPHEADER,array('Range: bytes=0-'.($this->m_DownloadBytesLimit - 1) ));
286
  //curl_setopt($curl, CURLINFO_HEADER_OUT, true); // For debugging
287
  // Do the download
288
  $success = curl_exec($curl);
366
 
367
  /*
368
  // Example usage:
 
369
  $Mp3Info = new Mp3Info();
370
+ $file = 'http://www.podcampohio.com/podpress_trac/web/177/0/TS-107667.mp3';
371
+ if( $Data = $Mp3Info->GetMp3Info($file) )
372
  {
373
  echo 'Success: ';
374
  echo print_r( $Data );
384
  }
385
  */
386
 
 
387
  ?>
powerpress.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Blubrry PowerPress
4
  Plugin URI: http://www.blubrry.com/powerpress/
5
  Description: <a href="http://www.blubrry.com/powerpress/" target="_blank">Blubrry PowerPress</a> adds podcasting support to your blog. Features include: media player, 3rd party statistics, iTunes integration, Blubrry Services (Media Statistics and Hosting) integration and a lot more.
6
- Version: 0.9.5
7
  Author: Blubrry
8
  Author URI: http://www.blubrry.com/
9
  Change Log:
@@ -29,7 +29,7 @@ License: GPL (http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt)
29
  */
30
 
31
  // WP_PLUGIN_DIR (REMEMBER TO USE THIS DEFINE IF NEEDED)
32
- define('POWERPRESS_VERSION', '0.9.5' );
33
 
34
  /////////////////////////////////////////////////////
35
  // The following define options should be placed in your
@@ -100,9 +100,11 @@ function powerpress_content($content)
100
 
101
  // PowerPress settings:
102
  $GeneralSettings = get_option('powerpress_general');
103
- // Lets set some default settings, if not already set...
104
- if( !isset($GeneralSettings['custom_feeds']['podcast']) )
105
- $GeneralSettings['custom_feeds']['podcast'] = 'Podcast Feed'; // Fixes scenario where the user never configured the custom default podcast feed.
 
 
106
  if( !isset($GeneralSettings['display_player']) )
107
  $GeneralSettings['display_player'] = 1;
108
  if( !isset($GeneralSettings['player_function']) )
@@ -119,6 +121,9 @@ function powerpress_content($content)
119
 
120
  // Figure out which players are alerady in the body of the page...
121
  $ExcludePlayers = array();
 
 
 
122
  if( preg_match_all('/(.?)\[(powerpress)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)/s', $content, $matches) )
123
  {
124
  if( isset($matches[3]) )
@@ -254,7 +259,7 @@ function powerpress_content($content)
254
  $player_links .= "<a href=\"$EnclosureURL\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a> (".powerpress_byte_size($EnclosureSize).")".PHP_EOL;
255
  }
256
 
257
- if( $player_links )
258
  {
259
  if( count($GeneralSettings['custom_feeds']) > 1 && $feed_slug != 'podcast' )
260
  {
@@ -437,7 +442,10 @@ function powerpress_rss2_head()
437
  if( $Feed['rss2_image'] )
438
  {
439
  echo"\t". '<image>' .PHP_EOL;
440
- echo "\t\t".'<title>' . wp_specialchars( get_bloginfo_rss('name') . get_wp_title_rss() ) . '</title>'.PHP_EOL;
 
 
 
441
  echo "\t\t".'<url>' . wp_specialchars($Feed['rss2_image']) . '</url>'.PHP_EOL;
442
  echo "\t\t".'<link>'. $Feed['url'] . '</link>' . PHP_EOL;
443
  echo "\t".'</image>' . PHP_EOL;
@@ -445,7 +453,10 @@ function powerpress_rss2_head()
445
  else // Use the default image
446
  {
447
  echo"\t". '<image>' .PHP_EOL;
448
- echo "\t\t".'<title>' . wp_specialchars( get_bloginfo_rss('name') . get_wp_title_rss() ) . '</title>'.PHP_EOL;
 
 
 
449
  echo "\t\t".'<url>' . powerpress_get_root_url() . 'rss_default.jpg</url>'.PHP_EOL;
450
  echo "\t\t".'<link>'. $Feed['url'] . '</link>' . PHP_EOL;
451
  echo "\t".'</image>' . PHP_EOL;
@@ -650,11 +661,15 @@ function powerpress_rss2_item()
650
  $subtitle = $EpisodeData['subtitle'];
651
  if( isset( $EpisodeData['keywords'] ) )
652
  $keywords = $EpisodeData['keywords'];
 
 
 
 
 
 
653
  // Code for future use:
654
  if( isset( $EpisodeData['author'] ) )
655
  $author = $EpisodeData['author'];
656
- if( isset( $EpisodeData['explicit'] ) )
657
- $explicit = $EpisodeData['explicit'];
658
  if( isset( $EpisodeData['block'] ) )
659
  $block = $EpisodeData['block'];
660
  }
@@ -845,18 +860,10 @@ function powerpress_rss_language($value)
845
  {
846
  if( powerpress_is_custom_podcast_feed() )
847
  {
848
- $feed_slug = get_query_var('feed');
849
- $cat_ID = get_query_var('cat');
850
-
851
- if( $cat_ID )
852
- $Feed = get_option('powerpress_cat_feed_'. $cat_ID);
853
- else if( $feed_slug == 'podcast' )
854
- $Feed = get_option('powerpress_feed');
855
- else
856
- $Feed = get_option('powerpress_feed_'. $feed_slug);
857
-
858
- if( $Feed && isset($Feed['rss_language']) && $Feed['rss_language'] != '' )
859
- $value = $Feed['rss_language'];
860
  }
861
  return $value;
862
  }
@@ -938,8 +945,10 @@ add_action('init', 'powerpress_init', 9);
938
  // Load the general feed settings for feeds handled by powerpress
939
  function powerpress_load_general_feed_settings()
940
  {
 
941
  global $powerpress_feed;
942
- if( $powerpress_feed !== false )
 
943
  {
944
  $powerpress_feed = false;
945
 
@@ -950,21 +959,24 @@ function powerpress_load_general_feed_settings()
950
 
951
  if( $GeneralSettings )
952
  {
 
 
 
953
  if( is_category() && is_array($GeneralSettings['custom_cat_feeds']) && in_array( get_query_var('cat'), $GeneralSettings['custom_cat_feeds']) )
954
  {
955
  $cat_ID = get_query_var('cat');
956
- $Feed = get_option('powerpress_feed'); // Get overall feed settings
957
  $FeedCustom = get_option('powerpress_cat_feed_'.$cat_ID); // Get custom feed specific settings
958
- $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $Feed);
959
 
960
  $powerpress_feed = array();
961
  $powerpress_feed['is_custom'] = true;
962
  $powerpress_feed['itunes_custom'] = ($GeneralSettings['episode_box_mode'] == 2);
963
  $powerpress_feed['category'] = $cat_ID;
964
- $powerpress_feed['process_podpress'] = true; // Category feeds could originate from Podpress
 
965
  $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/';
966
- $explicit = array("no", "yes", "clean");
967
- $powerpress_feed['explicit'] = $explicit[$Feed['itunes_explicit']];
968
  if( $Feed['itunes_talent_name'] )
969
  $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
970
  else
@@ -975,6 +987,8 @@ function powerpress_load_general_feed_settings()
975
  $powerpress_feed['feed_redirect_url'] = $Feed['feed_redirect_url'];
976
  if( $Feed['itunes_author_post'] == true )
977
  $powerpress_feed['itunes_author_post'] = true;
 
 
978
  return;
979
  }
980
 
@@ -982,15 +996,15 @@ function powerpress_load_general_feed_settings()
982
 
983
  if( isset($GeneralSettings['custom_feeds']) && is_array($GeneralSettings['custom_feeds']) && isset($GeneralSettings['custom_feeds'][ $feed_slug ] ))
984
  {
985
- $Feed = get_option('powerpress_feed'); // Get overall feed settings
986
  $FeedCustom = get_option('powerpress_feed_'.$feed_slug); // Get custom feed specific settings
987
- $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $Feed);
988
 
989
  $powerpress_feed = array();
990
  $powerpress_feed['is_custom'] = true;
991
  $powerpress_feed['itunes_custom'] = ($GeneralSettings['episode_box_mode'] == 2);
992
  $powerpress_feed['feed-slug'] = $feed_slug;
993
- $powerpress_feed['process_podpress'] = false; // We don't touch podpress data for custom feeds
 
994
  $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/';
995
  $explicit = array("no", "yes", "clean");
996
  $powerpress_feed['explicit'] = $explicit[$Feed['itunes_explicit']];
@@ -1005,53 +1019,55 @@ function powerpress_load_general_feed_settings()
1005
  $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
1006
  if( $Feed['feed_redirect_url'] != '' )
1007
  $powerpress_feed['feed_redirect_url'] = $Feed['feed_redirect_url'];
 
 
 
1008
  }
1009
- else
 
 
1010
  {
1011
- // One last check, we may still want to manage this feed, it's just not a custom feed...
1012
- $Feed = get_option('powerpress_feed');
1013
- $wp = $GLOBALS['wp_query'];
1014
- // First, determine if powerpress should even be rewriting this feed...
1015
- switch( $Feed['apply_to'] )
1016
  {
1017
- case 2: // RSS2 feed only
1018
- {
1019
- if( $feed_slug != 'feed' && $feed_slug != 'rss2')
1020
- break; // We're only adding podcasts to the rss2 feed in this situation
1021
-
1022
- if( $wp->query_vars['category_name'] != '' ) // don't touch the category feeds...
1023
- break;
1024
-
1025
- if( $wp->query_vars['tag'] != '' ) // don't touch the tag feeds...
1026
- break;
1027
-
1028
- if( $wp->query_vars['withcomments'] ) // don't touch the comments feeds...
1029
- break;
1030
 
1031
- // Okay we must be working with the normal rss2 feed...
1032
- } // important: no break here!
1033
- case 1: // All other feeds
1034
- {
1035
- $powerpress_feed = array(); // Only store what's needed for each feed item
1036
- $powerpress_feed['is_custom'] = false; // ($feed_slug == 'podcast'?true:false);
1037
- $powerpress_feed['itunes_custom'] = ($GeneralSettings['episode_box_mode'] == 2);
1038
- $powerpress_feed['feed-slug'] = $feed_slug;
1039
- $powerpress_feed['process_podpress'] = $GeneralSettings['process_podpress']; // We don't touch podpress data for custom feeds
1040
- $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/';
1041
- $explicit = array("no", "yes", "clean");
1042
- $powerpress_feed['explicit'] = $explicit[$Feed['itunes_explicit']];
1043
- if( $Feed['itunes_talent_name'] )
1044
- $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
1045
- else
1046
- $powerpress_feed['itunes_talent_name'] = get_bloginfo_rss('name');
1047
- if( version_compare( '5', phpversion(), '>=' ) )
1048
- $powerpress_feed['enhance_itunes_summary'] = 0;
1049
- else
1050
- $powerpress_feed['enhance_itunes_summary'] = @$Feed['enhance_itunes_summary'];
1051
- $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
1052
- }; break;
1053
- // All other cases we let fall through
1054
- }
 
1055
  }
1056
  }
1057
  }
@@ -1162,10 +1178,11 @@ function powerpress_do_all_pings()
1162
 
1163
  // Now call the WordPress do_all_pings()...
1164
  do_all_pings();
 
1165
  }
1166
 
1167
  remove_action('do_pings', 'do_all_pings');
1168
- add_action('do_pings', 'powerpress_do_all_pings');
1169
 
1170
  function powerpress_future_to_publish($post)
1171
  {
@@ -1292,7 +1309,9 @@ function powerpress_player_filter($content, $media_url, $ExtraData = array() )
1292
  case 'asf': {
1293
 
1294
  $content .= '<div class="powerpress_player" id="powerpress_player_'. $g_powerpress_player_id .'">';
1295
- if( !$cover_image || $autoplay ) // if we don't have a cover image or we're supposed to auto play the media anyway...
 
 
1296
  {
1297
  $content .= '<object id="winplayer" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'. $player_width .'" height="'. $player_height .'" standby="..." type="application/x-oleobject">';
1298
  $content .= ' <param name="url" value="'. $media_url .'" />';
@@ -1306,19 +1325,30 @@ function powerpress_player_filter($content, $media_url, $ExtraData = array() )
1306
  $content .= ' <param name="ShowCaptioning" value="false" />';
1307
  $content .= ' <param name="ShowDisplay" value="false" />';
1308
  $content .= ' <param name="ShowStatusBar" value="false" />';
1309
- $content .= ' <embed type="application/x-mplayer2" src="'. $media_url .'" width="'. $player_width .'" height="'. $player_height .'" scale="aspect" AutoStart="'. ($autoplay?'true':'false') .'" ShowDisplay="0" ShowStatusBar="0" AutoSize="1" AnimationAtStart="1" AllowChangeDisplaySize="1" ShowControls="1"></embed>';
1310
  $content .= '</object>';
1311
  }
1312
  else
1313
  {
 
 
 
1314
  $content .= '<div class="powerpress_player" id="powerpress_player_'. $g_powerpress_player_id .'">'.PHP_EOL;
1315
  $content .= '<a href="'. $media_url .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" onclick="';
1316
  $content .= "return powerpress_embed_winplayer('powerpress_player_{$g_powerpress_player_id}', '{$media_url}', {$player_width}, {$player_height} );";
1317
  $content .= '">';
1318
- $content .= '<img src="'. $cover_image .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" />';
1319
  $content .= '</a>';
1320
  $content .= "</div>\n";
1321
  }
 
 
 
 
 
 
 
 
1322
  $content .= "</div>\n";
1323
 
1324
  }; break;
@@ -1411,6 +1441,9 @@ function powerpress_shortcode_handler( $attributes, $content = null )
1411
 
1412
  while( list($feed_slug,$feed_title) = each($GeneralSettings['custom_feeds']) )
1413
  {
 
 
 
1414
  $EpisdoeData = powerpress_get_enclosure_data($post->ID, $feed_slug);
1415
  if( isset($EpisdoeData['embed']) && $EpisdoeData['embed'] )
1416
  $return .= $EpisdoeData['embed'];
@@ -1452,8 +1485,12 @@ function powerpress_do_pinw($pinw)
1452
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
1453
  <title>Blubrry PowerPress Player</title>
1454
  <?php wp_head(); ?>
 
 
 
1455
  </head>
1456
  <body>
 
1457
  <?php
1458
 
1459
  if( !$EpisdoeData )
@@ -1470,6 +1507,7 @@ function powerpress_do_pinw($pinw)
1470
  }
1471
 
1472
  ?>
 
1473
  </body>
1474
  </html>
1475
  <?php
@@ -1477,7 +1515,7 @@ function powerpress_do_pinw($pinw)
1477
  }
1478
 
1479
  // Adds content types that are missing from the default wp_check_filetype function
1480
- function powerpress_get_contenttype($file)
1481
  {
1482
  $parts = pathinfo($file);
1483
  switch( strtolower($parts['extension']) )
@@ -1558,9 +1596,12 @@ function powerpress_get_contenttype($file)
1558
  }
1559
 
1560
  // Last case let wordpress detect it:
1561
- $FileType = wp_check_filetype($file);
1562
- if( $FileType && isset($FileType['type']) )
1563
- return $FileType['type'];
 
 
 
1564
  return '';
1565
  }
1566
 
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, iTunes integration, Blubrry Services (Media Statistics and Hosting) integration and a lot more.
6
+ Version: 0.9.6
7
  Author: Blubrry
8
  Author URI: http://www.blubrry.com/
9
  Change Log:
29
  */
30
 
31
  // WP_PLUGIN_DIR (REMEMBER TO USE THIS DEFINE IF NEEDED)
32
+ define('POWERPRESS_VERSION', '0.9.6' );
33
 
34
  /////////////////////////////////////////////////////
35
  // The following define options should be placed in your
100
 
101
  // PowerPress settings:
102
  $GeneralSettings = get_option('powerpress_general');
103
+ // Lets make the default feed the top most feed listed:
104
+ if( isset($GeneralSettings['custom_feeds']['podcast']) )
105
+ unset($GeneralSettings['custom_feeds']['podcast']);
106
+ array_unshift($GeneralSettings['custom_feeds'], array('podcast'=>'Podcast Feed') ); // Fixes scenario where the user never configured the custom default podcast feed.
107
+
108
  if( !isset($GeneralSettings['display_player']) )
109
  $GeneralSettings['display_player'] = 1;
110
  if( !isset($GeneralSettings['player_function']) )
121
 
122
  // Figure out which players are alerady in the body of the page...
123
  $ExcludePlayers = array();
124
+ if( isset($GeneralSettings['disable_player']) )
125
+ $ExcludePlayers = $GeneralSettings['disable_player']; // automatically disable the players configured
126
+
127
  if( preg_match_all('/(.?)\[(powerpress)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)/s', $content, $matches) )
128
  {
129
  if( isset($matches[3]) )
259
  $player_links .= "<a href=\"$EnclosureURL\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a> (".powerpress_byte_size($EnclosureSize).")".PHP_EOL;
260
  }
261
 
262
+ if( $player_links && empty($GeneralSettings['disable_player'][$feed_slug]) )
263
  {
264
  if( count($GeneralSettings['custom_feeds']) > 1 && $feed_slug != 'podcast' )
265
  {
442
  if( $Feed['rss2_image'] )
443
  {
444
  echo"\t". '<image>' .PHP_EOL;
445
+ if( is_category() )
446
+ echo "\t\t".'<title>' . wp_specialchars( get_bloginfo_rss('name') ) . '</title>'.PHP_EOL;
447
+ else
448
+ echo "\t\t".'<title>' . wp_specialchars( get_bloginfo_rss('name') . get_wp_title_rss() ) . '</title>'.PHP_EOL;
449
  echo "\t\t".'<url>' . wp_specialchars($Feed['rss2_image']) . '</url>'.PHP_EOL;
450
  echo "\t\t".'<link>'. $Feed['url'] . '</link>' . PHP_EOL;
451
  echo "\t".'</image>' . PHP_EOL;
453
  else // Use the default image
454
  {
455
  echo"\t". '<image>' .PHP_EOL;
456
+ if( is_category() )
457
+ echo "\t\t".'<title>' . wp_specialchars( get_bloginfo_rss('name') ) . '</title>'.PHP_EOL;
458
+ else
459
+ echo "\t\t".'<title>' . wp_specialchars( get_bloginfo_rss('name') . get_wp_title_rss() ) . '</title>'.PHP_EOL;
460
  echo "\t\t".'<url>' . powerpress_get_root_url() . 'rss_default.jpg</url>'.PHP_EOL;
461
  echo "\t\t".'<link>'. $Feed['url'] . '</link>' . PHP_EOL;
462
  echo "\t".'</image>' . PHP_EOL;
661
  $subtitle = $EpisodeData['subtitle'];
662
  if( isset( $EpisodeData['keywords'] ) )
663
  $keywords = $EpisodeData['keywords'];
664
+ if( isset( $EpisodeData['explicit'] ) )
665
+ {
666
+ $explicit_array = array("no", "yes", "clean");
667
+ $explicit = $explicit_array[$EpisodeData['explicit']];
668
+ }
669
+
670
  // Code for future use:
671
  if( isset( $EpisodeData['author'] ) )
672
  $author = $EpisodeData['author'];
 
 
673
  if( isset( $EpisodeData['block'] ) )
674
  $block = $EpisodeData['block'];
675
  }
860
  {
861
  if( powerpress_is_custom_podcast_feed() )
862
  {
863
+ global $powerpress_feed;
864
+ return print_r($powerpress_feed, true);
865
+ if( $powerpress_feed && isset($powerpress_feed['rss_language']) && $powerpress_feed['rss_language'] != '' )
866
+ $value = $powerpress_feed['rss_language'];
 
 
 
 
 
 
 
 
867
  }
868
  return $value;
869
  }
945
  // Load the general feed settings for feeds handled by powerpress
946
  function powerpress_load_general_feed_settings()
947
  {
948
+ global $wp_query;
949
  global $powerpress_feed;
950
+
951
+ if( $powerpress_feed !== false ) // If it is not false (either NULL or an array) then we already looked these settings up
952
  {
953
  $powerpress_feed = false;
954
 
959
 
960
  if( $GeneralSettings )
961
  {
962
+ $FeedSettingsBasic = get_option('powerpress_feed'); // Get overall feed settings
963
+
964
+ // If we're in advanced mode and we're dealing with a category feed we're extending, lets work with it...
965
  if( is_category() && is_array($GeneralSettings['custom_cat_feeds']) && in_array( get_query_var('cat'), $GeneralSettings['custom_cat_feeds']) )
966
  {
967
  $cat_ID = get_query_var('cat');
 
968
  $FeedCustom = get_option('powerpress_cat_feed_'.$cat_ID); // Get custom feed specific settings
969
+ $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $FeedSettingsBasic);
970
 
971
  $powerpress_feed = array();
972
  $powerpress_feed['is_custom'] = true;
973
  $powerpress_feed['itunes_custom'] = ($GeneralSettings['episode_box_mode'] == 2);
974
  $powerpress_feed['category'] = $cat_ID;
975
+ $powerpress_feed['process_podpress'] = $GeneralSettings['process_podpress']; // Category feeds could originate from Podpress
976
+ $powerpress_feed['rss_language'] = ''; // default, let WordPress set the language
977
  $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/';
978
+ $explicit_array = array("no", "yes", "clean");
979
+ $powerpress_feed['explicit'] = $explicit_array[$Feed['itunes_explicit']];
980
  if( $Feed['itunes_talent_name'] )
981
  $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
982
  else
987
  $powerpress_feed['feed_redirect_url'] = $Feed['feed_redirect_url'];
988
  if( $Feed['itunes_author_post'] == true )
989
  $powerpress_feed['itunes_author_post'] = true;
990
+ if( $Feed['rss_language'] != '' )
991
+ $powerpress_feed['rss_language'] = $Feed['rss_language'];
992
  return;
993
  }
994
 
996
 
997
  if( isset($GeneralSettings['custom_feeds']) && is_array($GeneralSettings['custom_feeds']) && isset($GeneralSettings['custom_feeds'][ $feed_slug ] ))
998
  {
 
999
  $FeedCustom = get_option('powerpress_feed_'.$feed_slug); // Get custom feed specific settings
1000
+ $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $FeedSettingsBasic);
1001
 
1002
  $powerpress_feed = array();
1003
  $powerpress_feed['is_custom'] = true;
1004
  $powerpress_feed['itunes_custom'] = ($GeneralSettings['episode_box_mode'] == 2);
1005
  $powerpress_feed['feed-slug'] = $feed_slug;
1006
+ $powerpress_feed['process_podpress'] = ($feed_slug=='podcast'? $GeneralSettings['process_podpress']: false); // We don't touch podpress data for custom feeds
1007
+ $powerpress_feed['rss_language'] = ''; // RSS language should be set by WordPress by default
1008
  $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/';
1009
  $explicit = array("no", "yes", "clean");
1010
  $powerpress_feed['explicit'] = $explicit[$Feed['itunes_explicit']];
1019
  $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
1020
  if( $Feed['feed_redirect_url'] != '' )
1021
  $powerpress_feed['feed_redirect_url'] = $Feed['feed_redirect_url'];
1022
+ if( $Feed['rss_language'] != '' )
1023
+ $powerpress_feed['rss_language'] = $Feed['rss_language'];
1024
+ return;
1025
  }
1026
+
1027
+ // We fell this far,we must be in simple mode or the user never saved customized their custom feed settings
1028
+ switch( $FeedSettingsBasic['apply_to'] )
1029
  {
1030
+ case 0: // enhance only the podcast feed added by PowerPress, with the logic above this code should never be reached but it is added for readability.
 
 
 
 
1031
  {
1032
+ if( $feed_slug != 'podcast' )
1033
+ break;
1034
+ } // important: no break here!
1035
+ case 2: // RSS2 Main feed and podcast feed added by PowerPress only
1036
+ {
1037
+ if( $feed_slug != 'feed' && $feed_slug != 'rss2' && $feed_slug != 'podcast' )
1038
+ break; // We're only adding podcasts to the rss2 feed in this situation
1039
+
1040
+ if( $wp_query->is_category ) // don't touch the category feeds...
1041
+ break;
1042
+
1043
+ if( $wp_query->is_tag ) // don't touch the tag feeds...
1044
+ break;
1045
 
1046
+ if( $wp_query->is_comment_feed ) // don't touch the comments feeds...
1047
+ break;
1048
+ } // important: no break here!
1049
+ case 1: // All feeds
1050
+ {
1051
+ $powerpress_feed = array(); // Only store what's needed for each feed item
1052
+ $powerpress_feed['is_custom'] = false; // ($feed_slug == 'podcast'?true:false);
1053
+ $powerpress_feed['itunes_custom'] = ($GeneralSettings['episode_box_mode'] == 2);
1054
+ $powerpress_feed['feed-slug'] = $feed_slug;
1055
+ $powerpress_feed['process_podpress'] = $GeneralSettings['process_podpress']; // We don't touch podpress data for custom feeds
1056
+ $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/';
1057
+ $explicit = array("no", "yes", "clean");
1058
+ $powerpress_feed['explicit'] = $explicit[$FeedSettingsBasic['itunes_explicit']];
1059
+ if( $FeedSettingsBasic['itunes_talent_name'] )
1060
+ $powerpress_feed['itunes_talent_name'] = $FeedSettingsBasic['itunes_talent_name'];
1061
+ else
1062
+ $powerpress_feed['itunes_talent_name'] = get_bloginfo_rss('name');
1063
+ if( version_compare( '5', phpversion(), '>=' ) )
1064
+ $powerpress_feed['enhance_itunes_summary'] = 0;
1065
+ else
1066
+ $powerpress_feed['enhance_itunes_summary'] = @$FeedSettingsBasic['enhance_itunes_summary'];
1067
+ $powerpress_feed['posts_per_rss'] = $FeedSettingsBasic['posts_per_rss'];
1068
+ $powerpress_feed['rss_language'] = ''; // Cannot set the language setting in simple mode
1069
+ }; break;
1070
+ // All other cases we let fall through
1071
  }
1072
  }
1073
  }
1178
 
1179
  // Now call the WordPress do_all_pings()...
1180
  do_all_pings();
1181
+ remove_action('do_pings', 'do_all_pings');
1182
  }
1183
 
1184
  remove_action('do_pings', 'do_all_pings');
1185
+ add_action('do_pings', 'powerpress_do_all_pings', 1, 1);
1186
 
1187
  function powerpress_future_to_publish($post)
1188
  {
1309
  case 'asf': {
1310
 
1311
  $content .= '<div class="powerpress_player" id="powerpress_player_'. $g_powerpress_player_id .'">';
1312
+ $firefox = (stristr($_SERVER['HTTP_USER_AGENT'], 'firefox') !== false );
1313
+
1314
+ if( (!$cover_image && !$firefox ) || $autoplay ) // if we don't have a cover image or we're supposed to auto play the media anyway...
1315
  {
1316
  $content .= '<object id="winplayer" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'. $player_width .'" height="'. $player_height .'" standby="..." type="application/x-oleobject">';
1317
  $content .= ' <param name="url" value="'. $media_url .'" />';
1325
  $content .= ' <param name="ShowCaptioning" value="false" />';
1326
  $content .= ' <param name="ShowDisplay" value="false" />';
1327
  $content .= ' <param name="ShowStatusBar" value="false" />';
1328
+ $content .= ' <embed type="application/x-mplayer2" src="'. $media_url .'" width="'. $player_width .'" height="'. $player_height .'" scale="ASPECT" autostart="'. ($autoplay?'1':'0') .'" ShowDisplay="0" ShowStatusBar="0" autosize="1" AnimationAtStart="1" AllowChangeDisplaySize="1" ShowControls="1"></embed>';
1329
  $content .= '</object>';
1330
  }
1331
  else
1332
  {
1333
+ if( $cover_image == '' )
1334
+ $cover_image = powerpress_get_root_url() . 'play_video_default.jpg';
1335
+
1336
  $content .= '<div class="powerpress_player" id="powerpress_player_'. $g_powerpress_player_id .'">'.PHP_EOL;
1337
  $content .= '<a href="'. $media_url .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" onclick="';
1338
  $content .= "return powerpress_embed_winplayer('powerpress_player_{$g_powerpress_player_id}', '{$media_url}', {$player_width}, {$player_height} );";
1339
  $content .= '">';
1340
+ $content .= '<img src="'. $cover_image .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" border="0" />';
1341
  $content .= '</a>';
1342
  $content .= "</div>\n";
1343
  }
1344
+
1345
+ if( $firefox )
1346
+ {
1347
+ $content .= '<p style="font-size: 85%;margin-top:0;">'. __('Best viewed with');
1348
+ $content .= ' <a href="http://support.mozilla.com/en-US/kb/Using+the+Windows+Media+Player+plugin+with+Firefox#Installing_the_plugin" target="_blank">';
1349
+ $content .= __('Windows Media Player plugin for Firefox') .'</a></p>';
1350
+ }
1351
+
1352
  $content .= "</div>\n";
1353
 
1354
  }; break;
1441
 
1442
  while( list($feed_slug,$feed_title) = each($GeneralSettings['custom_feeds']) )
1443
  {
1444
+ if( isset($GeneralSettings['disable_player']) && isset($GeneralSettings['disable_player'][$feed_slug]) )
1445
+ continue;
1446
+
1447
  $EpisdoeData = powerpress_get_enclosure_data($post->ID, $feed_slug);
1448
  if( isset($EpisdoeData['embed']) && $EpisdoeData['embed'] )
1449
  $return .= $EpisdoeData['embed'];
1485
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
1486
  <title>Blubrry PowerPress Player</title>
1487
  <?php wp_head(); ?>
1488
+ <style type="text/css">
1489
+ body { font-size: 13px; font-family: Arial, Helvetica, sans-serif; }
1490
+ </style>
1491
  </head>
1492
  <body>
1493
+ <div style="margin: 5px;">
1494
  <?php
1495
 
1496
  if( !$EpisdoeData )
1507
  }
1508
 
1509
  ?>
1510
+ </div>
1511
  </body>
1512
  </html>
1513
  <?php
1515
  }
1516
 
1517
  // Adds content types that are missing from the default wp_check_filetype function
1518
+ function powerpress_get_contenttype($file, $use_wp_check_filetype = true)
1519
  {
1520
  $parts = pathinfo($file);
1521
  switch( strtolower($parts['extension']) )
1596
  }
1597
 
1598
  // Last case let wordpress detect it:
1599
+ if( $use_wp_check_filetype )
1600
+ {
1601
+ $FileType = wp_check_filetype($file);
1602
+ if( $FileType && isset($FileType['type']) )
1603
+ return $FileType['type'];
1604
+ }
1605
  return '';
1606
  }
1607
 
powerpressadmin-appearance.php CHANGED
@@ -5,6 +5,19 @@ function powerpressadmin_appearance()
5
  {
6
  $General = powerpress_get_settings('powerpress_general');
7
  $General = powerpress_default_settings($General, 'appearance');
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  ?>
9
  <input type="hidden" name="action" value="powerpress-save-appearance" />
10
  <h2><?php echo __("Appearance Settings"); ?></h2>
@@ -51,6 +64,28 @@ while( list($value,$desc) = each($playeroptions) )
51
  ?>
52
  </td>
53
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  <tr valign="top">
56
  <th scope="row">
5
  {
6
  $General = powerpress_get_settings('powerpress_general');
7
  $General = powerpress_default_settings($General, 'appearance');
8
+
9
+
10
+ $Players = array('podcast'=>'Default Podcast (podcast)');
11
+ if( isset($General['custom_feeds']) )
12
+ {
13
+ while( list($podcast_slug, $podcast_title) = each($General['custom_feeds']) )
14
+ {
15
+ if( $podcast_slug == 'podcast' )
16
+ continue;
17
+ $Players[$podcast_slug] = sprintf('%s (%s)', $podcast_title, $podcast_slug);
18
+ }
19
+ }
20
+
21
  ?>
22
  <input type="hidden" name="action" value="powerpress-save-appearance" />
23
  <h2><?php echo __("Appearance Settings"); ?></h2>
64
  ?>
65
  </td>
66
  </tr>
67
+ <?php
68
+ if( count($Players) > 1 )
69
+ {
70
+ ?>
71
+ <tr valign="top">
72
+ <th scope="row"><?php echo __("Disable Player for"); ?></th>
73
+ <td>
74
+ <input type="hidden" name="UpdateDisablePlayer" value="1" />
75
+ <?php
76
+ while( list($podcast_slug, $podcast_title) = each($Players) )
77
+ {
78
+ ?>
79
+ <p><input name="DisablePlayer[<?php echo $podcast_slug; ?>]" type="checkbox" value="1" <?php if( isset($General['disable_player'][$podcast_slug]) ) echo 'checked '; ?>/> <?php echo htmlspecialchars($podcast_title); ?> <?php echo __('feed episodes'); ?></p>
80
+ <?php
81
+ }
82
+ ?>
83
+ <p>Check the custom podcast feeds above that you do not want in-page players for.</p>
84
+ </td>
85
+ </tr>
86
+ <?php
87
+ }
88
+ ?>
89
 
90
  <tr valign="top">
91
  <th scope="row">
powerpressadmin-basic.php CHANGED
@@ -63,6 +63,11 @@ function SelectEntryBox(mode)
63
  {
64
  ?>
65
  <p style="margin-top: 5px;">Simple Mode (<strong><a href="#" onclick="return powerpress_changemode(1);">Switch to Advanced Mode</a></strong>)</p>
 
 
 
 
 
66
  <?php
67
  }
68
  else
@@ -243,11 +248,14 @@ while( list($value,$desc) = each($options) )
243
  (Disable player on a per episode basis)</p>
244
 
245
  <p style="margin-top: 15px;"><input id="episode_box_keywords" name="General[episode_box_keywords]" <?php if( $General['episode_box_mode'] != 2 ) echo 'disabled'; ?> type="checkbox" value="1"<?php if( $General['episode_box_keywords'] ) echo ' checked'; ?> /> iTunes Keywords Field
246
- (Leave blank to use your blog post tags)</p>
247
  <p style="margin-top: 15px;"><input id="episode_box_subtitle" name="General[episode_box_subtitle]" <?php if( $General['episode_box_mode'] != 2 ) echo 'disabled'; ?> type="checkbox" value="1"<?php if( $General['episode_box_subtitle'] ) echo ' checked'; ?> /> iTunes Subtitle Field
248
- (Leave blank to use the first 250 characters of your blog post)</p>
249
  <p style="margin-top: 15px;"><input id="episode_box_summary" name="General[episode_box_summary]" <?php if( $General['episode_box_mode'] != 2 ) echo 'disabled'; ?> type="checkbox" value="1"<?php if( $General['episode_box_summary'] ) echo ' checked'; ?> /> iTunes Summary Field
250
- (Leave blank to use your blog post)</p>
 
 
 
251
  <em>NOTE: An invalid entry into any of the iTunes fields may cause problems with your iTunes listing.
252
  It is highly recommended that you validate your feed using feedvalidator.org everytime you modify any of the iTunes fields listed above.</em><br />
253
  <em><strong>USE THE ITUNES FIELDS ABOVE AT YOUR OWN RISK.</strong></em>
@@ -295,6 +303,25 @@ while( list($value,$desc) = each($options) )
295
  </select> (specify default duration option when creating a new episode)
296
  </td>
297
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  </table>
299
  <br />
300
  <?php
63
  {
64
  ?>
65
  <p style="margin-top: 5px;">Simple Mode (<strong><a href="#" onclick="return powerpress_changemode(1);">Switch to Advanced Mode</a></strong>)</p>
66
+ <?php if( count($General['custom_feeds']) > 0 || count($General['custom_cat_feeds']) > 0 ) { ?>
67
+ <p>
68
+ NOTE: You have custom feed settings configured while in Advancede Mode which have presidence over the Feed Settings below.
69
+ </p>
70
+ <?php } ?>
71
  <?php
72
  }
73
  else
248
  (Disable player on a per episode basis)</p>
249
 
250
  <p style="margin-top: 15px;"><input id="episode_box_keywords" name="General[episode_box_keywords]" <?php if( $General['episode_box_mode'] != 2 ) echo 'disabled'; ?> type="checkbox" value="1"<?php if( $General['episode_box_keywords'] ) echo ' checked'; ?> /> iTunes Keywords Field
251
+ (Leave unchecked to use your blog post tags)</p>
252
  <p style="margin-top: 15px;"><input id="episode_box_subtitle" name="General[episode_box_subtitle]" <?php if( $General['episode_box_mode'] != 2 ) echo 'disabled'; ?> type="checkbox" value="1"<?php if( $General['episode_box_subtitle'] ) echo ' checked'; ?> /> iTunes Subtitle Field
253
+ (Leave unchecked to use the first 250 characters of your blog post)</p>
254
  <p style="margin-top: 15px;"><input id="episode_box_summary" name="General[episode_box_summary]" <?php if( $General['episode_box_mode'] != 2 ) echo 'disabled'; ?> type="checkbox" value="1"<?php if( $General['episode_box_summary'] ) echo ' checked'; ?> /> iTunes Summary Field
255
+ (Leave unchecked to use your blog post)</p>
256
+ <p style="margin-top: 15px;"><input id="episode_box_explicit" name="General[episode_box_explicit]" <?php if( $General['episode_box_mode'] != 2 ) echo 'disabled'; ?> type="checkbox" value="1"<?php if( $General['episode_box_explicit'] ) echo ' checked'; ?> /> iTunes Explicit Field
257
+ (Leave unchecked to use your feed's explicit setting)</p>
258
+
259
  <em>NOTE: An invalid entry into any of the iTunes fields may cause problems with your iTunes listing.
260
  It is highly recommended that you validate your feed using feedvalidator.org everytime you modify any of the iTunes fields listed above.</em><br />
261
  <em><strong>USE THE ITUNES FIELDS ABOVE AT YOUR OWN RISK.</strong></em>
303
  </select> (specify default duration option when creating a new episode)
304
  </td>
305
  </tr>
306
+
307
+ <tr valign="top">
308
+ <th scope="row">
309
+ <?php _e("Auto Add Media"); ?></th>
310
+ <td>
311
+ <select name="General[auto_enclose]" class="bpp_input_med">
312
+ <?php
313
+ $options = array(0=>'Disabled (default)', 1=>'First media link found in post content', 2=>'Last media link found in post content');
314
+
315
+ while( list($value,$desc) = each($options) )
316
+ echo "\t<option value=\"$value\"". ($General['auto_enclose']==$value?' selected':''). ">$desc</option>\n";
317
+
318
+ ?>
319
+ </select>
320
+ <p>When enabled, the first or last media link found in the post content is automatically added as your podcast episode.</p>
321
+ <p style="margin-bottom: 0;"><em>NOTE: Use this feature with caution. Links to media files could unintentionally become podcast episodes.</em></p>
322
+ </td>
323
+ </tr>
324
+
325
  </table>
326
  <br />
327
  <?php
powerpressadmin-categoryfeeds.php CHANGED
@@ -127,7 +127,7 @@ function powerpress_admin_categoryfeeds()
127
 
128
  echo "<td $class><a href='$url' title='". attribute_escape(sprintf(__('Visit %s'), $feed_title))."' target=\"_blank\">$short_url</a>";
129
  echo '<div class="row-actions">';
130
- echo '<span class="'.$action .'"><a href="http://www.feedvalidator.org/check.cgi?url='. urlencode($url) .'" target="_blank">' . __('Validate Feed') . '</a></span>';
131
  echo '</div>';
132
  echo "</td>";
133
 
127
 
128
  echo "<td $class><a href='$url' title='". attribute_escape(sprintf(__('Visit %s'), $feed_title))."' target=\"_blank\">$short_url</a>";
129
  echo '<div class="row-actions">';
130
+ echo '<span class="'.$action .'"><a href="http://www.feedvalidator.org/check.cgi?url='. urlencode( str_replace('&amp;', '&', $url) ) .'" target="_blank">' . __('Validate Feed') . '</a></span>';
131
  echo '</div>';
132
  echo "</td>";
133
 
powerpressadmin-customfeeds.php CHANGED
@@ -20,8 +20,7 @@ function powerpress_admin_customfeeds()
20
  ?>
21
  <h2><?php echo __("Custom Podcast Feeds"); ?></h2>
22
  <p>
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
  <p>
27
  If you are looking to organize episodes by topic, please use <a href="<?php echo admin_url('admin.php?page=powerpress/powerpressadmin_categoryfeeds.php'); ?>" title="Category Podcast Feeds">Category Podcast Feeds</a>.
20
  ?>
21
  <h2><?php echo __("Custom Podcast Feeds"); ?></h2>
22
  <p>
23
+ Custom podcast feeds allow you to associate multiple media files and/or formats to one blog post.
 
24
  </p>
25
  <p>
26
  If you are looking to organize episodes by topic, please use <a href="<?php echo admin_url('admin.php?page=powerpress/powerpressadmin_categoryfeeds.php'); ?>" title="Category Podcast Feeds">Category Podcast Feeds</a>.
powerpressadmin-editfeed.php CHANGED
@@ -263,7 +263,7 @@ while( list($value,$desc) = each($applyoptions) )
263
  </th>
264
  <td>
265
  <?php if( $cat_ID ) { ?>
266
- <p style="margin-top: 0;"><a href="<?php echo get_category_feed_link($cat_ID); ?>" target="_blank"><?php echo get_category_feed_link($cat_ID); ?></a> | <a href="http://www.feedvalidator.org/check.cgi?url=<?php echo urlencode(get_category_feed_link($cat_ID)); ?>" target="_blank"><?php _e('validate'); ?></a></p>
267
  <?php } else { ?>
268
  <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>
269
  <?php } ?>
263
  </th>
264
  <td>
265
  <?php if( $cat_ID ) { ?>
266
+ <p style="margin-top: 0;"><a href="<?php echo get_category_feed_link($cat_ID); ?>" target="_blank"><?php echo get_category_feed_link($cat_ID); ?></a> | <a href="http://www.feedvalidator.org/check.cgi?url=<?php echo urlencode( str_replace('&amp;', '&', get_category_feed_link($cat_ID))); ?>" target="_blank"><?php _e('validate'); ?></a></p>
267
  <?php } else { ?>
268
  <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>
269
  <?php } ?>
powerpressadmin-jquery.php CHANGED
@@ -34,8 +34,11 @@ function powerpress_add_blubrry_redirect($program_keyword)
34
 
35
  function powerpress_admin_jquery_init()
36
  {
37
- $Error = false;
38
  $Settings = false; // Important, never remove this
 
 
 
 
39
  $Programs = false;
40
  $Step = 1;
41
 
@@ -47,6 +50,10 @@ function powerpress_admin_jquery_init()
47
  {
48
  case 'powerpress-jquery-stats': {
49
 
 
 
 
 
50
  $StatsCached = get_option('powerpress_stats');
51
 
52
  powerpress_admin_jquery_header('Blubrry Media Statistics');
@@ -59,9 +66,6 @@ function powerpress_admin_jquery_init()
59
  }; break;
60
  case 'powerpress-jquery-media': {
61
 
62
- $Settings = get_option('powerpress_general');
63
-
64
-
65
  if( $Settings['blubrry_auth'] == '' )
66
  {
67
  powerpress_admin_jquery_header('Select Media');
@@ -74,7 +78,7 @@ function powerpress_admin_jquery_init()
74
  break;
75
  }
76
 
77
- $api_url = sprintf('%s/media/%s/index.json', rtrim(POWERPRESS_BLUBRRY_API_URL, '/'), $Settings['blubrry_program_keyword'] );
78
  $json_data = powerpress_remote_fopen($api_url, $Settings['blubrry_auth']);
79
  $results = powerpress_json_decode($json_data);
80
  // print_r($files);
@@ -82,17 +86,27 @@ function powerpress_admin_jquery_init()
82
  $FeedSlug = $_GET['podcast-feed'];
83
  powerpress_admin_jquery_header('Select Media');
84
  ?>
 
85
 
86
- <!-- <p style="text-align: right; position: absolute; top: 5px; right: 5px; margin: 0; padding:0;"><a href="#" onclick="self.parent.tb_remove();" title="Cancel"><img src="<?php echo admin_url(); ?>/images/no.png" /></a></p>
87
- <h2>Select Media</h2> -->
88
- <p>
89
- Select from media files uploaded to blubrry.com:
90
- </p>
 
 
 
 
 
 
 
 
 
91
  <!-- <ul class="media"> -->
92
  <div id="media-items-container">
93
  <div id="media-items">
94
  <?php
95
-
96
  if( isset($results['error']) )
97
  {
98
  echo $results['error'];
@@ -101,6 +115,11 @@ function powerpress_admin_jquery_init()
101
  {
102
  while( list($index,$data) = each($results) )
103
  {
 
 
 
 
 
104
  // old way:
105
  /*
106
  ?>
@@ -127,6 +146,17 @@ function powerpress_admin_jquery_init()
127
  ?>
128
  </div>
129
  </div>
 
 
 
 
 
 
 
 
 
 
 
130
  <!-- </ul> -->
131
 
132
  <?php
@@ -138,9 +168,9 @@ function powerpress_admin_jquery_init()
138
  check_admin_referer('powerpress-jquery-account');
139
 
140
  $Password = $_POST['Password'];
141
- $Settings = $_POST['Settings'];
142
  $Password = powerpress_stripslashes($Password);
143
- $General = powerpress_stripslashes($Settings);
144
 
145
  $Save = false;
146
  $Close = false;
@@ -154,10 +184,10 @@ function powerpress_admin_jquery_init()
154
 
155
  if( $_POST['Remove'] )
156
  {
157
- $Settings['blubrry_username'] = '';
158
- $Settings['blubrry_auth'] = '';
159
- $Settings['blubrry_program_keyword'] = '';
160
- $Settings['blubrry_hosting'] = 0;
161
  $Close = true;
162
  $Save = true;
163
  }
@@ -169,8 +199,8 @@ function powerpress_admin_jquery_init()
169
  // $Settings['blubrry_program_keyword'] = ''; // Reset the program keyword stored
170
 
171
  // Anytime we change the password we need to test it...
172
- $auth = base64_encode( $Settings['blubrry_username'] . ':' . $Password );
173
- if( $Settings['blubrry_hosting'] == 0 )
174
  $api_url = sprintf('%s/stats/index.json', rtrim(POWERPRESS_BLUBRRY_API_URL, '/') );
175
  else
176
  $api_url = sprintf('%s/media/index.json', rtrim(POWERPRESS_BLUBRRY_API_URL, '/') );
@@ -195,22 +225,22 @@ function powerpress_admin_jquery_init()
195
 
196
  if( count($Programs) > 0 )
197
  {
198
- $Settings['blubrry_auth'] = $auth;
199
 
200
- if( $Settings['blubrry_program_keyword'] != '' )
201
  {
202
- powerpress_add_blubrry_redirect($Settings['blubrry_program_keyword']);
203
  $Save = true;
204
  $Close = true;
205
  }
206
- else if( isset($Settings['blubrry_program_keyword']) )
207
  {
208
  $Error = 'You must select a program to continue.';
209
  }
210
  else if( count($Programs) == 1 )
211
  {
212
  list($keyword, $title) = each($Programs);
213
- $Settings['blubrry_program_keyword'] = $keyword;
214
  powerpress_add_blubrry_redirect($keyword);
215
  $Close = true;
216
  $Save = true;
@@ -229,7 +259,7 @@ function powerpress_admin_jquery_init()
229
  }
230
 
231
  if( $Save )
232
- powerpress_save_settings($Settings);
233
 
234
  // Clear cached statistics
235
  delete_option('powerpress_stats');
@@ -278,12 +308,12 @@ function powerpress_admin_jquery_init()
278
  <h2>Blubrry Services Integration</h2>
279
  <?php if( $Step == 1 ) { ?>
280
  <p>
281
- <label>Blubrry User Name</label>
282
- <input type="text" name="Settings[blubrry_username]" value="<?php echo $Settings['blubrry_username']; ?>" />
283
  </p>
284
  <p id="password_row">
285
- <label>Blubrry Password</label>
286
- <input type="password" name="Password" value="" />
287
  </p>
288
  <p><strong>Select Blubrry Services</strong></p>
289
  <p style="margin-left: 20px; margin-bottom: 0px;margin-top: 0px;">
@@ -318,38 +348,126 @@ while( list($value,$desc) = each($Programs) )
318
  powerpress_admin_jquery_footer();
319
  exit;
320
  }; break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
  }
322
 
323
  }
324
 
325
  function powerpress_admin_jquery_header($title, $other = false)
326
  {
 
327
  ?>
328
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
329
  <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
330
  <head>
331
  <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
332
  <title><?php bloginfo('name') ?> &rsaquo; <?php echo $title; ?> &#8212; WordPress</title>
333
- <!-- <link rel="stylesheet" href="wp-admin.css" type="text/css" media="screen" /> -->
334
- <link rel="stylesheet" href="<?php echo powerpress_get_root_url(); ?>css/jquery.css" type="text/css" media="screen" />
335
  <?php
336
 
 
337
  wp_admin_css( 'css/global' );
338
  wp_admin_css();
339
- wp_admin_css( 'css/colors' );
340
- wp_admin_css( 'css/ie' );
 
 
 
 
 
341
 
342
  ?>
 
343
  <?php if( $other ) echo $other; ?>
344
  </head>
345
  <body>
 
346
  <?php
347
  }
348
 
349
 
350
  function powerpress_admin_jquery_footer()
351
  {
 
 
352
  ?>
 
353
  </body>
354
  </html>
355
  <?php
34
 
35
  function powerpress_admin_jquery_init()
36
  {
 
37
  $Settings = false; // Important, never remove this
38
+ $Settings = get_option('powerpress_general');
39
+
40
+ $Error = false;
41
+
42
  $Programs = false;
43
  $Step = 1;
44
 
50
  {
51
  case 'powerpress-jquery-stats': {
52
 
53
+ // Make sure users have permission to access this
54
+ if( @$Settings['use_caps'] && !current_user_can('view_podcast_stats') )
55
+ return;
56
+
57
  $StatsCached = get_option('powerpress_stats');
58
 
59
  powerpress_admin_jquery_header('Blubrry Media Statistics');
66
  }; break;
67
  case 'powerpress-jquery-media': {
68
 
 
 
 
69
  if( $Settings['blubrry_auth'] == '' )
70
  {
71
  powerpress_admin_jquery_header('Select Media');
78
  break;
79
  }
80
 
81
+ $api_url = sprintf('%s/media/%s/index.json?quota=true', rtrim(POWERPRESS_BLUBRRY_API_URL, '/'), $Settings['blubrry_program_keyword'] );
82
  $json_data = powerpress_remote_fopen($api_url, $Settings['blubrry_auth']);
83
  $results = powerpress_json_decode($json_data);
84
  // print_r($files);
86
  $FeedSlug = $_GET['podcast-feed'];
87
  powerpress_admin_jquery_header('Select Media');
88
  ?>
89
+ <script language="JavaScript" type="text/javascript">
90
 
91
+ function SelectMedia(File)
92
+ {
93
+ self.parent.document.getElementById('powerpress_url_<?php echo $FeedSlug; ?>').value=File;
94
+ self.parent.document.getElementById('powerpress_hosting_<?php echo $FeedSlug; ?>').value='1';
95
+ self.parent.document.getElementById('powerpress_url_<?php echo $FeedSlug; ?>').readOnly='true';
96
+ self.parent.tb_remove();
97
+ }
98
+ </script>
99
+ <p style="text-align: right; position: absolute; top: 5px; right: 5px; margin: 0; padding:0;"><a href="#" onclick="self.parent.tb_remove();" title="Cancel"><img src="<?php echo admin_url(); ?>/images/no.png" /></a></p>
100
+ <div id="media-header">
101
+ <h2>Select Media</h2>
102
+ <div class="media-upload-link"><a href="<?php echo admin_url(); ?>?action=powerpress-jquery-upload&podcast-feed=<?php echo $FeedSlug; ?>&keepThis=true&TB_iframe=true&height=350&width=530&modal=true" class="thickbox" title="Upload Media File">Upload Media File</a></div>
103
+ <p>Select from media files uploaded to blubrry.com:</p>
104
+ </div>
105
  <!-- <ul class="media"> -->
106
  <div id="media-items-container">
107
  <div id="media-items">
108
  <?php
109
+ $QuotaData = false;
110
  if( isset($results['error']) )
111
  {
112
  echo $results['error'];
115
  {
116
  while( list($index,$data) = each($results) )
117
  {
118
+ if( $index === 'quota' )
119
+ {
120
+ $QuotaData = $data;
121
+ continue;
122
+ }
123
  // old way:
124
  /*
125
  ?>
146
  ?>
147
  </div>
148
  </div>
149
+ <div id="media-footer">
150
+ <div class="media-upload-link"><a href="<?php echo admin_url(); ?>?action=powerpress-jquery-upload&podcast-feed=<?php echo $FeedSlug; ?>&keepThis=true&TB_iframe=true&height=350&width=530&modal=true" class="thickbox" title="Upload Media File">Upload Media File</a></div>
151
+ <?php
152
+ if( $QuotaData ) {
153
+ $NextDate = strtotime( $QuotaData['published']['next_date']);
154
+ ?>
155
+ <p>You have uploaded <em><?php echo powerpress_byte_size($QuotaData['unpublished']['available']); ?></em> of your <em><?php echo powerpress_byte_size($QuotaData['unpublished']['total']); ?></em> limit</p>
156
+ <p>You are hosting <em><?php echo powerpress_byte_size($QuotaData['published']['available']); ?></em> of your <em><?php echo powerpress_byte_size($QuotaData['published']['total']); ?></em>/month limit.</p>
157
+ <p>Your limit will adjust on <?php echo date('m/d/Y', $NextDate); ?> to <em><?php echo powerpress_byte_size($QuotaData['published']['next_available']); ?></em>.</p>
158
+ <?php } ?>
159
+ </div>
160
  <!-- </ul> -->
161
 
162
  <?php
168
  check_admin_referer('powerpress-jquery-account');
169
 
170
  $Password = $_POST['Password'];
171
+ $SaveSettings = $_POST['Settings'];
172
  $Password = powerpress_stripslashes($Password);
173
+ $General = powerpress_stripslashes($SaveSettings);
174
 
175
  $Save = false;
176
  $Close = false;
184
 
185
  if( $_POST['Remove'] )
186
  {
187
+ $SaveSettings['blubrry_username'] = '';
188
+ $SaveSettings['blubrry_auth'] = '';
189
+ $SaveSettings['blubrry_program_keyword'] = '';
190
+ $SaveSettings['blubrry_hosting'] = 0;
191
  $Close = true;
192
  $Save = true;
193
  }
199
  // $Settings['blubrry_program_keyword'] = ''; // Reset the program keyword stored
200
 
201
  // Anytime we change the password we need to test it...
202
+ $auth = base64_encode( $SaveSettings['blubrry_username'] . ':' . $Password );
203
+ if( $SaveSettings['blubrry_hosting'] == 0 )
204
  $api_url = sprintf('%s/stats/index.json', rtrim(POWERPRESS_BLUBRRY_API_URL, '/') );
205
  else
206
  $api_url = sprintf('%s/media/index.json', rtrim(POWERPRESS_BLUBRRY_API_URL, '/') );
225
 
226
  if( count($Programs) > 0 )
227
  {
228
+ $SaveSettings['blubrry_auth'] = $auth;
229
 
230
+ if( $SaveSettings['blubrry_program_keyword'] != '' )
231
  {
232
+ powerpress_add_blubrry_redirect($SaveSettings['blubrry_program_keyword']);
233
  $Save = true;
234
  $Close = true;
235
  }
236
+ else if( isset($SaveSettings['blubrry_program_keyword']) )
237
  {
238
  $Error = 'You must select a program to continue.';
239
  }
240
  else if( count($Programs) == 1 )
241
  {
242
  list($keyword, $title) = each($Programs);
243
+ $SaveSettings['blubrry_program_keyword'] = $keyword;
244
  powerpress_add_blubrry_redirect($keyword);
245
  $Close = true;
246
  $Save = true;
259
  }
260
 
261
  if( $Save )
262
+ powerpress_save_settings($SaveSettings);
263
 
264
  // Clear cached statistics
265
  delete_option('powerpress_stats');
308
  <h2>Blubrry Services Integration</h2>
309
  <?php if( $Step == 1 ) { ?>
310
  <p>
311
+ <label for="blubrry_username">Blubrry User Name</label>
312
+ <input type="text" id="blubrry_username" name="Settings[blubrry_username]" value="<?php echo $Settings['blubrry_username']; ?>" />
313
  </p>
314
  <p id="password_row">
315
+ <label for="password_password">Blubrry Password</label>
316
+ <input type="password" id="password_password" name="Password" value="" />
317
  </p>
318
  <p><strong>Select Blubrry Services</strong></p>
319
  <p style="margin-left: 20px; margin-bottom: 0px;margin-top: 0px;">
348
  powerpress_admin_jquery_footer();
349
  exit;
350
  }; break;
351
+ case 'powerpress-jquery-upload': {
352
+
353
+ $RedirectURL = false;
354
+ $Error = false;
355
+ if( $Settings['blubrry_hosting'] == 0 )
356
+ {
357
+ $Error = __('This feature is available to Blubrry Hosting users only.');
358
+ }
359
+
360
+ if( $Error == false )
361
+ {
362
+ $api_url = sprintf('%s/media/%s/upload_session.json', rtrim(POWERPRESS_BLUBRRY_API_URL, '/'), $Settings['blubrry_program_keyword'] );
363
+ $json_data = powerpress_remote_fopen($api_url, $Settings['blubrry_auth']);
364
+ $results = powerpress_json_decode($json_data);
365
+ // We need to obtain an upload session for this user...
366
+ if( isset($results['error']) )
367
+ {
368
+ $Error = $results['error'];
369
+ if( strstr($Error, 'currently not available') )
370
+ $Error = 'Unable to find podcasts for this account.';
371
+ }
372
+ else if( !is_array($results) )
373
+ {
374
+ $Error = $json_data;
375
+ }
376
+ else
377
+ {
378
+ if( isset($results['url']) && !empty($results['url']) )
379
+ $RedirectURL = $results['url'];
380
+ }
381
+ }
382
+
383
+ if( $Error == false && $RedirectURL )
384
+ {
385
+ header("Location: $RedirectURL");
386
+ exit;
387
+ $Error = '<a href="'.$RedirectURL.'&amp;nocookie=true&amp;ReturnURL='. urlencode( admin_url() . '?action=powerpress-jquery-upload-complete') .'">Session initialized, click here to upload.</a>';
388
+ }
389
+ else if( $Error == false )
390
+ {
391
+ $Error = __('Unable to obtain upload session.');
392
+ }
393
+
394
+ powerpress_admin_jquery_header('Uploader');
395
+ echo '<h2>Coming Soon</h2>';
396
+ echo '<p>';
397
+ echo $Error;
398
+ echo '</p>';
399
+ echo '<p><a href="#" onclick="self.parent.tb_remove();">close</a></p>';
400
+ powerpress_admin_jquery_footer();
401
+ exit;
402
+ }; break;
403
+ case 'powerpress-jquery-upload-complete': {
404
+ $File = $_GET['File'];
405
+ $Message = $_GET['Message'];
406
+
407
+ powerpress_admin_jquery_header('Upload Complete');
408
+ echo '<h2>Coming Soon</h2>';
409
+ echo '<p>File: ';
410
+ echo $File;
411
+ echo ' - ';
412
+ echo $Message;
413
+ echo '</p>';
414
+ echo '<p><a href="#" onclick="self.parent.tb_remove();">close</a></p>';
415
+
416
+ if( $Message == '' )
417
+ {
418
+ ?>
419
+ <script language="JavaScript" type="text/javascript">
420
+ <?php if( $File != '' ) { ?>
421
+ self.parent.SelectMedia('<?php echo $File ; ?>'); <?php } ?>
422
+ self.parent.tb_remove();
423
+ </script>
424
+ <?php
425
+ }
426
+ powerpress_admin_jquery_footer();
427
+ exit;
428
+ }; break;
429
  }
430
 
431
  }
432
 
433
  function powerpress_admin_jquery_header($title, $other = false)
434
  {
435
+ add_thickbox(); // we use the thckbox for some settings
436
  ?>
437
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
438
  <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
439
  <head>
440
  <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
441
  <title><?php bloginfo('name') ?> &rsaquo; <?php echo $title; ?> &#8212; WordPress</title>
 
 
442
  <?php
443
 
444
+
445
  wp_admin_css( 'css/global' );
446
  wp_admin_css();
447
+ wp_enqueue_script('utils');
448
+
449
+ do_action('admin_print_styles');
450
+ do_action('admin_print_scripts');
451
+ do_action('admin_head');
452
+
453
+ echo '<!-- done adding extra stuff -->';
454
 
455
  ?>
456
+ <link rel="stylesheet" href="<?php echo powerpress_get_root_url(); ?>css/jquery.css" type="text/css" media="screen" />
457
  <?php if( $other ) echo $other; ?>
458
  </head>
459
  <body>
460
+ <div id="container">
461
  <?php
462
  }
463
 
464
 
465
  function powerpress_admin_jquery_footer()
466
  {
467
+ do_action('admin_print_footer_scripts');
468
+
469
  ?>
470
+ </div><!-- end container -->
471
  </body>
472
  </html>
473
  <?php
powerpressadmin-metabox.php CHANGED
@@ -15,6 +15,7 @@ function powerpress_meta_box($object, $box)
15
  $iTunesKeywords = '';
16
  $iTunesSubtitle = '';
17
  $iTunesSummary = '';
 
18
  $NoPlayer = false;
19
  $GeneralSettings = get_option('powerpress_general');
20
  if( !isset($GeneralSettings['set_size']) )
@@ -48,6 +49,8 @@ function powerpress_meta_box($object, $box)
48
  $iTunesSummary = $ExtraData['summary'];
49
  if( $ExtraData && isset($ExtraData['no_player']) )
50
  $NoPlayer = $ExtraData['no_player'];
 
 
51
  }
52
 
53
 
@@ -102,7 +105,7 @@ function powerpress_meta_box($object, $box)
102
  <label for "Powerpress[<?php echo $FeedSlug; ?>][url]">Media URL</label>
103
  <div class="powerpress_row_content">
104
  <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%;" />
105
- <a href="<?php echo admin_url(); ?>?action=powerpress-jquery-media&podcast-feed=<?php echo $FeedSlug; ?>&KeepThis=true&TB_iframe=true" title="Select Media File" class="thickbox"><img src="<?php echo powerpress_get_root_url(); ?>/images/blubrry_folder.png" alt="Browse Media Files" /></a>
106
  <input type="hidden" id="powerpress_hosting_<?php echo $FeedSlug; ?>" name="Powerpress[<?php echo $FeedSlug; ?>][hosting]" value="0" />
107
  <?php
108
 
@@ -218,6 +221,26 @@ function powerpress_meta_box($object, $box)
218
  Leave blank to use your blog post.</em>
219
  </div>
220
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
  <?php
222
  }
223
  }
15
  $iTunesKeywords = '';
16
  $iTunesSubtitle = '';
17
  $iTunesSummary = '';
18
+ $iTunesExplicit = '';
19
  $NoPlayer = false;
20
  $GeneralSettings = get_option('powerpress_general');
21
  if( !isset($GeneralSettings['set_size']) )
49
  $iTunesSummary = $ExtraData['summary'];
50
  if( $ExtraData && isset($ExtraData['no_player']) )
51
  $NoPlayer = $ExtraData['no_player'];
52
+ if( $ExtraData && isset($ExtraData['explicit']) )
53
+ $iTunesExplicit = $ExtraData['explicit'];
54
  }
55
 
56
 
105
  <label for "Powerpress[<?php echo $FeedSlug; ?>][url]">Media URL</label>
106
  <div class="powerpress_row_content">
107
  <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%;" />
108
+ <a href="<?php echo admin_url(); ?>?action=powerpress-jquery-media&podcast-feed=<?php echo $FeedSlug; ?>&KeepThis=true&TB_iframe=true&modal=true" title="Select Media File" class="thickbox"><img src="<?php echo powerpress_get_root_url(); ?>/images/blubrry_folder.png" alt="Browse Media Files" /></a>
109
  <input type="hidden" id="powerpress_hosting_<?php echo $FeedSlug; ?>" name="Powerpress[<?php echo $FeedSlug; ?>][hosting]" value="0" />
110
  <?php
111
 
221
  Leave blank to use your blog post.</em>
222
  </div>
223
  </div>
224
+ <?php
225
+ }
226
+
227
+ if( $GeneralSettings['episode_box_explicit'] )
228
+ {
229
+ ?>
230
+ <div class="powerpress_row">
231
+ <label for "Powerpress[<?php echo $FeedSlug; ?>][summary]">iTunes Explicit</label>
232
+ <div class="powerpress_row_content">
233
+ <select id="powerpress_explicit_<?php echo $FeedSlug; ?>" name="Powerpress[<?php echo $FeedSlug; ?>][explicit]" style="width: 200px;">
234
+ <?php
235
+ $explicit_array = array(''=>'Use feed\'s explicit setting', 0=>"no - display nothing", 1=>"yes - explicit content", 2=>"clean - no explicit content");
236
+
237
+ while( list($value,$desc) = each($explicit_array) )
238
+ echo "\t<option value=\"$value\"". ($iTunesExplicit==$value?' selected':''). ">$desc</option>\n";
239
+
240
+ ?>
241
+ </select>
242
+ </div>
243
+ </div>
244
  <?php
245
  }
246
  }
powerpressadmin-mt.php CHANGED
@@ -298,7 +298,7 @@
298
  powerpressadmin_mt_import_print_log();
299
 
300
  ?>
301
- <style>
302
  .column-exclude {
303
  width: 80px;
304
  }
298
  powerpressadmin_mt_import_print_log();
299
 
300
  ?>
301
+ <style type="text/css">
302
  .column-exclude {
303
  width: 80px;
304
  }
powerpressadmin-podpress.php CHANGED
@@ -250,7 +250,7 @@
250
  powerpressadmin_podpress_import_print_log();
251
 
252
  ?>
253
- <style>
254
  .column-exclude {
255
  width: 80px;
256
  }
250
  powerpressadmin_podpress_import_print_log();
251
 
252
  ?>
253
+ <style type="text/css">
254
  .column-exclude {
255
  width: 80px;
256
  }
powerpressadmin.php CHANGED
@@ -26,6 +26,11 @@ function powerpress_admin_init()
26
  {
27
  global $wp_rewrite;
28
 
 
 
 
 
 
29
  if( !current_user_can('manage_options') )
30
  {
31
  powerpress_page_message_add_error( __('You do not have sufficient permission to manage options.') );
@@ -49,8 +54,7 @@ function powerpress_admin_init()
49
  $VersionDiff = version_compare($wp_version, 2.6);
50
  if( $VersionDiff < 0 )
51
  powerpress_page_message_add_error( __('Blubrry PowerPress requires Wordpress version 2.6 or greater.') );
52
-
53
- add_thickbox(); // we use the thckbox for some settings
54
 
55
  // Save settings here
56
  if( isset($_POST[ 'Feed' ]) || isset($_POST[ 'General' ]) )
@@ -145,6 +149,13 @@ function powerpress_admin_init()
145
  powerpress_page_message_add_error( 'Invalid Coverat image: ' . htmlspecialchars($_FILES['coverart_image_file']['name']) );
146
  }
147
  }
 
 
 
 
 
 
 
148
 
149
 
150
  // Check to see if we need to update the feed title
@@ -185,6 +196,8 @@ function powerpress_admin_init()
185
  $General['episode_box_subtitle'] = 0;
186
  if( !isset($General['episode_box_summary'] ) )
187
  $General['episode_box_summary'] = 0;
 
 
188
  }
189
 
190
  if( $_POST['action'] == 'powerpress-save-tags' )
@@ -432,15 +445,16 @@ function powerpress_admin_init()
432
  {
433
  case 'powerpress-delete-feed': {
434
  $delete_slug = $_GET['feed_slug'];
 
435
  check_admin_referer('powerpress-delete-feed-'.$delete_slug);
436
 
437
  $Episodes = powerpress_admin_episodes_per_feed($delete_slug);
438
 
439
- if( $delete_slug == 'podcast' )
440
  {
441
  powerpress_page_message_add_error( __('Cannot delete default podcast feed.') );
442
  }
443
- else if( $Episodes > 0 )
444
  {
445
  powerpress_page_message_add_error( sprintf(__('Cannot delete feed. Feed contains %d episode(s).'), $Episodes) );
446
  }
@@ -536,10 +550,6 @@ function powerpress_admin_init()
536
  }; break;
537
  }
538
  }
539
-
540
-
541
- if( function_exists('powerpress_admin_jquery_init') )
542
- powerpress_admin_jquery_init();
543
 
544
  if( defined('POWERPRESS_PLAYERS') && POWERPRESS_PLAYERS )
545
  powerpress_admin_players_init();
@@ -699,6 +709,13 @@ function powerpress_edit_post($post_ID, $post)
699
  if ( !current_user_can('edit_post', $post_ID) )
700
  return $postID;
701
 
 
 
 
 
 
 
 
702
  $Episodes = $_POST['Powerpress'];
703
 
704
  if( $Episodes )
@@ -728,34 +745,36 @@ function powerpress_edit_post($post_ID, $post)
728
  {
729
  if( strpos($MediaURL, 'http://') !== 0 && strpos($MediaURL, 'https://') !== 0 && $Powerpress['hosting'] != 1 ) // If the url entered does not start with a http:// or https://
730
  {
731
- $Settings = get_option('powerpress_general');
732
- $MediaURL = rtrim(@$Settings['default_url'], '/') .'/'. $MediaURL;
733
  }
734
  }
735
  else
736
  {
737
  if( strpos($MediaURL, 'http://') !== 0 && $Powerpress['hosting'] != 1 ) // If the url entered does not start with a http://
738
  {
739
- $Settings = get_option('powerpress_general');
740
- $MediaURL = rtrim(@$Settings['default_url'], '/') .'/'. $MediaURL;
741
  }
742
  }
743
 
744
  $FileSize = '';
745
  $ContentType = '';
746
  $Duration = false;
747
- $Embed = false;
 
748
 
749
  // Get the content type based on the file extension, first we have to remove query string if it exists
750
  $UrlParts = parse_url($Powerpress['url']);
751
  if( $UrlParts['path'] )
752
  {
753
- // using functions that already exist in Wordpress when possible:
754
- $FileType = powerpress_get_contenttype($UrlParts['path']);
755
- if( $FileType )
756
- $ContentType = $FileType;
757
- else
758
- $ContentType = 'application/binary';
 
 
 
759
  }
760
 
761
  //Set the duration specified by the user
@@ -776,60 +795,51 @@ function powerpress_edit_post($post_ID, $post)
776
  {
777
  if( @$Powerpress['set_size'] == 0 || @$Powerpress['set_duration'] == 0 )
778
  {
779
- $Settings = get_option('powerpress_general');
780
-
781
- // Get meta info via API
782
- $api_url = sprintf('%s/media/%s/%s?format=json&info=true', rtrim(POWERPRESS_BLUBRRY_API_URL, '/'), $Settings['blubrry_program_keyword'], $Powerpress['url'] );
783
- $content = powerpress_remote_fopen($api_url, $Settings['blubrry_auth']);
784
- if( $content )
785
  {
786
- $MediaInfo = powerpress_json_decode($content);
787
  if( @$Powerpress['set_size'] == 0 )
788
  $FileSize = $MediaInfo['length'];
789
  if( @$Powerpress['set_duration'] == 0 )
790
- $Duration = $Duration = powerpress_readable_duration($MediaInfo['duration'], true);
 
 
 
 
 
 
791
  }
792
  }
793
  }
794
  else
795
  {
796
- // Lets use the mp3info class:
797
- require_once(dirname(__FILE__).'/mp3info.class.php');
798
-
799
- $Mp3Info = new Mp3Info();
800
- if( $Powerpress['set_duration'] == 0 && $ContentType == 'audio/mpeg' )
801
  {
802
- $Mp3Data = $Mp3Info->GetMp3Info($MediaURL);
803
- if( $Mp3Data )
 
 
 
804
  {
805
- if( @$Powerpress['set_size'] == 0 )
806
- $FileSize = $Mp3Info->GetContentLength();
807
- $Duration = $Mp3Data['playtime_string'];
808
- if( substr_count($Duration, ':' ) == 0 )
809
- {
810
- if( $Duration < 60 )
811
- $Duration = '00:00:'.$Duration;
812
  }
813
- else if( substr_count($Duration, ':' ) == 1 )
814
  {
815
- $Duration = '00:'.$Duration;
816
- }
817
- $Duration = powerpress_readable_duration($Duration, true); // Fix so it looks better when viewed for editing
818
- }
819
- }
820
 
821
- // Just get the file size
822
- if( $Powerpress['set_size'] == 0 && $FileSize == '' )
823
- {
824
- $headers = wp_get_http_headers($MediaURL);
825
- if( $headers && $headers['content-length'] )
826
- {
827
- $FileSize = (int) $headers['content-length'];
828
- }
829
  }
830
  }
831
  }
832
 
 
833
  $EnclosureData = $MediaURL . "\n" . $FileSize . "\n". $ContentType;
834
  $ToSerialize = array();
835
  // iTunes duration
@@ -879,11 +889,10 @@ function powerpress_edit_post($post_ID, $post)
879
  } // Loop through posted episodes...
880
  }
881
 
882
- if( $post->post_status == 'publish' || $post->post_status == 'private' )
 
883
  {
884
- $Settings = get_option('powerpress_general');
885
-
886
- if( $Settings['blubrry_hosting'] )
887
  powerpress_process_hosting($post_ID, $post->post_title); // Call anytime blog post is in the published state
888
  }
889
 
@@ -895,7 +904,21 @@ add_action('edit_post', 'powerpress_edit_post', 10, 2);
895
  // Do the iTunes pinging here...
896
  function powerpress_publish_post($post_id)
897
  {
898
- powerpress_do_ping_itunes($post_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
899
  }
900
 
901
  add_action('publish_post', 'powerpress_publish_post');
@@ -903,7 +926,15 @@ add_action('publish_post', 'powerpress_publish_post');
903
  // Admin page, html meta header
904
  function powerpress_admin_head()
905
  {
906
- if( strstr($_GET['page'], 'powerpress' ) )
 
 
 
 
 
 
 
 
907
  {
908
  ?>
909
  <script type="text/javascript">
@@ -982,7 +1013,7 @@ function powerpress_changemode(Mode)
982
  </style>
983
  <?php
984
  }
985
- else
986
  {
987
  ?>
988
  <style type="text/css">
@@ -1018,6 +1049,7 @@ function powerpress_changemode(Mode)
1018
  }
1019
  </style>
1020
  <script language="javascript">
 
1021
  function powerpress_check_url(url)
1022
  {
1023
  var DestDiv = 'powerpress_warning';
@@ -1068,6 +1100,11 @@ function powerpress_check_url(url)
1068
  </script>
1069
  <?php
1070
  }
 
 
 
 
 
1071
  }
1072
 
1073
  add_action('admin_head', 'powerpress_admin_head');
@@ -1417,7 +1454,10 @@ function powerpress_remote_fopen($url, $basic_auth = false, $post_args = array()
1417
  $error = curl_errno($curl);
1418
  curl_close($curl);
1419
  if( $error )
 
 
1420
  return false;
 
1421
  return $content;
1422
  }
1423
 
@@ -1508,10 +1548,12 @@ function powerpress_process_hosting($post_ID, $post_title)
1508
  {
1509
  $errors = array();
1510
  $Settings = get_option('powerpress_general');
1511
- $CustomFeeds = array('podcast'=>'podcast');
1512
  if( is_array($Settings['custom_feeds']) )
1513
  $CustomFeeds = $Settings['custom_feeds'];
1514
-
 
 
1515
  while( list($feed_slug,$null) = each($CustomFeeds) )
1516
  {
1517
  $field = 'enclosure';
@@ -1528,6 +1570,7 @@ function powerpress_process_hosting($post_ID, $post_title)
1528
  $EpisodeData = unserialize($Serialized);
1529
  if( strtolower(substr($EnclosureURL, 0, 7) ) != 'http://' && $EpisodeData && isset($EpisodeData['hosting']) && $EpisodeData['hosting'] )
1530
  {
 
1531
  $error = false;
1532
  // First we need to get media information...
1533
 
@@ -1553,6 +1596,7 @@ function powerpress_process_hosting($post_ID, $post_title)
1553
  else if( isset($results['error']) )
1554
  {
1555
  $error = 'Blubrry Hosting Error (media info): '. $results['error'];
 
1556
  }
1557
  else
1558
  {
@@ -1560,10 +1604,13 @@ function powerpress_process_hosting($post_ID, $post_title)
1560
  $error = 'Blubrry Hosting Error (publish): An error occurred publishing media '. $EnclosureURL .'.';
1561
  $error .= '<a href="#" onclick="document.getElementById(\'powerpress_error_'. $rand_id .'\');this.style.display=\'none\';return false;">Display Error</a>';
1562
  $error .= '<div id="powerpress_error_'. $rand_id .'" style="display: none;">'. $json_data .'</div>';
 
1563
  }
1564
 
1565
  if( $error == false )
1566
  {
 
 
1567
  $api_url = sprintf('%s/media/%s/%s?format=json&publish=true', rtrim(POWERPRESS_BLUBRRY_API_URL, '/'), urlencode($Settings['blubrry_program_keyword']), urlencode($EnclosureURL) );
1568
  $json_data = powerpress_remote_fopen($api_url, $Settings['blubrry_auth'], array(), 60*30); // give this up to 30 minutes, though 3 seocnds to 20 seconds is all one should need.
1569
  $results = powerpress_json_decode($json_data);
@@ -1578,7 +1625,7 @@ function powerpress_process_hosting($post_ID, $post_title)
1578
  else if( isset($results['error']) )
1579
  {
1580
  $error = 'Blubrry Hosting Error (publish): '. $results['error'];
1581
-
1582
  }
1583
  else
1584
  {
@@ -1586,26 +1633,12 @@ function powerpress_process_hosting($post_ID, $post_title)
1586
  $error = 'Blubrry Hosting Error (publish): An error occurred publishing media <em>'. $EnclosureURL .'</em>. ';
1587
  $error .= '<a href="#" onclick="document.getElementById(\'powerpress_error_'. $rand_id .'\');this.style.display=\'none\';return false;">Display Error</a>';
1588
  $error .= '<div id="powerpress_error_'. $rand_id .'" style="display: none;">'. $json_data .'</div>';
 
1589
  }
1590
  }
1591
-
1592
- if( $error )
1593
- {
1594
- $errors[] = $error;
1595
- // TODO Need to print an eerror message at the top of the screen
1596
- //mail('cio@rawvoice.com', 'Publishing From WordPress', print_r( array('file'=>$EnclosureURL, 'episode_data'=>$EpisodeData, 'error'=>$g_powerpress_error), true) );
1597
- }
1598
- // Make the API call here to publish media file...
1599
- //
1600
  }
1601
  }
1602
  }
1603
-
1604
- if( count($errors) > 0 )
1605
- {
1606
- add_option('powerpress_errors', $errors);
1607
- }
1608
-
1609
  }
1610
 
1611
  function powerpress_json_decode($value)
@@ -1863,6 +1896,119 @@ function powerpress_get_media_info($file)
1863
  return array('error'=>'Error occurred obtaining media information.');
1864
  }
1865
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1866
  require_once( dirname(__FILE__).'/powerpressadmin-jquery.php');
1867
  // Only include the dashboard when appropriate.
1868
  require_once(dirname(__FILE__).'/powerpressadmin-dashboard.php');
26
  {
27
  global $wp_rewrite;
28
 
29
+ add_thickbox(); // we use the thckbox for some settings
30
+
31
+ if( function_exists('powerpress_admin_jquery_init') )
32
+ powerpress_admin_jquery_init();
33
+
34
  if( !current_user_can('manage_options') )
35
  {
36
  powerpress_page_message_add_error( __('You do not have sufficient permission to manage options.') );
54
  $VersionDiff = version_compare($wp_version, 2.6);
55
  if( $VersionDiff < 0 )
56
  powerpress_page_message_add_error( __('Blubrry PowerPress requires Wordpress version 2.6 or greater.') );
57
+
 
58
 
59
  // Save settings here
60
  if( isset($_POST[ 'Feed' ]) || isset($_POST[ 'General' ]) )
149
  powerpress_page_message_add_error( 'Invalid Coverat image: ' . htmlspecialchars($_FILES['coverart_image_file']['name']) );
150
  }
151
  }
152
+
153
+ if( isset($_POST['UpdateDisablePlayer']) )
154
+ {
155
+ $General['disable_player'] = array();
156
+ if( isset($_POST['DisablePlayer']) )
157
+ $General['disable_player'] = $_POST['DisablePlayer'];
158
+ }
159
 
160
 
161
  // Check to see if we need to update the feed title
196
  $General['episode_box_subtitle'] = 0;
197
  if( !isset($General['episode_box_summary'] ) )
198
  $General['episode_box_summary'] = 0;
199
+ if( !isset($General['episode_box_explicit'] ) )
200
+ $General['episode_box_explicit'] = 0;
201
  }
202
 
203
  if( $_POST['action'] == 'powerpress-save-tags' )
445
  {
446
  case 'powerpress-delete-feed': {
447
  $delete_slug = $_GET['feed_slug'];
448
+ $force_deletion = @$_GET['force'];
449
  check_admin_referer('powerpress-delete-feed-'.$delete_slug);
450
 
451
  $Episodes = powerpress_admin_episodes_per_feed($delete_slug);
452
 
453
+ if( $delete_slug == 'podcast' && $force_deletion == false )
454
  {
455
  powerpress_page_message_add_error( __('Cannot delete default podcast feed.') );
456
  }
457
+ else if( $Episodes > 0 && $force_deletion == false )
458
  {
459
  powerpress_page_message_add_error( sprintf(__('Cannot delete feed. Feed contains %d episode(s).'), $Episodes) );
460
  }
550
  }; break;
551
  }
552
  }
 
 
 
 
553
 
554
  if( defined('POWERPRESS_PLAYERS') && POWERPRESS_PLAYERS )
555
  powerpress_admin_players_init();
709
  if ( !current_user_can('edit_post', $post_ID) )
710
  return $postID;
711
 
712
+ $GeneralSettings = get_option('powerpress_general');
713
+
714
+ if( isset($GeneralSettings['auto_enclose']) && $GeneralSettings['auto_enclose'] )
715
+ {
716
+ powerpress_do_enclose($post->post_content, $post_ID, ($GeneralSettings['auto_enclose']==2) );
717
+ }
718
+
719
  $Episodes = $_POST['Powerpress'];
720
 
721
  if( $Episodes )
745
  {
746
  if( strpos($MediaURL, 'http://') !== 0 && strpos($MediaURL, 'https://') !== 0 && $Powerpress['hosting'] != 1 ) // If the url entered does not start with a http:// or https://
747
  {
748
+ $MediaURL = rtrim(@$GeneralSettings['default_url'], '/') .'/'. $MediaURL;
 
749
  }
750
  }
751
  else
752
  {
753
  if( strpos($MediaURL, 'http://') !== 0 && $Powerpress['hosting'] != 1 ) // If the url entered does not start with a http://
754
  {
755
+ $MediaURL = rtrim(@$GeneralSettings['default_url'], '/') .'/'. $MediaURL;
 
756
  }
757
  }
758
 
759
  $FileSize = '';
760
  $ContentType = '';
761
  $Duration = false;
762
+ if( $Powerpress['set_duration'] == 0 )
763
+ $Duration = ''; // allow the duration to be detected
764
 
765
  // Get the content type based on the file extension, first we have to remove query string if it exists
766
  $UrlParts = parse_url($Powerpress['url']);
767
  if( $UrlParts['path'] )
768
  {
769
+ // using functions that already exist in WordPress when possible:
770
+ $ContentType = powerpress_get_contenttype($UrlParts['path']);
771
+ }
772
+
773
+ if( !$ContentType )
774
+ {
775
+ $error = __('Error') ." [{$Powerpress['url']}]: " .__('Unable to determine content type of media (e.g. audio/mpeg). Verify file extension is correct and try again.');
776
+ powerpress_add_error($error);
777
+ continue;
778
  }
779
 
780
  //Set the duration specified by the user
795
  {
796
  if( @$Powerpress['set_size'] == 0 || @$Powerpress['set_duration'] == 0 )
797
  {
798
+ $MediaInfo = powerpress_get_media_info($Powerpress['url']);
799
+ if( !isset($MediaInfo['error']) )
 
 
 
 
800
  {
 
801
  if( @$Powerpress['set_size'] == 0 )
802
  $FileSize = $MediaInfo['length'];
803
  if( @$Powerpress['set_duration'] == 0 )
804
+ $Duration = powerpress_readable_duration($MediaInfo['duration'], true);
805
+ }
806
+ else
807
+ {
808
+ $error = __('Error') ." ({$Powerpress['url']}): {$MediaInfo['error']}";
809
+ powerpress_add_error($error);
810
+ continue;
811
  }
812
  }
813
  }
814
  else
815
  {
816
+ $MediaInfo = powerpress_get_media_info_local($MediaURL, $ContentType, 0, $Duration);
817
+ if( isset($MediaInfo['error']) )
 
 
 
818
  {
819
+ $error = __('Error') ." ({$MediaURL}): {$MediaInfo['error']}";
820
+ powerpress_add_error($error);
821
+ continue;
822
+ }
823
+ else if( empty($MediaInfo['length']) )
824
  {
825
+ $error = __('Error') ." ({$MediaURL}): ". __('Unable to obtain size of media.');
826
+ powerpress_add_error($error);
827
+ continue;
 
 
 
 
828
  }
829
+ else
830
  {
831
+ // Detect the duration
832
+ if( $Powerpress['set_duration'] == 0 && $MediaInfo['duration'] )
833
+ $Duration = powerpress_readable_duration($MediaInfo['duration'], true); // Fix so it looks better when viewed for editing
 
 
834
 
835
+ // Detect the file size
836
+ if( $Powerpress['set_size'] == 0 && $MediaInfo['length'] > 0 )
837
+ $FileSize = $MediaInfo['length'];
 
 
 
 
 
838
  }
839
  }
840
  }
841
 
842
+ // If we made if this far, we have the content type and file size...
843
  $EnclosureData = $MediaURL . "\n" . $FileSize . "\n". $ContentType;
844
  $ToSerialize = array();
845
  // iTunes duration
889
  } // Loop through posted episodes...
890
  }
891
 
892
+ // Anytime the post is marked published, private or scheduled for the future we need to make sure we're making the media available for hosting
893
+ if( $post->post_status == 'publish' || $post->post_status == 'private' || $post->post_status == 'future' )
894
  {
895
+ if( $GeneralSettings['blubrry_hosting'] )
 
 
896
  powerpress_process_hosting($post_ID, $post->post_title); // Call anytime blog post is in the published state
897
  }
898
 
904
  // Do the iTunes pinging here...
905
  function powerpress_publish_post($post_id)
906
  {
907
+ // Delete scheduled _encloseme requests...
908
+ global $wpdb;
909
+ $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE meta_key = '_encloseme' ");
910
+
911
+ $GeneralSettings = get_option('powerpress_general');
912
+ if( isset($GeneralSettings['auto_enclose']) && $GeneralSettings['auto_enclose'] )
913
+ {
914
+ $post = &get_post($post_id);
915
+ powerpress_do_enclose($post->post_content, $post_id, ($GeneralSettings['auto_enclose']==2) );
916
+ }
917
+
918
+ if( isset($GeneralSettings['ping_itunes']) && $GeneralSettings['ping_itunes'] )
919
+ {
920
+ powerpress_do_ping_itunes($post_id);
921
+ }
922
  }
923
 
924
  add_action('publish_post', 'powerpress_publish_post');
926
  // Admin page, html meta header
927
  function powerpress_admin_head()
928
  {
929
+ global $parent_file, $hook_suffix;
930
+ $page_name = '';
931
+ if ( isset($parent_file) && !empty($parent_file) )
932
+ $page_name = substr($parent_file, 0, -4);
933
+ else
934
+ $page_name = str_replace(array('.php', '-new', '-add'), '', $hook_suffix);
935
+
936
+ // Powerpress page
937
+ if( strstr($page_name, 'powerpress' ) )
938
  {
939
  ?>
940
  <script type="text/javascript">
1013
  </style>
1014
  <?php
1015
  }
1016
+ else if( $page_name == 'edit' || $page_name == 'edit-pages' ) // || $page_name == '' ) // we don't know the page, we better include our CSS just in case
1017
  {
1018
  ?>
1019
  <style type="text/css">
1049
  }
1050
  </style>
1051
  <script language="javascript">
1052
+
1053
  function powerpress_check_url(url)
1054
  {
1055
  var DestDiv = 'powerpress_warning';
1100
  </script>
1101
  <?php
1102
  }
1103
+ else
1104
+ {
1105
+ // Print this line for debugging when loooking for other pages to include header data for
1106
+ //echo "<!-- WP Page Name: $page_name; Hook Suffix: $hook_suffix -->\n";
1107
+ }
1108
  }
1109
 
1110
  add_action('admin_head', 'powerpress_admin_head');
1454
  $error = curl_errno($curl);
1455
  curl_close($curl);
1456
  if( $error )
1457
+ {
1458
+ global $g_powerpress_remote_error;
1459
  return false;
1460
+ }
1461
  return $content;
1462
  }
1463
 
1548
  {
1549
  $errors = array();
1550
  $Settings = get_option('powerpress_general');
1551
+ $CustomFeeds = array();
1552
  if( is_array($Settings['custom_feeds']) )
1553
  $CustomFeeds = $Settings['custom_feeds'];
1554
+ if( !isset($CustomFeeds['podcast']) )
1555
+ $CustomFeeds['podcast'] = 'podcast';
1556
+
1557
  while( list($feed_slug,$null) = each($CustomFeeds) )
1558
  {
1559
  $field = 'enclosure';
1570
  $EpisodeData = unserialize($Serialized);
1571
  if( strtolower(substr($EnclosureURL, 0, 7) ) != 'http://' && $EpisodeData && isset($EpisodeData['hosting']) && $EpisodeData['hosting'] )
1572
  {
1573
+
1574
  $error = false;
1575
  // First we need to get media information...
1576
 
1596
  else if( isset($results['error']) )
1597
  {
1598
  $error = 'Blubrry Hosting Error (media info): '. $results['error'];
1599
+ powerpress_add_error($error);
1600
  }
1601
  else
1602
  {
1604
  $error = 'Blubrry Hosting Error (publish): An error occurred publishing media '. $EnclosureURL .'.';
1605
  $error .= '<a href="#" onclick="document.getElementById(\'powerpress_error_'. $rand_id .'\');this.style.display=\'none\';return false;">Display Error</a>';
1606
  $error .= '<div id="powerpress_error_'. $rand_id .'" style="display: none;">'. $json_data .'</div>';
1607
+ powerpress_add_error($error);
1608
  }
1609
 
1610
  if( $error == false )
1611
  {
1612
+ // Extend the max execution time here
1613
+ set_time_limit(60*20); // give it 10 minutes just in case
1614
  $api_url = sprintf('%s/media/%s/%s?format=json&publish=true', rtrim(POWERPRESS_BLUBRRY_API_URL, '/'), urlencode($Settings['blubrry_program_keyword']), urlencode($EnclosureURL) );
1615
  $json_data = powerpress_remote_fopen($api_url, $Settings['blubrry_auth'], array(), 60*30); // give this up to 30 minutes, though 3 seocnds to 20 seconds is all one should need.
1616
  $results = powerpress_json_decode($json_data);
1625
  else if( isset($results['error']) )
1626
  {
1627
  $error = 'Blubrry Hosting Error (publish): '. $results['error'];
1628
+ powerpress_add_error($error);
1629
  }
1630
  else
1631
  {
1633
  $error = 'Blubrry Hosting Error (publish): An error occurred publishing media <em>'. $EnclosureURL .'</em>. ';
1634
  $error .= '<a href="#" onclick="document.getElementById(\'powerpress_error_'. $rand_id .'\');this.style.display=\'none\';return false;">Display Error</a>';
1635
  $error .= '<div id="powerpress_error_'. $rand_id .'" style="display: none;">'. $json_data .'</div>';
1636
+ powerpress_add_error($error);
1637
  }
1638
  }
 
 
 
 
 
 
 
 
 
1639
  }
1640
  }
1641
  }
 
 
 
 
 
 
1642
  }
1643
 
1644
  function powerpress_json_decode($value)
1896
  return array('error'=>'Error occurred obtaining media information.');
1897
  }
1898
 
1899
+ // Call this function when there is no enclosure currently detected for the post but users set the option to auto-add first media file linked within post option is checked.
1900
+ function powerpress_do_enclose( $content, $post_ID, $use_last_media_link = false )
1901
+ {
1902
+ $ltrs = '\w';
1903
+ $gunk = '/#~:.?+=&%@!\-';
1904
+ $punc = '.:?\-';
1905
+ $any = $ltrs . $gunk . $punc;
1906
+
1907
+ preg_match_all( "{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp );
1908
+
1909
+ if( $use_last_media_link )
1910
+ $post_links_temp[0] = array_reverse($post_links_temp[0]);
1911
+
1912
+ $enclosure = false;
1913
+ foreach ( (array) $post_links_temp[0] as $link_test ) {
1914
+ $test = parse_url( $link_test );
1915
+ // Wordpress also acecpts query strings, which doesn't matter to us what's more important is taht the request ends with a file extension.
1916
+ // get the file extension at the end of the request:
1917
+ if( preg_match('/\.([a-z0-9]{2,7})$/i', $link_test, $matches) )
1918
+ {
1919
+ // see if the file extension is one of the supported media types...
1920
+ $content_type = powerpress_get_contenttype('test.'.$matches[1], false); // we want to strictly use the content types known for media, so pass false for second argument
1921
+ if( $content_type )
1922
+ {
1923
+ $enclosure = $link_test;
1924
+ $MediaInfo = powerpress_get_media_info_local($link_test, $content_type);
1925
+ if( !isset($MediaInfo['error']) && !empty($MediaInfo['length']) )
1926
+ {
1927
+ // Insert enclosure here:
1928
+ $EnclosureData = $link_test . "\n" . $MediaInfo['length'] . "\n". $content_type;
1929
+ if( !empty($MediaInfo['duration']) )
1930
+ $EnclosureData .= "\n".serialize( array('duration'=>$MediaInfo['duration']) );
1931
+ add_post_meta($post_ID, 'enclosure', $EnclosureData, true);
1932
+ break; // We don't wnat to insert anymore enclosures, this was it!
1933
+ }
1934
+ }
1935
+ }
1936
+ }
1937
+ }
1938
+
1939
+ function powerpress_get_media_info_local($media_file, $content_type='', $file_size=0, $duration='')
1940
+ {
1941
+ $error_msg = '';
1942
+ if( $content_type == '' )
1943
+ $content_type = powerpress_get_contenttype($media_file);
1944
+
1945
+ if( $content_type == '' )
1946
+ return array('error'=>'Unable to detect content type.');
1947
+
1948
+ if( $content_type == 'audio/mpeg' && $duration === '' ) // if duration has a value or is set to false then we don't want to try to obtain it here...
1949
+ {
1950
+ // Lets use the mp3info class:
1951
+ require_once(dirname(__FILE__).'/mp3info.class.php');
1952
+ $Mp3Info = new Mp3Info();
1953
+ $Mp3Data = $Mp3Info->GetMp3Info($media_file);
1954
+ if( $Mp3Data )
1955
+ {
1956
+ if( $file_size == 0 )
1957
+ $file_size = $Mp3Info->GetContentLength();
1958
+
1959
+ $duration = powerpress_readable_duration($Mp3Data['playtime_string'], true); // Fix so it looks better when viewed for editing
1960
+ }
1961
+ else
1962
+ {
1963
+ if( $Mp3Info->GetError() )
1964
+ return array('error'=>$Mp3Info->GetError() );
1965
+ else
1966
+ return array('error'=>'Error occurred obtaining media information.');
1967
+ }
1968
+ }
1969
+
1970
+ if( $content_type != '' && $file_size == 0 )
1971
+ {
1972
+ $response = wp_remote_head( $media_file );
1973
+ if ( is_wp_error( $response ) )
1974
+ {
1975
+ return array('error'=>$response->get_error_message() );
1976
+ }
1977
+
1978
+ if( isset($response['response']['code']) && $response['response']['code'] < 200 || $response['response']['code'] > 290 )
1979
+ {
1980
+ return array('error'=>trim('Error, HTTP '.$response['response']['code']) );
1981
+ }
1982
+
1983
+ $headers = wp_remote_retrieve_headers( $response );
1984
+
1985
+ if( $headers && strstr($headers['content-type'], 'text') )
1986
+ {
1987
+ return array('error'=>'Invalid content type returned from server.' );
1988
+ }
1989
+
1990
+ //$headers = wp_get_http_headers($media_file);
1991
+ if( $headers && $headers['content-length'] )
1992
+ $file_size = (int) $headers['content-length'];
1993
+ }
1994
+
1995
+ if( $file_size == 0 )
1996
+ return array('error'=>'Error occurred obtaining media file size.' );
1997
+
1998
+ return array('content-type'=>$content_type, 'length'=>$file_size, 'duration'=>$duration);
1999
+ }
2000
+
2001
+ function powerpress_add_error($error)
2002
+ {
2003
+ $Errors = get_option('powerpress_errors');
2004
+ if( !is_array($Errors) )
2005
+ $Errors = array();
2006
+ $Errors[] = $error;
2007
+ update_option('powerpress_errors', $Errors);
2008
+ }
2009
+
2010
+
2011
+
2012
  require_once( dirname(__FILE__).'/powerpressadmin-jquery.php');
2013
  // Only include the dashboard when appropriate.
2014
  require_once(dirname(__FILE__).'/powerpressadmin-dashboard.php');
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Angelo Mandato, Blubrry.com
3
  Tags: podcast, podcasting, itunes, enclosure, zune, iphone, youtube, viddler, blip.tv, audio, video, rss2, feed, player, media, rss, mp3, music, embed, feedburner, statistics, stats, flv, flash, id3, episodes, blubrry
4
  Requires at least: 2.6.0
5
  Tested up to: 2.8.4
6
- Stable tag: 0.9.5
7
 
8
  Add podcasting support to your blog.
9
 
@@ -85,6 +85,31 @@ As a alternative, PowerPress allows you to create additional Custom Podcast Feed
85
 
86
  == Changelog ==
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  = 0.9.5 =
89
  * Released on 8/15/2009
90
  * Redirect logic enhanced to track in page plays for users using the Blubrry/RawVoice/TechPodcasts statistics redirect system.
@@ -216,6 +241,8 @@ Pat McSweeny, Developer for [RawVoice](http://www.rawvoice.com) - Developed init
216
 
217
  Jerry Stephens, Way of the Geek [wayofthegeek.org](http://wayofthegeek.org) - Contributed initial code fix for excerpt bug resolved in v0.6.1
218
 
 
 
219
 
220
  == Feedback ==
221
  http://www.blubrry.com/powerpress/
3
  Tags: podcast, podcasting, itunes, enclosure, zune, iphone, youtube, viddler, blip.tv, audio, video, rss2, feed, player, media, rss, mp3, music, embed, feedburner, statistics, stats, flv, flash, id3, episodes, blubrry
4
  Requires at least: 2.6.0
5
  Tested up to: 2.8.4
6
+ Stable tag: 0.9.6
7
 
8
  Add podcasting support to your blog.
9
 
85
 
86
  == Changelog ==
87
 
88
+ = 0.9.6 =
89
+ * Released on 8/31/2009
90
+ * Added Auto Add Media option, auto adds first/last media link found in post content. (default is off)
91
+ * Added option in Appearance settings to disable player per custom podcast feed basis.
92
+ * Added option to Episode Entry Box Custom Mode to select iTunes Explicit setting on a per episode basis.
93
+ * Added note when in simple mode if there are advanced mode settings that take precedence.
94
+ * Fixed bug with language setting not getting applied to the default PowerPress custom podcast feed in some cases.
95
+ * Fixed a bug in the getid3 library where it would occasionally not detect the media duration.
96
+ * Detecting mp3 duration change, increased the amount of the file downloaded from 25k to 40k for users who have a lot of tags in their mp3 files.
97
+ * Consolidated duplicate code for detecting media information.
98
+ * Display error message when PowerPress cannot detect media file content type.
99
+ * Display error message when PowerPress cannot detect media file size and duration information.
100
+ * Display error message when PowerPress encounters an error with Blubrry Services.
101
+ * Stream lined code for loading PowerPress general and feed settings.
102
+ * Added more agressive code to prevent WordPress from deleting enclosures when scheduling blog posts.
103
+ * Improved the look of the AJAX windows for selecting media/configuring services.
104
+ * Fixed bug where 'more' link for statistics would fail if user was not a blog admin.
105
+ * Added code to admin_head() function so css/js only included on appropriate pages (Thanks @Frumph!).
106
+ * Made Default Podcast Episode first media player listed when displaying multiple players on page.
107
+ * Blubrry Media Hosting list of uploaded media screen enhanced with new in-page media upload option and monthly quota information.
108
+ * Fixed bug with Podcast Category feed links to FeedValidator (thanks Darcy Fiander).
109
+ * Fixed bug with Podcast Category feed title not matching the feed image title FeedValidator (thanks Darcy Fiander).
110
+ * Fixed Windows Media embed issue with Firefox 3.x+ and re-added note to use the Firefox Windows Media addon.
111
+
112
+
113
  = 0.9.5 =
114
  * Released on 8/15/2009
115
  * Redirect logic enhanced to track in page plays for users using the Blubrry/RawVoice/TechPodcasts statistics redirect system.
241
 
242
  Jerry Stephens, Way of the Geek [wayofthegeek.org](http://wayofthegeek.org) - Contributed initial code fix for excerpt bug resolved in v0.6.1
243
 
244
+ Darcy Fiander, Rooty Radio (http://rootyradio.com) - Fixed bug with category links to FeedValidator.org and category title warning when validating category feeds.
245
+
246
 
247
  == Feedback ==
248
  http://www.blubrry.com/powerpress/