PowerPress Podcasting plugin by Blubrry - Version 7.5

Version Description

  • Released on 7/23/2019
  • Added new Apple categories announced in July. The new Apple Categories will be made available on Apple Podcasts mid August, 2019.
  • Added Multi-program Blubrry Podcast Hosting, perfect for Category podcasting.
  • Added Update Google PubSubHubbub, lets Google Podcasts and other podcast directory services when your podcast publishes new episodes.
  • Added support for various languages to podcast as including "Thai" and "Vietnamese".
Download this release

Release Info

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

Code changes from version 7.4.4 to 7.5

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