PowerPress Podcasting plugin by Blubrry - Version 7.5.2

Version Description

  • Released on 7/25/2019
  • Fixed logic bug introduced in 7.5 for sites using versions of PHP 5.4 or older.
  • Added code changes to Blubrry Hosting's Post to Social from PowerPress feature. (Last beta release of this feature!)
Download this release

Release Info

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

Code changes from version 7.5.1 to 7.5.2

Files changed (3) hide show
  1. powerpress.php +3867 -3867
  2. powerpressadmin-pts.php +59 -39
  3. readme.txt +500 -496
powerpress.php CHANGED
@@ -1,3868 +1,3868 @@
1
- <?php
2
- /*
3
- Plugin Name: Blubrry PowerPress
4
- Plugin URI: http://create.blubrry.com/resources/powerpress/
5
- Description: <a href="http://create.blubrry.com/resources/powerpress/" target="_blank">Blubrry PowerPress</a> is the No. 1 Podcasting plugin for WordPress. Developed by podcasters for podcasters; features include Simple and Advanced modes, multiple audio/video player options, subscribe to podcast tools, podcast SEO features, and more! Fully supports Apple Podcasts (previously iTunes), Google Podcasts, Spotify, Stitcher, and Blubrry Podcasting directories, as well as all podcast applications and clients.
6
- Version: 7.5.1
7
- Author: Blubrry
8
- Author URI: http://www.blubrry.com/
9
- Requires at least: 3.6
10
- Tested up to: 5.2.2
11
- Text Domain: powerpress
12
- Change Log:
13
- Please see readme.txt for detailed change log.
14
-
15
- Contributors:
16
- Angelo Mandato, CIO Blubrry - Plugin founder, architect and lead developer
17
- See readme.txt for full list of contributors.
18
-
19
- Credits:
20
- getID3(), License: GPL 2.0+ by James Heinrich <info [at] getid3.org> http://www.getid3.org
21
- Note: getid3.php analyze() function modified to prevent redundant filesize() function call.
22
-
23
- Copyright 2008-2019 Blubrry (http://www.blubrry.com)
24
-
25
- License: GPL (http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt)
26
-
27
- This project uses source that is GPL licensed.
28
- */
29
-
30
-
31
- if( !function_exists('add_action') ) {
32
- header( 'Status: 403 Forbidden' );
33
- header( 'HTTP/1.1 403 Forbidden' );
34
- exit();
35
- }
36
-
37
- // WP_PLUGIN_DIR (REMEMBER TO USE THIS DEFINE IF NEEDED)
38
- define('POWERPRESS_VERSION', '7.5.1' );
39
-
40
- // Translation support:
41
- if ( !defined('POWERPRESS_ABSPATH') )
42
- define('POWERPRESS_ABSPATH', dirname(__FILE__) );
43
-
44
-
45
-
46
- /////////////////////////////////////////////////////
47
- // The following define options should be placed in your
48
- // wp-config.php file so the setting is not disrupted when
49
- // you upgrade the plugin.
50
- /////////////////////////////////////////////////////
51
-
52
- if( !defined('POWERPRESS_BLUBRRY_API_URL') )
53
- define('POWERPRESS_BLUBRRY_API_URL', 'http://api.blubrry.com/');
54
-
55
- // Replace validator service with one that is more reliable here:
56
- define('POWERPRESS_FEEDVALIDATOR_URL', 'http://castfeedvalidator.com/?url=');
57
-
58
- // Display custom play image for quicktime media. Applies to on page player only.
59
- //define('POWERPRESS_PLAY_IMAGE', 'http://www.blubrry.com/themes/blubrry/images/player/PlayerBadge150x50NoBorder.jpg');
60
-
61
- if( !defined('POWERPRESS_CONTENT_ACTION_PRIORITY') )
62
- define('POWERPRESS_CONTENT_ACTION_PRIORITY', 10 );
63
-
64
- // Added so administrators can customize what capability is needed for PowerPress
65
- if( !defined('POWERPRESS_CAPABILITY_MANAGE_OPTIONS') )
66
- define('POWERPRESS_CAPABILITY_MANAGE_OPTIONS', 'manage_options');
67
- if( !defined('POWERPRESS_CAPABILITY_EDIT_PAGES') )
68
- define('POWERPRESS_CAPABILITY_EDIT_PAGES', 'edit_pages');
69
-
70
- //define('POWERPRESS_ENABLE_HTTPS_MEDIA', true); // Add this define to your wp-config.php if you wnat to allow media URLs that begin with https://
71
-
72
- // Define variables, advanced users could define these in their own wp-config.php so lets not try to re-define
73
- if( !defined('POWERPRESS_LINK_SEPARATOR') )
74
- define('POWERPRESS_LINK_SEPARATOR', '|');
75
- if( !defined('POWERPRESS_TEXT_SEPARATOR') )
76
- define('POWERPRESS_TEXT_SEPARATOR', ':');
77
- if( !defined('POWERPRESS_PLAY_IMAGE') )
78
- define('POWERPRESS_PLAY_IMAGE', 'play_video_default.jpg');
79
- if( !defined('PHP_EOL') )
80
- define('PHP_EOL', "\n"); // We need this variable defined for new lines.
81
- if( defined('POWERPRESS_DEBUG') ) {
82
- if( !defined('PHP_EOL_WEB') ) {
83
- define('PHP_EOL_WEB', "\n"); // Helps with readability
84
- }
85
- } else {
86
- if( !defined('PHP_EOL_WEB') ) {
87
- define('PHP_EOL_WEB', ''); // We don't necessarily need new lines for web output
88
- }
89
- }
90
-
91
- if( !defined('POWERPRESS_SUBSCRIBE') )
92
- define('POWERPRESS_SUBSCRIBE', true);
93
- if(!defined('POWERPRESS_NEW_APPLE_CATEGORIES')) {
94
- define('POWERPRESS_NEW_APPLE_CATEGORIES', true);
95
- }
96
- // Set regular expression values for determining mobile devices
97
- if( !defined('POWERPRESS_MOBILE_REGEX') )
98
- define('POWERPRESS_MOBILE_REGEX', 'iphone|ipod|ipad|aspen|android|blackberry|opera mini|webos|incognito|webmate|silk');
99
-
100
- $powerpress_feed = NULL; // DO NOT CHANGE
101
-
102
- function powerpress_content($content)
103
- {
104
- global $post, $g_powerpress_excerpt_post_id;
105
-
106
- if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) || defined('PODCASTING_VERSION') )
107
- return $content;
108
-
109
- if( empty($post->ID) || !is_object($post) )
110
- return $content;
111
-
112
- if( defined('POWERPRESS_DO_ENCLOSE_FIX') )
113
- $content = preg_replace('/\<!--.*added by PowerPress.*-->/im', '', $content );
114
-
115
- if( is_feed() )
116
- return $content; // We don't want to do anything to the feed
117
-
118
- if( function_exists('post_password_required') )
119
- {
120
- if( post_password_required($post) )
121
- return $content;
122
- }
123
-
124
- // PowerPress settings:
125
- $GeneralSettings = get_option('powerpress_general');
126
-
127
- // No player or links to add to content...
128
- if( !empty($GeneralSettings['disable_appearance']) )
129
- return $content;
130
-
131
- // check for themes/plugins where we know we need to do this...
132
- if( empty($GeneralSettings['player_aggressive']) )
133
- {
134
- if( !empty($GLOBALS['fb_ver']) && version_compare($GLOBALS['fb_ver'], '1.0', '<=') ) {
135
- $GeneralSettings['player_aggressive'] = 1;
136
- }
137
- if( defined('JETPACK__VERSION') && version_compare(JETPACK__VERSION, '2.0', '>=') ) {
138
- $GeneralSettings['player_aggressive'] = 1; // Jet pack still doesn't behave with PowerPress the_content
139
- }
140
- if( defined('WPSEO_VERSION') ) {
141
- $GeneralSettings['player_aggressive'] = 4;
142
- }
143
- }
144
-
145
- if( !empty($GeneralSettings['player_aggressive']) )
146
- {
147
- if( $GeneralSettings['player_aggressive'] == 4 )
148
- {
149
- $in_http_head = powerpress_in_wp_head();
150
- if( $in_http_head === true )
151
- return $content;
152
- }
153
- else if( $GeneralSettings['player_aggressive'] == 2 ) // If we do not have theme issues then lets keep this logic clean. and only display playes after the wp_head only
154
- {
155
- if( empty($GLOBALS['powerpress_wp_head_completed']) )
156
- return $content;
157
- }
158
- else // method 1 or 3...
159
- {
160
- if( strstr($content, '<!--powerpress_player-->') !== false )
161
- return $content; // The players were already added to the content
162
-
163
- if( $GeneralSettings['player_aggressive'] != 3 && $g_powerpress_excerpt_post_id > 0 )
164
- $g_powerpress_excerpt_post_id = 0; // Hack, set this to zero so it always goes past...
165
-
166
- if( $GeneralSettings['player_aggressive'] == 3 )
167
- $GeneralSettings['player_aggressive'] = 1; // remainder of the system will function as normal
168
- }
169
- }
170
-
171
- // Problem: If the_excerpt is used instead of the_content, both the_exerpt and the_content will be called here.
172
- // Important to note, get_the_excerpt will be called before the_content is called, so we add a simple little hack
173
- if( current_filter() == 'get_the_excerpt' )
174
- {
175
- $g_powerpress_excerpt_post_id = $post->ID;
176
- return $content; // We don't want to do anything to this content yet...
177
- }
178
- else if( current_filter() == 'the_content' && $g_powerpress_excerpt_post_id == $post->ID )
179
- {
180
- return $content; // We don't want to do anything to this excerpt content in this call either...
181
- }
182
- else if( class_exists('custom_post_widget') && powerpress_in_custom_post_widget() )
183
- {
184
- return $content; // Custom Post Widget compatibility
185
- }
186
-
187
-
188
- if( !isset($GeneralSettings['custom_feeds']) )
189
- $GeneralSettings['custom_feeds'] = array('podcast'=>'Default Podcast Feed');
190
- if( empty($GeneralSettings['custom_feeds']['podcast']) )
191
- $GeneralSettings['custom_feeds']['podcast'] = 'Default Podcast Feed';
192
-
193
- // Re-order so the default podcast episode is the top most...
194
- $Temp = $GeneralSettings['custom_feeds'];
195
- $GeneralSettings['custom_feeds'] = array();
196
- $GeneralSettings['custom_feeds']['podcast'] = 'Default Podcast Feed';
197
- foreach( $Temp as $feed_slug=> $feed_title )
198
- {
199
- if( $feed_slug == 'podcast' )
200
- continue;
201
- $GeneralSettings['custom_feeds'][ $feed_slug ] = $feed_title;
202
- }
203
-
204
- // Handle post type feeds....
205
- if( !empty($GeneralSettings['posttype_podcasting']) )
206
- {
207
- $post_type = get_query_var('post_type');
208
- if ( is_array( $post_type ) ) {
209
- $post_type = reset( $post_type ); // get first element in array
210
- }
211
-
212
- // Get the feed slugs and titles for this post type
213
- $PostTypeSettingsArray = get_option('powerpress_posttype_'.$post_type);
214
- // Loop through this array of post type settings...
215
- if( !empty($PostTypeSettingsArray) )
216
- {
217
- switch($post_type)
218
- {
219
- case 'post':
220
- case 'page': {
221
- // Do nothing!, we want the default podcast to appear in these post types
222
- }; break;
223
- default: {
224
- if( !empty($post_type) && empty($PostTypeSettingsArray['podcast']) )
225
- unset($GeneralSettings['custom_feeds']['podcast']); // special case, we do not want an accidental podcast episode to appear in a custom post type if the feature is enabled
226
- }; break;
227
- }
228
-
229
- foreach( $PostTypeSettingsArray as $feed_slug=> $postTypeSettings )
230
- {
231
- if( !empty( $postTypeSettings['title']) )
232
- $GeneralSettings['custom_feeds'][ $feed_slug ] = $postTypeSettings['title'];
233
- else
234
- $GeneralSettings['custom_feeds'][ $feed_slug ] = $feed_slug;
235
- }
236
- }
237
- }
238
-
239
- if( !isset($GeneralSettings['display_player']) )
240
- $GeneralSettings['display_player'] = 1;
241
- if( !isset($GeneralSettings['player_function']) )
242
- $GeneralSettings['player_function'] = 1;
243
- if( !isset($GeneralSettings['podcast_link']) )
244
- $GeneralSettings['podcast_link'] = 1;
245
-
246
- // The blog owner doesn't want anything displayed, so don't bother wasting anymore CPU cycles
247
- if( $GeneralSettings['display_player'] == 0 )
248
- return $content;
249
-
250
- if( current_filter() == 'the_excerpt' && empty($GeneralSettings['display_player_excerpt']) )
251
- return $content; // We didn't want to modify this since the user didn't enable it for excerpts
252
-
253
- if( !empty($GeneralSettings['hide_player_more']) && strstr($content, 'class="more-link"') )
254
- return $content; // We do not want to add players and links if the read-more class found
255
-
256
- // Figure out which players are alerady in the body of the page...
257
- $ExcludePlayers = array();
258
- if( isset($GeneralSettings['disable_player']) )
259
- $ExcludePlayers = $GeneralSettings['disable_player']; // automatically disable the players configured
260
-
261
- if( !empty($GeneralSettings['process_podpress']) && strstr($content, '[display_podcast]') )
262
- return $content;
263
-
264
- if( preg_match_all('/(.?)\[(powerpress)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)/s', $content, $matches) )
265
- {
266
- if( isset($matches[3]) )
267
- {
268
- foreach( $matches[3] as $key=> $row )
269
- {
270
- $attributes = shortcode_parse_atts($row);
271
- if( isset($attributes['url']) )
272
- {
273
- // not a problem...
274
- }
275
- else if( isset($attributes['feed']) )
276
- {
277
- // we want to exclude this feed from the links aera...
278
- $ExcludePlayers[ $attributes['feed'] ] = true;
279
- }
280
- else
281
- {
282
- // we don't want to include any players below...
283
- $ExcludePlayers = $GeneralSettings['custom_feeds'];
284
- }
285
- }
286
- }
287
- }
288
-
289
- // LOOP HERE TO DISPLAY EACH MEDIA TYPE
290
- $new_content = '';
291
- foreach( $GeneralSettings['custom_feeds'] as $feed_slug=> $feed_title )
292
- {
293
- // Get the enclosure data
294
- $EpisodeData = powerpress_get_enclosure_data($post->ID, $feed_slug);
295
-
296
- if( !$EpisodeData && !empty($GeneralSettings['process_podpress']) && $feed_slug == 'podcast' )
297
- $EpisodeData = powerpress_get_enclosure_data_podpress($post->ID);
298
-
299
- if( !$EpisodeData || !$EpisodeData['url'] )
300
- continue;
301
-
302
- // Just in case, if there's no URL lets escape!
303
- if( !$EpisodeData['url'] )
304
- continue;
305
-
306
- // If the player is not already inserted in the body of the post using the shortcode...
307
- //if( preg_match('/\[powerpress(.*)\]/is', $content) == 0 )
308
- if( !isset($ExcludePlayers[ $feed_slug ]) ) // If the player is not in our exclude list because it's already in the post body somewhere...
309
- {
310
- if( isset($GeneralSettings['premium_caps']) && $GeneralSettings['premium_caps'] && !powerpress_premium_content_authorized($feed_slug) )
311
- {
312
- $new_content .= powerpress_premium_content_message($post->ID, $feed_slug, $EpisodeData);
313
- }
314
- else
315
- {
316
- if( $GeneralSettings['player_function'] != 3 && $GeneralSettings['player_function'] != 0 ) // Play in new window only or disabled
317
- {
318
- do_action('wp_powerpress_player_scripts');
319
- $AddDefaultPlayer = empty($EpisodeData['no_player']);
320
-
321
- if( $EpisodeData && !empty($EpisodeData['embed']) )
322
- {
323
- $new_content .= trim($EpisodeData['embed']);
324
- if( !empty($GeneralSettings['embed_replace_player']) )
325
- $AddDefaultPlayer = false;
326
- }
327
-
328
- if( $AddDefaultPlayer )
329
- {
330
- $image = '';
331
- if( isset($EpisodeData['image']) && $EpisodeData['image'] != '' )
332
- $image = $EpisodeData['image'];
333
-
334
- $new_content .= apply_filters('powerpress_player', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData );
335
- }
336
- }
337
-
338
- if( !isset($EpisodeData['no_links']) ) {
339
- do_action('wp_powerpress_player_scripts');
340
- $new_content .= apply_filters('powerpress_player_links', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData );
341
- $new_content .= apply_filters('powerpress_player_subscribe_links', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData );
342
- }
343
- }
344
- }
345
- }
346
-
347
- if( $new_content == '' )
348
- return $content;
349
-
350
- switch( $GeneralSettings['display_player'] )
351
- {
352
- case 1: { // Below posts
353
- return $content.$new_content.( !empty($GeneralSettings['player_aggressive']) && $GeneralSettings['player_aggressive'] == 1 ?'<!--powerpress_player-->':'');
354
- }; break;
355
- case 2: { // Above posts
356
- return ( !empty($GeneralSettings['player_aggressive']) && $GeneralSettings['player_aggressive'] == 1 ?'<!--powerpress_player-->':'').$new_content.$content;
357
- }; break;
358
- }
359
- return $content;
360
- }//end function
361
-
362
-
363
- add_filter('get_the_excerpt', 'powerpress_content', (POWERPRESS_CONTENT_ACTION_PRIORITY - 1) );
364
- add_filter('the_content', 'powerpress_content', POWERPRESS_CONTENT_ACTION_PRIORITY);
365
- if( !defined('POWERPRESS_NO_THE_EXCERPT') )
366
- add_filter('the_excerpt', 'powerpress_content', POWERPRESS_CONTENT_ACTION_PRIORITY);
367
-
368
-
369
- /* Specail case fix Yoast bug which messes up the HTML */
370
- function powerpress_yoast_gawp_fix($content)
371
- {
372
- $content= preg_replace(
373
- array('/return powerpress\_pinw\(\"/', '/return powerpress\_embed\_winplayer\(\"/', '/return powerpress\_show\_embed\(\"/', '/return powerpress\_embed\_html5v\(\"/', '/return powerpress\_embed\_html5a\(\"/', ),
374
- array('return powerpress_pinw(\'', 'return powerpress_embed_winplayer(\'', 'return powerpress_show_embed(\'', 'return powerpress_embed_html5v(\'', 'return powerpress_embed_html5a(\'' ),
375
- $content);
376
-
377
- return $content;
378
- }
379
-
380
- function powerpress_header()
381
- {
382
- // PowerPress settings:
383
- $Powerpress = get_option('powerpress_general');
384
- if( !isset($Powerpress['custom_feeds']) )
385
- $Powerpress['custom_feeds'] = array('podcast'=>'Default Podcast Feed');
386
-
387
- if( empty($Powerpress['disable_appearance']) || $Powerpress['disable_appearance'] == false )
388
- {
389
- if( !isset($Powerpress['player_function']) || $Powerpress['player_function'] > 0 ) // Don't include the player in the header if it is not needed...
390
- {
391
- $PowerpressPluginURL = powerpress_get_root_url();
392
- ?>
393
- <script type="text/javascript"><!--
394
- <?php
395
- $new_window_width = 420;
396
- $new_window_height = 240;
397
-
398
- if( isset($Powerpress['new_window_width']) && $Powerpress['new_window_width'] > 0 )
399
- $new_window_width = $Powerpress['new_window_width'];
400
- else if( isset($Powerpress['new_window_width']) )
401
- $new_window_width = 420;
402
-
403
- if( isset($Powerpress['new_window_height']) && $Powerpress['new_window_height'] > 0 )
404
- $new_window_height = $Powerpress['new_window_height'];
405
- else if( isset($Powerpress['new_window_height']) )
406
- $new_window_height = 240;
407
-
408
- if( empty($Powerpress['new_window_nofactor']) )
409
- {
410
- $new_window_width += 40;
411
- $new_window_height += 80;
412
- }
413
-
414
- ?>
415
- function powerpress_pinw(pinw_url){window.open(pinw_url, 'PowerPressPlayer','toolbar=0,status=0,resizable=1,width=<?php echo ($new_window_width); ?>,height=<?php echo ($new_window_height); ?>'); return false;}
416
- //-->
417
- </script>
418
- <?php
419
- }
420
- }
421
-
422
- if( !empty($Powerpress['feed_links']) )
423
- {
424
- if( is_home() ) {
425
- $feed_slug = 'podcast';
426
- $href = get_feed_link($feed_slug);
427
- // Podcast default and channel feed settings
428
- $Settings = get_option('powerpress_feed_'. $feed_slug);
429
-
430
- if( empty($Settings) && $feed_slug == 'podcast' )
431
- $Settings = get_option('powerpress_feed'); // Get the main feed settings
432
-
433
- if( empty($Settings['title']) )
434
- $Settings['title'] = get_bloginfo_rss('name'); // Get blog title
435
-
436
- // Get the default podcast feed...
437
- echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $Settings['title'] ) . '" href="' . esc_url( $href ) . '" />' . "\n";
438
- } else if( is_category() ) {
439
-
440
- $category_id = get_query_var('cat');
441
- if( $category_id ) {
442
- $Settings = get_option('powerpress_cat_feed_'.$category_id );
443
- if( empty($Settings['title']) ) {
444
- $Settings['title'] = get_cat_name( $category_id ); // Get category title
445
- $Settings['title'] .= ' '. apply_filters( 'document_title_separator', '-' ) .' ';
446
- $Settings['title'] .= get_bloginfo_rss('name');
447
- }
448
- if( empty($Settings['title']) ) {
449
- $Settings['title'] = get_bloginfo_rss('name'); // Get blog title, best we can do
450
- }
451
-
452
- if( !empty($Settings['feed_redirect_url']) )
453
- $Settings['feed_url'] = $Settings['feed_redirect_url'];
454
- else if( !empty($General['cat_casting_podcast_feeds']) )
455
- $Settings['feed_url'] = get_category_feed_link($category_id, 'podcast');
456
- else
457
- $Settings['feed_url'] = get_category_feed_link( $category_id ); // Get category feed URL
458
-
459
- // Get the category podcast feed...
460
- echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $Settings['title'] ) . '" href="' . esc_url( $Settings['feed_url'] ) . '" />' . "\n";
461
- }
462
- }
463
- }
464
- }
465
-
466
- add_action('wp_head', 'powerpress_header');
467
-
468
- function powerpress_wp_head_completed()
469
- {
470
- $GLOBALS['powerpress_wp_head_completed'] = true;
471
- }
472
-
473
- add_action('wp_head', 'powerpress_wp_head_completed', 100000);
474
-
475
- function powerpress_exit_on_http_head($return)
476
- {
477
- if( is_feed() )
478
- {
479
- // Set the content type for HTTP headers...
480
- header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
481
-
482
- // Needs authentication?
483
- $GeneralSettings = get_option('powerpress_general');
484
- if( !empty($GeneralSettings['premium_caps']) )
485
- {
486
- $feed_slug = get_query_var('feed');
487
- $FeedSettings = get_option('powerpress_feed_'.$feed_slug);
488
- if( !empty($FeedSettings['premium']) )
489
- {
490
- return false; // Let the logic further into PowerPress authenticate this HEAD request
491
- }
492
- }
493
- }
494
- return $return;
495
- }
496
-
497
- add_filter('exit_on_http_head', 'powerpress_exit_on_http_head' );
498
-
499
- function powerpress_rss2_ns()
500
- {
501
- if( !powerpress_is_podcast_feed() )
502
- return;
503
-
504
- // Okay, lets add the namespace
505
- echo 'xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"'.PHP_EOL;
506
- if( !defined('POWERPRESS_RAWVOICE_RSS') || POWERPRESS_RAWVOICE_RSS != false )
507
- {
508
- echo 'xmlns:rawvoice="http://www.rawvoice.com/rawvoiceRssModule/"'.PHP_EOL;
509
- }
510
- if( !defined('POWERPRESS_GOOGLEPLAY_RSS') || POWERPRESS_GOOGLEPLAY_RSS != false )
511
- {
512
- echo 'xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"'.PHP_EOL;
513
- //echo 'xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0/play-podcasts.xsd"'.PHP_EOL;
514
- }
515
- }
516
-
517
- add_action('rss2_ns', 'powerpress_rss2_ns');
518
- add_action('rss2_ns_powerpress', 'powerpress_rss2_ns');
519
-
520
- function powerpress_rss2_head()
521
- {
522
- global $powerpress_feed;
523
-
524
- if( !powerpress_is_podcast_feed() )
525
- return; // Not a feed we manage
526
-
527
- $feed_slug = get_query_var( 'feed' );
528
- $cat_ID = get_query_var('cat');
529
-
530
- $Feed = get_option('powerpress_feed'); // Get the main feed settings
531
- if( !empty($powerpress_feed['category']) )
532
- {
533
- $CustomFeed = get_option('powerpress_cat_feed_'.$powerpress_feed['category']); // Get the custom podcast feed settings saved in the database
534
- if( $CustomFeed )
535
- $Feed = powerpress_merge_empty_feed_settings($CustomFeed, $Feed);
536
- }
537
- else if( !empty($powerpress_feed['term_taxonomy_id']) )
538
- {
539
- $CustomFeed = get_option('powerpress_taxonomy_'.$powerpress_feed['term_taxonomy_id']); // Get the taxonomy podcast settings saved in the database
540
- if( $CustomFeed )
541
- $Feed = powerpress_merge_empty_feed_settings($CustomFeed, $Feed);
542
- }
543
- else if( !empty($powerpress_feed['post_type']) )
544
- {
545
- $PostTypeSettingsArray = get_option('powerpress_posttype_'.$powerpress_feed['post_type']); // Get the post type podcast feed settings saved in the database
546
- if( !empty($PostTypeSettingsArray[ $feed_slug ]) )
547
- {
548
- $CustomFeed = $PostTypeSettingsArray[ $feed_slug ];
549
- $Feed = powerpress_merge_empty_feed_settings($CustomFeed, $Feed, ($feed_slug == 'podcast') );
550
- }
551
- }
552
- else if( powerpress_is_custom_podcast_feed() ) // If we're handling a custom podcast feed...
553
- {
554
- $CustomFeed = get_option('powerpress_feed_'.$feed_slug); // Get the custom podcast feed settings saved in the database
555
- $Feed = powerpress_merge_empty_feed_settings($CustomFeed, $Feed, ($feed_slug == 'podcast') );
556
- }
557
-
558
- if( !isset($Feed['url']) || trim($Feed['url']) == '' )
559
- {
560
- if( is_category() )
561
- $Feed['url'] = get_category_link($cat_ID);
562
- else {
563
-
564
- $blogHomepage = get_option('page_for_posts');
565
- if( !empty($blogHomepage) ) {
566
- $Feed['url'] = get_permalink( $blogHomepage );
567
- }
568
-
569
- if( empty($Feed['url']) )
570
- $Feed['url'] = get_bloginfo('url');
571
- }
572
- }
573
-
574
- $General = get_option('powerpress_general');
575
-
576
- // We made it this far, lets write stuff to the feed!
577
- echo '<!-- podcast_generator="Blubrry PowerPress/'. POWERPRESS_VERSION .'" ';
578
- if( isset($General['advanced_mode_2']) && empty($General['advanced_mode_2']) )
579
- echo 'mode="simple" ';
580
- else
581
- echo 'mode="advanced" ';
582
- // Additional info for diagnostics
583
- if( !empty($powerpress_feed['category']) )
584
- echo 'category="'.$powerpress_feed['category'].'" ';
585
- if( !empty($powerpress_feed['term_taxonomy_id']) )
586
- echo 'ttid="'.$powerpress_feed['term_taxonomy_id'].'" ';
587
- if( !empty($powerpress_feed['post_type']) )
588
- echo 'posttype="'.$powerpress_feed['post_type'].'" ';
589
- if( !empty($powerpress_feed['feed-slug']) )
590
- echo 'feedslug="'.$powerpress_feed['feed-slug'].'" ';
591
-
592
- $feedComment = apply_filters('powerpress_feed_comment', '');
593
- $feedComment = str_replace( array('<!--', '-->'), array('|!~~', '~~>'), $feedComment);
594
- $feedComment = trim($feedComment);
595
- if( !empty($feedComment) )
596
- echo $feedComment.' ';
597
-
598
- echo 'Blubrry PowerPress Podcasting plugin for WordPress (https://www.blubrry.com/powerpress/) -->'.PHP_EOL;
599
-
600
- // Websub!
601
- if(!empty($General['websub_enabled']) && $General['websub_enabled'] == 1) {
602
- echo "\t<atom:link rel=\"hub\" href=\"https://pubsubhubbub.appspot.com/\" />" . PHP_EOL;
603
- }
604
-
605
- // add the itunes:new-feed-url tag to feed
606
- if( powerpress_is_custom_podcast_feed() )
607
- {
608
- if( !empty($Feed['itunes_new_feed_url']) )
609
- {
610
- $Feed['itunes_new_feed_url'] = str_replace('&amp;', '&', $Feed['itunes_new_feed_url']);
611
- echo "\t<itunes:new-feed-url>". htmlspecialchars(trim($Feed['itunes_new_feed_url'])) .'</itunes:new-feed-url>'.PHP_EOL;
612
- }
613
- }
614
- else if( !empty($Feed['itunes_new_feed_url']) && ($feed_slug == 'feed' || $feed_slug == 'rss2') ) // If it is the default feed (We don't wnat to apply this to category or tag feeds
615
- {
616
- $Feed['itunes_new_feed_url'] = str_replace('&amp;', '&', $Feed['itunes_new_feed_url']);
617
- echo "\t<itunes:new-feed-url>". htmlspecialchars(trim($Feed['itunes_new_feed_url'])) .'</itunes:new-feed-url>'.PHP_EOL;
618
- }
619
-
620
- if( !empty($General['itunes_cdata']) ) {
621
- if( !empty($Feed['itunes_summary']) )
622
- echo "\t".'<itunes:summary><![CDATA['. powerpress_format_itunes_value( $Feed['itunes_summary'], 'summary', true ) .']]></itunes:summary>'.PHP_EOL;
623
- else
624
- echo "\t".'<itunes:summary><![CDATA['. powerpress_format_itunes_value( get_bloginfo('description'), 'summary', true ) .']]></itunes:summary>'.PHP_EOL;
625
- } else {
626
- if( !empty($Feed['itunes_summary']) )
627
- echo "\t".'<itunes:summary>'. powerpress_format_itunes_value( $Feed['itunes_summary'], 'summary' ) .'</itunes:summary>'.PHP_EOL;
628
- else
629
- echo "\t".'<itunes:summary>'. powerpress_format_itunes_value( get_bloginfo('description'), 'summary' ) .'</itunes:summary>'.PHP_EOL;
630
- }
631
-
632
- if( !empty($powerpress_feed['itunes_talent_name']) )
633
- echo "\t<itunes:author>" . esc_html($powerpress_feed['itunes_talent_name']) . '</itunes:author>'.PHP_EOL;
634
-
635
- if( !empty($powerpress_feed['explicit']) && $powerpress_feed['explicit'] != 'no' )
636
- echo "\t".'<itunes:explicit>' . $powerpress_feed['explicit'] . '</itunes:explicit>'.PHP_EOL;
637
-
638
- if( !empty($Feed['itunes_block']) )
639
- echo "\t<itunes:block>yes</itunes:block>".PHP_EOL;
640
-
641
- if( !empty($Feed['itunes_complete']) )
642
- echo "\t<itunes:complete>yes</itunes:complete>".PHP_EOL;
643
-
644
- if( !empty($Feed['itunes_image']) )
645
- {
646
- echo "\t".'<itunes:image href="' . esc_html( powerpress_url_in_feed(str_replace(' ', '+', $Feed['itunes_image'])), 'double') . '" />'.PHP_EOL;
647
- }
648
- else
649
- {
650
- echo "\t".'<itunes:image href="' . powerpress_url_in_feed(powerpress_get_root_url()) . 'itunes_default.jpg" />'.PHP_EOL;
651
- }
652
-
653
- if( !empty($Feed['itunes_type']) ) {
654
- echo "\t".'<itunes:type>'. esc_html($Feed['itunes_type']) .'</itunes:type>'.PHP_EOL;
655
- }
656
-
657
- if( !empty($Feed['email']) )
658
- {
659
- echo "\t".'<itunes:owner>'.PHP_EOL;
660
- echo "\t\t".'<itunes:name>' . esc_html($powerpress_feed['itunes_talent_name']) . '</itunes:name>'.PHP_EOL;
661
- echo "\t\t".'<itunes:email>' . esc_html($Feed['email']) . '</itunes:email>'.PHP_EOL;
662
- echo "\t".'</itunes:owner>'.PHP_EOL;
663
- echo "\t".'<managingEditor>'. esc_html($Feed['email'] .' ('. $powerpress_feed['itunes_talent_name'] .')') .'</managingEditor>'.PHP_EOL;
664
- }
665
-
666
- if( !empty($Feed['copyright']) )
667
- {
668
- // In case the user entered the copyright html version or the copyright UTF-8 or ASCII symbol or just (c)
669
- $Feed['copyright'] = str_replace(array('&copy;', '(c)', '(C)', chr(194) . chr(169), chr(169) ), '&#xA9;', $Feed['copyright']);
670
- echo "\t".'<copyright>'. esc_html($Feed['copyright']) . '</copyright>'.PHP_EOL;
671
- }
672
-
673
- if( !empty($Feed['itunes_subtitle']) )
674
- echo "\t".'<itunes:subtitle>' . powerpress_format_itunes_value($Feed['itunes_subtitle'], 'subtitle') . '</itunes:subtitle>'.PHP_EOL;
675
- else
676
- echo "\t".'<itunes:subtitle>'. powerpress_format_itunes_value( get_bloginfo('description'), 'subtitle') .'</itunes:subtitle>'.PHP_EOL;
677
- $podcast_title_safe = '';
678
- if( version_compare($GLOBALS['wp_version'], 4.4, '<' ) ) {
679
- $podcast_title_safe .= get_bloginfo_rss('name');
680
- }
681
- $podcast_title_safe .= get_wp_title_rss();
682
- if( empty($General['disable_rss_image']) )
683
- {
684
- if( !empty($Feed['rss2_image']) || !empty($Feed['itunes_image']) )
685
- {
686
- if( !empty($Feed['rss2_image']) ) // If the RSS image is set, use it, otherwise use the iTunes image...
687
- $rss_image = $Feed['rss2_image'];
688
- else
689
- $rss_image = $Feed['itunes_image'];
690
-
691
- echo "\t". '<image>' .PHP_EOL;
692
- echo "\t\t".'<title>' . $podcast_title_safe . '</title>'.PHP_EOL;
693
- echo "\t\t".'<url>' . esc_html( str_replace(' ', '+', $rss_image)) . '</url>'.PHP_EOL;
694
- echo "\t\t".'<link>'. $Feed['url'] . '</link>' . PHP_EOL;
695
- echo "\t".'</image>' . PHP_EOL;
696
- }
697
- else // Use the default image
698
- {
699
- echo "\t". '<image>' .PHP_EOL;
700
- echo "\t\t".'<title>' . $podcast_title_safe . '</title>'.PHP_EOL;
701
- echo "\t\t".'<url>' . powerpress_get_root_url() . 'rss_default.jpg</url>'.PHP_EOL;
702
- echo "\t\t".'<link>'. $Feed['url'] . '</link>' . PHP_EOL;
703
- echo "\t".'</image>' . PHP_EOL;
704
- }
705
- }
706
-
707
- // Handle iTunes categories
708
- $Cat1 = false; $Cat2 = false; $Cat3 = false; $SubCat1 = false; $SubCat2 = false; $SubCat3 = false;
709
- if(defined('POWERPRESS_NEW_APPLE_CATEGORIES') && POWERPRESS_NEW_APPLE_CATEGORIES == true) {
710
- $Categories = powerpress_apple_categories();
711
- for ($i = 1; $i <= 3; $i++) {
712
- if(!empty($Feed['itunes_cat_'.$i] && empty($Feed['apple_cat_'.$i]))) {
713
- $mappings = array('01-00' => '01-00', '01-01' => '01-02', '01-02' => '01-03', '01-03' => '01-04', '01-04' => '01-01',
714
- '01-05' => '01-05', '01-06' => '01-06', '02-00' => '02-00', '02-01' => '12-01', '02-02' => '02-01', '02-03' => '02-03',
715
- '02-04' => '02-00', '02-05' => '02-00', '03-00' => '03-00', '04-00' => '04-00', '04-01' => '04-00', '04-02' => '04-00',
716
- '04-03' => '09-01', '04-04' => '04-03', '04-05' => '04-00', '05-00' => '10-00', '05-01' => '10-02', '05-02' => '10-03',
717
- '05-03' => '10-06', '05-04' => '10-05', '05-05' => '10-05', '06-00' => '06-00', '06-01' => '06-00', '06-02' => '06-00',
718
- '06-03' => '06-00', '06-04' => '06-00', '07-00' => '07-00', '07-01' => '07-01', '07-02' => '07-00', '07-03' => '04-04',
719
- '07-04' => '07-06', '08-00' => '09-00', '09-00' => '11-00', '11-00' => '13-00', '11-01' => '13-01', '11-02' => '13-02',
720
- '11-03' => '13-03', '11-04' => '13-04', '11-05' => '13-05', '11-06' => '13-06', '11-07' => '13-07', '12-00' => '14-00',
721
- '12-01' => '07-03', '12-02' => '14-06', '12-03' => '14-09', '13-00' => '15-00', '13-01' => '08-00', '13-02' => '15-02',
722
- '13-03' => '15-03', '13-04' => '15-04', '14-00' => '16-00', '14-01' => '16-00', '14-02' => '16-00', '14-03' => '16-15',
723
- '14-04' => '16-00', '15-00' => '17-00', '15-01' => '17-00', '15-02' => '12-07', '15-03' => '17-00', '15-04' => '17-00', '16-00' => '19-00');
724
- $Feed['apple_cat_'. $i] = $mappings[$Feed['itunes_cat_'.$i]];
725
-
726
- }
727
- }
728
- if (!empty($Feed['apple_cat_1']))
729
- list($Cat1, $SubCat1) = explode('-', $Feed['apple_cat_1']);
730
- if (!empty($Feed['apple_cat_2']))
731
- list($Cat2, $SubCat2) = explode('-', $Feed['apple_cat_2']);
732
- if (!empty($Feed['apple_cat_3']))
733
- list($Cat3, $SubCat3) = explode('-', $Feed['apple_cat_3']);
734
- }
735
- else {
736
- $Categories = powerpress_itunes_categories();
737
- if (!empty($Feed['itunes_cat_1']))
738
- list($Cat1, $SubCat1) = explode('-', $Feed['itunes_cat_1']);
739
- if (!empty($Feed['itunes_cat_2']))
740
- list($Cat2, $SubCat2) = explode('-', $Feed['itunes_cat_2']);
741
- if (!empty($Feed['itunes_cat_3']))
742
- list($Cat3, $SubCat3) = explode('-', $Feed['itunes_cat_3']);
743
- }
744
-
745
- if( $Cat1 )
746
- {
747
- $CatDesc = $Categories[$Cat1.'-00'];
748
- $SubCatDesc = $Categories[$Cat1.'-'.$SubCat1];
749
- echo "\t".'<itunes:category text="'. esc_html($CatDesc) .'">'.PHP_EOL;
750
- if( $SubCat1 != '00' )
751
- echo "\t\t".'<itunes:category text="'. esc_html($SubCatDesc) .'"></itunes:category>'.PHP_EOL;
752
-
753
- // End this category set
754
- echo "\t".'</itunes:category>'.PHP_EOL;
755
- }
756
-
757
- if( $Cat2 )
758
- {
759
- $CatDesc = $Categories[$Cat2.'-00'];
760
- $SubCatDesc = $Categories[$Cat2.'-'.$SubCat2];
761
-
762
- echo "\t".'<itunes:category text="'. esc_html($CatDesc) .'">'.PHP_EOL;
763
- if( $SubCat2 != '00' )
764
- echo "\t\t".'<itunes:category text="'. esc_html($SubCatDesc) .'"></itunes:category>'.PHP_EOL;
765
- echo "\t".'</itunes:category>'.PHP_EOL;
766
- }
767
-
768
- if( $Cat3 )
769
- {
770
- $CatDesc = $Categories[$Cat3.'-00'];
771
- $SubCatDesc = $Categories[$Cat3.'-'.$SubCat3];
772
-
773
- echo "\t".'<itunes:category text="'. esc_html($CatDesc) .'">'.PHP_EOL;
774
- if( $SubCat3 != '00' )
775
- echo "\t\t".'<itunes:category text="'. esc_html($SubCatDesc) .'"></itunes:category>'.PHP_EOL;
776
- // End this category set
777
- echo "\t".'</itunes:category>'.PHP_EOL;
778
- }
779
- // End Handle iTunes categories
780
-
781
- if( !empty($Feed['googleplay_email']) )
782
- {
783
- echo "\t".'<googleplay:email>' . esc_html($Feed['googleplay_email']) . '</googleplay:email>'.PHP_EOL;
784
- }
785
-
786
- if( !empty($Feed['googleplay_description']) )
787
- {
788
- echo "\t".'<googleplay:description>' . esc_html($Feed['googleplay_description']) . '</googleplay:description>'.PHP_EOL;
789
- }
790
-
791
- if( !empty($Feed['googleplay_explicit']) )
792
- {
793
- echo "\t".'<googleplay:explicit>Yes</googleplay:explicit>'.PHP_EOL;
794
- }
795
-
796
- // google_play_cat // google_play_explicit
797
- if( !empty($Feed['googleplay_cat']) )
798
- {
799
- $play_cats = powerpress_googleplay_categories();
800
- if( !empty($play_cats[ $Feed['googleplay_cat'] ]) )
801
- {
802
- echo "\t".'<googleplay:category text="'. esc_html($play_cats[ $Feed['googleplay_cat'] ]) .'" />'.PHP_EOL;
803
- }
804
- }
805
-
806
- if( !empty($Feed['googleplay_image']) )
807
- {
808
- echo "\t".'<googleplay:image href="' . esc_html( str_replace(' ', '+', $Feed['googleplay_image']), 'double') . '" />'.PHP_EOL;
809
- }
810
-
811
- // RawVoice RSS Tags
812
- if( !defined('POWERPRESS_RAWVOICE_RSS') || POWERPRESS_RAWVOICE_RSS != false )
813
- {
814
- if( !empty($Feed['parental_rating']) )
815
- echo "\t<rawvoice:rating>". $Feed['parental_rating'] ."</rawvoice:rating>".PHP_EOL;
816
- if( !empty($Feed['location']) )
817
- echo "\t<rawvoice:location>". htmlspecialchars($Feed['location']) ."</rawvoice:location>".PHP_EOL;
818
- if( !empty($Feed['frequency']) )
819
- echo "\t<rawvoice:frequency>". htmlspecialchars($Feed['frequency']) ."</rawvoice:frequency>".PHP_EOL;
820
- if( !empty($Feed['donate_link']) && !empty($Feed['donate_url']) )
821
- echo "\t<rawvoice:donate href=\"". htmlspecialchars( $Feed['donate_url'] ) ."\">". htmlspecialchars( (empty($Feed['donate_label'])?'':$Feed['donate_label']) ) ."</rawvoice:donate>".PHP_EOL;
822
-
823
- if( !empty($Feed['itunes_url']) || !empty($Feed['blubrry_url']) || !empty($Feed['stitcher_url']) || !empty($Feed['tunein_url']) || !empty($Feed['spotify_url']) ) {
824
- echo "\t<rawvoice:subscribe feed=\"";
825
- self_link();
826
- echo '"';
827
-
828
- // Subscribe page // empty($FeedSettings['subscribe_page_link_href']) && empty($FeedSettings['subscribe_page_link_id'])
829
- if( !empty($Feed['subscribe_page_link_id']) ) {
830
- $link = get_page_link($Feed['subscribe_page_link_id']);
831
- if( !empty($link) ) {
832
- echo " html=\"". htmlspecialchars( $link ) .'"';
833
- }
834
- } else if( !empty($Feed['subscribe_page_link_href']) ) {
835
- echo " html=\"". htmlspecialchars( $Feed['subscribe_page_link_href'] ) .'"';
836
- }
837
-
838
- if( !empty($Feed['itunes_url']) )
839
- echo " itunes=\"". htmlspecialchars( $Feed['itunes_url'] ) .'"';
840
- if( !empty($Feed['blubrry_url']) )
841
- echo " blubrry=\"". htmlspecialchars( $Feed['blubrry_url'] ) .'"';
842
- if( !empty($Feed['stitcher_url']) )
843
- echo " stitcher=\"". htmlspecialchars( $Feed['stitcher_url'] ) .'"';
844
- if( !empty($Feed['tunein_url']) )
845
- echo " tunein=\"". htmlspecialchars( $Feed['tunein_url'] ) .'"';
846
- if( !empty($Feed['spotify_url']) )
847
- echo " spotify=\"". htmlspecialchars( $Feed['spotify_url'] ) .'"';
848
- echo "></rawvoice:subscribe>".PHP_EOL;
849
- }
850
- }
851
- }
852
-
853
- add_action('rss2_head', 'powerpress_rss2_head');
854
- add_action('rss2_head_powerpress', 'powerpress_rss2_head');
855
-
856
- function powerpress_rss2_item()
857
- {
858
- global $post, $powerpress_feed;
859
-
860
- // are we processing a feed that powerpress should handle
861
- if( !powerpress_is_podcast_feed() )
862
- return;
863
-
864
- if( function_exists('post_password_required') )
865
- {
866
- if( post_password_required($post) )
867
- return;
868
- }
869
-
870
- // Check and see if we're working with a podcast episode
871
- $custom_enclosure = false;
872
- if( powerpress_is_custom_podcast_feed() && get_query_var('feed') !== 'podcast' && !is_category() && !is_tax() && !is_tag() )
873
- {
874
- $EpisodeData = powerpress_get_enclosure_data($post->ID, get_query_var('feed') );
875
- $custom_enclosure = true;
876
- }
877
- else
878
- {
879
- $EpisodeData = powerpress_get_enclosure_data($post->ID, 'podcast');
880
- if( !$EpisodeData && !empty($powerpress_feed['process_podpress']) )
881
- {
882
- $EpisodeData = powerpress_get_enclosure_data_podpress($post->ID);
883
- $custom_enclosure = true;
884
- }
885
- }
886
-
887
- // No episode data to include
888
- if( empty($EpisodeData) || empty($EpisodeData['url']) )
889
- return;
890
-
891
- // If enclosure not added, check to see why...
892
- if( defined('POWERPRESS_ENCLOSURE_FIX') && POWERPRESS_ENCLOSURE_FIX && !$custom_enclosure && $GLOBALS['powerpress_rss_enclosure_post_id'] != $post->ID )
893
- {
894
- $enclosure_in_wp = apply_filters('rss_enclosure', '<enclosure url="' . trim(htmlspecialchars($EpisodeData['url']) . '" length="' . $EpisodeData['size'] . '" type="' . $EpisodeData['type'] . '" />' . "\n") );
895
- if( !$enclosure_in_wp )
896
- $custom_enclosure = true;
897
- }
898
-
899
- // Lets print the enclosure tag
900
- if( $custom_enclosure ) // We need to add the enclosure tag here...
901
- {
902
- if( empty($EpisodeData['size']) )
903
- $EpisodeData['size'] = 5242880; // Use the dummy 5MB size since we don't have a size to quote
904
-
905
- echo "\t". sprintf('<enclosure url="%s" length="%d" type="%s" />%s',
906
- powerpress_url_in_feed(trim($EpisodeData['url'])),
907
- trim($EpisodeData['size']),
908
- trim($EpisodeData['type']),
909
- PHP_EOL);
910
- }
911
-
912
- $author = $powerpress_feed['itunes_talent_name'];
913
- if( isset($powerpress_feed['itunes_author_post']) )
914
- $author = get_the_author();
915
-
916
- $explicit = $powerpress_feed['explicit'];
917
- $summary = '';
918
- $subtitle = '';
919
- $block = false;
920
- $cc = false;
921
-
922
- if( isset( $EpisodeData['summary'] ) && strlen($EpisodeData['summary']) > 1 )
923
- $summary = $EpisodeData['summary'];
924
- if( isset( $EpisodeData['subtitle'] ) && strlen($EpisodeData['subtitle']) > 1 )
925
- $subtitle = $EpisodeData['subtitle'];
926
- if( isset( $EpisodeData['explicit'] ) && is_numeric($EpisodeData['explicit']) )
927
- {
928
- $explicit_array = array("no", "yes", "clean");
929
- $explicit = $explicit_array[$EpisodeData['explicit']];
930
- }
931
-
932
- if( !empty( $EpisodeData['author'] ) )
933
- $author = $EpisodeData['author'];
934
- if( !empty( $EpisodeData['block'] ) )
935
- $block = 'yes';
936
- if( !empty( $EpisodeData['cc'] ) )
937
- $cc = 'yes';
938
-
939
- $General = get_option('powerpress_general');
940
- $summary_cdata = ( !empty( $General['itunes_cdata'] ) ? true : false );
941
-
942
- if( empty($subtitle) ) {
943
- $subtitle = powerpress_get_the_exerpt( false, !empty($General['feed_action_hook']) );
944
- }
945
-
946
- // If no summary specified and we have enhanced summary enabled...
947
- if( empty($summary) && !empty($powerpress_feed['enhance_itunes_summary']) ) {
948
- $summary = powerpress_enhanced_itunes_summary( !empty($General['feed_action_hook']) );
949
- if( !empty($summary) ) {
950
- $summary_cdata = true; // Always use CDATA for enhanced iTunes summary
951
- }
952
- }
953
-
954
- if( empty($summary) ) { // Backwards compatibility with PodPress, the excerpt is used as the itunes summary if set
955
- $summary = powerpress_get_the_exerpt( true, !empty($General['feed_action_hook']) ); // Will call powerpress_get_the_content(true) if the excerpt does not exist
956
- }
957
-
958
- if( !empty($subtitle) ) {
959
- echo "\t<itunes:subtitle>". powerpress_format_itunes_value($subtitle, 'subtitle') .'</itunes:subtitle>'.PHP_EOL;
960
- }
961
-
962
- if( !empty($summary) ) {
963
- if( $summary_cdata ) {
964
- echo "\t\t<itunes:summary><![CDATA[". powerpress_format_itunes_value($summary, 'summary', true) .']]></itunes:summary>'.PHP_EOL;
965
- } else {
966
- echo "\t\t<itunes:summary>". powerpress_format_itunes_value($summary, 'summary') .'</itunes:summary>'.PHP_EOL;
967
- }
968
- }
969
-
970
- if( !empty($author) ) {
971
- echo "\t\t<itunes:author>" . esc_html($author) . '</itunes:author>'.PHP_EOL;
972
- }
973
-
974
- // itunes episode image
975
- if( !empty( $EpisodeData['itunes_image']) ) {
976
- echo "\t\t".'<itunes:image href="' . esc_html( powerpress_url_in_feed(str_replace(' ', '+', $EpisodeData['itunes_image'])), 'double') . '" />'.PHP_EOL;
977
- } else if( !empty($powerpress_feed['itunes_image']) ) {
978
- echo "\t\t".'<itunes:image href="' . esc_html( powerpress_url_in_feed(str_replace(' ', '+', $powerpress_feed['itunes_image'])), 'double') . '" />'.PHP_EOL;
979
- }
980
-
981
- if( !empty($EpisodeData['season']) ) {
982
- echo "\t\t".'<itunes:season>'. esc_html($EpisodeData['season']) .'</itunes:season>'.PHP_EOL;
983
- }
984
-
985
- if( !empty($EpisodeData['episode_no']) ) {
986
- echo "\t\t".'<itunes:episode>'. esc_html($EpisodeData['episode_no']) .'</itunes:episode>'.PHP_EOL;
987
- }
988
-
989
- if( !empty($EpisodeData['episode_title']) ) {
990
- echo "\t\t".'<itunes:title>'. esc_html($EpisodeData['episode_title']) .'</itunes:title>'.PHP_EOL;
991
- }
992
-
993
- if( !empty($EpisodeData['episode_type']) ) {
994
- echo "\t\t".'<itunes:episodeType>'. esc_html($EpisodeData['episode_type']) .'</itunes:episodeType>'.PHP_EOL;
995
- }
996
-
997
- if( !empty($explicit) && $explicit != 'no' ) {
998
- echo "\t\t<itunes:explicit>" . $explicit . '</itunes:explicit>'.PHP_EOL;
999
- }
1000
-
1001
- if( !empty($EpisodeData['duration']) && preg_match('/^(\d{1,2}:){0,2}\d{1,2}$/i', ltrim($EpisodeData['duration'], '0:') ) ) { // Include duration if it is valid
1002
- echo "\t\t<itunes:duration>" . ltrim($EpisodeData['duration'], '0:') . '</itunes:duration>'.PHP_EOL;
1003
- }
1004
-
1005
- if( $block && $block == 'yes' ) {
1006
- echo "\t\t<itunes:block>yes</itunes:block>".PHP_EOL;
1007
- }
1008
-
1009
- if( $cc && $cc == 'yes' ) {
1010
- echo "\t\t<itunes:isClosedCaptioned>yes</itunes:isClosedCaptioned>".PHP_EOL;
1011
- }
1012
-
1013
- if( !empty($powerpress_feed['itunes_feature']) ) { // We are using the itunes:order option to feature a specific episode.
1014
- // Skip inserting the order tag
1015
- } else {
1016
- if( isset( $EpisodeData['order'] ) && is_numeric( $EpisodeData['order'] ) )
1017
- echo "\t\t<itunes:order>". $EpisodeData['order'] ."</itunes:order>".PHP_EOL;
1018
- }
1019
-
1020
- // Google Play tags:
1021
- if( empty($powerpress_feed['feed_maximizer_on']) ) { // These tags for the most part replicate what is in the itunes tags, so lets not include them when we want to maximize the feed
1022
- if( !empty( $EpisodeData['gp_desc'] ) ) {
1023
- echo "\t\t<googleplay:description>". powerpress_format_itunes_value($EpisodeData['gp_desc'], 'summary') ."</googleplay:description>".PHP_EOL;
1024
- }
1025
-
1026
- if( !empty( $EpisodeData['gp_explicit'] ) ) {
1027
- echo "\t\t<googleplay:explicit>yes</googleplay:explicit>".PHP_EOL;
1028
- }
1029
- }
1030
-
1031
- if( !empty( $EpisodeData['gp_block'] ) ) {
1032
- echo "\t\t<googleplay:block>yes</googleplay:block>".PHP_EOL;
1033
- }
1034
-
1035
-
1036
- // RawVoice RSS Tags
1037
- if( empty($powerpress_feed['feed_maximizer_on']) )
1038
- {
1039
- if( !defined('POWERPRESS_RAWVOICE_RSS') || POWERPRESS_RAWVOICE_RSS != false )
1040
- {
1041
- if( !empty($EpisodeData['ishd']) )
1042
- echo "\t\t<rawvoice:isHD>yes</rawvoice:isHD>".PHP_EOL;;
1043
- if( !empty($EpisodeData['image']) )
1044
- echo "\t\t<rawvoice:poster url=\"". $EpisodeData['image'] ."\" />".PHP_EOL;
1045
- if( !empty($EpisodeData['embed']) )
1046
- echo "\t\t<rawvoice:embed>". htmlspecialchars($EpisodeData['embed']) ."</rawvoice:embed>".PHP_EOL;
1047
- else if( !empty($powerpress_feed['podcast_embed_in_feed']) && function_exists('powerpress_generate_embed') )
1048
- {
1049
- $player = powerpressplayer_embedable($EpisodeData['url'], $EpisodeData);
1050
- $embed_content = '';
1051
-
1052
- if( $player )
1053
- $embed_content = powerpress_generate_embed($player, $EpisodeData);
1054
- if( $embed_content )
1055
- echo "\t\t<rawvoice:embed>". htmlspecialchars( $embed_content ) ."</rawvoice:embed>".PHP_EOL;
1056
- }
1057
-
1058
- if( !empty($EpisodeData['webm_src']) )
1059
- {
1060
- echo "\t\t<rawvoice:webm src=\"". $EpisodeData['webm_src'] ."\"";
1061
- if( $EpisodeData['webm_length'] )
1062
- echo " length=\"". $EpisodeData['webm_length'] ."\"";
1063
- echo " type=\"video/webm\" />".PHP_EOL;
1064
- }
1065
-
1066
- $GeneralSettings = get_option('powerpress_general');
1067
-
1068
- if( !empty($GeneralSettings) && !empty($GeneralSettings['metamarks']) )
1069
- {
1070
- require_once(POWERPRESS_ABSPATH .'/powerpressadmin-metamarks.php');
1071
- powerpress_metamarks_print_rss2($EpisodeData);
1072
- }
1073
- }
1074
- }
1075
- }
1076
-
1077
- add_action('rss2_item', 'powerpress_rss2_item');
1078
- add_action('rss2_item_powerpress', 'powerpress_rss2_item');
1079
-
1080
- /*
1081
- This filter is only necessary for feeds that are not specifically for podcasting, e.g. a category feed that did not have category podcasting added to it
1082
- */
1083
- function powerpress_filter_rss_enclosure($content)
1084
- {
1085
- if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) || defined('PODCASTING_VERSION') ) {
1086
- return $content; // Another podcasting plugin is enabled...
1087
- }
1088
-
1089
- if( powerpress_is_custom_podcast_feed() && get_query_var('feed') !== 'podcast' && !is_category() && !is_tag() && !is_tax() )
1090
- return ''; // We will handle this enclosure in the powerpress_rss2_item() function
1091
-
1092
- $match_count = preg_match('/\surl="([^"]*)"/', $content, $matches); // No URL found, weird
1093
- if( count($matches) != 2)
1094
- return $content;
1095
-
1096
- // Original Media URL
1097
- $OrigURL = $matches[1];
1098
-
1099
- if( substr($OrigURL, 0, 5) != 'http:' && substr($OrigURL, 0, 6) != 'https:' )
1100
- return ''; // The URL value is invalid
1101
-
1102
- global $post, $powerpress_rss_enclosure_post_id;
1103
- if( empty($powerpress_rss_enclosure_post_id) )
1104
- $powerpress_rss_enclosure_post_id = -1;
1105
-
1106
- if( $powerpress_rss_enclosure_post_id == $post->ID )
1107
- return ''; // we've already included one enclosure, lets not allow anymore
1108
- $powerpress_rss_enclosure_post_id = $post->ID;
1109
-
1110
- $EpisodeData = powerpress_get_enclosure_data($post->ID);
1111
-
1112
- // Modified Media URL
1113
- $ModifiedURL = powerpress_url_in_feed($EpisodeData['url']); // powerpress_add_redirect_url($OrigURL);
1114
-
1115
- // Check that the content type is a valid one...
1116
- $match_count = preg_match('/\stype="([^"]*)"/', $content, $matches);
1117
- if( count($matches) > 1 && strstr($matches[1], '/') == false )
1118
- {
1119
- $ContentType = powerpress_get_contenttype($ModifiedURL);
1120
- $content = str_replace("type=\"{$matches[1]}\"", "type=\"$ContentType\"", $content);
1121
- }
1122
-
1123
- // Check that the content length is a digit greater that zero
1124
- $match_count = preg_match('/\slength="([^"]*)"/', $content, $matches);
1125
- if( count($matches) > 1 && empty($matches[1]) )
1126
- {
1127
- $content = str_replace("length=\"{$matches[1]}\"", "length=\"5242880\"", $content);
1128
- }
1129
-
1130
- // Replace the original url with the modified one...
1131
- if( $OrigURL != $ModifiedURL )
1132
- return str_replace($OrigURL, $ModifiedURL, $content);
1133
- return $content;
1134
- }
1135
-
1136
-
1137
- add_filter('rss_enclosure', 'powerpress_filter_rss_enclosure', 11);
1138
-
1139
- function powerpress_bloginfo_rss($content, $field = '')
1140
- {
1141
- $new_value = '';
1142
- if( powerpress_is_custom_podcast_feed() )
1143
- {
1144
- if( is_category() ) {
1145
- $Feed = get_option('powerpress_cat_feed_'.get_query_var('cat') );
1146
- }
1147
- else if( is_tax() || is_tag() ) {
1148
- global $powerpress_feed;
1149
- if( !empty($powerpress_feed['term_taxonomy_id']) )
1150
- $Feed = get_option('powerpress_taxonomy_'.$powerpress_feed['term_taxonomy_id'] );
1151
- }
1152
- else
1153
- {
1154
- global $powerpress_feed;
1155
-
1156
- if( !empty($powerpress_feed['post_type']) )
1157
- {
1158
- $feed_slug = get_query_var('feed');
1159
- $PostTypeSettingsArray = get_option('powerpress_posttype_'.$powerpress_feed['post_type'] );
1160
- if( !empty($PostTypeSettingsArray[ $feed_slug ]) )
1161
- $Feed = $PostTypeSettingsArray[ $feed_slug ];
1162
- }
1163
- else
1164
- {
1165
- $Feed = get_option('powerpress_feed_'.get_query_var('feed') );
1166
- if( empty($Feed) && get_query_var('feed') === 'podcast' )
1167
- $Feed = get_option('powerpress_feed');
1168
- }
1169
- }
1170
-
1171
- if( $Feed )
1172
- {
1173
- switch( $field )
1174
- {
1175
- case 'description': {
1176
- if( !empty($Feed['description']) )
1177
- $new_value = $Feed['description'];
1178
- else if( is_category() )
1179
- {
1180
- $category = get_category( get_query_var('cat') );
1181
- if( $category->description )
1182
- $new_value = $category->description;
1183
- }
1184
- }; break;
1185
- case 'url': {
1186
- // If the website URL is set for this podcast then lets use it...
1187
- if( !empty($Feed['url']) )
1188
- return trim($Feed['url']);
1189
-
1190
- if( is_category() ) {
1191
- return get_category_link( get_query_var('cat') );
1192
- } else {
1193
- $urlTemp = '';
1194
- $blogHomepage = get_option('page_for_posts');
1195
- if( !empty($blogHomepage) ) {
1196
- $urlTemp = get_permalink( $blogHomepage );
1197
- }
1198
-
1199
- if( empty($urlTemp) )
1200
- $urlTemp = get_bloginfo('url');
1201
- if( !empty($urlTemp) )
1202
- return $urlTemp;
1203
- }
1204
- }; break;
1205
- case 'name': { // As of wp 4.4+ title is handled by get_the_title_rss completely.
1206
- if( !empty($Feed['title']) )
1207
- $new_value = $Feed['title'];
1208
- }; break;
1209
- case 'language': {
1210
- // Get the feed language
1211
- $lang = '';
1212
- if( isset($Feed['rss_language']) && $Feed['rss_language'] != '' )
1213
- $lang = $Feed['rss_language'];
1214
- if( strlen($lang) == 5 )
1215
- $lang = substr($lang,0,3) . strtoupper( substr($lang, 3) ); // Format example: en-US for English, United States
1216
- if( !empty($lang) )
1217
- return $lang;
1218
- }; break;
1219
- }
1220
- }
1221
- }
1222
-
1223
- if( !empty($new_value) )
1224
- {
1225
- $new_value = wptexturize($new_value);
1226
- $new_value = convert_chars($new_value);
1227
- $new_value = esc_html($new_value);
1228
- //$new_value = convert_chars($new_value);
1229
- return $new_value;
1230
- }
1231
-
1232
- return $content;
1233
- }
1234
-
1235
- add_filter('get_bloginfo_rss', 'powerpress_bloginfo_rss', 10, 2);
1236
-
1237
-
1238
- function powerpress_wp_title_rss($title)
1239
- {
1240
- if( version_compare($GLOBALS['wp_version'], 4.4, '>=' ) )
1241
- {
1242
- if( powerpress_is_custom_podcast_feed() )
1243
- {
1244
- if( is_category() ) {
1245
- $Feed = get_option('powerpress_cat_feed_'.get_query_var('cat') );
1246
- }
1247
- else if( is_tax() || is_tag() ) {
1248
- global $powerpress_feed;
1249
- if( !empty($powerpress_feed['term_taxonomy_id']) )
1250
- $Feed = get_option('powerpress_taxonomy_'.$powerpress_feed['term_taxonomy_id'] );
1251
- }
1252
- else
1253
- {
1254
- global $powerpress_feed;
1255
-
1256
- if( !empty($powerpress_feed['post_type']) )
1257
- {
1258
- $feed_slug = get_query_var('feed');
1259
- if( !empty($feed_slug) ) {
1260
- $PostTypeSettingsArray = get_option('powerpress_posttype_'.$powerpress_feed['post_type'] );
1261
- if( !empty($PostTypeSettingsArray[ $feed_slug ]) )
1262
- $Feed = $PostTypeSettingsArray[ $feed_slug ];
1263
- }
1264
- }
1265
- else
1266
- {
1267
- $feed_slug = get_query_var('feed');
1268
- $Feed = false;
1269
- if( !empty($feed_slug) ) {
1270
- $Feed = get_option('powerpress_feed_'.get_query_var('feed') );
1271
- }
1272
- if( empty($Feed) && get_query_var('feed') === 'podcast' )
1273
- $Feed = get_option('powerpress_feed');
1274
- }
1275
- }
1276
-
1277
- if( $Feed )
1278
- {
1279
- if( !empty($Feed['title']) )
1280
- return esc_html( $Feed['title'] );
1281
- }
1282
- }
1283
- }
1284
- else
1285
- {
1286
- if( powerpress_is_custom_podcast_feed() )
1287
- {
1288
- if( is_category() )
1289
- {
1290
- $Feed = get_option('powerpress_cat_feed_'.get_query_var('cat') );
1291
- if( $Feed && isset($Feed['title']) && $Feed['title'] != '' )
1292
- return ''; // We alrady did a custom title, lets not add the category to it...
1293
- }
1294
- else
1295
- {
1296
- return ''; // It is not a category, lets not mess with our beautiful title then
1297
- }
1298
- }
1299
- }
1300
-
1301
- return $title;
1302
- }
1303
-
1304
- add_filter('get_wp_title_rss', 'powerpress_wp_title_rss');
1305
-
1306
- function powerpress_the_title_rss($title)
1307
- {
1308
- $new_title = $title;
1309
- $GeneralSettings = get_option('powerpress_general');
1310
- // If it is a custom podcast channel...
1311
- if( !empty($GeneralSettings['seo_feed_title']) )
1312
- {
1313
- $feed_slug = 'podcast';
1314
- // IF custom post type or channel, use that feed slug...
1315
- if( get_query_var('feed') !== 'podcast' && !is_category() && !is_tax() && !is_tag() )
1316
- $feed_slug = get_query_var('feed');
1317
-
1318
- // Get the episode specific title...
1319
- $EpisodeData = powerpress_get_enclosure_data(get_the_ID(), $feed_slug);
1320
- if( !empty($EpisodeData['feed_title']) )
1321
- {
1322
- $feed_title = ent2ncr( $EpisodeData['feed_title'] );
1323
- $feed_title = strip_tags( $feed_title );
1324
- $feed_title = esc_html( $feed_title );
1325
-
1326
- //switch( $GeneralSettings['custom_feed_title'] )
1327
- switch( $GeneralSettings['seo_feed_title'] )
1328
- {
1329
- case 1: { // Replaces title
1330
- $new_title = $feed_title;
1331
- }; break;
1332
- case 2: { // Prefixes title
1333
- $new_title = $feed_title . ' ' . $title;
1334
- }; break;
1335
- case 3: { // Postfixes title
1336
- $new_title = $title . ' ' . $feed_title;
1337
- }; break;
1338
- }
1339
- }
1340
- }
1341
-
1342
- return $new_title;
1343
- }
1344
-
1345
- add_filter('the_title_rss', 'powerpress_the_title_rss', 11);
1346
-
1347
-
1348
- function powerpress_feed_content_type($content_type = '', $feedslug = '')
1349
- {
1350
- switch( $feedslug )
1351
- {
1352
- case 'rss':
1353
- case 'rss2':
1354
- case 'atom':
1355
- case 'rdf': {
1356
- // Do nothing, let WordPress take care of these
1357
- }; break;
1358
- case 'podcast': {
1359
- // This one is ours!
1360
- $content_type = 'application/rss+xml';
1361
- }; break;
1362
- default: { // Check for the custom podcast feeds
1363
- $GeneralSettings = get_option('powerpress_general');
1364
- if( !empty($GeneralSettings['custom_feeds'][ $feedslug ]) )
1365
- {
1366
- $content_type = 'application/rss+xml';
1367
- }
1368
- else if( !empty($GeneralSettings['posttype_podcasting']) )
1369
- {
1370
- // We need to look up these settings...
1371
- $FeedSlugPostTypesArray = get_option('powerpress_posttype-podcasting');
1372
- if( is_array($FeedSlugPostTypesArray) && !empty($FeedSlugPostTypesArray[ $feedslug ]) )
1373
- {
1374
- $content_type = 'application/rss+xml';
1375
- }
1376
- }
1377
- }
1378
- }
1379
-
1380
- return $content_type;
1381
- }
1382
-
1383
- add_filter( 'feed_content_type', 'powerpress_feed_content_type', 10, 2 );
1384
-
1385
- // Following code only works for WP 3.3 or older. WP 3.4+ now uses the get_locale setting, so we have to override directly in the get_bloginfo_rss functoin.
1386
- if( version_compare($GLOBALS['wp_version'], '3.4', '<') )
1387
- {
1388
- function powerpress_rss_language($value)
1389
- {
1390
- if( powerpress_is_custom_podcast_feed() )
1391
- {
1392
- global $powerpress_feed;
1393
- if( $powerpress_feed && isset($powerpress_feed['rss_language']) && $powerpress_feed['rss_language'] != '' )
1394
- $value = $powerpress_feed['rss_language'];
1395
- }
1396
- return $value;
1397
- }
1398
-
1399
- add_filter('option_rss_language', 'powerpress_rss_language');
1400
- }
1401
-
1402
- function powerpress_do_podcast_feed($for_comments=false)
1403
- {
1404
- global $wp_query, $powerpress_feed;
1405
-
1406
- powerpress_is_podcast_feed(); // Loads the feed settings if not already loaded...
1407
-
1408
- $GeneralSettings = get_option('powerpress_general');
1409
- if( isset($GeneralSettings['premium_caps']) && $GeneralSettings['premium_caps'] )
1410
- {
1411
- $feed_slug = get_query_var('feed');
1412
-
1413
- if( $feed_slug != 'podcast' )
1414
- {
1415
- $FeedSettings = get_option('powerpress_feed_'.$feed_slug);
1416
- if( !empty($FeedSettings['premium']) )
1417
- {
1418
- require_once( POWERPRESS_ABSPATH.'/powerpress-feed-auth.php');
1419
- powerpress_feed_auth( $feed_slug );
1420
- }
1421
- }
1422
- }
1423
-
1424
- // Use the template to gurantee future WordPress behavior
1425
- if( defined('POWERPRESS_FEED_TEMPLATE') ) {
1426
- load_template( POWERPRESS_FEED_TEMPLATE );
1427
- } else {
1428
- load_template( POWERPRESS_ABSPATH . '/feed-podcast.php' );
1429
- }
1430
- }
1431
-
1432
- function powerpress_template_redirect()
1433
- {
1434
- if( is_feed() && powerpress_is_custom_podcast_feed() )
1435
- {
1436
- if ( defined('WPSEO_VERSION') && version_compare(WPSEO_VERSION, '7.7', '>=') && class_exists( 'WPSEO_Frontend' ) ) {
1437
- $wpseo_frontend = WPSEO_Frontend::get_instance();
1438
- if( !empty($wpseo_frontend) ) {
1439
- remove_action( 'template_redirect', array( $wpseo_frontend, 'noindex_feed' ) );
1440
- }
1441
- }
1442
-
1443
- remove_action('template_redirect', 'ol_feed_redirect'); // Remove this action so feedsmith doesn't redirect
1444
- global $powerpress_feed;
1445
- if( !isset($powerpress_feed['feed_redirect_url']) )
1446
- $powerpress_feed['feed_redirect_url'] = '';
1447
- $redirect_value = ( !empty($_GET['redirect'])? $_GET['redirect'] : false );
1448
- if( is_array($powerpress_feed) && trim($powerpress_feed['feed_redirect_url']) != '' && !preg_match("/feedburner|feedsqueezer|feedvalidator/i", $_SERVER['HTTP_USER_AGENT'] ) && $redirect_value != 'no' )
1449
- {
1450
- if (function_exists('status_header'))
1451
- status_header( 301 );
1452
- header("Location: " . trim($powerpress_feed['feed_redirect_url']));
1453
- header("HTTP/1.1 301 Moved Permanently");
1454
- exit();
1455
- }
1456
- }
1457
- }
1458
-
1459
- add_action('template_redirect', 'powerpress_template_redirect', 0);
1460
-
1461
-
1462
- function powerpress_rewrite_rules_array($array)
1463
- {
1464
- global $wp_rewrite;
1465
- $settings = get_option('powerpress_general');
1466
-
1467
- $podcast_feeds = array('podcast'=>true);
1468
- if( isset($settings['custom_feeds']) && is_array($settings['custom_feeds']) )
1469
- $podcast_feeds = array_merge($settings['custom_feeds'], $podcast_feeds );
1470
-
1471
- $merged_slugs = '';
1472
- foreach( $podcast_feeds as $feed_slug=> $feed_title )
1473
- {
1474
- if( $merged_slugs != '' )
1475
- $merged_slugs .= '|';
1476
- $merged_slugs .= $feed_slug;
1477
- }
1478
-
1479
- // $wp_rewrite->index most likely index.php
1480
- $new_array[ 'feed/('.$merged_slugs.')/?$' ] = $wp_rewrite->index. '?feed='. $wp_rewrite->preg_index(1);
1481
-
1482
- // If feature is not enabled, use the default permalinks
1483
- if( empty($settings['permalink_feeds_only']) )
1484
- return array_merge($new_array, $array);
1485
-
1486
- global $wpdb;
1487
- reset($podcast_feeds);
1488
- foreach( $podcast_feeds as $feed_slug=> $feed_title )
1489
- {
1490
- $page_name_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_name = '".$feed_slug."'");
1491
- if( $page_name_id )
1492
- {
1493
- $new_array[ $feed_slug.'/?$' ] = $wp_rewrite->index. '?pagename='. $feed_slug.'&page_id='.$page_name_id;
1494
- unset($podcast_feeds[ $feed_slug ]);
1495
- continue;
1496
- }
1497
-
1498
- $category = get_category_by_slug($feed_slug);
1499
- if( $category )
1500
- {
1501
- $new_array[ $feed_slug.'/?$' ] = $wp_rewrite->index. '?cat='. $category->term_id; // category_name='. $feed_slug .'&
1502
- unset($podcast_feeds[ $feed_slug ]);
1503
- }
1504
- }
1505
-
1506
- if( count($podcast_feeds) > 0 )
1507
- {
1508
- reset($podcast_feeds);
1509
- $remaining_slugs = '';
1510
- foreach( $podcast_feeds as $feed_slug=> $feed_title )
1511
- {
1512
- if( $remaining_slugs != '' )
1513
- $remaining_slugs .= '|';
1514
- $remaining_slugs .= $feed_slug;
1515
- }
1516
-
1517
- $new_array[ '('.$remaining_slugs.')/?$' ] = $wp_rewrite->index. '?pagename='. $wp_rewrite->preg_index(1);
1518
- }
1519
-
1520
- return array_merge($new_array, $array);
1521
- }
1522
-
1523
- add_filter('rewrite_rules_array', 'powerpress_rewrite_rules_array');
1524
-
1525
-
1526
- function powerpress_pre_transient_rewrite_rules($return_rules)
1527
- {
1528
- global $wp_rewrite;
1529
- $GeneralSettings = get_option('powerpress_general');
1530
- if( !in_array('podcast', $wp_rewrite->feeds) )
1531
- $wp_rewrite->feeds[] = 'podcast';
1532
-
1533
- if( $GeneralSettings && isset($GeneralSettings['custom_feeds']) && is_array($GeneralSettings['custom_feeds']) )
1534
- {
1535
- foreach( $GeneralSettings['custom_feeds'] as $feed_slug=> $null )
1536
- {
1537
- if( !in_array($feed_slug, $wp_rewrite->feeds) )
1538
- $wp_rewrite->feeds[] = $feed_slug;
1539
- }
1540
- }
1541
-
1542
- return $return_rules;
1543
- }
1544
-
1545
- add_filter('pre_transient_rewrite_rules', 'powerpress_pre_transient_rewrite_rules');
1546
-
1547
- function powerpress_init()
1548
- {
1549
- $GeneralSettings = get_option('powerpress_general');
1550
-
1551
- if( !empty($GeneralSettings['powerpress-beta-features']) && file_exists(POWERPRESS_ABSPATH.'/powerpressadmin-pts.php') )
1552
- {
1553
- require_once(POWERPRESS_ABSPATH.'/powerpressadmin-pts.php');
1554
- }
1555
-
1556
- if( empty($GeneralSettings['disable_appearance']) || $GeneralSettings['disable_appearance'] == false )
1557
- {
1558
- require_once( POWERPRESS_ABSPATH.'/powerpress-player.php');
1559
- powerpressplayer_init($GeneralSettings);
1560
- }
1561
-
1562
- // Enable the playlist feature for PowerPress
1563
- if( !empty($GeneralSettings['playlist_player']) ) // Either not set or set on
1564
- {
1565
- require_once(POWERPRESS_ABSPATH.'/powerpress-playlist.php');
1566
- }
1567
-
1568
- if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) || defined('PODCASTING_VERSION') )
1569
- return false; // Another podcasting plugin is enabled...
1570
-
1571
- // If we are to process podpress data..
1572
- if( !empty($GeneralSettings['process_podpress']) )
1573
- {
1574
- powerpress_podpress_redirect_check();
1575
- }
1576
-
1577
- // Add the podcast feeds;
1578
- if( !defined('POWERPRESS_NO_PODCAST_FEED') )
1579
- {
1580
- add_feed('podcast', 'powerpress_do_podcast_feed');
1581
- }
1582
-
1583
- if( $GeneralSettings && isset($GeneralSettings['custom_feeds']) && is_array($GeneralSettings['custom_feeds']) )
1584
- {
1585
- foreach( $GeneralSettings['custom_feeds'] as $feed_slug=> $feed_title )
1586
- {
1587
- if( $feed_slug != 'podcast' )
1588
- add_feed($feed_slug, 'powerpress_do_podcast_feed');
1589
- }
1590
- }
1591
-
1592
- if( !empty($GeneralSettings['posttype_podcasting']) )
1593
- {
1594
- // Loop through the posttype podcasting settings and set the feeds for the custom post type slugs...
1595
- global $wp_rewrite;
1596
-
1597
-
1598
- $FeedSlugPostTypesArray = get_option('powerpress_posttype-podcasting'); // Changed field slightly so it does not conflict with a post type "podcasting"
1599
- if( $FeedSlugPostTypesArray === false )
1600
- {
1601
- // Simple one-time fix...
1602
- $FeedSlugPostTypesArray = get_option('powerpress_posttype_podcasting');
1603
- if( empty($FeedSlugPostTypesArray) )
1604
- $FeedSlugPostTypesArray = array();
1605
- update_option('powerpress_posttype-podcasting', $FeedSlugPostTypesArray);
1606
- if( !array_key_exists('title', $FeedSlugPostTypesArray) ) // AS long as it doesn't have post type specific settings...
1607
- delete_option('powerpress_posttype_podcasting');
1608
- }
1609
-
1610
- if( empty($FeedSlugPostTypesArray) )
1611
- {
1612
- $FeedSlugPostTypesArray = array();
1613
- }
1614
- foreach( $FeedSlugPostTypesArray as $feed_slug=> $FeedSlugPostTypes )
1615
- {
1616
- if ( !in_array($feed_slug, $wp_rewrite->feeds) ) // we need to add this feed name
1617
- {
1618
- add_feed($feed_slug, 'powerpress_do_podcast_feed');
1619
- foreach( $FeedSlugPostTypes as $post_type_slug=> $title )
1620
- {
1621
- add_rewrite_rule( '/'. $post_type_slug .'/feed/'. $feed_slug .'/?$', 'index.php?post_type='. $post_type_slug .'&feed='.$feed_slug, 'top' ); // capture the post type feeds
1622
- add_rewrite_rule( '/'. $post_type_slug .'/feed/'. $feed_slug .'/?$', 'index.php?post_type='. $post_type_slug .'&feed='.$feed_slug, 'bottom' ); // capture the post type feeds
1623
- }
1624
- }
1625
- }
1626
- }
1627
-
1628
- if( defined('GAWP_VERSION') )
1629
- {
1630
- add_filter('the_content', 'powerpress_yoast_gawp_fix', 120 );
1631
- }
1632
-
1633
- if( !empty($GeneralSettings['subscribe_links']) )
1634
- {
1635
- // 2 Subscribe page shortocde [powerpress_subscribe feedslug="podcast"]
1636
- // 3 Subscribe sidebar widget: iTunes, RSS
1637
- add_filter('powerpress_player_subscribe_links', 'powerpressplayer_link_subscribe_pre', 1, 3);
1638
- add_filter('powerpress_player_subscribe_links', 'powerpressplayer_link_subscribe_post', 1000, 3);
1639
- }
1640
- wp_register_style(
1641
- 'powerpress-subscribe-style',
1642
- powerpress_get_root_url() . 'css/subscribe.css',
1643
- array(),
1644
- '20141021',
1645
- 'all' );
1646
-
1647
- if( !empty($GeneralSettings['rss_emoji']) ) {
1648
- if( has_filter('the_content_feed', 'wp_staticize_emoji') ) {
1649
- remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); // Remove the emoji images
1650
- remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
1651
- //add_filter( 'the_content_feed', 'wp_encode_emoji' ); // Convert an emoji to &#x1Fxxx;
1652
- //add_filter( 'get_wp_title_rss', 'wp_encode_emoji' );
1653
- }
1654
- }
1655
-
1656
- remove_action( 'wp_head', 'feed_links', 2 );
1657
- remove_action( 'wp_head', 'feed_links_extra', 3 );
1658
- }
1659
-
1660
- add_action('init', 'powerpress_init', -100); // We need to add the feeds before other plugins start screwing with them
1661
-
1662
- function powerpress_wp_print_styles()
1663
- {
1664
- $Settings = get_option('powerpress_general');
1665
-
1666
- if( !empty($Settings['audio_player_max_width']) )
1667
- {
1668
- echo '<style type="text/css">'."\n";
1669
- if( is_numeric($Settings['audio_player_max_width']) )
1670
- $Settings['audio_player_max_width'] .= 'px';
1671
- echo '.powerpress_player .wp-audio-shortcode { max-width: '.$Settings['audio_player_max_width'].'; }'."\n";
1672
- echo '</style>'."\n";
1673
- }
1674
- }
1675
-
1676
- add_action('wp_print_styles', 'powerpress_wp_print_styles');
1677
-
1678
- function powerpress_request($qv)
1679
- {
1680
- if( !empty($qv['feed']) )
1681
- {
1682
- $podcast_feed_slug = false;
1683
- if( $qv['feed'] == 'podcast' ) {
1684
- $GeneralSettings = get_option('powerpress_general');
1685
- if( empty($GeneralSettings['posttype_podcasting']) )
1686
- $podcast_feed_slug = 'podcast';
1687
- } else if( $qv['feed'] == 'rss' || $qv['feed'] == 'rss2' || $qv['feed'] == 'atom' || $qv['feed'] == 'rdf' || $qv['feed'] == 'feed' ) { // 'feed', 'rdf', 'rss', 'rss2', 'atom'
1688
- // Skip
1689
- } else {
1690
- $GeneralSettings = get_option('powerpress_general');
1691
- if( empty($GeneralSettings['posttype_podcasting']) && isset($GeneralSettings['custom_feeds']) && is_array($GeneralSettings['custom_feeds']) && !empty($GeneralSettings['custom_feeds'][ $qv['feed'] ] ) )
1692
- $podcast_feed_slug = $qv['feed'];
1693
-
1694
-
1695
- }
1696
-
1697
- if( $podcast_feed_slug )
1698
- {
1699
- if( !defined('POWERPRESS_POSTTYPE_MIXING') && $qv['feed'] == 'podcast' ) {
1700
- $qv['post_type'] = 'post';
1701
- } else {
1702
- $qv['post_type'] = get_post_types( array('public'=> true, 'capability_type'=>'post') );
1703
- if( !empty($qv['post_type']['attachment']) )
1704
- unset($qv['post_type']['attachment']);
1705
- }
1706
-
1707
- $FeedCustom = get_option('powerpress_feed_'.$podcast_feed_slug); // Get custom feed specific settings
1708
- // See if the user set a custom post type only...
1709
- if( !empty($FeedCustom) && !empty( $FeedCustom['custom_post_type']) )
1710
- $qv['post_type'] = $FeedCustom['custom_post_type'];
1711
- }
1712
- }
1713
- return $qv;
1714
- }
1715
-
1716
- add_filter('request', 'powerpress_request');
1717
-
1718
-
1719
- function powerpress_plugins_loaded()
1720
- {
1721
- // Translation support loaded:
1722
- load_plugin_textdomain('powerpress', // domain / keyword name of plugin
1723
- POWERPRESS_ABSPATH .'/languages', // Absolute path
1724
- basename(POWERPRESS_ABSPATH).'/languages' ); // relative path in plugins folder
1725
-
1726
- /*
1727
- ####
1728
- # Defines that effect translation defined now:
1729
- ####
1730
- */
1731
- // Set specific play and download labels for your installation of PowerPress
1732
- if( !defined('POWERPRESS_LINKS_TEXT') )
1733
- define('POWERPRESS_LINKS_TEXT', __('Podcast', 'powerpress') );
1734
- if( !defined('POWERPRESS_DURATION_TEXT') )
1735
- define('POWERPRESS_DURATION_TEXT', __('Duration', 'powerpress') );
1736
- if( !defined('POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT') )
1737
- define('POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT', __('Play in new window', 'powerpress') );
1738
- if( !defined('POWERPRESS_DOWNLOAD_TEXT') )
1739
- define('POWERPRESS_DOWNLOAD_TEXT', __('Download', 'powerpress') );
1740
- if( !defined('POWERPRESS_PLAY_TEXT') )
1741
- define('POWERPRESS_PLAY_TEXT', __('Play', 'powerpress') );
1742
- if( !defined('POWERPRESS_EMBED_TEXT') )
1743
- define('POWERPRESS_EMBED_TEXT', __('Embed', 'powerpress') );
1744
- if( !defined('POWERPRESS_READ_TEXT') )
1745
- define('POWERPRESS_READ_TEXT', __('Read', 'powerpress') );
1746
- }
1747
- add_action('plugins_loaded', 'powerpress_plugins_loaded');
1748
-
1749
-
1750
- function powerpress_w3tc_can_print_comment($settings)
1751
- {
1752
- return false;
1753
- }
1754
-
1755
- // Disable minifying if W3TC is enabled
1756
- function powerpress_w3tc_minify_enable($enable)
1757
- {
1758
- if( is_feed() )
1759
- return false;
1760
- return $enable;
1761
- }
1762
-
1763
- // Load the general feed settings for feeds handled by powerpress
1764
- function powerpress_load_general_feed_settings()
1765
- {
1766
- global $wp_query;
1767
- global $powerpress_feed;
1768
-
1769
- if( $powerpress_feed !== false ) // If it is not false (either NULL or an array) then we already looked these settings up
1770
- {
1771
- $powerpress_feed = false;
1772
-
1773
- // Get the powerpress settings
1774
- $GeneralSettings = get_option('powerpress_general');
1775
- if( !isset($GeneralSettings['custom_feeds']['podcast']) )
1776
- $GeneralSettings['custom_feeds']['podcast'] = 'Podcast Feed'; // Fixes scenario where the user never configured the custom default podcast feed.
1777
- if( empty($GeneralSettings['default_url']) )
1778
- $GeneralSettings['default_url'] = '';
1779
-
1780
- if( $GeneralSettings )
1781
- {
1782
- $FeedSettingsBasic = get_option('powerpress_feed'); // Get overall feed settings
1783
- if( is_feed() && defined( 'WPCACHEHOME' ) && empty($GeneralSettings['allow_feed_comments']) )
1784
- {
1785
- global $wp_super_cache_comments;
1786
- $wp_super_cache_comments = 0;
1787
- }
1788
-
1789
- if( is_feed() && defined('W3TC') && empty($GeneralSettings['allow_feed_comments']) )
1790
- {
1791
- add_filter( 'w3tc_can_print_comment', 'powerpress_w3tc_can_print_comment', 10, 1 );
1792
- }
1793
-
1794
- if( is_feed() && defined('W3TC') )
1795
- {
1796
- add_filter( 'w3tc_minify_enable', 'powerpress_w3tc_minify_enable');
1797
- }
1798
-
1799
- // If we're in advanced mode and we're dealing with a category feed we're extending, lets work with it...
1800
- if( is_category() && isset($GeneralSettings['custom_cat_feeds']) && is_array($GeneralSettings['custom_cat_feeds']) && in_array( get_query_var('cat'), $GeneralSettings['custom_cat_feeds']) )
1801
- {
1802
- $cat_ID = get_query_var('cat');
1803
- $FeedCustom = get_option('powerpress_cat_feed_'.$cat_ID); // Get custom feed specific settings
1804
- $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $FeedSettingsBasic);
1805
-
1806
- $powerpress_feed = array();
1807
- if( !empty($GeneralSettings['feed_accel']) )
1808
- $powerpress_feed['feed_accel'] = true;
1809
- $powerpress_feed['is_custom'] = true;
1810
- $powerpress_feed['category'] = $cat_ID;
1811
- $powerpress_feed['process_podpress'] = !empty($GeneralSettings['process_podpress']); // Category feeds could originate from Podpress
1812
- $powerpress_feed['rss_language'] = ''; // default, let WordPress set the language
1813
- $powerpress_feed['default_url'] = '';
1814
- if( !empty($GeneralSettings['default_url']) )
1815
- $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/';
1816
- $explicit_array = array("no", "yes", "clean");
1817
- $powerpress_feed['explicit'] = $explicit_array[$Feed['itunes_explicit']];
1818
- if( !empty($Feed['itunes_talent_name']) )
1819
- $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
1820
- else
1821
- $powerpress_feed['itunes_talent_name'] = get_wp_title_rss();
1822
- $powerpress_feed['enhance_itunes_summary'] = $Feed['enhance_itunes_summary'];
1823
- if( !empty($GeneralSettings['seo_itunes']) )
1824
- $powerpress_feed['enhance_itunes_summary'] = 1;
1825
- $powerpress_feed['posts_per_rss'] = false;
1826
- if( !empty($Feed['posts_per_rss']) && is_numeric($Feed['posts_per_rss']) && $Feed['posts_per_rss'] > 0 )
1827
- $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
1828
- $powerpress_feed['feed_redirect_url'] = '';
1829
- if( !empty($Feed['feed_redirect_url']) )
1830
- $powerpress_feed['feed_redirect_url'] = $Feed['feed_redirect_url'];
1831
- if( $Feed['itunes_author_post'] == true )
1832
- $powerpress_feed['itunes_author_post'] = true;
1833
- if( $Feed['rss_language'] != '' )
1834
- $powerpress_feed['rss_language'] = $Feed['rss_language'];
1835
-
1836
- if( !empty($GeneralSettings['podcast_embed_in_feed']) )
1837
- $powerpress_feed['podcast_embed_in_feed'] = true;
1838
- if( !empty($Feed['maximize_feed']) )
1839
- $powerpress_feed['maximize_feed'] = true;
1840
- if( !empty($Feed['episode_itunes_image']) && !empty($Feed['itunes_image']) )
1841
- $powerpress_feed['itunes_image'] = $Feed['itunes_image'];
1842
- return;
1843
- }
1844
- else if( ( defined('POWERPRESS_TAXONOMY_PODCASTING') || !empty($GeneralSettings['taxonomy_podcasting']) ) && ( is_tag() || is_tax() ) )
1845
- {
1846
- // We need to get the term_id and the tax_id (tt_id)
1847
- $term_slug = get_query_var('term');
1848
- $taxonomy = get_query_var('taxonomy');
1849
-
1850
- if( empty($term_slug) && empty($taxonomy) ) // Handle situation where tag is the taxonomy we're working with
1851
- {
1852
- $term_slug = get_query_var('tag');
1853
- if( !empty($term_slug) )
1854
- $taxonomy = 'post_tag';
1855
- }
1856
-
1857
- $term = false;
1858
- if( !empty($term_slug) && !empty($taxonomy) )
1859
- {
1860
- $term = term_exists($term_slug, $taxonomy);
1861
- }
1862
-
1863
- if( !empty($term['term_taxonomy_id']) )
1864
- {
1865
- $FeedCustom = get_option('powerpress_taxonomy_'.$term['term_taxonomy_id'] ); // Get custom feed specific settings
1866
- if( $FeedCustom )
1867
- {
1868
- $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $FeedSettingsBasic);
1869
-
1870
- $powerpress_feed = array();
1871
- if( !empty($GeneralSettings['feed_accel']) )
1872
- $powerpress_feed['feed_accel'] = true;
1873
- $powerpress_feed['is_custom'] = true;
1874
- $powerpress_feed['term_taxonomy_id'] = $term['term_taxonomy_id'];
1875
- $powerpress_feed['process_podpress'] = false; // Taxonomy feeds will not originate from Podpress
1876
- $powerpress_feed['rss_language'] = ''; // default, let WordPress set the language
1877
- $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/';
1878
- $explicit_array = array("no", "yes", "clean");
1879
- $powerpress_feed['explicit'] = $explicit_array[$Feed['itunes_explicit']];
1880
- if( !empty($Feed['itunes_talent_name']) )
1881
- $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
1882
- else
1883
- $powerpress_feed['itunes_talent_name'] = get_wp_title_rss();
1884
- $powerpress_feed['enhance_itunes_summary'] = $Feed['enhance_itunes_summary'];
1885
- if( !empty($GeneralSettings['seo_itunes']) )
1886
- $powerpress_feed['enhance_itunes_summary'] = 1;
1887
- $powerpress_feed['posts_per_rss'] = false;
1888
- if( !empty($Feed['posts_per_rss']) && is_numeric($Feed['posts_per_rss']) && $Feed['posts_per_rss'] > 0 )
1889
- $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
1890
- if( $Feed['feed_redirect_url'] != '' )
1891
- $powerpress_feed['feed_redirect_url'] = $Feed['feed_redirect_url'];
1892
- if( $Feed['itunes_author_post'] == true )
1893
- $powerpress_feed['itunes_author_post'] = true;
1894
- if( $Feed['rss_language'] != '' )
1895
- $powerpress_feed['rss_language'] = $Feed['rss_language'];
1896
-
1897
- if( !empty($GeneralSettings['podcast_embed_in_feed']) )
1898
- $powerpress_feed['podcast_embed_in_feed'] = true;
1899
- if( !empty($Feed['maximize_feed']) )
1900
- $powerpress_feed['maximize_feed'] = true;
1901
- if( !empty($Feed['episode_itunes_image']) && !empty($Feed['itunes_image']) )
1902
- $powerpress_feed['itunes_image'] = $Feed['itunes_image'];
1903
- return;
1904
- }
1905
- }
1906
- }
1907
-
1908
- $feed_slug = get_query_var('feed');
1909
- // Are we dealing with a custom podcast channel or a custom post type podcast feed...
1910
- if( !empty($GeneralSettings['posttype_podcasting']) || isset($GeneralSettings['custom_feeds'][ $feed_slug ]) )
1911
- {
1912
- $Feed = false;
1913
- if( !empty($GeneralSettings['posttype_podcasting']) )
1914
- {
1915
- $post_type = get_query_var('post_type');
1916
-
1917
- if( !empty($post_type) )
1918
- {
1919
- if ( is_array( $post_type ) ) {
1920
- $post_type = reset( $post_type ); // get first element in array
1921
- }
1922
-
1923
- // Get the settings for this podcast post type
1924
- $PostTypeSettingsArray = get_option('powerpress_posttype_'. $post_type);
1925
- if( !empty($PostTypeSettingsArray[ $feed_slug ]) )
1926
- {
1927
- $FeedCustom = $PostTypeSettingsArray[ $feed_slug ];
1928
- $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $FeedSettingsBasic);
1929
- $Feed['post_type'] = $post_type;
1930
- }
1931
- }
1932
- }
1933
- if( empty($Feed) && isset($GeneralSettings['custom_feeds'][ $feed_slug ]) )
1934
- {
1935
- $FeedCustom = get_option('powerpress_feed_'.$feed_slug); // Get custom feed specific settings
1936
- $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $FeedSettingsBasic, ($feed_slug == 'podcast') );
1937
- }
1938
-
1939
- if( $Feed )
1940
- {
1941
- $powerpress_feed = array();
1942
- if( !empty($GeneralSettings['feed_accel']) )
1943
- $powerpress_feed['feed_accel'] = true;
1944
- $powerpress_feed['is_custom'] = true;
1945
- $powerpress_feed['feed-slug'] = $feed_slug;
1946
- if( !empty($Feed['post_type']) )
1947
- $powerpress_feed['post_type'] = $Feed['post_type'];
1948
- $powerpress_feed['process_podpress'] = ($feed_slug=='podcast'? !empty($GeneralSettings['process_podpress']): false); // We don't touch podpress data for custom feeds
1949
- $powerpress_feed['rss_language'] = ''; // RSS language should be set by WordPress by default
1950
- $powerpress_feed['default_url'] = '';
1951
- if( !empty($powerpress_feed['default_url']) )
1952
- $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/';
1953
- $explicit = array("no", "yes", "clean");
1954
- $powerpress_feed['explicit'] ='no';
1955
- if( !empty($Feed['itunes_explicit']) )
1956
- $powerpress_feed['explicit'] = $explicit[ $Feed['itunes_explicit'] ];
1957
- if( !empty($Feed['itunes_talent_name']) )
1958
- $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
1959
- else
1960
- $powerpress_feed['itunes_talent_name'] = get_wp_title_rss();
1961
- $powerpress_feed['enhance_itunes_summary'] = $Feed['enhance_itunes_summary'];
1962
- if( !empty($GeneralSettings['seo_itunes']) )
1963
- $powerpress_feed['enhance_itunes_summary'] = 1;
1964
- $powerpress_feed['posts_per_rss'] = false;
1965
- if( !empty($Feed['posts_per_rss']) && is_numeric($Feed['posts_per_rss']) && $Feed['posts_per_rss'] > 0 )
1966
- $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
1967
- if( !empty($Feed['feed_redirect_url']) )
1968
- $powerpress_feed['feed_redirect_url'] = $Feed['feed_redirect_url'];
1969
- if( !empty($Feed['itunes_author_post'] ) )
1970
- $powerpress_feed['itunes_author_post'] = true;
1971
- if( !empty($Feed['rss_language']) )
1972
- $powerpress_feed['rss_language'] = $Feed['rss_language'];
1973
- if( !empty($GeneralSettings['podcast_embed_in_feed']) )
1974
- $powerpress_feed['podcast_embed_in_feed'] = true;
1975
- if( !empty($Feed['maximize_feed']) )
1976
- $powerpress_feed['maximize_feed'] = true;
1977
- if( !empty($Feed['episode_itunes_image']) && !empty($Feed['itunes_image']) )
1978
- $powerpress_feed['itunes_image'] = $Feed['itunes_image'];
1979
- return;
1980
- }
1981
- }
1982
-
1983
- if( !isset($FeedSettingsBasic['apply_to']) )
1984
- $FeedSettingsBasic['apply_to'] = 1;
1985
-
1986
- // We fell this far,we must be in simple mode or the user never saved customized their custom feed settings
1987
- switch( $FeedSettingsBasic['apply_to'] )
1988
- {
1989
- 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.
1990
- {
1991
- if( $feed_slug != 'podcast' )
1992
- break;
1993
- } // important: no break here!
1994
- case 2: // RSS2 Main feed and podcast feed added by PowerPress only
1995
- {
1996
- if( $feed_slug != 'feed' && $feed_slug != 'rss2' && $feed_slug != 'podcast' )
1997
- break; // We're only adding podcasts to the rss2 feed in this situation
1998
-
1999
- if( $wp_query->is_category ) // don't touch the category feeds...
2000
- break;
2001
-
2002
- if( $wp_query->is_tag ) // don't touch the tag feeds...
2003
- break;
2004
-
2005
- if( $wp_query->is_comment_feed ) // don't touch the comments feeds...
2006
- break;
2007
- } // important: no break here!
2008
- case 1: // All feeds
2009
- {
2010
- $powerpress_feed = array(); // Only store what's needed for each feed item
2011
- if( !empty($GeneralSettings['feed_accel']) )
2012
- $powerpress_feed['feed_accel'] = true;
2013
- $powerpress_feed['is_custom'] = false; // ($feed_slug == 'podcast'?true:false);
2014
- $powerpress_feed['feed-slug'] = $feed_slug;
2015
- $powerpress_feed['process_podpress'] = !empty($GeneralSettings['process_podpress']); // We don't touch podpress data for custom feeds
2016
- $powerpress_feed['default_url'] = '';
2017
- if( !empty($GeneralSettings['default_url']) )
2018
- $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/';
2019
- $explicit = array("no", "yes", "clean");
2020
- $powerpress_feed['explicit'] = 'no';
2021
- if( !empty($FeedSettingsBasic['itunes_explicit']) )
2022
- $powerpress_feed['explicit'] = $explicit[$FeedSettingsBasic['itunes_explicit']];
2023
- if( !empty($FeedSettingsBasic['itunes_talent_name']) )
2024
- $powerpress_feed['itunes_talent_name'] = $FeedSettingsBasic['itunes_talent_name'];
2025
- else
2026
- $powerpress_feed['itunes_talent_name'] = get_wp_title_rss();
2027
- $powerpress_feed['enhance_itunes_summary'] = 0;
2028
- if( isset($FeedSettingsBasic['enhance_itunes_summary']) )
2029
- $powerpress_feed['enhance_itunes_summary'] = $FeedSettingsBasic['enhance_itunes_summary'];
2030
- if( !empty($GeneralSettings['seo_itunes']) )
2031
- $powerpress_feed['enhance_itunes_summary'] = 1;
2032
- $powerpress_feed['posts_per_rss'] = false;
2033
- if( !empty($FeedSettingsBasic['posts_per_rss']) && is_numeric($FeedSettingsBasic['posts_per_rss']) && $FeedSettingsBasic['posts_per_rss'] > 0 )
2034
- $powerpress_feed['posts_per_rss'] = $FeedSettingsBasic['posts_per_rss'];
2035
- if( !empty($FeedSettingsBasic['itunes_author_post']) )
2036
- $powerpress_feed['itunes_author_post'] = true;
2037
- $powerpress_feed['rss_language'] = ''; // Cannot set the language setting in simple mode
2038
- if( !empty($GeneralSettings['podcast_embed_in_feed']) )
2039
- $powerpress_feed['podcast_embed_in_feed'] = true;
2040
- if( !empty($FeedSettingsBasic['episode_itunes_image']) && !empty($FeedSettingsBasic['itunes_image']) )
2041
- $powerpress_feed['itunes_image'] = $FeedSettingsBasic['itunes_image'];
2042
-
2043
- }; break;
2044
- // All other cases we let fall through
2045
- }
2046
- }
2047
- }
2048
- }
2049
-
2050
- // Returns true of the feed should be treated as a podcast feed
2051
- function powerpress_is_podcast_feed()
2052
- {
2053
- if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) || defined('PODCASTING_VERSION') )
2054
- return false; // Another podcasting plugin is enabled...
2055
-
2056
- global $powerpress_feed;
2057
- if( $powerpress_feed !== false && !is_array($powerpress_feed) )
2058
- powerpress_load_general_feed_settings();
2059
- if( $powerpress_feed === false )
2060
- return false;
2061
- return true;
2062
- }
2063
-
2064
- // Returns true if the feed is a custom feed added by PowerPress
2065
- function powerpress_is_custom_podcast_feed()
2066
- {
2067
- if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) || defined('PODCASTING_VERSION') )
2068
- return false; // Another podcasting plugin is enabled...
2069
-
2070
- global $powerpress_feed;
2071
- if( $powerpress_feed !== false && !is_array($powerpress_feed) )
2072
- powerpress_load_general_feed_settings();
2073
- if( $powerpress_feed === false )
2074
- return false;
2075
- return $powerpress_feed['is_custom'];
2076
- }
2077
-
2078
- function powerpress_posts_fields($cols)
2079
- {
2080
- if( !is_feed() )
2081
- return $cols;
2082
-
2083
- if( is_category() || is_tag() || is_tax() ) {
2084
- if( get_query_var('feed') !== 'podcast' )
2085
- return $cols;
2086
- }
2087
-
2088
- if( powerpress_is_custom_podcast_feed() || get_query_var('feed') === 'podcast' )
2089
- {
2090
- if( !empty($GLOBALS['powerpress_feed']['feed_accel']) )
2091
- {
2092
- $feed_slug = get_query_var('feed');
2093
- global $wpdb;
2094
- $cols .= ", pp_{$wpdb->postmeta}.meta_value AS podcast_meta_value ";
2095
- }
2096
- }
2097
-
2098
- return $cols;
2099
- }
2100
- //$fields = apply_filters_ref_array( 'posts_fields', array( $fields, &$this ) );
2101
- add_filter('posts_fields', 'powerpress_posts_fields' );
2102
-
2103
- function powerpress_posts_join($join)
2104
- {
2105
- if( !is_feed() )
2106
- return $join;
2107
-
2108
- if( is_category() || is_tag() || is_tax() ) {
2109
- if( get_query_var('feed') !== 'podcast' )
2110
- return $join;
2111
- }
2112
-
2113
- if( powerpress_is_custom_podcast_feed() || get_query_var('feed') === 'podcast' )
2114
- {
2115
- global $wpdb;
2116
- $join .= " INNER JOIN {$wpdb->postmeta} AS pp_{$wpdb->postmeta} ";
2117
- $join .= " ON {$wpdb->posts}.ID = pp_{$wpdb->postmeta}.post_id ";
2118
- }
2119
-
2120
- return $join;
2121
- }
2122
-
2123
- add_filter('posts_join', 'powerpress_posts_join' );
2124
-
2125
- function powerpress_posts_where($where)
2126
- {
2127
- if( !is_feed() )
2128
- return $where;
2129
- if( is_category() || is_tag() || is_tax() ) {
2130
- if( get_query_var('feed') !== 'podcast' )
2131
- return $where;
2132
- }
2133
-
2134
- if( powerpress_is_custom_podcast_feed() || get_query_var('feed') === 'podcast' )
2135
- {
2136
- global $wpdb, $powerpress_feed;
2137
- $where .= " AND (";
2138
-
2139
- if( powerpress_is_custom_podcast_feed() && get_query_var('feed') !== 'podcast' )
2140
- $where .= " pp_{$wpdb->postmeta}.meta_key = '_". get_query_var('feed') .":enclosure' ";
2141
- else
2142
- $where .= " pp_{$wpdb->postmeta}.meta_key = 'enclosure' ";
2143
-
2144
- // Include Podpress data if exists...
2145
- if( !empty($powerpress_feed['process_podpress']) && get_query_var('feed') === 'podcast' )
2146
- $where .= " OR pp_{$wpdb->postmeta}.meta_key = 'podPressMedia' OR pp_{$wpdb->postmeta}.meta_key = '_podPressMedia' ";
2147
-
2148
- $where .= ") ";
2149
- }
2150
- return $where;
2151
- }
2152
-
2153
- add_filter('posts_where', 'powerpress_posts_where' );
2154
-
2155
- // Add the groupby needed for enclosures only
2156
- function powerpress_posts_groupby($groupby)
2157
- {
2158
- if( !is_feed() )
2159
- return $groupby;
2160
-
2161
- if( is_category() || is_tag() || is_tax() ) {
2162
- if( get_query_var('feed') !== 'podcast' )
2163
- return $groupby;
2164
- }
2165
-
2166
- if( powerpress_is_custom_podcast_feed() || get_query_var('feed') === 'podcast' )
2167
- {
2168
- global $wpdb;
2169
- $groupby = " {$wpdb->posts}.ID ";
2170
- }
2171
- return $groupby;
2172
- }
2173
- add_filter('posts_groupby', 'powerpress_posts_groupby');
2174
-
2175
- function powerpress_post_limits($limits)
2176
- {
2177
- if( !is_feed() )
2178
- return $limits;
2179
-
2180
- if( powerpress_is_custom_podcast_feed() || get_query_var('feed') === 'podcast' )
2181
- {
2182
- global $powerpress_feed;
2183
- if( !empty($powerpress_feed['posts_per_rss']) && preg_match('/^(\d)+$/', trim($powerpress_feed['posts_per_rss'])) )
2184
- $limits = "LIMIT 0, {$powerpress_feed['posts_per_rss']}";
2185
- }
2186
- return $limits;
2187
- }
2188
- add_filter('post_limits', 'powerpress_post_limits');
2189
-
2190
-
2191
- function powerpress_do_all_pings()
2192
- {
2193
- global $wpdb;
2194
- $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE meta_key = '_encloseme' ");
2195
-
2196
- // Now call the WordPress do_all_pings()...
2197
- do_all_pings();
2198
- remove_action('do_pings', 'do_all_pings');
2199
- }
2200
-
2201
- remove_action('do_pings', 'do_all_pings');
2202
- add_action('do_pings', 'powerpress_do_all_pings', 1, 1);
2203
-
2204
- /*
2205
- Helper functions:
2206
- */
2207
- function powerpress_podpress_redirect_check()
2208
- {
2209
- if( preg_match('/podpress_trac\/([^\/]+)\/([^\/]+)\/([^\/]+)\/(.*)$/', $_SERVER['REQUEST_URI'], $matches) )
2210
- {
2211
- $post_id = $matches[2];
2212
- $mediaNum = $matches[3];
2213
- //$filename = $matches[4];
2214
- //$method = $matches[1];
2215
-
2216
- if( is_numeric($post_id) && is_numeric($mediaNum))
2217
- {
2218
- $EpisodeData = powerpress_get_enclosure_data_podpress($post_id, $mediaNum);
2219
- if( $EpisodeData && isset($EpisodeData['url']) )
2220
- {
2221
- if( strpos($EpisodeData['url'], 'http://' ) !== 0 && strpos($EpisodeData['url'], 'https://' ) !== 0 )
2222
- {
2223
- die('Error occurred obtaining the URL for the requested media file.');
2224
- exit;
2225
- }
2226
-
2227
- $EnclosureURL = str_replace(' ', '%20', $EpisodeData['url']);
2228
- header('Location: '.$EnclosureURL, true, 302);
2229
- header('Content-Length: 0');
2230
- exit;
2231
- }
2232
- // Let the WordPress 404 page load as normal
2233
- }
2234
- }
2235
- }
2236
-
2237
- function the_powerpress_content()
2238
- {
2239
- echo get_the_powerpress_content();
2240
- }
2241
-
2242
- function get_the_powerpress_content()
2243
- {
2244
- global $post;
2245
-
2246
- if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) || defined('PODCASTING_VERSION') )
2247
- return '';
2248
-
2249
- if( function_exists('post_password_required') )
2250
- {
2251
- if( post_password_required($post) )
2252
- return '';
2253
- }
2254
-
2255
- // PowerPress settings:
2256
- $GeneralSettings = get_option('powerpress_general');
2257
-
2258
- // No player or links to add to content...
2259
- if( !empty($GeneralSettings['disable_appearance']) )
2260
- return $content;
2261
-
2262
- if( !isset($GeneralSettings['custom_feeds']) )
2263
- $GeneralSettings['custom_feeds'] = array('podcast'=>'Default Podcast Feed');
2264
-
2265
- // Re-order so the default podcast episode is the top most...
2266
- $Temp = $GeneralSettings['custom_feeds'];
2267
- $GeneralSettings['custom_feeds'] = array();
2268
- $GeneralSettings['custom_feeds']['podcast'] = 'Default Podcast Feed';
2269
-
2270
- foreach( $Temp as $feed_slug=> $feed_title )
2271
- {
2272
- if( $feed_slug == 'podcast' )
2273
- continue;
2274
- $GeneralSettings['custom_feeds'][ $feed_slug ] = $feed_title;
2275
- }
2276
-
2277
- // Handle post type feeds....
2278
- if( !empty($GeneralSettings['posttype_podcasting']) )
2279
- {
2280
- $post_type = get_query_var('post_type');
2281
- if ( is_array( $post_type ) ) {
2282
- $post_type = reset( $post_type ); // get first element in array
2283
- }
2284
-
2285
- // Get the feed slugs and titles for this post type
2286
- $PostTypeSettingsArray = get_option('powerpress_posttype_'.$post_type);
2287
- // Loop through this array of post type settings...
2288
- if( !empty($PostTypeSettingsArray) )
2289
- {
2290
- switch($post_type)
2291
- {
2292
- case 'post':
2293
- case 'page': {
2294
- // Do nothing!, we want the default podcast to appear in these post types
2295
- }; break;
2296
- default: {
2297
- if( !empty($post_type) && empty($PostTypeSettingsArray['podcast']) )
2298
- unset($GeneralSettings['custom_feeds']['podcast']); // special case, we do not want an accidental podcast episode to appear in a custom post type if the feature is enabled
2299
- }; break;
2300
- }
2301
-
2302
- foreach( $PostTypeSettingsArray as $feed_slug=> $postTypeSettings )
2303
- {
2304
- if( !empty( $postTypeSettings['title']) )
2305
- $GeneralSettings['custom_feeds'][ $feed_slug ] = $postTypeSettings['title'];
2306
- else
2307
- $GeneralSettings['custom_feeds'][ $feed_slug ] = $feed_slug;
2308
- }
2309
- }
2310
- }
2311
-
2312
- if( !isset($GeneralSettings['display_player']) )
2313
- $GeneralSettings['display_player'] = 1;
2314
- if( !isset($GeneralSettings['player_function']) )
2315
- $GeneralSettings['player_function'] = 1;
2316
- if( !isset($GeneralSettings['podcast_link']) )
2317
- $GeneralSettings['podcast_link'] = 1;
2318
-
2319
- // Figure out which players are alerady in the body of the page...
2320
- $ExcludePlayers = array();
2321
- if( isset($GeneralSettings['disable_player']) )
2322
- $ExcludePlayers = $GeneralSettings['disable_player']; // automatically disable the players configured
2323
-
2324
- // LOOP HERE TO DISPLAY EACH MEDIA TYPE
2325
- $new_content = '';
2326
- foreach( $GeneralSettings['custom_feeds'] as $feed_slug=> $feed_title )
2327
- {
2328
- // Get the enclosure data
2329
- $EpisodeData = powerpress_get_enclosure_data($post->ID, $feed_slug);
2330
-
2331
- if( !$EpisodeData && !empty($GeneralSettings['process_podpress']) && $feed_slug == 'podcast' )
2332
- $EpisodeData = powerpress_get_enclosure_data_podpress($post->ID);
2333
-
2334
- if( !$EpisodeData || !$EpisodeData['url'] )
2335
- continue;
2336
-
2337
- // Just in case, if there's no URL lets escape!
2338
- if( !$EpisodeData['url'] )
2339
- continue;
2340
-
2341
- // If the player is not already inserted in the body of the post using the shortcode...
2342
- //if( preg_match('/\[powerpress(.*)\]/is', $content) == 0 )
2343
- if( !isset($ExcludePlayers[ $feed_slug ]) ) // If the player is not in our exclude list because it's already in the post body somewhere...
2344
- {
2345
- if( isset($GeneralSettings['premium_caps']) && $GeneralSettings['premium_caps'] && !powerpress_premium_content_authorized($feed_slug) )
2346
- {
2347
- $new_content .= powerpress_premium_content_message($post->ID, $feed_slug, $EpisodeData);
2348
- }
2349
- else
2350
- {
2351
- if( $GeneralSettings['player_function'] != 3 && $GeneralSettings['player_function'] != 0 ) // Play in new window only or disabled
2352
- {
2353
- do_action('wp_powerpress_player_scripts');
2354
- $AddDefaultPlayer = empty($EpisodeData['no_player']);
2355
-
2356
- if( $EpisodeData && !empty($EpisodeData['embed']) )
2357
- {
2358
- $new_content .= trim($EpisodeData['embed']);
2359
- if( !empty($GeneralSettings['embed_replace_player']) )
2360
- $AddDefaultPlayer = false;
2361
- }
2362
-
2363
- if( $AddDefaultPlayer )
2364
- {
2365
- $image = '';
2366
- $width = '';
2367
- $height = '';
2368
- if( isset($EpisodeData['image']) && $EpisodeData['image'] != '' )
2369
- $image = $EpisodeData['image'];
2370
- if( !empty($EpisodeData['width']) && is_numeric($EpisodeData['width']) )
2371
- $width = $EpisodeData['width'];
2372
- if( !empty($EpisodeData['height']) && is_numeric($EpisodeData['height']) )
2373
- $height = $EpisodeData['height'];
2374
-
2375
- $new_content .= apply_filters('powerpress_player', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData );
2376
- }
2377
- }
2378
-
2379
- if( !isset($EpisodeData['no_links']) )
2380
- {
2381
- do_action('wp_powerpress_player_scripts');
2382
- $new_content .= apply_filters('powerpress_player_links', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData );
2383
- $new_content .= apply_filters('powerpress_player_subscribe_links', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData );
2384
- }
2385
- }
2386
- }
2387
- }
2388
-
2389
- return $new_content;
2390
- }
2391
-
2392
-
2393
-
2394
- // Adds content types that are missing from the default wp_check_filetype function
2395
- function powerpress_get_contenttype($file, $use_wp_check_filetype = true)
2396
- {
2397
- $parts = pathinfo($file);
2398
- if( !empty($parts['extension']) )
2399
- {
2400
- switch( strtolower($parts['extension']) )
2401
- {
2402
- // Audio formats
2403
- case 'mp3': // most common
2404
- case 'mpga':
2405
- case 'mp2':
2406
- case 'mp2a':
2407
- case 'm2a':
2408
- case 'm3a':
2409
- return 'audio/mpeg';
2410
- case 'm4a':
2411
- return 'audio/x-m4a';
2412
- case 'm4b': // Audio book format
2413
- return 'audio/m4b';
2414
- case 'm4r': // iPhone ringtone format
2415
- return 'audio/m4r';
2416
- // OGG Internet content types as set forth by rfc5334 (http://tools.ietf.org/html/rfc5334)
2417
- case 'opus':
2418
- case 'oga':
2419
- case 'spx':
2420
- return 'audio/ogg';
2421
- case 'wma':
2422
- return 'audio/x-ms-wma';
2423
- case 'wax':
2424
- return 'audio/x-ms-wax';
2425
- case 'ra':
2426
- case 'ram':
2427
- return 'audio/x-pn-realaudio';
2428
- case 'mp4a':
2429
- return 'audio/mp4';
2430
-
2431
- // Video formats
2432
- case 'm4v':
2433
- return 'video/x-m4v';
2434
- case 'mpeg':
2435
- case 'mpg':
2436
- case 'mpe':
2437
- case 'm1v':
2438
- case 'm2v':
2439
- return 'video/mpeg';
2440
- case 'mp4':
2441
- case 'mp4v':
2442
- case 'mpg4':
2443
- return 'video/mp4';
2444
- case 'asf':
2445
- case 'asx':
2446
- return 'video/x-ms-asf';
2447
- case 'wmx':
2448
- return 'video/x-ms-wmx';
2449
- case 'avi':
2450
- return 'video/x-msvideo';
2451
- case 'wmv':
2452
- return 'video/x-ms-wmv'; // Check this
2453
- case 'flv':
2454
- return 'video/x-flv';
2455
- case 'mov':
2456
- case 'qt':
2457
- return 'video/quicktime';
2458
- case 'divx':
2459
- return 'video/divx';
2460
- case '3gp':
2461
- return 'video/3gpp';
2462
- case 'webm':
2463
- return 'video/webm';
2464
- case 'ogg': {
2465
- if( !defined('POWERPRESS_OGG_VIDEO') )
2466
- return 'audio/ogg';
2467
- } // Let this fall through as ogg/video
2468
- case 'ogv':
2469
- return 'video/ogg';
2470
-
2471
- // rarely used
2472
- case 'mid':
2473
- case 'midi':
2474
- return 'audio/midi';
2475
- case 'wav':
2476
- return 'audio/wav';
2477
- case 'aa':
2478
- return 'audio/audible';
2479
- case 'pdf':
2480
- return 'application/pdf';
2481
- case 'torrent':
2482
- return 'application/x-bittorrent';
2483
- case 'swf':
2484
- return 'application/x-shockwave-flash';
2485
- case 'ogx':
2486
- return 'application/ogg';
2487
-
2488
- // Most recently added by Apple:
2489
- case 'epub':
2490
- return 'document/x-epub';
2491
-
2492
- default: // Let it fall through
2493
- }
2494
- }
2495
-
2496
- // Last case let wordpress detect it:
2497
- if( $use_wp_check_filetype )
2498
- {
2499
- $FileType = wp_check_filetype($file);
2500
- if( $FileType && isset($FileType['type']) )
2501
- return $FileType['type'];
2502
- }
2503
- return '';
2504
- }
2505
-
2506
-
2507
- function powerpress_itunes_categories($PrefixSubCategories = false)
2508
- {
2509
- $temp = array();
2510
- $temp['01-00'] = 'Arts';
2511
- $temp['01-01'] = 'Design';
2512
- $temp['01-02'] = 'Fashion & Beauty';
2513
- $temp['01-03'] = 'Food';
2514
- $temp['01-04'] = 'Literature';
2515
- $temp['01-05'] = 'Performing Arts';
2516
- $temp['01-06'] = 'Visual Arts';
2517
-
2518
- $temp['02-00'] = 'Business';
2519
- $temp['02-01'] = 'Business News';
2520
- $temp['02-02'] = 'Careers';
2521
- $temp['02-03'] = 'Investing';
2522
- $temp['02-04'] = 'Management & Marketing';
2523
- $temp['02-05'] = 'Shopping';
2524
-
2525
- $temp['03-00'] = 'Comedy';
2526
-
2527
- $temp['04-00'] = 'Education';
2528
- $temp['04-01'] = 'Education Technology';
2529
- $temp['04-02'] = 'Higher Education';
2530
- $temp['04-03'] = 'K-12';
2531
- $temp['04-04'] = 'Language Courses';
2532
- $temp['04-05'] = 'Training';
2533
-
2534
- $temp['05-00'] = 'Games & Hobbies';
2535
- $temp['05-01'] = 'Automotive';
2536
- $temp['05-02'] = 'Aviation';
2537
- $temp['05-03'] = 'Hobbies';
2538
- $temp['05-04'] = 'Other Games';
2539
- $temp['05-05'] = 'Video Games';
2540
-
2541
- $temp['06-00'] = 'Government & Organizations';
2542
- $temp['06-01'] = 'Local';
2543
- $temp['06-02'] = 'National';
2544
- $temp['06-03'] = 'Non-Profit';
2545
- $temp['06-04'] = 'Regional';
2546
-
2547
- $temp['07-00'] = 'Health';
2548
- $temp['07-01'] = 'Alternative Health';
2549
- $temp['07-02'] = 'Fitness & Nutrition';
2550
- $temp['07-03'] = 'Self-Help';
2551
- $temp['07-04'] = 'Sexuality';
2552
-
2553
- $temp['08-00'] = 'Kids & Family';
2554
-
2555
- $temp['09-00'] = 'Music';
2556
-
2557
- $temp['10-00'] = 'News & Politics';
2558
-
2559
- $temp['11-00'] = 'Religion & Spirituality';
2560
- $temp['11-01'] = 'Buddhism';
2561
- $temp['11-02'] = 'Christianity';
2562
- $temp['11-03'] = 'Hinduism';
2563
- $temp['11-04'] = 'Islam';
2564
- $temp['11-05'] = 'Judaism';
2565
- $temp['11-06'] = 'Other';
2566
- $temp['11-07'] = 'Spirituality';
2567
-
2568
- $temp['12-00'] = 'Science & Medicine';
2569
- $temp['12-01'] = 'Medicine';
2570
- $temp['12-02'] = 'Natural Sciences';
2571
- $temp['12-03'] = 'Social Sciences';
2572
-
2573
- $temp['13-00'] = 'Society & Culture';
2574
- $temp['13-01'] = 'History';
2575
- $temp['13-02'] = 'Personal Journals';
2576
- $temp['13-03'] = 'Philosophy';
2577
- $temp['13-04'] = 'Places & Travel';
2578
-
2579
- $temp['14-00'] = 'Sports & Recreation';
2580
- $temp['14-01'] = 'Amateur';
2581
- $temp['14-02'] = 'College & High School';
2582
- $temp['14-03'] = 'Outdoor';
2583
- $temp['14-04'] = 'Professional';
2584
-
2585
- $temp['15-00'] = 'Technology';
2586
- $temp['15-01'] = 'Gadgets';
2587
- $temp['15-02'] = 'Tech News';
2588
- $temp['15-03'] = 'Podcasting';
2589
- $temp['15-04'] = 'Software How-To';
2590
-
2591
- $temp['16-00'] = 'TV & Film';
2592
-
2593
- if( $PrefixSubCategories )
2594
- {
2595
- foreach( $temp as $key=> $val )
2596
- {
2597
- $parts = explode('-', $key);
2598
- $cat = $parts[0];
2599
- $subcat = $parts[1];
2600
-
2601
- if( $subcat != '00' )
2602
- $temp[$key] = $temp[$cat.'-00'].' > '.$val;
2603
- }
2604
- reset($temp);
2605
- }
2606
-
2607
- return $temp;
2608
- }
2609
-
2610
- /**
2611
- * Categories for 2019+ Apple Podcast directory
2612
- */
2613
- function powerpress_apple_categories($PrefixSubCategories = false) {
2614
- $temp = array();
2615
- $temp['01-00'] = 'Arts';
2616
- $temp['01-01'] = 'Books';
2617
- $temp['01-02'] = 'Design';
2618
- $temp['01-03'] = 'Fashion & Beauty';
2619
- $temp['01-04'] = 'Food';
2620
- $temp['01-05'] = 'Performing Arts';
2621
- $temp['01-06'] = 'Visual Arts';
2622
-
2623
- $temp['02-00'] = 'Business';
2624
- $temp['02-01'] = 'Careers';
2625
- $temp['02-02'] = 'Entrepreneurship';
2626
- $temp['02-03'] = 'Investing';
2627
- $temp['02-04'] = 'Management';
2628
- $temp['02-05'] = 'Marketing';
2629
- $temp['02-06'] = 'Non-profit';
2630
-
2631
- $temp['03-00'] = 'Comedy';
2632
- $temp['03-01'] = 'Comedy Interviews';
2633
- $temp['03-02'] = 'Improv';
2634
- $temp['03-03'] = 'Stand-Up';
2635
-
2636
- $temp['04-00'] = 'Education';
2637
- $temp['04-01'] = 'Courses';
2638
- $temp['04-02'] = 'How To';
2639
- $temp['04-03'] = 'Language Learning';
2640
- $temp['04-04'] = 'Self-Improvement';
2641
-
2642
- $temp['05-00'] = 'Fiction';
2643
- $temp['05-01'] = 'Comedy Fiction';
2644
- $temp['05-02'] = 'Drama';
2645
- $temp['05-03'] = 'Science Fiction';
2646
-
2647
- $temp['06-00'] = 'Government';
2648
-
2649
- $temp['07-00'] = 'Health & Fitness';
2650
- $temp['07-01'] = 'Alternative Health';
2651
- $temp['07-02'] = 'Fitness';
2652
- $temp['07-03'] = 'Medicine';
2653
- $temp['07-04'] = 'Mental Health';
2654
- $temp['07-05'] = 'Nutrition';
2655
- $temp['07-06'] = 'Sexuality';
2656
-
2657
- $temp['08-00'] = 'History';
2658
-
2659
- $temp['09-00'] = 'Kids & Family';
2660
- $temp['09-01'] = 'Education for Kids';
2661
- $temp['09-02'] = 'Parenting';
2662
- $temp['09-03'] = 'Pets & Animals';
2663
- $temp['09-04'] = 'Stories for Kids';
2664
-
2665
- $temp['10-00'] = 'Leisure';
2666
- $temp['10-01'] = 'Animation & Manga';
2667
- $temp['10-02'] = 'Automotive';
2668
- $temp['10-03'] = 'Aviation';
2669
- $temp['10-04'] = 'Crafts';
2670
- $temp['10-05'] = 'Games';
2671
- $temp['10-06'] = 'Hobbies';
2672
- $temp['10-07'] = 'Home & Garden';
2673
- $temp['10-08'] = 'Video Games';
2674
-
2675
- $temp['11-00'] = 'Music';
2676
- $temp['11-01'] = 'Music Commentary';
2677
- $temp['11-02'] = 'Music History';
2678
- $temp['11-03'] = 'Music Interviews';
2679
-
2680
- $temp['12-00'] = 'News';
2681
- $temp['12-01'] = 'Business News';
2682
- $temp['12-02'] = 'Daily News';
2683
- $temp['12-03'] = 'Entertainment News';
2684
- $temp['12-04'] = 'News Commentary';
2685
- $temp['12-05'] = 'Politics';
2686
- $temp['12-06'] = 'Sports News';
2687
- $temp['12-07'] = 'Tech News';
2688
-
2689
- $temp['13-00'] = 'Religion & Spirituality';
2690
- $temp['13-01'] = 'Buddhism';
2691
- $temp['13-02'] = 'Christianity';
2692
- $temp['13-03'] = 'Hinduism';
2693
- $temp['13-04'] = 'Islam';
2694
- $temp['13-05'] = 'Judaism';
2695
- $temp['13-06'] = 'Religion';
2696
- $temp['13-07'] = 'Spirituality';
2697
-
2698
- $temp['14-00'] = 'Science';
2699
- $temp['14-01'] = 'Astronomy';
2700
- $temp['14-02'] = 'Chemistry';
2701
- $temp['14-03'] = 'Earth Sciences';
2702
- $temp['14-04'] = 'Life Sciences';
2703
- $temp['14-05'] = 'Mathematics';
2704
- $temp['14-06'] = 'Natural Sciences';
2705
- $temp['14-07'] = 'Nature';
2706
- $temp['14-08'] = 'Physics';
2707
- $temp['14-09'] = 'Social Sciences';
2708
-
2709
- $temp['15-00'] = 'Society & Culture';
2710
- $temp['15-01'] = 'Documentary';
2711
- $temp['15-02'] = 'Personal Journals';
2712
- $temp['15-03'] = 'Philosophy';
2713
- $temp['15-04'] = 'Places & Travel';
2714
- $temp['15-06'] = 'Relationships';
2715
-
2716
- $temp['16-00'] = 'Sports';
2717
- $temp['16-01'] = 'Baseball';
2718
- $temp['16-02'] = 'Basketball';
2719
- $temp['16-03'] = 'Cricket';
2720
- $temp['16-04'] = 'Fantasy Sports';
2721
- $temp['16-05'] = 'Football';
2722
- $temp['16-06'] = 'Golf';
2723
- $temp['16-07'] = 'Hockey';
2724
- $temp['16-08'] = 'Rugby';
2725
- $temp['16-09'] = 'Running';
2726
- $temp['16-10'] = 'Soccer';
2727
- $temp['16-11'] = 'Swimming';
2728
- $temp['16-12'] = 'Tennis';
2729
- $temp['16-13'] = 'Volleyball';
2730
- $temp['16-15'] = 'Wilderness';
2731
- $temp['16-16'] = 'Wrestling';
2732
-
2733
- $temp['17-00'] = 'Technology';
2734
-
2735
- $temp['18-00'] = 'True Crime';
2736
-
2737
- $temp['19-00'] = 'TV & Film';
2738
- $temp['19-01'] = 'After shows';
2739
- $temp['19-02'] = 'Film History';
2740
- $temp['19-03'] = 'Film Interviews';
2741
- $temp['19-04'] = 'Film Reviews';
2742
- $temp['19-05'] = 'TV Reviews';
2743
-
2744
- if( $PrefixSubCategories )
2745
- {
2746
- foreach( $temp as $key=> $val )
2747
- {
2748
- $parts = explode('-', $key);
2749
- $cat = $parts[0];
2750
- $subcat = $parts[1];
2751
-
2752
- if( $subcat != '00' )
2753
- $temp[$key] = $temp[$cat.'-00'].' > '.$val;
2754
- }
2755
- reset($temp);
2756
- }
2757
-
2758
- return $temp;
2759
- }
2760
-
2761
- function powerpress_googleplay_categories()
2762
- {
2763
- $temp = array();
2764
- $temp['01-00'] = 'Arts';
2765
- $temp['02-00'] = 'Business';
2766
- $temp['03-00'] = 'Comedy';
2767
- $temp['04-00'] = 'Education';
2768
- $temp['05-00'] = 'Games & Hobbies';
2769
- $temp['06-00'] = 'Government & Organizations';
2770
- $temp['07-00'] = 'Health';
2771
- $temp['08-00'] = 'Kids & Family';
2772
- $temp['09-00'] = 'Music';
2773
- $temp['10-00'] = 'News & Politics';
2774
- $temp['11-00'] = 'Religion & Spirituality';
2775
- $temp['12-00'] = 'Science & Medicine';
2776
- $temp['13-00'] = 'Society & Culture';
2777
- $temp['14-00'] = 'Sports & Recreation';
2778
- $temp['15-00'] = 'Technology';
2779
- $temp['16-00'] = 'TV & Film';
2780
-
2781
- return $temp;
2782
- }
2783
-
2784
- function powerpress_get_root_url()
2785
- {
2786
- /*
2787
- // OLD CODE:
2788
- $powerpress_dirname = basename( POWERPRESS_ABSPATH );
2789
- return WP_PLUGIN_URL . '/'. $powerpress_dirname .'/';
2790
- */
2791
- $local_path = __FILE__;
2792
- if( DIRECTORY_SEPARATOR == '\\' ) { // Win32 fix
2793
- $local_path = basename(dirname(__FILE__)) .'/'. basename(__FILE__);
2794
- }
2795
- $plugin_url = plugins_url('', $local_path);
2796
- return $plugin_url . '/';
2797
- }
2798
-
2799
- function powerpress_get_the_exerpt($for_summary = false, $no_filters = false, $post_id = false)
2800
- {
2801
- if( $no_filters ) {
2802
- if( $post_id > 0 ) {
2803
- $post = get_post($post_id);
2804
- $subtitle = $post->post_excerpt;
2805
- if ( $subtitle == '') {
2806
-
2807
- $subtitle = $post->post_content;
2808
- $shortcodesTemp = $GLOBALS['shortcode_tags'];
2809
- $GLOBALS['shortcode_tags']['skipto'] = 'powerpress_shortcode_skipto';
2810
- $subtitle = do_shortcode($subtitle);
2811
- $GLOBALS['shortcode_tags'] = $shortcodesTemp;
2812
-
2813
- $subtitle = strip_shortcodes( $subtitle );
2814
- $subtitle = str_replace(']]>', ']]&gt;', $subtitle);
2815
- $subtitle = strip_tags($subtitle);
2816
- }
2817
- }
2818
- else if( is_object($GLOBALS['post']) )
2819
- {
2820
- $subtitle = $GLOBALS['post']->post_excerpt;
2821
- if ( $subtitle == '') {
2822
-
2823
- $subtitle = $GLOBALS['post']->post_content;
2824
-
2825
- $shortcodesTemp = $GLOBALS['shortcode_tags'];
2826
- $GLOBALS['shortcode_tags']['skipto'] = 'powerpress_shortcode_skipto';
2827
- $subtitle = do_shortcode($subtitle);
2828
- $GLOBALS['shortcode_tags'] = $shortcodesTemp;
2829
-
2830
- $subtitle = strip_shortcodes( $subtitle );
2831
- $subtitle = str_replace(']]>', ']]&gt;', $subtitle);
2832
- $subtitle = strip_tags($subtitle);
2833
- }
2834
- }
2835
- } else {
2836
- $subtitle = get_the_excerpt();
2837
- }
2838
-
2839
- $subtitle = trim( strip_tags( $subtitle ) );
2840
- if( !empty($subtitle) )
2841
- return $subtitle;
2842
- return powerpress_get_the_content( $for_summary, $no_filters );
2843
- }
2844
-
2845
- function powerpress_get_the_content($for_summary = true, $no_filters = false, $no_strip_tags = false) {
2846
- if( $no_filters ) {
2847
- global $post;
2848
- $content_no_html = $post->post_content;
2849
-
2850
- $shortcodesTemp = $GLOBALS['shortcode_tags'];
2851
- $GLOBALS['shortcode_tags']['skipto'] = 'powerpress_shortcode_skipto';
2852