Blubrry PowerPress 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. Version: 8.3.5 Author: Blubrry Author URI: https://blubrry.com/ Requires at least: 3.6 Tested up to: 5.5 Text Domain: powerpress Change Log: Please see readme.txt for detailed change log. Contributors: Angelo Mandato, CIO Blubrry - Plugin founder, architect and lead developer See readme.txt for full list of contributors. Credits: getID3(), License: GPL 2.0+ by James Heinrich http://www.getid3.org Note: getid3.php analyze() function modified to prevent redundant filesize() function call. Copyright 2008-2019 Blubrry (https://blubrry.com) License: GPL (http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt) This project uses source that is GPL licensed. */ if( !function_exists('add_action') ) { header( 'Status: 403 Forbidden' ); header( 'HTTP/1.1 403 Forbidden' ); exit(); } // WP_PLUGIN_DIR (REMEMBER TO USE THIS DEFINE IF NEEDED) define('POWERPRESS_VERSION', '8.3.4' ); // Translation support: if ( !defined('POWERPRESS_ABSPATH') ) define('POWERPRESS_ABSPATH', dirname(__FILE__) ); ///////////////////////////////////////////////////// // The following define options should be placed in your // wp-config.php file so the setting is not disrupted when // you upgrade the plugin. ///////////////////////////////////////////////////// if( !defined('POWERPRESS_BLUBRRY_API_URL') ) define('POWERPRESS_BLUBRRY_API_URL', 'http://api.blubrry.com/'); // Replace validator service with one that is more reliable here: define('POWERPRESS_FEEDVALIDATOR_URL', 'https://castfeedvalidator.com/?url='); // Display custom play image for quicktime media. Applies to on page player only. //define('POWERPRESS_PLAY_IMAGE', 'http://www.blubrry.com/themes/blubrry/images/player/PlayerBadge150x50NoBorder.jpg'); if( !defined('POWERPRESS_CONTENT_ACTION_PRIORITY') ) define('POWERPRESS_CONTENT_ACTION_PRIORITY', 10 ); // Added so administrators can customize what capability is needed for PowerPress if( !defined('POWERPRESS_CAPABILITY_MANAGE_OPTIONS') ) define('POWERPRESS_CAPABILITY_MANAGE_OPTIONS', 'manage_options'); if( !defined('POWERPRESS_CAPABILITY_EDIT_PAGES') ) define('POWERPRESS_CAPABILITY_EDIT_PAGES', 'edit_pages'); // Define variables, advanced users could define these in their own wp-config.php so lets not try to re-define if( !defined('POWERPRESS_LINK_SEPARATOR') ) define('POWERPRESS_LINK_SEPARATOR', '|'); if( !defined('POWERPRESS_TEXT_SEPARATOR') ) define('POWERPRESS_TEXT_SEPARATOR', ':'); if( !defined('POWERPRESS_PLAY_IMAGE') ) define('POWERPRESS_PLAY_IMAGE', 'play_video_default.jpg'); if( !defined('PHP_EOL') ) define('PHP_EOL', "\n"); // We need this variable defined for new lines. if( defined('POWERPRESS_DEBUG') ) { if( !defined('PHP_EOL_WEB') ) { define('PHP_EOL_WEB', "\n"); // Helps with readability } } else { if( !defined('PHP_EOL_WEB') ) { define('PHP_EOL_WEB', ''); // We don't necessarily need new lines for web output } } if( !defined('POWERPRESS_SUBSCRIBE') ) define('POWERPRESS_SUBSCRIBE', true); if(!defined('POWERPRESS_NEW_APPLE_CATEGORIES')) { define('POWERPRESS_NEW_APPLE_CATEGORIES', true); } // Set regular expression values for determining mobile devices if( !defined('POWERPRESS_MOBILE_REGEX') ) define('POWERPRESS_MOBILE_REGEX', 'iphone|ipod|ipad|aspen|android|blackberry|opera mini|webos|incognito|webmate|silk'); $powerpress_feed = NULL; // DO NOT CHANGE function powerpress_content($content) { global $post, $g_powerpress_excerpt_post_id; if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) || defined('PODCASTING_VERSION') ) return $content; if( empty($post->ID) || !is_object($post) ) return $content; if( defined('POWERPRESS_DO_ENCLOSE_FIX') ) $content = preg_replace('/\/im', '', $content ); if( is_feed() ) return $content; // We don't want to do anything to the feed if( function_exists('post_password_required') ) { if( post_password_required($post) ) return $content; } // PowerPress settings: $GeneralSettings = get_option('powerpress_general'); // No player or links to add to content... if( !empty($GeneralSettings['disable_appearance']) ) return $content; // check for themes/plugins where we know we need to do this... if( empty($GeneralSettings['player_aggressive']) ) { if( !empty($GLOBALS['fb_ver']) && version_compare($GLOBALS['fb_ver'], '1.0', '<=') ) { $GeneralSettings['player_aggressive'] = 1; } if( defined('JETPACK__VERSION') && version_compare(JETPACK__VERSION, '2.0', '>=') ) { $GeneralSettings['player_aggressive'] = 1; // Jet pack still doesn't behave with PowerPress the_content } if( defined('WPSEO_VERSION') ) { $GeneralSettings['player_aggressive'] = 4; } } if( !empty($GeneralSettings['player_aggressive']) ) { if( $GeneralSettings['player_aggressive'] == 4 ) { $in_http_head = powerpress_in_wp_head(); if( $in_http_head === true ) return $content; } 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 { if( empty($GLOBALS['powerpress_wp_head_completed']) ) return $content; } else // method 1 or 3... { if( strstr($content, '') !== false ) return $content; // The players were already added to the content if( $GeneralSettings['player_aggressive'] != 3 && $g_powerpress_excerpt_post_id > 0 ) $g_powerpress_excerpt_post_id = 0; // Hack, set this to zero so it always goes past... if( $GeneralSettings['player_aggressive'] == 3 ) $GeneralSettings['player_aggressive'] = 1; // remainder of the system will function as normal } } // Problem: If the_excerpt is used instead of the_content, both the_exerpt and the_content will be called here. // Important to note, get_the_excerpt will be called before the_content is called, so we add a simple little hack if( current_filter() == 'get_the_excerpt' ) { $g_powerpress_excerpt_post_id = $post->ID; return $content; // We don't want to do anything to this content yet... } else if( current_filter() == 'the_content' && $g_powerpress_excerpt_post_id == $post->ID ) { return $content; // We don't want to do anything to this excerpt content in this call either... } else if( class_exists('custom_post_widget') && powerpress_in_custom_post_widget() ) { return $content; // Custom Post Widget compatibility } if( !isset($GeneralSettings['custom_feeds']) ) $GeneralSettings['custom_feeds'] = array('podcast'=>'Default Podcast Feed'); if( empty($GeneralSettings['custom_feeds']['podcast']) ) $GeneralSettings['custom_feeds']['podcast'] = 'Default Podcast Feed'; // Re-order so the default podcast episode is the top most... $Temp = $GeneralSettings['custom_feeds']; $GeneralSettings['custom_feeds'] = array(); $GeneralSettings['custom_feeds']['podcast'] = 'Default Podcast Feed'; foreach( $Temp as $feed_slug=> $feed_title ) { if( $feed_slug == 'podcast' ) continue; $GeneralSettings['custom_feeds'][ $feed_slug ] = $feed_title; } // Handle post type feeds.... if( !empty($GeneralSettings['posttype_podcasting']) ) { $post_type = get_query_var('post_type'); if ( is_array( $post_type ) ) { $post_type = reset( $post_type ); // get first element in array } // Get the feed slugs and titles for this post type $PostTypeSettingsArray = get_option('powerpress_posttype_'.$post_type); // Loop through this array of post type settings... if( !empty($PostTypeSettingsArray) ) { switch($post_type) { case 'post': case 'page': { // Do nothing!, we want the default podcast to appear in these post types }; break; default: { if( !empty($post_type) && empty($PostTypeSettingsArray['podcast']) ) 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 }; break; } foreach( $PostTypeSettingsArray as $feed_slug=> $postTypeSettings ) { if( !empty( $postTypeSettings['title']) ) $GeneralSettings['custom_feeds'][ $feed_slug ] = $postTypeSettings['title']; else $GeneralSettings['custom_feeds'][ $feed_slug ] = $feed_slug; } } } if( !isset($GeneralSettings['display_player']) ) $GeneralSettings['display_player'] = 1; if( !isset($GeneralSettings['player_function']) ) $GeneralSettings['player_function'] = 1; if( !isset($GeneralSettings['podcast_link']) ) $GeneralSettings['podcast_link'] = 1; // The blog owner doesn't want anything displayed, so don't bother wasting anymore CPU cycles if( $GeneralSettings['display_player'] == 0 ) return $content; if( current_filter() == 'the_excerpt' && empty($GeneralSettings['display_player_excerpt']) ) return $content; // We didn't want to modify this since the user didn't enable it for excerpts if( !empty($GeneralSettings['hide_player_more']) && strstr($content, 'class="more-link"') ) return $content; // We do not want to add players and links if the read-more class found // Figure out which players are alerady in the body of the page... $ExcludePlayers = array(); if( isset($GeneralSettings['disable_player']) ) $ExcludePlayers = $GeneralSettings['disable_player']; // automatically disable the players configured if( !empty($GeneralSettings['process_podpress']) && strstr($content, '[display_podcast]') ) return $content; if( preg_match_all('/(.?)\[(powerpress)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)/s', $content, $matches) ) { if( isset($matches[3]) ) { foreach( $matches[3] as $key=> $row ) { $attributes = shortcode_parse_atts($row); if( isset($attributes['url']) ) { // not a problem... } else if( isset($attributes['feed']) ) { // we want to exclude this feed from the links aera... $ExcludePlayers[ $attributes['feed'] ] = true; } else { // we don't want to include any players below... $ExcludePlayers = $GeneralSettings['custom_feeds']; } } } } // LOOP HERE TO DISPLAY EACH MEDIA TYPE $new_content = ''; foreach( $GeneralSettings['custom_feeds'] as $feed_slug=> $feed_title ) { // Get the enclosure data $EpisodeData = powerpress_get_enclosure_data($post->ID, $feed_slug); if( !$EpisodeData && !empty($GeneralSettings['process_podpress']) && $feed_slug == 'podcast' ) $EpisodeData = powerpress_get_enclosure_data_podpress($post->ID); if( !$EpisodeData || !$EpisodeData['url'] ) continue; // Just in case, if there's no URL lets escape! if( !$EpisodeData['url'] ) continue; // If the player is not already inserted in the body of the post using the shortcode... //if( preg_match('/\[powerpress(.*)\]/is', $content) == 0 ) if( !isset($ExcludePlayers[ $feed_slug ]) ) // If the player is not in our exclude list because it's already in the post body somewhere... { if( isset($GeneralSettings['premium_caps']) && $GeneralSettings['premium_caps'] && !powerpress_premium_content_authorized($feed_slug) ) { $new_content .= powerpress_premium_content_message($post->ID, $feed_slug, $EpisodeData); } else { if( $GeneralSettings['player_function'] != 3 && $GeneralSettings['player_function'] != 0 ) // Play in new window only or disabled { do_action('wp_powerpress_player_scripts'); $AddDefaultPlayer = empty($EpisodeData['no_player']); if( $EpisodeData && !empty($EpisodeData['embed']) ) { $new_content .= trim($EpisodeData['embed']); if( !empty($GeneralSettings['embed_replace_player']) ) $AddDefaultPlayer = false; } if( $AddDefaultPlayer ) { $image = ''; if( isset($EpisodeData['image']) && $EpisodeData['image'] != '' ) $image = $EpisodeData['image']; $new_content .= apply_filters('powerpress_player', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData ); } } if( !isset($EpisodeData['no_links']) ) { do_action('wp_powerpress_player_scripts'); $new_content .= apply_filters('powerpress_player_links', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData ); $new_content .= apply_filters('powerpress_player_subscribe_links', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData ); } } } } if( $new_content == '' ) return $content; switch( $GeneralSettings['display_player'] ) { case 1: { // Below posts return $content.$new_content.( !empty($GeneralSettings['player_aggressive']) && $GeneralSettings['player_aggressive'] == 1 ?'':''); }; break; case 2: { // Above posts return ( !empty($GeneralSettings['player_aggressive']) && $GeneralSettings['player_aggressive'] == 1 ?'':'').$new_content.$content; }; break; } return $content; }//end function add_filter('get_the_excerpt', 'powerpress_content', (POWERPRESS_CONTENT_ACTION_PRIORITY - 1) ); add_filter('the_content', 'powerpress_content', POWERPRESS_CONTENT_ACTION_PRIORITY); if( !defined('POWERPRESS_NO_THE_EXCERPT') ) add_filter('the_excerpt', 'powerpress_content', POWERPRESS_CONTENT_ACTION_PRIORITY); /* Specail case fix Yoast bug which messes up the HTML */ function powerpress_yoast_gawp_fix($content) { $content= preg_replace( array('/return powerpress\_pinw\(\"/', '/return powerpress\_embed\_winplayer\(\"/', '/return powerpress\_show\_embed\(\"/', '/return powerpress\_embed\_html5v\(\"/', '/return powerpress\_embed\_html5a\(\"/', ), array('return powerpress_pinw(\'', 'return powerpress_embed_winplayer(\'', 'return powerpress_show_embed(\'', 'return powerpress_embed_html5v(\'', 'return powerpress_embed_html5a(\'' ), $content); return $content; } function powerpress_header() { // PowerPress settings: $Powerpress = get_option('powerpress_general'); if( !isset($Powerpress['custom_feeds']) ) $Powerpress['custom_feeds'] = array('podcast'=>'Default Podcast Feed'); if( empty($Powerpress['disable_appearance']) || $Powerpress['disable_appearance'] == false ) { if( !isset($Powerpress['player_function']) || $Powerpress['player_function'] > 0 ) // Don't include the player in the header if it is not needed... { $PowerpressPluginURL = powerpress_get_root_url(); ?> ' . "\n"; } else if( is_category() ) { $category_id = get_query_var('cat'); if( $category_id ) { $Settings = get_option('powerpress_cat_feed_'.$category_id ); if( empty($Settings['title']) ) { $Settings['title'] = get_cat_name( $category_id ); // Get category title $Settings['title'] .= ' '. apply_filters( 'document_title_separator', '-' ) .' '; $Settings['title'] .= get_bloginfo_rss('name'); } if( empty($Settings['title']) ) { $Settings['title'] = get_bloginfo_rss('name'); // Get blog title, best we can do } if( !empty($Settings['feed_redirect_url']) ) $Settings['feed_url'] = $Settings['feed_redirect_url']; else if( !empty($General['cat_casting_podcast_feeds']) ) $Settings['feed_url'] = get_category_feed_link($category_id, 'podcast'); else $Settings['feed_url'] = get_category_feed_link( $category_id ); // Get category feed URL // Get the category podcast feed... echo '' . "\n"; } } } } add_action('wp_head', 'powerpress_header'); function powerpress_wp_head_completed() { $GLOBALS['powerpress_wp_head_completed'] = true; } add_action('wp_head', 'powerpress_wp_head_completed', 100000); function powerpress_exit_on_http_head($return) { if( is_feed() ) { // Set the content type for HTTP headers... header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true); // Needs authentication? $GeneralSettings = get_option('powerpress_general'); if( !empty($GeneralSettings['premium_caps']) ) { $feed_slug = get_query_var('feed'); $FeedSettings = get_option('powerpress_feed_'.$feed_slug); if( !empty($FeedSettings['premium']) ) { return false; // Let the logic further into PowerPress authenticate this HEAD request } } } return $return; } add_filter('exit_on_http_head', 'powerpress_exit_on_http_head' ); function powerpress_rss2_ns() { if( !powerpress_is_podcast_feed() ) return; // Okay, lets add the namespace echo 'xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"'.PHP_EOL; if( !defined('POWERPRESS_RAWVOICE_RSS') || POWERPRESS_RAWVOICE_RSS != false ) { echo 'xmlns:rawvoice="http://www.rawvoice.com/rawvoiceRssModule/"'.PHP_EOL; } if( !defined('POWERPRESS_GOOGLEPLAY_RSS') || POWERPRESS_GOOGLEPLAY_RSS != false ) { echo 'xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"'.PHP_EOL; //echo 'xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0/play-podcasts.xsd"'.PHP_EOL; } } add_action('rss2_ns', 'powerpress_rss2_ns'); add_action('rss2_ns_powerpress', 'powerpress_rss2_ns'); function powerpress_rss2_head() { global $powerpress_feed; if( !powerpress_is_podcast_feed() ) return; // Not a feed we manage $feed_slug = get_query_var( 'feed' ); $cat_ID = get_query_var('cat'); $Feed = get_option('powerpress_feed'); // Get the main feed settings if( !empty($powerpress_feed['category']) ) { $CustomFeed = get_option('powerpress_cat_feed_'.$powerpress_feed['category']); // Get the custom podcast feed settings saved in the database if( $CustomFeed ) $Feed = powerpress_merge_empty_feed_settings($CustomFeed, $Feed); } else if( !empty($powerpress_feed['term_taxonomy_id']) ) { $CustomFeed = get_option('powerpress_taxonomy_'.$powerpress_feed['term_taxonomy_id']); // Get the taxonomy podcast settings saved in the database if( $CustomFeed ) $Feed = powerpress_merge_empty_feed_settings($CustomFeed, $Feed); } else if( !empty($powerpress_feed['post_type']) ) { $PostTypeSettingsArray = get_option('powerpress_posttype_'.$powerpress_feed['post_type']); // Get the post type podcast feed settings saved in the database if( !empty($PostTypeSettingsArray[ $feed_slug ]) ) { $CustomFeed = $PostTypeSettingsArray[ $feed_slug ]; $Feed = powerpress_merge_empty_feed_settings($CustomFeed, $Feed, ($feed_slug == 'podcast') ); } } else if( powerpress_is_custom_podcast_feed() ) // If we're handling a custom podcast feed... { $CustomFeed = get_option('powerpress_feed_'.$feed_slug); // Get the custom podcast feed settings saved in the database $Feed = powerpress_merge_empty_feed_settings($CustomFeed, $Feed, ($feed_slug == 'podcast') ); } if( !isset($Feed['url']) || trim($Feed['url']) == '' ) { if( is_category() ) $Feed['url'] = get_category_link($cat_ID); else { $blogHomepage = get_option('page_for_posts'); if( !empty($blogHomepage) ) { $Feed['url'] = get_permalink( $blogHomepage ); } if( empty($Feed['url']) ) $Feed['url'] = get_bloginfo('url'); } } $General = get_option('powerpress_general'); // We made it this far, lets write stuff to the feed! echo ''), array('|!~~', '~~>'), $feedComment); $feedComment = trim($feedComment); if( !empty($feedComment) ) echo $feedComment.' '; echo 'Blubrry PowerPress Podcasting plugin for WordPress (https://www.blubrry.com/powerpress/) -->'.PHP_EOL; // Websub! if(!(defined('POWERPRESS_DISABLE_WEBSUB') && POWERPRESS_DISABLE_WEBSUB )) { echo "\t" . PHP_EOL; } // add the itunes:new-feed-url tag to feed if( powerpress_is_custom_podcast_feed() ) { if( !empty($Feed['itunes_new_feed_url']) ) { $Feed['itunes_new_feed_url'] = str_replace('&', '&', $Feed['itunes_new_feed_url']); echo "\t". htmlspecialchars(trim($Feed['itunes_new_feed_url'])) .''.PHP_EOL; } } 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 { $Feed['itunes_new_feed_url'] = str_replace('&', '&', $Feed['itunes_new_feed_url']); echo "\t". htmlspecialchars(trim($Feed['itunes_new_feed_url'])) .''.PHP_EOL; } if( !empty($General['itunes_cdata']) ) { if( !empty($Feed['itunes_summary']) ) echo "\t".''.PHP_EOL; else echo "\t".''.PHP_EOL; } else { if( !empty($Feed['itunes_summary']) ) echo "\t".''. powerpress_format_itunes_value( $Feed['itunes_summary'], 'summary' ) .''.PHP_EOL; else echo "\t".''. powerpress_format_itunes_value( get_bloginfo('description'), 'summary' ) .''.PHP_EOL; } if( !empty($powerpress_feed['itunes_talent_name']) ) echo "\t" . esc_html($powerpress_feed['itunes_talent_name']) . ''.PHP_EOL; if( !empty($powerpress_feed['explicit']) && $powerpress_feed['explicit'] != 'no' ) echo "\t".'' . $powerpress_feed['explicit'] . ''.PHP_EOL; if( !empty($Feed['itunes_block']) ) echo "\tyes".PHP_EOL; if( !empty($Feed['itunes_complete']) ) echo "\tyes".PHP_EOL; if( !empty($Feed['itunes_image']) ) { echo "\t".''.PHP_EOL; } else { echo "\t".''.PHP_EOL; } if( !empty($Feed['itunes_type']) ) { echo "\t".''. esc_html($Feed['itunes_type']) .''.PHP_EOL; } if( !empty($Feed['email']) ) { echo "\t".''.PHP_EOL; echo "\t\t".'' . esc_html($powerpress_feed['itunes_talent_name']) . ''.PHP_EOL; echo "\t\t".'' . esc_html($Feed['email']) . ''.PHP_EOL; echo "\t".''.PHP_EOL; echo "\t".''. esc_html($Feed['email'] .' ('. $powerpress_feed['itunes_talent_name'] .')') .''.PHP_EOL; } if( !empty($Feed['copyright']) ) { // In case the user entered the copyright html version or the copyright UTF-8 or ASCII symbol or just (c) $Feed['copyright'] = str_replace(array('©', '(c)', '(C)', chr(194) . chr(169), chr(169) ), '©', $Feed['copyright']); echo "\t".''. esc_html($Feed['copyright']) . ''.PHP_EOL; } if( !empty($Feed['itunes_subtitle']) ) echo "\t".'' . powerpress_format_itunes_value($Feed['itunes_subtitle'], 'subtitle') . ''.PHP_EOL; else echo "\t".''. powerpress_format_itunes_value( get_bloginfo('description'), 'subtitle') .''.PHP_EOL; $podcast_title_safe = ''; if( version_compare($GLOBALS['wp_version'], 4.4, '<' ) ) { $podcast_title_safe .= get_bloginfo_rss('name'); } $podcast_title_safe .= get_wp_title_rss(); if( empty($General['disable_rss_image']) ) { if( !empty($Feed['rss2_image']) || !empty($Feed['itunes_image']) ) { if( !empty($Feed['rss2_image']) ) // If the RSS image is set, use it, otherwise use the iTunes image... $rss_image = $Feed['rss2_image']; else $rss_image = $Feed['itunes_image']; echo "\t". '' .PHP_EOL; echo "\t\t".'' . $podcast_title_safe . ''.PHP_EOL; echo "\t\t".'' . esc_html( str_replace(' ', '+', $rss_image)) . ''.PHP_EOL; echo "\t\t".''. $Feed['url'] . '' . PHP_EOL; echo "\t".'' . PHP_EOL; } else // Use the default image { echo "\t". '' .PHP_EOL; echo "\t\t".'' . $podcast_title_safe . ''.PHP_EOL; echo "\t\t".'' . powerpress_get_root_url() . 'rss_default.jpg'.PHP_EOL; echo "\t\t".''. $Feed['url'] . '' . PHP_EOL; echo "\t".'' . PHP_EOL; } } // Handle iTunes categories $Cat1 = false; $Cat2 = false; $Cat3 = false; $SubCat1 = false; $SubCat2 = false; $SubCat3 = false; if(defined('POWERPRESS_NEW_APPLE_CATEGORIES') && POWERPRESS_NEW_APPLE_CATEGORIES == true) { $Categories = powerpress_apple_categories(); for ($i = 1; $i <= 3; $i++) { if(!empty($Feed['itunes_cat_'.$i]) && empty($Feed['apple_cat_'.$i])) { $mappings = array('01-00' => '01-00', '01-01' => '01-02', '01-02' => '01-03', '01-03' => '01-04', '01-04' => '01-01', '01-05' => '01-05', '01-06' => '01-06', '02-00' => '02-00', '02-01' => '12-01', '02-02' => '02-01', '02-03' => '02-03', '02-04' => '02-00', '02-05' => '02-00', '03-00' => '03-00', '04-00' => '04-00', '04-01' => '04-00', '04-02' => '04-00', '04-03' => '09-01', '04-04' => '04-03', '04-05' => '04-00', '05-00' => '10-00', '05-01' => '10-02', '05-02' => '10-03', '05-03' => '10-06', '05-04' => '10-05', '05-05' => '10-05', '06-00' => '06-00', '06-01' => '06-00', '06-02' => '06-00', '06-03' => '06-00', '06-04' => '06-00', '07-00' => '07-00', '07-01' => '07-01', '07-02' => '07-00', '07-03' => '04-04', '07-04' => '07-06', '08-00' => '09-00', '09-00' => '11-00', '11-00' => '13-00', '11-01' => '13-01', '11-02' => '13-02', '11-03' => '13-03', '11-04' => '13-04', '11-05' => '13-05', '11-06' => '13-06', '11-07' => '13-07', '12-00' => '14-00', '12-01' => '07-03', '12-02' => '14-06', '12-03' => '14-09', '13-00' => '15-00', '13-01' => '08-00', '13-02' => '15-02', '13-03' => '15-03', '13-04' => '15-04', '14-00' => '16-00', '14-01' => '16-00', '14-02' => '16-00', '14-03' => '16-15', '14-04' => '16-00', '15-00' => '17-00', '15-01' => '17-00', '15-02' => '12-07', '15-03' => '17-00', '15-04' => '17-00', '16-00' => '19-00'); $Feed['apple_cat_'. $i] = $mappings[$Feed['itunes_cat_'.$i]]; } } if (!empty($Feed['apple_cat_1'])) list($Cat1, $SubCat1) = explode('-', $Feed['apple_cat_1']); if (!empty($Feed['apple_cat_2'])) list($Cat2, $SubCat2) = explode('-', $Feed['apple_cat_2']); if (!empty($Feed['apple_cat_3'])) list($Cat3, $SubCat3) = explode('-', $Feed['apple_cat_3']); $googleplay_category_mapping = array( '01-00' => '01-00', '02-00' => '02-00', '03-00' => '03-00', '04-00' => '04-00', '05-00' => '13-00', '06-00' => '06-00', '07-00' => '07-00', '08-00' => '13-00', '09-00' => '08-00', '10-00' => '05-00', '11-00' => '09-00', '12-00' => '10-00', '13-00' => '11-00', '14-00' => '12-00', '15-00' => '13-00', '16-00' => '14-00', '17-00' => '15-00', '18-00' => '13-00', '19-00' => '16-00', ); } else { $Categories = powerpress_itunes_categories(); if (!empty($Feed['itunes_cat_1'])) list($Cat1, $SubCat1) = explode('-', $Feed['itunes_cat_1']); if (!empty($Feed['itunes_cat_2'])) list($Cat2, $SubCat2) = explode('-', $Feed['itunes_cat_2']); if (!empty($Feed['itunes_cat_3'])) list($Cat3, $SubCat3) = explode('-', $Feed['itunes_cat_3']); $googleplay_category_mapping = array( '01-00' => '01-00', '02-00' => '02-00', '03-00' => '03-00', '04-00' => '04-00', '05-00' => '05-00', '06-00' => '06-00', '07-00' => '07-00', '08-00' => '08-00', '09-00' => '09-00', '10-00' => '10-00', '11-00' => '11-00', '12-00' => '12-00', '13-00' => '13-00', '14-00' => '14-00', '15-00' => '15-00', '16-00' => '16-00', ); } $googleplay_categories = powerpress_googleplay_categories(); if( $Cat1 ) { $CatDesc = $Categories[$Cat1.'-00']; $SubCatDesc = $Categories[$Cat1.'-'.$SubCat1]; echo "\t".'' . PHP_EOL . "\t\t" . '' . PHP_EOL; // End this category set echo "\t".''.PHP_EOL; } else { echo '" />'.PHP_EOL; } //Get the googleplay category and put it in the feed $gplay_category = $googleplay_categories[$googleplay_category_mapping[$Cat1.'-00']]; echo "\t",''.PHP_EOL; } if( $Cat2 ) { $CatDesc = $Categories[$Cat2.'-00']; $SubCatDesc = $Categories[$Cat2.'-'.$SubCat2]; echo "\t".'' . PHP_EOL . "\t\t" . '' . PHP_EOL; // End this category set echo "\t".''.PHP_EOL; } else { echo '" />'.PHP_EOL; } } if( $Cat3 ) { $CatDesc = $Categories[$Cat3.'-00']; $SubCatDesc = $Categories[$Cat3.'-'.$SubCat3]; echo "\t".'' . PHP_EOL . "\t\t" . '' . PHP_EOL; // End this category set echo "\t".''.PHP_EOL; } else { echo '" />'.PHP_EOL; } } // End Handle iTunes categories // RawVoice RSS Tags if( !defined('POWERPRESS_RAWVOICE_RSS') || POWERPRESS_RAWVOICE_RSS != false ) { if( !empty($Feed['parental_rating']) ) echo "\t". $Feed['parental_rating'] ."".PHP_EOL; if( !empty($Feed['location']) ) echo "\t". htmlspecialchars($Feed['location']) ."".PHP_EOL; if( !empty($Feed['frequency']) ) echo "\t". htmlspecialchars($Feed['frequency']) ."".PHP_EOL; if( !empty($Feed['donate_link']) && !empty($Feed['donate_url']) ) echo "\t". htmlspecialchars( (empty($Feed['donate_label'])?'':$Feed['donate_label']) ) ."".PHP_EOL; if( !empty($Feed['itunes_url']) || !empty($Feed['blubrry_url']) || !empty($Feed['stitcher_url']) || !empty($Feed['tunein_url']) || !empty($Feed['spotify_url']) ) { echo "\t".PHP_EOL; } } } add_action('rss2_head', 'powerpress_rss2_head'); add_action('rss2_head_powerpress', 'powerpress_rss2_head'); function powerpress_rss2_item() { global $post, $powerpress_feed; // are we processing a feed that powerpress should handle if( !powerpress_is_podcast_feed() ) return; if( function_exists('post_password_required') ) { if( post_password_required($post) ) return; } // Check and see if we're working with a podcast episode $custom_enclosure = false; if( powerpress_is_custom_podcast_feed() && get_query_var('feed') !== 'podcast' && !is_category() && !is_tax() && !is_tag() ) { $EpisodeData = powerpress_get_enclosure_data($post->ID, get_query_var('feed') ); $custom_enclosure = true; } else { $EpisodeData = powerpress_get_enclosure_data($post->ID, 'podcast'); if( !$EpisodeData && !empty($powerpress_feed['process_podpress']) ) { $EpisodeData = powerpress_get_enclosure_data_podpress($post->ID); $custom_enclosure = true; } } // No episode data to include if( empty($EpisodeData) || empty($EpisodeData['url']) ) return; // If enclosure not added, check to see why... if( defined('POWERPRESS_ENCLOSURE_FIX') && POWERPRESS_ENCLOSURE_FIX && !$custom_enclosure && $GLOBALS['powerpress_rss_enclosure_post_id'] != $post->ID ) { $enclosure_in_wp = apply_filters('rss_enclosure', '' . "\n") ); if( !$enclosure_in_wp ) $custom_enclosure = true; } // Lets print the enclosure tag if( $custom_enclosure ) // We need to add the enclosure tag here... { if( empty($EpisodeData['size']) ) $EpisodeData['size'] = 5242880; // Use the dummy 5MB size since we don't have a size to quote echo "\t". sprintf('%s', powerpress_url_in_feed(trim($EpisodeData['url'])), trim($EpisodeData['size']), trim($EpisodeData['type']), PHP_EOL); } $author = $powerpress_feed['itunes_talent_name']; if( isset($powerpress_feed['itunes_author_post']) ) $author = get_the_author(); $explicit = $powerpress_feed['explicit']; $summary = ''; $subtitle = ''; $block = false; $cc = false; if( isset( $EpisodeData['summary'] ) && strlen($EpisodeData['summary']) > 1 ) $summary = $EpisodeData['summary']; if( isset( $EpisodeData['subtitle'] ) && strlen($EpisodeData['subtitle']) > 1 ) $subtitle = $EpisodeData['subtitle']; if( isset( $EpisodeData['explicit'] ) && is_numeric($EpisodeData['explicit']) ) { $explicit_array = array("no", "yes", "clean"); $explicit = $explicit_array[$EpisodeData['explicit']]; } if( !empty( $EpisodeData['author'] ) ) $author = $EpisodeData['author']; if( !empty( $EpisodeData['block'] ) ) $block = 'yes'; if( !empty( $EpisodeData['cc'] ) ) $cc = 'yes'; $General = get_option('powerpress_general'); $summary_cdata = ( !empty( $General['itunes_cdata'] ) ? true : false ); if( empty($subtitle) ) { $subtitle = powerpress_get_the_exerpt( false, !empty($General['feed_action_hook']) ); } // If no summary specified and we have enhanced summary enabled... if( empty($summary) && !empty($powerpress_feed['enhance_itunes_summary']) ) { $summary = powerpress_enhanced_itunes_summary( !empty($General['feed_action_hook']) ); if( !empty($summary) ) { $summary_cdata = true; // Always use CDATA for enhanced iTunes summary } } if( empty($summary) ) { // Backwards compatibility with PodPress, the excerpt is used as the itunes summary if set $summary = powerpress_get_the_exerpt( true, !empty($General['feed_action_hook']) ); // Will call powerpress_get_the_content(true) if the excerpt does not exist } if( !empty($subtitle) ) { echo "\t". powerpress_format_itunes_value($subtitle, 'subtitle') .''.PHP_EOL; } if( !empty($summary) ) { if( $summary_cdata ) { echo "\t\t'.PHP_EOL; } else { echo "\t\t". powerpress_format_itunes_value($summary, 'summary') .''.PHP_EOL; } } if( !empty($author) ) { echo "\t\t" . esc_html($author) . ''.PHP_EOL; } // itunes episode image if( !empty( $EpisodeData['itunes_image']) ) { echo "\t\t".''.PHP_EOL; } else if( !empty($powerpress_feed['itunes_image']) ) { echo "\t\t".''.PHP_EOL; } if( !empty($EpisodeData['season']) ) { echo "\t\t".''. esc_html($EpisodeData['season']) .''.PHP_EOL; } if( !empty($EpisodeData['episode_no']) ) { echo "\t\t".''. esc_html($EpisodeData['episode_no']) .''.PHP_EOL; } if( !empty($EpisodeData['episode_title']) ) { echo "\t\t".''. esc_html($EpisodeData['episode_title']) .''.PHP_EOL; } if( !empty($EpisodeData['episode_type']) ) { echo "\t\t".''. esc_html($EpisodeData['episode_type']) .''.PHP_EOL; } if( !empty($explicit) && $explicit != 'no' ) { echo "\t\t" . $explicit . ''.PHP_EOL; } 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 echo "\t\t" . ltrim($EpisodeData['duration'], '0:') . ''.PHP_EOL; } if( $block && $block == 'yes' ) { echo "\t\tyes".PHP_EOL; } if( $cc && $cc == 'yes' ) { echo "\t\tyes".PHP_EOL; } if( !empty($powerpress_feed['itunes_feature']) ) { // We are using the itunes:order option to feature a specific episode. // Skip inserting the order tag } else { if( isset( $EpisodeData['order'] ) && is_numeric( $EpisodeData['order'] ) ) echo "\t\t". $EpisodeData['order'] ."".PHP_EOL; } // Google Play tags: 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 if( !empty( $EpisodeData['gp_desc'] ) ) { echo "\t\t". powerpress_format_itunes_value($EpisodeData['gp_desc'], 'summary') ."".PHP_EOL; } if( !empty( $EpisodeData['gp_explicit'] ) ) { echo "\t\tyes".PHP_EOL; } } if( !empty( $EpisodeData['gp_block'] ) ) { echo "\t\tyes".PHP_EOL; } // RawVoice RSS Tags if( empty($powerpress_feed['feed_maximizer_on']) ) { if( !defined('POWERPRESS_RAWVOICE_RSS') || POWERPRESS_RAWVOICE_RSS != false ) { if( !empty($EpisodeData['ishd']) ) echo "\t\tyes".PHP_EOL;; if( !empty($EpisodeData['image']) ) echo "\t\t".PHP_EOL; if( !empty($EpisodeData['embed']) ) echo "\t\t". htmlspecialchars($EpisodeData['embed']) ."".PHP_EOL; else if( !empty($powerpress_feed['podcast_embed_in_feed']) && function_exists('powerpress_generate_embed') ) { $player = powerpressplayer_embedable($EpisodeData['url'], $EpisodeData); $embed_content = ''; if( $player ) $embed_content = powerpress_generate_embed($player, $EpisodeData); if( $embed_content ) echo "\t\t". htmlspecialchars( $embed_content ) ."".PHP_EOL; } if( !empty($EpisodeData['webm_src']) ) { echo "\t\t".PHP_EOL; } $GeneralSettings = get_option('powerpress_general'); require_once(POWERPRESS_ABSPATH .'/powerpress-metamarks.php'); powerpress_metamarks_print_rss2($EpisodeData); } } } add_action('rss2_item', 'powerpress_rss2_item'); add_action('rss2_item_powerpress', 'powerpress_rss2_item'); /* 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 */ function powerpress_filter_rss_enclosure($content) { if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) || defined('PODCASTING_VERSION') ) { return $content; // Another podcasting plugin is enabled... } if( powerpress_is_custom_podcast_feed() && get_query_var('feed') !== 'podcast' && !is_category() && !is_tag() && !is_tax() ) return ''; // We will handle this enclosure in the powerpress_rss2_item() function $match_count = preg_match('/\surl="([^"]*)"/', $content, $matches); // No URL found, weird if( count($matches) != 2) return $content; // Original Media URL $OrigURL = $matches[1]; if( substr($OrigURL, 0, 5) != 'http:' && substr($OrigURL, 0, 6) != 'https:' ) return ''; // The URL value is invalid global $post, $powerpress_rss_enclosure_post_id; if( empty($powerpress_rss_enclosure_post_id) ) $powerpress_rss_enclosure_post_id = -1; if( $powerpress_rss_enclosure_post_id == $post->ID ) return ''; // we've already included one enclosure, lets not allow anymore $powerpress_rss_enclosure_post_id = $post->ID; $EpisodeData = powerpress_get_enclosure_data($post->ID); // Modified Media URL $ModifiedURL = powerpress_url_in_feed($EpisodeData['url']); // powerpress_add_redirect_url($OrigURL); // Check that the content type is a valid one... $match_count = preg_match('/\stype="([^"]*)"/', $content, $matches); if( count($matches) > 1 && strstr($matches[1], '/') == false ) { $ContentType = powerpress_get_contenttype($ModifiedURL); $content = str_replace("type=\"{$matches[1]}\"", "type=\"$ContentType\"", $content); } // Check that the content length is a digit greater that zero $match_count = preg_match('/\slength="([^"]*)"/', $content, $matches); if( count($matches) > 1 && empty($matches[1]) ) { $content = str_replace("length=\"{$matches[1]}\"", "length=\"5242880\"", $content); } // Replace the original url with the modified one... if( $OrigURL != $ModifiedURL ) return str_replace($OrigURL, $ModifiedURL, $content); return $content; } add_filter('rss_enclosure', 'powerpress_filter_rss_enclosure', 11); function powerpress_bloginfo_rss($content, $field = '') { $new_value = ''; if( powerpress_is_custom_podcast_feed() ) { if( is_category() ) { $Feed = get_option('powerpress_cat_feed_'.get_query_var('cat') ); } else if( is_tax() || is_tag() ) { global $powerpress_feed; if( !empty($powerpress_feed['term_taxonomy_id']) ) $Feed = get_option('powerpress_taxonomy_'.$powerpress_feed['term_taxonomy_id'] ); } else { global $powerpress_feed; if( !empty($powerpress_feed['post_type']) ) { $feed_slug = get_query_var('feed'); $PostTypeSettingsArray = get_option('powerpress_posttype_'.$powerpress_feed['post_type'] ); if( !empty($PostTypeSettingsArray[ $feed_slug ]) ) $Feed = $PostTypeSettingsArray[ $feed_slug ]; } else { $Feed = get_option('powerpress_feed_'.get_query_var('feed') ); if( empty($Feed) && get_query_var('feed') === 'podcast' ) $Feed = get_option('powerpress_feed'); } } if( $Feed ) { switch( $field ) { case 'description': { if( !empty($Feed['description']) ) $new_value = $Feed['description']; else if( is_category() ) { $category = get_category( get_query_var('cat') ); if( $category->description ) $new_value = $category->description; } }; break; case 'url': { // If the website URL is set for this podcast then lets use it... if( !empty($Feed['url']) ) return trim($Feed['url']); if( is_category() ) { return get_category_link( get_query_var('cat') ); } else { $urlTemp = ''; $blogHomepage = get_option('page_for_posts'); if( !empty($blogHomepage) ) { $urlTemp = get_permalink( $blogHomepage ); } if( empty($urlTemp) ) $urlTemp = get_bloginfo('url'); if( !empty($urlTemp) ) return $urlTemp; } }; break; case 'name': { // As of wp 4.4+ title is handled by get_the_title_rss completely. if( !empty($Feed['title']) ) $new_value = $Feed['title']; }; break; case 'language': { // Get the feed language $lang = ''; if( isset($Feed['rss_language']) && $Feed['rss_language'] != '' ) $lang = $Feed['rss_language']; if( strlen($lang) == 5 ) $lang = substr($lang,0,3) . strtoupper( substr($lang, 3) ); // Format example: en-US for English, United States if( !empty($lang) ) return $lang; }; break; } } } if( !empty($new_value) ) { $new_value = wptexturize($new_value); $new_value = convert_chars($new_value); $new_value = esc_html($new_value); //$new_value = convert_chars($new_value); return $new_value; } return $content; } add_filter('get_bloginfo_rss', 'powerpress_bloginfo_rss', 10, 2); function powerpress_wp_title_rss($title) { if( version_compare($GLOBALS['wp_version'], 4.4, '>=' ) ) { if( powerpress_is_custom_podcast_feed() ) { if( is_category() ) { $Feed = get_option('powerpress_cat_feed_'.get_query_var('cat') ); } else if( is_tax() || is_tag() ) { global $powerpress_feed; if( !empty($powerpress_feed['term_taxonomy_id']) ) $Feed = get_option('powerpress_taxonomy_'.$powerpress_feed['term_taxonomy_id'] ); } else { global $powerpress_feed; if( !empty($powerpress_feed['post_type']) ) { $feed_slug = get_query_var('feed'); if( !empty($feed_slug) ) { $PostTypeSettingsArray = get_option('powerpress_posttype_'.$powerpress_feed['post_type'] ); if( !empty($PostTypeSettingsArray[ $feed_slug ]) ) $Feed = $PostTypeSettingsArray[ $feed_slug ]; } } else { $feed_slug = get_query_var('feed'); $Feed = false; if( !empty($feed_slug) ) { $Feed = get_option('powerpress_feed_'.get_query_var('feed') ); } if( empty($Feed) && get_query_var('feed') === 'podcast' ) $Feed = get_option('powerpress_feed'); } } if( $Feed ) { if( !empty($Feed['title']) ) return esc_html( $Feed['title'] ); } } } else { if( powerpress_is_custom_podcast_feed() ) { if( is_category() ) { $Feed = get_option('powerpress_cat_feed_'.get_query_var('cat') ); if( $Feed && isset($Feed['title']) && $Feed['title'] != '' ) return ''; // We alrady did a custom title, lets not add the category to it... } else { return ''; // It is not a category, lets not mess with our beautiful title then } } } return $title; } add_filter('get_wp_title_rss', 'powerpress_wp_title_rss'); function powerpress_the_title_rss($title) { $new_title = $title; $GeneralSettings = get_option('powerpress_general'); // If it is a custom podcast channel... if( !empty($GeneralSettings['seo_feed_title']) ) { $feed_slug = 'podcast'; // IF custom post type or channel, use that feed slug... if( get_query_var('feed') !== 'podcast' && !is_category() && !is_tax() && !is_tag() ) $feed_slug = get_query_var('feed'); // Get the episode specific title... $EpisodeData = powerpress_get_enclosure_data(get_the_ID(), $feed_slug); if( !empty($EpisodeData['feed_title']) ) { $feed_title = ent2ncr( $EpisodeData['feed_title'] ); $feed_title = strip_tags( $feed_title ); $feed_title = esc_html( $feed_title ); //switch( $GeneralSettings['custom_feed_title'] ) switch( $GeneralSettings['seo_feed_title'] ) { case 1: { // Replaces title $new_title = $feed_title; }; break; case 2: { // Prefixes title $new_title = $feed_title . ' ' . $title; }; break; case 3: { // Postfixes title $new_title = $title . ' ' . $feed_title; }; break; } } } return $new_title; } add_filter('the_title_rss', 'powerpress_the_title_rss', 11); function powerpress_feed_content_type($content_type = '', $feedslug = '') { switch( $feedslug ) { case 'rss': case 'rss2': case 'atom': case 'rdf': { // Do nothing, let WordPress take care of these }; break; case 'podcast': { // This one is ours! $content_type = 'application/rss+xml'; }; break; default: { // Check for the custom podcast feeds $GeneralSettings = get_option('powerpress_general'); if( !empty($GeneralSettings['custom_feeds'][ $feedslug ]) ) { $content_type = 'application/rss+xml'; } else if( !empty($GeneralSettings['posttype_podcasting']) ) { // We need to look up these settings... $FeedSlugPostTypesArray = get_option('powerpress_posttype-podcasting'); if( is_array($FeedSlugPostTypesArray) && !empty($FeedSlugPostTypesArray[ $feedslug ]) ) { $content_type = 'application/rss+xml'; } } } } return $content_type; } add_filter( 'feed_content_type', 'powerpress_feed_content_type', 10, 2 ); // 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. if( version_compare($GLOBALS['wp_version'], '3.4', '<') ) { function powerpress_rss_language($value) { if( powerpress_is_custom_podcast_feed() ) { global $powerpress_feed; if( $powerpress_feed && isset($powerpress_feed['rss_language']) && $powerpress_feed['rss_language'] != '' ) $value = $powerpress_feed['rss_language']; } return $value; } add_filter('option_rss_language', 'powerpress_rss_language'); } //filter to ensure that guid doesn't come up blank function powerpress_the_guid($guid) { global $post; // Simple case, what is in the DB is better than an empty value if( empty($guid) && !empty($post->guid) ) { return $post->guid; } if( !empty($post->guid) ) { if( preg_match('/^https?:\/\//i', $post->guid, $matches) == false ) { $powerpressGuid = get_post_meta($post->ID, '_powerpress_guid', true); if( !empty($powerpressGuid) ) return $powerpressGuid; } } return $guid; } function powerpress_do_podcast_feed($for_comments=false) { global $wp_query, $powerpress_feed; powerpress_is_podcast_feed(); // Loads the feed settings if not already loaded... $GeneralSettings = get_option('powerpress_general'); if( isset($GeneralSettings['premium_caps']) && $GeneralSettings['premium_caps'] ) { $feed_slug = get_query_var('feed'); if( $feed_slug != 'podcast' ) { $FeedSettings = get_option('powerpress_feed_'.$feed_slug); if( !empty($FeedSettings['premium']) ) { require_once( POWERPRESS_ABSPATH.'/powerpress-feed-auth.php'); powerpress_feed_auth( $feed_slug ); } } } // Use the template to gurantee future WordPress behavior if( defined('POWERPRESS_FEED_TEMPLATE') ) { load_template( POWERPRESS_FEED_TEMPLATE ); } else { load_template( POWERPRESS_ABSPATH . '/feed-podcast.php' ); } } function powerpress_template_redirect() { if( is_feed() && powerpress_is_custom_podcast_feed() ) { if ( defined('WPSEO_VERSION') && version_compare(WPSEO_VERSION, '7.7', '>=') && class_exists( 'WPSEO_Frontend' ) ) { $wpseo_frontend = WPSEO_Frontend::get_instance(); if( !empty($wpseo_frontend) ) { remove_action( 'template_redirect', array( $wpseo_frontend, 'noindex_feed' ) ); } } remove_action('template_redirect', 'ol_feed_redirect'); // Remove this action so feedsmith doesn't redirect global $powerpress_feed; if( !isset($powerpress_feed['feed_redirect_url']) ) $powerpress_feed['feed_redirect_url'] = ''; $redirect_value = ( !empty($_GET['redirect'])? $_GET['redirect'] : false ); if( is_array($powerpress_feed) && trim($powerpress_feed['feed_redirect_url']) != '' && !preg_match("/feedburner|feedsqueezer|feedvalidator/i", $_SERVER['HTTP_USER_AGENT'] ) && $redirect_value != 'no' ) { if (function_exists('status_header')) status_header( 301 ); header("Location: " . trim($powerpress_feed['feed_redirect_url'])); header("HTTP/1.1 301 Moved Permanently"); exit(); } } } add_action('template_redirect', 'powerpress_template_redirect', 0); function powerpress_rewrite_rules_array($array) { global $wp_rewrite; $settings = get_option('powerpress_general'); $podcast_feeds = array('podcast'=>true); if( isset($settings['custom_feeds']) && is_array($settings['custom_feeds']) ) $podcast_feeds = array_merge($settings['custom_feeds'], $podcast_feeds ); $merged_slugs = ''; foreach( $podcast_feeds as $feed_slug=> $feed_title ) { if( $merged_slugs != '' ) $merged_slugs .= '|'; $merged_slugs .= $feed_slug; } // $wp_rewrite->index most likely index.php $new_array[ 'feed/('.$merged_slugs.')/?$' ] = $wp_rewrite->index. '?feed='. $wp_rewrite->preg_index(1); // If feature is not enabled, use the default permalinks if( empty($settings['permalink_feeds_only']) ) return array_merge($new_array, $array); global $wpdb; reset($podcast_feeds); foreach( $podcast_feeds as $feed_slug=> $feed_title ) { $page_name_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_name = '".$feed_slug."'"); if( $page_name_id ) { $new_array[ $feed_slug.'/?$' ] = $wp_rewrite->index. '?pagename='. $feed_slug.'&page_id='.$page_name_id; unset($podcast_feeds[ $feed_slug ]); continue; } $category = get_category_by_slug($feed_slug); if( $category ) { $new_array[ $feed_slug.'/?$' ] = $wp_rewrite->index. '?cat='. $category->term_id; // category_name='. $feed_slug .'& unset($podcast_feeds[ $feed_slug ]); } } if( count($podcast_feeds) > 0 ) { reset($podcast_feeds); $remaining_slugs = ''; foreach( $podcast_feeds as $feed_slug=> $feed_title ) { if( $remaining_slugs != '' ) $remaining_slugs .= '|'; $remaining_slugs .= $feed_slug; } $new_array[ '('.$remaining_slugs.')/?$' ] = $wp_rewrite->index. '?pagename='. $wp_rewrite->preg_index(1); } return array_merge($new_array, $array); } add_filter('rewrite_rules_array', 'powerpress_rewrite_rules_array'); function powerpress_pre_transient_rewrite_rules($return_rules) { global $wp_rewrite; $GeneralSettings = get_option('powerpress_general'); if( !in_array('podcast', $wp_rewrite->feeds) ) $wp_rewrite->feeds[] = 'podcast'; if( $GeneralSettings && isset($GeneralSettings['custom_feeds']) && is_array($GeneralSettings['custom_feeds']) ) { foreach( $GeneralSettings['custom_feeds'] as $feed_slug=> $null ) { if( !in_array($feed_slug, $wp_rewrite->feeds) ) $wp_rewrite->feeds[] = $feed_slug; } } return $return_rules; } add_filter('pre_transient_rewrite_rules', 'powerpress_pre_transient_rewrite_rules'); function powerpress_init() { $GeneralSettings = get_option('powerpress_general'); if( !empty($GeneralSettings['powerpress-beta-features']) && file_exists(POWERPRESS_ABSPATH.'/powerpressadmin-pts.php') ) { require_once(POWERPRESS_ABSPATH.'/powerpressadmin-pts.php'); } if( empty($GeneralSettings['disable_appearance']) || $GeneralSettings['disable_appearance'] == false ) { require_once( POWERPRESS_ABSPATH.'/powerpress-player.php'); powerpressplayer_init($GeneralSettings); } // Enable the playlist feature for PowerPress if( !empty($GeneralSettings['playlist_player']) ) // Either not set or set on { require_once(POWERPRESS_ABSPATH.'/powerpress-playlist.php'); } if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) || defined('PODCASTING_VERSION') ) return false; // Another podcasting plugin is enabled... // If we are to process podpress data.. if( !empty($GeneralSettings['process_podpress']) ) { powerpress_podpress_redirect_check(); } // Add the podcast feeds; if( !defined('POWERPRESS_NO_PODCAST_FEED') ) { add_feed('podcast', 'powerpress_do_podcast_feed'); } if( $GeneralSettings && isset($GeneralSettings['custom_feeds']) && is_array($GeneralSettings['custom_feeds']) ) { foreach( $GeneralSettings['custom_feeds'] as $feed_slug=> $feed_title ) { if( $feed_slug != 'podcast' ) add_feed($feed_slug, 'powerpress_do_podcast_feed'); } } if( !empty($GeneralSettings['posttype_podcasting']) ) { // Loop through the posttype podcasting settings and set the feeds for the custom post type slugs... global $wp_rewrite; $FeedSlugPostTypesArray = get_option('powerpress_posttype-podcasting'); // Changed field slightly so it does not conflict with a post type "podcasting" if( $FeedSlugPostTypesArray === false ) { // Simple one-time fix... $FeedSlugPostTypesArray = get_option('powerpress_posttype_podcasting'); if( empty($FeedSlugPostTypesArray) ) $FeedSlugPostTypesArray = array(); update_option('powerpress_posttype-podcasting', $FeedSlugPostTypesArray); if( !array_key_exists('title', $FeedSlugPostTypesArray) ) // AS long as it doesn't have post type specific settings... delete_option('powerpress_posttype_podcasting'); } if( empty($FeedSlugPostTypesArray) ) { $FeedSlugPostTypesArray = array(); } foreach( $FeedSlugPostTypesArray as $feed_slug=> $FeedSlugPostTypes ) { if ( !in_array($feed_slug, $wp_rewrite->feeds) ) // we need to add this feed name { add_feed($feed_slug, 'powerpress_do_podcast_feed'); foreach( $FeedSlugPostTypes as $post_type_slug=> $title ) { 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 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 } } } } if( defined('GAWP_VERSION') ) { add_filter('the_content', 'powerpress_yoast_gawp_fix', 120 ); } if( !empty($GeneralSettings['subscribe_links']) ) { // 2 Subscribe page shortocde [powerpress_subscribe feedslug="podcast"] // 3 Subscribe sidebar widget: iTunes, RSS add_filter('powerpress_player_subscribe_links', 'powerpressplayer_link_subscribe_pre', 1, 3); add_filter('powerpress_player_subscribe_links', 'powerpressplayer_link_subscribe_post', 1000, 3); } wp_register_style( 'powerpress-subscribe-style', powerpress_get_root_url() . 'css/subscribe.css', array(), '20141021', 'all' ); if( !empty($GeneralSettings['rss_emoji']) ) { if( has_filter('the_content_feed', 'wp_staticize_emoji') ) { remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); // Remove the emoji images remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); //add_filter( 'the_content_feed', 'wp_encode_emoji' ); // Convert an emoji to xxx; //add_filter( 'get_wp_title_rss', 'wp_encode_emoji' ); } } if( !defined('POWERPRESS_NO_REMOVE_WP_HEAD') ) { remove_action('wp_head', 'feed_links', 2); remove_action('wp_head', 'feed_links_extra', 3); } add_filter( 'the_guid', 'powerpress_the_guid', 11 ); } add_action('init', 'powerpress_init', -100); // We need to add the feeds before other plugins start screwing with them function powerpress_wp_print_styles() { $Settings = get_option('powerpress_general'); if( !empty($Settings['audio_player_max_width']) ) { echo ''."\n"; } } add_action('wp_print_styles', 'powerpress_wp_print_styles'); function powerpress_request($qv) { if( !empty($qv['feed']) ) { $podcast_feed_slug = false; if( $qv['feed'] == 'podcast' ) { $GeneralSettings = get_option('powerpress_general'); if( empty($GeneralSettings['posttype_podcasting']) ) $podcast_feed_slug = 'podcast'; } else if( $qv['feed'] == 'rss' || $qv['feed'] == 'rss2' || $qv['feed'] == 'atom' || $qv['feed'] == 'rdf' || $qv['feed'] == 'feed' ) { // 'feed', 'rdf', 'rss', 'rss2', 'atom' // Skip } else { $GeneralSettings = get_option('powerpress_general'); if( empty($GeneralSettings['posttype_podcasting']) && isset($GeneralSettings['custom_feeds']) && is_array($GeneralSettings['custom_feeds']) && !empty($GeneralSettings['custom_feeds'][ $qv['feed'] ] ) ) $podcast_feed_slug = $qv['feed']; } if( $podcast_feed_slug ) { if( !defined('POWERPRESS_POSTTYPE_MIXING') && $qv['feed'] == 'podcast' ) { $qv['post_type'] = 'post'; } else { $qv['post_type'] = get_post_types( array('public'=> true, 'capability_type'=>'post') ); if( !empty($qv['post_type']['attachment']) ) unset($qv['post_type']['attachment']); } $FeedCustom = get_option('powerpress_feed_'.$podcast_feed_slug); // Get custom feed specific settings // See if the user set a custom post type only... if( !empty($FeedCustom) && !empty( $FeedCustom['custom_post_type']) ) $qv['post_type'] = $FeedCustom['custom_post_type']; } } return $qv; } add_filter('request', 'powerpress_request'); function powerpress_plugins_loaded() { // Translation support loaded: load_plugin_textdomain('powerpress', // domain / keyword name of plugin POWERPRESS_ABSPATH .'/languages', // Absolute path basename(POWERPRESS_ABSPATH).'/languages' ); // relative path in plugins folder /* #### # Defines that effect translation defined now: #### */ // Set specific play and download labels for your installation of PowerPress if( !defined('POWERPRESS_LINKS_TEXT') ) define('POWERPRESS_LINKS_TEXT', __('Podcast', 'powerpress') ); if( !defined('POWERPRESS_DURATION_TEXT') ) define('POWERPRESS_DURATION_TEXT', __('Duration', 'powerpress') ); if( !defined('POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT') ) define('POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT', __('Play in new window', 'powerpress') ); if( !defined('POWERPRESS_DOWNLOAD_TEXT') ) define('POWERPRESS_DOWNLOAD_TEXT', __('Download', 'powerpress') ); if( !defined('POWERPRESS_PLAY_TEXT') ) define('POWERPRESS_PLAY_TEXT', __('Play', 'powerpress') ); if( !defined('POWERPRESS_EMBED_TEXT') ) define('POWERPRESS_EMBED_TEXT', __('Embed', 'powerpress') ); if( !defined('POWERPRESS_READ_TEXT') ) define('POWERPRESS_READ_TEXT', __('Read', 'powerpress') ); } add_action('plugins_loaded', 'powerpress_plugins_loaded'); function powerpress_w3tc_can_print_comment($settings) { return false; } // Disable minifying if W3TC is enabled function powerpress_w3tc_minify_enable($enable) { if( is_feed() ) return false; return $enable; } // Load the general feed settings for feeds handled by powerpress function powerpress_load_general_feed_settings() { global $wp_query; global $powerpress_feed; if( $powerpress_feed !== false ) // If it is not false (either NULL or an array) then we already looked these settings up { $powerpress_feed = false; // Get the powerpress settings $GeneralSettings = get_option('powerpress_general'); if( !isset($GeneralSettings['custom_feeds']['podcast']) ) $GeneralSettings['custom_feeds']['podcast'] = 'Podcast Feed'; // Fixes scenario where the user never configured the custom default podcast feed. if( empty($GeneralSettings['default_url']) ) $GeneralSettings['default_url'] = ''; if( $GeneralSettings ) { $FeedSettingsBasic = get_option('powerpress_feed'); // Get overall feed settings if( is_feed() && defined( 'WPCACHEHOME' ) && empty($GeneralSettings['allow_feed_comments']) ) { global $wp_super_cache_comments; $wp_super_cache_comments = 0; } if( is_feed() && defined('W3TC') && empty($GeneralSettings['allow_feed_comments']) ) { add_filter( 'w3tc_can_print_comment', 'powerpress_w3tc_can_print_comment', 10, 1 ); } if( is_feed() && defined('W3TC') ) { add_filter( 'w3tc_minify_enable', 'powerpress_w3tc_minify_enable'); } // If we're in advanced mode and we're dealing with a category feed we're extending, lets work with it... if( is_category() && isset($GeneralSettings['custom_cat_feeds']) && is_array($GeneralSettings['custom_cat_feeds']) && in_array( get_query_var('cat'), $GeneralSettings['custom_cat_feeds']) ) { $cat_ID = get_query_var('cat'); $FeedCustom = get_option('powerpress_cat_feed_'.$cat_ID); // Get custom feed specific settings $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $FeedSettingsBasic); $powerpress_feed = array(); if( !empty($GeneralSettings['feed_accel']) ) $powerpress_feed['feed_accel'] = true; $powerpress_feed['is_custom'] = true; $powerpress_feed['category'] = $cat_ID; $powerpress_feed['process_podpress'] = !empty($GeneralSettings['process_podpress']); // Category feeds could originate from Podpress $powerpress_feed['rss_language'] = ''; // default, let WordPress set the language $powerpress_feed['default_url'] = ''; if( !empty($GeneralSettings['default_url']) ) $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/'; $explicit_array = array("no", "yes", "clean"); $powerpress_feed['explicit'] = $explicit_array[$Feed['itunes_explicit']]; if( !empty($Feed['itunes_talent_name']) ) $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name']; else $powerpress_feed['itunes_talent_name'] = get_wp_title_rss(); $powerpress_feed['enhance_itunes_summary'] = $Feed['enhance_itunes_summary']; if( !empty($GeneralSettings['seo_itunes']) ) $powerpress_feed['enhance_itunes_summary'] = 1; $powerpress_feed['posts_per_rss'] = false; if( !empty($Feed['posts_per_rss']) && is_numeric($Feed['posts_per_rss']) && $Feed['posts_per_rss'] > 0 ) $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss']; $powerpress_feed['feed_redirect_url'] = ''; if( !empty($Feed['feed_redirect_url']) ) $powerpress_feed['feed_redirect_url'] = $Feed['feed_redirect_url']; if( $Feed['itunes_author_post'] == true ) $powerpress_feed['itunes_author_post'] = true; if( $Feed['rss_language'] != '' ) $powerpress_feed['rss_language'] = $Feed['rss_language']; if( !empty($GeneralSettings['podcast_embed_in_feed']) ) $powerpress_feed['podcast_embed_in_feed'] = true; if( !empty($Feed['maximize_feed']) ) $powerpress_feed['maximize_feed'] = true; if( !empty($Feed['episode_itunes_image']) && !empty($Feed['itunes_image']) ) $powerpress_feed['itunes_image'] = $Feed['itunes_image']; return; } else if( ( defined('POWERPRESS_TAXONOMY_PODCASTING') || !empty($GeneralSettings['taxonomy_podcasting']) ) && ( is_tag() || is_tax() ) ) { // We need to get the term_id and the tax_id (tt_id) $term_slug = get_query_var('term'); $taxonomy = get_query_var('taxonomy'); if( empty($term_slug) && empty($taxonomy) ) // Handle situation where tag is the taxonomy we're working with { $term_slug = get_query_var('tag'); if( !empty($term_slug) ) $taxonomy = 'post_tag'; } $term = false; if( !empty($term_slug) && !empty($taxonomy) ) { $term = term_exists($term_slug, $taxonomy); } if( !empty($term['term_taxonomy_id']) ) { $FeedCustom = get_option('powerpress_taxonomy_'.$term['term_taxonomy_id'] ); // Get custom feed specific settings if( $FeedCustom ) { $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $FeedSettingsBasic); $powerpress_feed = array(); if( !empty($GeneralSettings['feed_accel']) ) $powerpress_feed['feed_accel'] = true; $powerpress_feed['is_custom'] = true; $powerpress_feed['term_taxonomy_id'] = $term['term_taxonomy_id']; $powerpress_feed['process_podpress'] = false; // Taxonomy feeds will not originate from Podpress $powerpress_feed['rss_language'] = ''; // default, let WordPress set the language $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/'; $explicit_array = array("no", "yes", "clean"); $powerpress_feed['explicit'] = $explicit_array[$Feed['itunes_explicit']]; if( !empty($Feed['itunes_talent_name']) ) $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name']; else $powerpress_feed['itunes_talent_name'] = get_wp_title_rss(); $powerpress_feed['enhance_itunes_summary'] = $Feed['enhance_itunes_summary']; if( !empty($GeneralSettings['seo_itunes']) ) $powerpress_feed['enhance_itunes_summary'] = 1; $powerpress_feed['posts_per_rss'] = false; if( !empty($Feed['posts_per_rss']) && is_numeric($Feed['posts_per_rss']) && $Feed['posts_per_rss'] > 0 ) $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss']; if( $Feed['feed_redirect_url'] != '' ) $powerpress_feed['feed_redirect_url'] = $Feed['feed_redirect_url']; if( $Feed['itunes_author_post'] == true ) $powerpress_feed['itunes_author_post'] = true; if( $Feed['rss_language'] != '' ) $powerpress_feed['rss_language'] = $Feed['rss_language']; if( !empty($GeneralSettings['podcast_embed_in_feed']) ) $powerpress_feed['podcast_embed_in_feed'] = true; if( !empty($Feed['maximize_feed']) ) $powerpress_feed['maximize_feed'] = true; if( !empty($Feed['episode_itunes_image']) && !empty($Feed['itunes_image']) ) $powerpress_feed['itunes_image'] = $Feed['itunes_image']; return; } } } $feed_slug = get_query_var('feed'); // Are we dealing with a custom podcast channel or a custom post type podcast feed... if( !empty($GeneralSettings['posttype_podcasting']) || isset($GeneralSettings['custom_feeds'][ $feed_slug ]) ) { $Feed = false; if( !empty($GeneralSettings['posttype_podcasting']) ) { $post_type = get_query_var('post_type'); if( !empty($post_type) ) { if ( is_array( $post_type ) ) { $post_type = reset( $post_type ); // get first element in array } // Get the settings for this podcast post type $PostTypeSettingsArray = get_option('powerpress_posttype_'. $post_type); if( !empty($PostTypeSettingsArray[ $feed_slug ]) ) { $FeedCustom = $PostTypeSettingsArray[ $feed_slug ]; $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $FeedSettingsBasic); $Feed['post_type'] = $post_type; } } } if( empty($Feed) && isset($GeneralSettings['custom_feeds'][ $feed_slug ]) ) { $FeedCustom = get_option('powerpress_feed_'.$feed_slug); // Get custom feed specific settings $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $FeedSettingsBasic, ($feed_slug == 'podcast') ); } if( $Feed ) { $powerpress_feed = array(); if( !empty($GeneralSettings['feed_accel']) ) $powerpress_feed['feed_accel'] = true; $powerpress_feed['is_custom'] = true; $powerpress_feed['feed-slug'] = $feed_slug; if( !empty($Feed['post_type']) ) $powerpress_feed['post_type'] = $Feed['post_type']; $powerpress_feed['process_podpress'] = ($feed_slug=='podcast'? !empty($GeneralSettings['process_podpress']): false); // We don't touch podpress data for custom feeds $powerpress_feed['rss_language'] = ''; // RSS language should be set by WordPress by default $powerpress_feed['default_url'] = ''; if( !empty($powerpress_feed['default_url']) ) $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/'; $explicit = array("no", "yes", "clean"); $powerpress_feed['explicit'] ='no'; if( !empty($Feed['itunes_explicit']) ) $powerpress_feed['explicit'] = $explicit[ $Feed['itunes_explicit'] ]; if( !empty($Feed['itunes_talent_name']) ) $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name']; else $powerpress_feed['itunes_talent_name'] = get_wp_title_rss(); $powerpress_feed['enhance_itunes_summary'] = $Feed['enhance_itunes_summary']; if( !empty($GeneralSettings['seo_itunes']) ) $powerpress_feed['enhance_itunes_summary'] = 1; $powerpress_feed['posts_per_rss'] = false; if( !empty($Feed['posts_per_rss']) && is_numeric($Feed['posts_per_rss']) && $Feed['posts_per_rss'] > 0 ) $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss']; if( !empty($Feed['feed_redirect_url']) ) $powerpress_feed['feed_redirect_url'] = $Feed['feed_redirect_url']; if( !empty($Feed['itunes_author_post'] ) ) $powerpress_feed['itunes_author_post'] = true; if( !empty($Feed['rss_language']) ) $powerpress_feed['rss_language'] = $Feed['rss_language']; if( !empty($GeneralSettings['podcast_embed_in_feed']) ) $powerpress_feed['podcast_embed_in_feed'] = true; if( !empty($Feed['maximize_feed']) ) $powerpress_feed['maximize_feed'] = true; if( !empty($Feed['episode_itunes_image']) && !empty($Feed['itunes_image']) ) $powerpress_feed['itunes_image'] = $Feed['itunes_image']; return; } } if( !isset($FeedSettingsBasic['apply_to']) ) $FeedSettingsBasic['apply_to'] = 1; // We fell this far,we must be in simple mode or the user never saved customized their custom feed settings switch( $FeedSettingsBasic['apply_to'] ) { 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. { if( $feed_slug != 'podcast' ) break; } // important: no break here! case 2: // RSS2 Main feed and podcast feed added by PowerPress only { if( $feed_slug != 'feed' && $feed_slug != 'rss2' && $feed_slug != 'podcast' ) break; // We're only adding podcasts to the rss2 feed in this situation if( $wp_query->is_category ) // don't touch the category feeds... break; if( $wp_query->is_tag ) // don't touch the tag feeds... break; if( $wp_query->is_comment_feed ) // don't touch the comments feeds... break; } // important: no break here! case 1: // All feeds { $powerpress_feed = array(); // Only store what's needed for each feed item if( !empty($GeneralSettings['feed_accel']) ) $powerpress_feed['feed_accel'] = true; $powerpress_feed['is_custom'] = false; // ($feed_slug == 'podcast'?true:false); $powerpress_feed['feed-slug'] = $feed_slug; $powerpress_feed['process_podpress'] = !empty($GeneralSettings['process_podpress']); // We don't touch podpress data for custom feeds $powerpress_feed['default_url'] = ''; if( !empty($GeneralSettings['default_url']) ) $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/'; $explicit = array("no", "yes", "clean"); $powerpress_feed['explicit'] = 'no'; if( !empty($FeedSettingsBasic['itunes_explicit']) ) $powerpress_feed['explicit'] = $explicit[$FeedSettingsBasic['itunes_explicit']]; if( !empty($FeedSettingsBasic['itunes_talent_name']) ) $powerpress_feed['itunes_talent_name'] = $FeedSettingsBasic['itunes_talent_name']; else $powerpress_feed['itunes_talent_name'] = get_wp_title_rss(); $powerpress_feed['enhance_itunes_summary'] = 0; if( isset($FeedSettingsBasic['enhance_itunes_summary']) ) $powerpress_feed['enhance_itunes_summary'] = $FeedSettingsBasic['enhance_itunes_summary']; if( !empty($GeneralSettings['seo_itunes']) ) $powerpress_feed['enhance_itunes_summary'] = 1; $powerpress_feed['posts_per_rss'] = false; if( !empty($FeedSettingsBasic['posts_per_rss']) && is_numeric($FeedSettingsBasic['posts_per_rss']) && $FeedSettingsBasic['posts_per_rss'] > 0 ) $powerpress_feed['posts_per_rss'] = $FeedSettingsBasic['posts_per_rss']; if( !empty($FeedSettingsBasic['itunes_author_post']) ) $powerpress_feed['itunes_author_post'] = true; $powerpress_feed['rss_language'] = ''; // Cannot set the language setting in simple mode if( !empty($GeneralSettings['podcast_embed_in_feed']) ) $powerpress_feed['podcast_embed_in_feed'] = true; if( !empty($FeedSettingsBasic['episode_itunes_image']) && !empty($FeedSettingsBasic['itunes_image']) ) $powerpress_feed['itunes_image'] = $FeedSettingsBasic['itunes_image']; }; break; // All other cases we let fall through } } } } // Returns true of the feed should be treated as a podcast feed function powerpress_is_podcast_feed() { if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) || defined('PODCASTING_VERSION') ) return false; // Another podcasting plugin is enabled... global $powerpress_feed; if( $powerpress_feed !== false && !is_array($powerpress_feed) ) powerpress_load_general_feed_settings(); if( $powerpress_feed === false ) return false; return true; } // Returns true if the feed is a custom feed added by PowerPress function powerpress_is_custom_podcast_feed() { if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) || defined('PODCASTING_VERSION') ) return false; // Another podcasting plugin is enabled... global $powerpress_feed; if( $powerpress_feed !== false && !is_array($powerpress_feed) ) powerpress_load_general_feed_settings(); if( $powerpress_feed === false ) return false; return $powerpress_feed['is_custom']; } function powerpress_posts_fields($cols) { if( !is_feed() ) return $cols; if( is_category() || is_tag() || is_tax() ) { if( get_query_var('feed') !== 'podcast' ) return $cols; } if( powerpress_is_custom_podcast_feed() || get_query_var('feed') === 'podcast' ) { if( !empty($GLOBALS['powerpress_feed']['feed_accel']) ) { $feed_slug = get_query_var('feed'); global $wpdb; $cols .= ", pp_{$wpdb->postmeta}.meta_value AS podcast_meta_value "; } } return $cols; } //$fields = apply_filters_ref_array( 'posts_fields', array( $fields, &$this ) ); add_filter('posts_fields', 'powerpress_posts_fields' ); function powerpress_posts_join($join) { if( !is_feed() ) return $join; if( is_category() || is_tag() || is_tax() ) { if( get_query_var('feed') !== 'podcast' ) return $join; } if( powerpress_is_custom_podcast_feed() || get_query_var('feed') === 'podcast' ) { global $wpdb; $join .= " INNER JOIN {$wpdb->postmeta} AS pp_{$wpdb->postmeta} "; $join .= " ON {$wpdb->posts}.ID = pp_{$wpdb->postmeta}.post_id "; } return $join; } add_filter('posts_join', 'powerpress_posts_join' ); function powerpress_posts_where($where) { if( !is_feed() ) return $where; if( is_category() || is_tag() || is_tax() ) { if( get_query_var('feed') !== 'podcast' ) return $where; } if( powerpress_is_custom_podcast_feed() || get_query_var('feed') === 'podcast' ) { global $wpdb, $powerpress_feed; $where .= " AND ("; if( powerpress_is_custom_podcast_feed() && get_query_var('feed') !== 'podcast' ) $where .= " pp_{$wpdb->postmeta}.meta_key = '_". get_query_var('feed') .":enclosure' "; else $where .= " pp_{$wpdb->postmeta}.meta_key = 'enclosure' "; // Include Podpress data if exists... if( !empty($powerpress_feed['process_podpress']) && get_query_var('feed') === 'podcast' ) $where .= " OR pp_{$wpdb->postmeta}.meta_key = 'podPressMedia' OR pp_{$wpdb->postmeta}.meta_key = '_podPressMedia' "; $where .= ") "; } return $where; } add_filter('posts_where', 'powerpress_posts_where' ); // Add the groupby needed for enclosures only function powerpress_posts_groupby($groupby) { if( !is_feed() ) return $groupby; if( is_category() || is_tag() || is_tax() ) { if( get_query_var('feed') !== 'podcast' ) return $groupby; } if( powerpress_is_custom_podcast_feed() || get_query_var('feed') === 'podcast' ) { global $wpdb; $groupby = " {$wpdb->posts}.ID "; } return $groupby; } add_filter('posts_groupby', 'powerpress_posts_groupby'); function powerpress_post_limits($limits) { if( !is_feed() ) return $limits; if( powerpress_is_custom_podcast_feed() || get_query_var('feed') === 'podcast' ) { global $powerpress_feed; if( !empty($powerpress_feed['posts_per_rss']) && preg_match('/^(\d)+$/', trim($powerpress_feed['posts_per_rss'])) ) $limits = "LIMIT 0, {$powerpress_feed['posts_per_rss']}"; } return $limits; } add_filter('post_limits', 'powerpress_post_limits'); function powerpress_do_all_pings() { global $wpdb; $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE meta_key = '_encloseme' "); // Now call the WordPress do_all_pings()... do_all_pings(); remove_action('do_pings', 'do_all_pings'); } remove_action('do_pings', 'do_all_pings'); add_action('do_pings', 'powerpress_do_all_pings', 1, 1); /* Helper functions: */ function powerpress_podpress_redirect_check() { if( preg_match('/podpress_trac\/([^\/]+)\/([^\/]+)\/([^\/]+)\/(.*)$/', $_SERVER['REQUEST_URI'], $matches) ) { $post_id = $matches[2]; $mediaNum = $matches[3]; //$filename = $matches[4]; //$method = $matches[1]; if( is_numeric($post_id) && is_numeric($mediaNum)) { $EpisodeData = powerpress_get_enclosure_data_podpress($post_id, $mediaNum); if( $EpisodeData && isset($EpisodeData['url']) ) { if( strpos($EpisodeData['url'], 'http://' ) !== 0 && strpos($EpisodeData['url'], 'https://' ) !== 0 ) { die('Error occurred obtaining the URL for the requested media file.'); exit; } $EnclosureURL = str_replace(' ', '%20', $EpisodeData['url']); header('Location: '.$EnclosureURL, true, 302); header('Content-Length: 0'); exit; } // Let the WordPress 404 page load as normal } } } function the_powerpress_content() { echo get_the_powerpress_content(); } function get_the_powerpress_content() { global $post; if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) || defined('PODCASTING_VERSION') ) return ''; if( function_exists('post_password_required') ) { if( post_password_required($post) ) return ''; } // PowerPress settings: $GeneralSettings = get_option('powerpress_general'); // No player or links to add to content... if( !empty($GeneralSettings['disable_appearance']) ) return $content; if( !isset($GeneralSettings['custom_feeds']) ) $GeneralSettings['custom_feeds'] = array('podcast'=>'Default Podcast Feed'); // Re-order so the default podcast episode is the top most... $Temp = $GeneralSettings['custom_feeds']; $GeneralSettings['custom_feeds'] = array(); $GeneralSettings['custom_feeds']['podcast'] = 'Default Podcast Feed'; foreach( $Temp as $feed_slug=> $feed_title ) { if( $feed_slug == 'podcast' ) continue; $GeneralSettings['custom_feeds'][ $feed_slug ] = $feed_title; } // Handle post type feeds.... if( !empty($GeneralSettings['posttype_podcasting']) ) { $post_type = get_query_var('post_type'); if ( is_array( $post_type ) ) { $post_type = reset( $post_type ); // get first element in array } // Get the feed slugs and titles for this post type $PostTypeSettingsArray = get_option('powerpress_posttype_'.$post_type); // Loop through this array of post type settings... if( !empty($PostTypeSettingsArray) ) { switch($post_type) { case 'post': case 'page': { // Do nothing!, we want the default podcast to appear in these post types }; break; default: { if( !empty($post_type) && empty($PostTypeSettingsArray['podcast']) ) 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 }; break; } foreach( $PostTypeSettingsArray as $feed_slug=> $postTypeSettings ) { if( !empty( $postTypeSettings['title']) ) $GeneralSettings['custom_feeds'][ $feed_slug ] = $postTypeSettings['title']; else $GeneralSettings['custom_feeds'][ $feed_slug ] = $feed_slug; } } } if( !isset($GeneralSettings['display_player']) ) $GeneralSettings['display_player'] = 1; if( !isset($GeneralSettings['player_function']) ) $GeneralSettings['player_function'] = 1; if( !isset($GeneralSettings['podcast_link']) ) $GeneralSettings['podcast_link'] = 1; // Figure out which players are alerady in the body of the page... $ExcludePlayers = array(); if( isset($GeneralSettings['disable_player']) ) $ExcludePlayers = $GeneralSettings['disable_player']; // automatically disable the players configured // LOOP HERE TO DISPLAY EACH MEDIA TYPE $new_content = ''; foreach( $GeneralSettings['custom_feeds'] as $feed_slug=> $feed_title ) { // Get the enclosure data $EpisodeData = powerpress_get_enclosure_data($post->ID, $feed_slug); if( !$EpisodeData && !empty($GeneralSettings['process_podpress']) && $feed_slug == 'podcast' ) $EpisodeData = powerpress_get_enclosure_data_podpress($post->ID); if( !$EpisodeData || !$EpisodeData['url'] ) continue; // Just in case, if there's no URL lets escape! if( !$EpisodeData['url'] ) continue; // If the player is not already inserted in the body of the post using the shortcode... //if( preg_match('/\[powerpress(.*)\]/is', $content) == 0 ) if( !isset($ExcludePlayers[ $feed_slug ]) ) // If the player is not in our exclude list because it's already in the post body somewhere... { if( isset($GeneralSettings['premium_caps']) && $GeneralSettings['premium_caps'] && !powerpress_premium_content_authorized($feed_slug) ) { $new_content .= powerpress_premium_content_message($post->ID, $feed_slug, $EpisodeData); } else { if( $GeneralSettings['player_function'] != 3 && $GeneralSettings['player_function'] != 0 ) // Play in new window only or disabled { do_action('wp_powerpress_player_scripts'); $AddDefaultPlayer = empty($EpisodeData['no_player']); if( $EpisodeData && !empty($EpisodeData['embed']) ) { $new_content .= trim($EpisodeData['embed']); if( !empty($GeneralSettings['embed_replace_player']) ) $AddDefaultPlayer = false; } if( $AddDefaultPlayer ) { $image = ''; $width = ''; $height = ''; if( isset($EpisodeData['image']) && $EpisodeData['image'] != '' ) $image = $EpisodeData['image']; if( !empty($EpisodeData['width']) && is_numeric($EpisodeData['width']) ) $width = $EpisodeData['width']; if( !empty($EpisodeData['height']) && is_numeric($EpisodeData['height']) ) $height = $EpisodeData['height']; $new_content .= apply_filters('powerpress_player', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData ); } } if( !isset($EpisodeData['no_links']) ) { do_action('wp_powerpress_player_scripts'); $new_content .= apply_filters('powerpress_player_links', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData ); $new_content .= apply_filters('powerpress_player_subscribe_links', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData ); } } } } return $new_content; } // Adds content types that are missing from the default wp_check_filetype function function powerpress_get_contenttype($file, $use_wp_check_filetype = true) { $parts = pathinfo($file); if( !empty($parts['extension']) ) { switch( strtolower($parts['extension']) ) { // Audio formats case 'mp3': // most common case 'mpga': case 'mp2': case 'mp2a': case 'm2a': case 'm3a': return 'audio/mpeg'; case 'm4a': return 'audio/x-m4a'; case 'm4b': // Audio book format return 'audio/m4b'; case 'm4r': // iPhone ringtone format return 'audio/m4r'; // OGG Internet content types as set forth by rfc5334 (http://tools.ietf.org/html/rfc5334) case 'opus': case 'oga': case 'spx': return 'audio/ogg'; case 'wma': return 'audio/x-ms-wma'; case 'wax': return 'audio/x-ms-wax'; case 'ra': case 'ram': return 'audio/x-pn-realaudio'; case 'mp4a': return 'audio/mp4'; // Video formats case 'm4v': return 'video/x-m4v'; case 'mpeg': case 'mpg': case 'mpe': case 'm1v': case 'm2v': return 'video/mpeg'; case 'mp4': case 'mp4v': case 'mpg4': return 'video/mp4'; case 'asf': case 'asx': return 'video/x-ms-asf'; case 'wmx': return 'video/x-ms-wmx'; case 'avi': return 'video/x-msvideo'; case 'wmv': return 'video/x-ms-wmv'; // Check this case 'flv': return 'video/x-flv'; case 'mov': case 'qt': return 'video/quicktime'; case 'divx': return 'video/divx'; case '3gp': return 'video/3gpp'; case 'webm': return 'video/webm'; case 'ogg': { if( !defined('POWERPRESS_OGG_VIDEO') ) return 'audio/ogg'; } // Let this fall through as ogg/video case 'ogv': return 'video/ogg'; // rarely used case 'mid': case 'midi': return 'audio/midi'; case 'wav': return 'audio/wav'; case 'aa': return 'audio/audible'; case 'pdf': return 'application/pdf'; case 'torrent': return 'application/x-bittorrent'; case 'swf': return 'application/x-shockwave-flash'; case 'ogx': return 'application/ogg'; // Most recently added by Apple: case 'epub': return 'document/x-epub'; default: // Let it fall through } } // Last case let wordpress detect it: if( $use_wp_check_filetype ) { $FileType = wp_check_filetype($file); if( $FileType && isset($FileType['type']) ) return $FileType['type']; } return ''; } function powerpress_itunes_categories($PrefixSubCategories = false) { $temp = array(); $temp['01-00'] = 'Arts'; $temp['01-01'] = 'Design'; $temp['01-02'] = 'Fashion & Beauty'; $temp['01-03'] = 'Food'; $temp['01-04'] = 'Literature'; $temp['01-05'] = 'Performing Arts'; $temp['01-06'] = 'Visual Arts'; $temp['02-00'] = 'Business'; $temp['02-01'] = 'Business News'; $temp['02-02'] = 'Careers'; $temp['02-03'] = 'Investing'; $temp['02-04'] = 'Management & Marketing'; $temp['02-05'] = 'Shopping'; $temp['03-00'] = 'Comedy'; $temp['04-00'] = 'Education'; $temp['04-01'] = 'Education Technology'; $temp['04-02'] = 'Higher Education'; $temp['04-03'] = 'K-12'; $temp['04-04'] = 'Language Courses'; $temp['04-05'] = 'Training'; $temp['05-00'] = 'Games & Hobbies'; $temp['05-01'] = 'Automotive'; $temp['05-02'] = 'Aviation'; $temp['05-03'] = 'Hobbies'; $temp['05-04'] = 'Other Games'; $temp['05-05'] = 'Video Games'; $temp['06-00'] = 'Government & Organizations'; $temp['06-01'] = 'Local'; $temp['06-02'] = 'National'; $temp['06-03'] = 'Non-Profit'; $temp['06-04'] = 'Regional'; $temp['07-00'] = 'Health'; $temp['07-01'] = 'Alternative Health'; $temp['07-02'] = 'Fitness & Nutrition'; $temp['07-03'] = 'Self-Help'; $temp['07-04'] = 'Sexuality'; $temp['08-00'] = 'Kids & Family'; $temp['09-00'] = 'Music'; $temp['10-00'] = 'News & Politics'; $temp['11-00'] = 'Religion & Spirituality'; $temp['11-01'] = 'Buddhism'; $temp['11-02'] = 'Christianity'; $temp['11-03'] = 'Hinduism'; $temp['11-04'] = 'Islam'; $temp['11-05'] = 'Judaism'; $temp['11-06'] = 'Other'; $temp['11-07'] = 'Spirituality'; $temp['12-00'] = 'Science & Medicine'; $temp['12-01'] = 'Medicine'; $temp['12-02'] = 'Natural Sciences'; $temp['12-03'] = 'Social Sciences'; $temp['13-00'] = 'Society & Culture'; $temp['13-01'] = 'History'; $temp['13-02'] = 'Personal Journals'; $temp['13-03'] = 'Philosophy'; $temp['13-04'] = 'Places & Travel'; $temp['14-00'] = 'Sports & Recreation'; $temp['14-01'] = 'Amateur'; $temp['14-02'] = 'College & High School'; $temp['14-03'] = 'Outdoor'; $temp['14-04'] = 'Professional'; $temp['15-00'] = 'Technology'; $temp['15-01'] = 'Gadgets'; $temp['15-02'] = 'Tech News'; $temp['15-03'] = 'Podcasting'; $temp['15-04'] = 'Software How-To'; $temp['16-00'] = 'TV & Film'; if( $PrefixSubCategories ) { foreach( $temp as $key=> $val ) { $parts = explode('-', $key); $cat = $parts[0]; $subcat = $parts[1]; if( $subcat != '00' ) $temp[$key] = $temp[$cat.'-00'].' > '.$val; } reset($temp); } return $temp; } /** * Categories for 2019+ Apple Podcast directory */ function powerpress_apple_categories($PrefixSubCategories = false) { $temp = array(); $temp['01-00'] = 'Arts'; $temp['01-01'] = 'Books'; $temp['01-02'] = 'Design'; $temp['01-03'] = 'Fashion & Beauty'; $temp['01-04'] = 'Food'; $temp['01-05'] = 'Performing Arts'; $temp['01-06'] = 'Visual Arts'; $temp['02-00'] = 'Business'; $temp['02-01'] = 'Careers'; $temp['02-02'] = 'Entrepreneurship'; $temp['02-03'] = 'Investing'; $temp['02-04'] = 'Management'; $temp['02-05'] = 'Marketing'; $temp['02-06'] = 'Non-Profit'; $temp['03-00'] = 'Comedy'; $temp['03-01'] = 'Comedy Interviews'; $temp['03-02'] = 'Improv'; $temp['03-03'] = 'Stand-Up'; $temp['04-00'] = 'Education'; $temp['04-01'] = 'Courses'; $temp['04-02'] = 'How To'; $temp['04-03'] = 'Language Learning'; $temp['04-04'] = 'Self-Improvement'; $temp['05-00'] = 'Fiction'; $temp['05-01'] = 'Comedy Fiction'; $temp['05-02'] = 'Drama'; $temp['05-03'] = 'Science Fiction'; $temp['06-00'] = 'Government'; $temp['07-00'] = 'Health & Fitness'; $temp['07-01'] = 'Alternative Health'; $temp['07-02'] = 'Fitness'; $temp['07-03'] = 'Medicine'; $temp['07-04'] = 'Mental Health'; $temp['07-05'] = 'Nutrition'; $temp['07-06'] = 'Sexuality'; $temp['08-00'] = 'History'; $temp['09-00'] = 'Kids & Family'; $temp['09-01'] = 'Education for Kids'; $temp['09-02'] = 'Parenting'; $temp['09-03'] = 'Pets & Animals'; $temp['09-04'] = 'Stories for Kids'; $temp['10-00'] = 'Leisure'; $temp['10-01'] = 'Animation & Manga'; $temp['10-02'] = 'Automotive'; $temp['10-03'] = 'Aviation'; $temp['10-04'] = 'Crafts'; $temp['10-05'] = 'Games'; $temp['10-06'] = 'Hobbies'; $temp['10-07'] = 'Home & Garden'; $temp['10-08'] = 'Video Games'; $temp['11-00'] = 'Music'; $temp['11-01'] = 'Music Commentary'; $temp['11-02'] = 'Music History'; $temp['11-03'] = 'Music Interviews'; $temp['12-00'] = 'News'; $temp['12-01'] = 'Business News'; $temp['12-02'] = 'Daily News'; $temp['12-03'] = 'Entertainment News'; $temp['12-04'] = 'News Commentary'; $temp['12-05'] = 'Politics'; $temp['12-06'] = 'Sports News'; $temp['12-07'] = 'Tech News'; $temp['13-00'] = 'Religion & Spirituality'; $temp['13-01'] = 'Buddhism'; $temp['13-02'] = 'Christianity'; $temp['13-03'] = 'Hinduism'; $temp['13-04'] = 'Islam'; $temp['13-05'] = 'Judaism'; $temp['13-06'] = 'Religion'; $temp['13-07'] = 'Spirituality'; $temp['14-00'] = 'Science'; $temp['14-01'] = 'Astronomy'; $temp['14-02'] = 'Chemistry'; $temp['14-03'] = 'Earth Sciences'; $temp['14-04'] = 'Life Sciences'; $temp['14-05'] = 'Mathematics'; $temp['14-06'] = 'Natural Sciences'; $temp['14-07'] = 'Nature'; $temp['14-08'] = 'Physics'; $temp['14-09'] = 'Social Sciences'; $temp['15-00'] = 'Society & Culture'; $temp['15-01'] = 'Documentary'; $temp['15-02'] = 'Personal Journals'; $temp['15-03'] = 'Philosophy'; $temp['15-04'] = 'Places & Travel'; $temp['15-06'] = 'Relationships'; $temp['16-00'] = 'Sports'; $temp['16-01'] = 'Baseball'; $temp['16-02'] = 'Basketball'; $temp['16-03'] = 'Cricket'; $temp['16-04'] = 'Fantasy Sports'; $temp['16-05'] = 'Football'; $temp['16-06'] = 'Golf'; $temp['16-07'] = 'Hockey'; $temp['16-08'] = 'Rugby'; $temp['16-09'] = 'Running'; $temp['16-10'] = 'Soccer'; $temp['16-11'] = 'Swimming'; $temp['16-12'] = 'Tennis'; $temp['16-13'] = 'Volleyball'; $temp['16-15'] = 'Wilderness'; $temp['16-16'] = 'Wrestling'; $temp['17-00'] = 'Technology'; $temp['18-00'] = 'True Crime'; $temp['19-00'] = 'TV & Film'; $temp['19-01'] = 'After Shows'; $temp['19-02'] = 'Film History'; $temp['19-03'] = 'Film Interviews'; $temp['19-04'] = 'Film Reviews'; $temp['19-05'] = 'TV Reviews'; if( $PrefixSubCategories ) { foreach( $temp as $key=> $val ) { $parts = explode('-', $key); $cat = $parts[0]; $subcat = $parts[1]; if( $subcat != '00' ) $temp[$key] = $temp[$cat.'-00'].' > '.$val; } reset($temp); } return $temp; } function powerpress_googleplay_categories() { $temp = array(); $temp['01-00'] = 'Arts'; $temp['02-00'] = 'Business'; $temp['03-00'] = 'Comedy'; $temp['04-00'] = 'Education'; $temp['05-00'] = 'Games & Hobbies'; $temp['06-00'] = 'Government & Organizations'; $temp['07-00'] = 'Health'; $temp['08-00'] = 'Kids & Family'; $temp['09-00'] = 'Music'; $temp['10-00'] = 'News & Politics'; $temp['11-00'] = 'Religion & Spirituality'; $temp['12-00'] = 'Science & Medicine'; $temp['13-00'] = 'Society & Culture'; $temp['14-00'] = 'Sports & Recreation'; $temp['15-00'] = 'Technology'; $temp['16-00'] = 'TV & Film'; return $temp; } function powerpress_get_root_url() { /* // OLD CODE: $powerpress_dirname = basename( POWERPRESS_ABSPATH ); return WP_PLUGIN_URL . '/'. $powerpress_dirname .'/'; */ $local_path = __FILE__; if( DIRECTORY_SEPARATOR == '\\' ) { // Win32 fix $local_path = basename(dirname(__FILE__)) .'/'. basename(__FILE__); } $plugin_url = plugins_url('', $local_path); return $plugin_url . '/'; } function powerpress_get_the_exerpt($for_summary = false, $no_filters = false, $post_id = false) { if( $no_filters ) { if( $post_id > 0 ) { $post = get_post($post_id); $subtitle = $post->post_excerpt; if ( $subtitle == '') { $subtitle = $post->post_content; $shortcodesTemp = $GLOBALS['shortcode_tags']; $GLOBALS['shortcode_tags']['skipto'] = 'powerpress_shortcode_skipto'; $subtitle = do_shortcode($subtitle); $GLOBALS['shortcode_tags'] = $shortcodesTemp; $subtitle = strip_shortcodes( $subtitle ); $subtitle = str_replace(']]>', ']]>', $subtitle); $subtitle = strip_tags($subtitle); } } else if( is_object($GLOBALS['post']) ) { $subtitle = $GLOBALS['post']->post_excerpt; if ( $subtitle == '') { $subtitle = $GLOBALS['post']->post_content; $shortcodesTemp = $GLOBALS['shortcode_tags']; $GLOBALS['shortcode_tags']['skipto'] = 'powerpress_shortcode_skipto'; $subtitle = do_shortcode($subtitle); $GLOBALS['shortcode_tags'] = $shortcodesTemp; $subtitle = strip_shortcodes( $subtitle ); $subtitle = str_replace(']]>', ']]>', $subtitle); $subtitle = strip_tags($subtitle); } } } else { $subtitle = get_the_excerpt(); } $subtitle = trim( strip_tags( $subtitle ) ); if( !empty($subtitle) ) return $subtitle; return powerpress_get_the_content( $for_summary, $no_filters ); } function powerpress_get_the_content($for_summary = true, $no_filters = false, $no_strip_tags = false) { if( $no_filters ) { global $post; $content_no_html = $post->post_content; $shortcodesTemp = $GLOBALS['shortcode_tags']; $GLOBALS['shortcode_tags']['skipto'] = 'powerpress_shortcode_skipto'; $content_no_html = do_shortcode($content_no_html); $GLOBALS['shortcode_tags'] = $shortcodesTemp; //$content_no_html = strip_shortcodes( $content_no_html ); $content_no_html = str_replace(']]>', ']]>', $content_no_html); $content_no_html = wp_staticize_emoji( _oembed_filter_feed_content( $content_no_html ) ); } else { $content_no_html = get_the_content(); } $content_no_html = strip_shortcodes( $content_no_html ); if( $no_strip_tags ) return $content_no_html; if( $for_summary ) { return trim( strip_tags($content_no_html, '