PluginProbe
PowerPress Podcasting plugin by Blubrry / trunk
PowerPress Podcasting plugin by Blubrry vtrunk
11.17.9 11.17.8 11.17.7 11.17.6 11.17.4 11.17.3 11.17.2 11.17.1 11.17 11.16.11 11.16.10 11.16.9 11.16.8 11.16.7 11.16.6 11.16.5 11.16.4 11.16.3 11.16.2 11.16.1 11.9.13 11.9.14 11.9.15 11.9.16 11.9.17 All 383 releases
powerpress / feed-podcast.php

feed-podcast.php in PowerPress Podcasting plugin by Blubrry trunk, at feed-podcast.php

233 lines 9.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * RSS2 Podcast Feed Template for displaying RSS2 Podcast Posts feed.
4 *
5 * @package WordPress
6 */
7
8 function powerpress_get_the_content_feed($feed_type, $no_filters = false)
9 {
10 if( $no_filters == false )
11 return get_the_content_feed($feed_type);
12
13 if ( post_password_required() ) {
14 return __( 'There is no content because this is a protected post.' );
15 }
16
17 global $post, $powerpress_feed;
18 $content = $post->post_content;
19 if( function_exists('do_blocks') )
20 $content = do_blocks($content);
21 if( empty($powerpress_feed['disable_wptexturize']) ) // disable smart typography
22 $content = wptexturize($content);
23 $content = wpautop($content);
24 $content = shortcode_unautop($content);
25 $content = prepend_attachment($content);
26 if( function_exists('wp_filter_content_tags') )
27 $content = wp_filter_content_tags($content);
28
29 $shortcodesTemp = $GLOBALS['shortcode_tags'];
30 $GLOBALS['shortcode_tags']['skipto'] = 'powerpress_shortcode_skipto';
31 $content = do_shortcode($content);
32 $GLOBALS['shortcode_tags'] = $shortcodesTemp;
33
34 $content = capital_P_dangit($content);
35
36 $content = convert_smilies($content);
37
38 $content = strip_shortcodes( $content );
39 $content = str_replace(']]>', ']]&gt;', $content);
40
41 // convert named HTML entities to numeric for XML compatibility (e.g. &copy; → &#169;)
42 $content = convert_chars( ent2ncr( $content ) );
43
44 if( function_exists('_oembed_filter_feed_content') ) // WP 4.4+
45 return ( _oembed_filter_feed_content( $content ) );
46
47 if( function_exists('wp_encode_emoji') ) // WP 4.2+
48 return wp_encode_emoji( $content );
49
50 return $content;
51 }
52
53
54 function powerpress_get_the_excerpt_rss($no_filters = true)
55 {
56 if( $no_filters == false ) {
57 $output = get_the_excerpt();
58 return apply_filters( 'the_excerpt_rss', $output );
59 }
60
61 global $post;
62
63 if ( post_password_required() ) {
64 return __( 'There is no excerpt because this is a protected post.' );
65 }
66 $output = strip_tags($post->post_excerpt);
67 if ( $output == '') {
68 $output = $post->post_content;
69 $shortcodesTemp = $GLOBALS['shortcode_tags'];
70 $GLOBALS['shortcode_tags']['skipto'] = 'powerpress_shortcode_skipto';
71 $output = do_shortcode($output);
72 $GLOBALS['shortcode_tags'] = $shortcodesTemp;
73 $output = strip_shortcodes( $output );
74 $output = str_replace(']]>', ']]&gt;', $output);
75 $output = strip_tags($output);
76 }
77
78 return convert_chars( ent2ncr( $output ) );
79 }
80
81 $GeneralSettings = get_option('powerpress_general');
82
83 if (is_feed() && !headers_sent()) {
84 // Add the Access-Control-Allow-Origin header to allow all origins.
85 header("Access-Control-Allow-Origin: *");
86 }
87 header('Content-Type: application/rss+xml; charset=' . get_option('blog_charset'), true);
88 $more = 1;
89
90
91 $FeedActionHook = '';
92 if( !empty($GeneralSettings['feed_action_hook']) )
93 $FeedActionHook = '_powerpress';
94
95 echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'."\n"; ?>
96 <rss version="2.0"
97 xmlns:content="http://purl.org/rss/1.0/modules/content/"
98 xmlns:wfw="http://wellformedweb.org/CommentAPI/"
99 xmlns:dc="http://purl.org/dc/elements/1.1/"
100 xmlns:atom="http://www.w3.org/2005/Atom"
101 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
102 xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
103 <?php do_action('rss2_ns'.$FeedActionHook); ?>
104 >
105 <channel>
106 <title><?php if( version_compare($GLOBALS['wp_version'], '4.4', '<' ) ) { bloginfo_rss('name'); } wp_title_rss(); ?></title>
107 <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
108 <link><?php bloginfo_rss('url') ?></link>
109 <description><?php bloginfo_rss("description") ?></description>
110 <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
111 <language><?php bloginfo_rss( 'language' ); ?></language>
112 <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
113 <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
114 <?php if( !empty($FeedActionHook) ) { echo '<generator>Blubrry PowerPress/' . POWERPRESS_VERSION . '</generator>'. PHP_EOL; } ?>
115 <?php do_action('rss2_head'.$FeedActionHook); ?>
116 <?php
117
118 $ItemCount = 0;
119 $trailerCount = 0;
120
121 while( have_posts()) :
122 the_post();
123 $EpisodeData = powerpress_get_enclosure_data(get_the_ID());
124
125 $trailerAttrs = false;
126 if( !empty($EpisodeData['episode_type']) && $EpisodeData['episode_type']=='trailer') {
127 $trailerAttrs = array(
128 'url' => trim(esc_url($EpisodeData['url'])),
129 'length' => ((int) ($EpisodeData['size'] ?? 0)) ?: 5242880, // take 5242880 if invalid
130 'type' => esc_attr(trim($EpisodeData['type'])),
131 'title' => esc_html(powerpress_trim_value($EpisodeData['episode_title'] ?? get_the_title(), 'trailer')),
132 'pubdate' => mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false),
133 );
134
135 if ( !empty($EpisodeData['season']) )
136 $trailerAttrs['season'] = esc_attr($EpisodeData['season']);
137 }
138
139 if ($trailerAttrs) {
140 $trailerCount += 1;
141
142 $season_attr = isset($trailerAttrs['season']) ? " season=\"{$trailerAttrs['season']}\"" : '';
143 ?>
144 <podcast:trailer url="<?php echo $trailerAttrs['url']; ?>" pubdate="<?php echo $trailerAttrs['pubdate']; ?>" length="<?php echo $trailerAttrs['length']; ?>" type="<?php echo $trailerAttrs['type']; ?>"<?php echo $season_attr; ?>><?php echo $trailerAttrs['title']; ?></podcast:trailer>
145 <?php
146 }
147
148 if ($trailerCount > 0)
149 break;
150 endwhile;
151
152 rewind_posts();
153
154 while( have_posts()) :
155 //if( empty($GeneralSettings['feed_accel']) )
156 the_post();
157 //else
158 // $GLOBALS['post'] = $GLOBALS['wp_query']->next_post(); // Use this rather than the_post() that way we do not add additional queries to the database
159
160 $EpisodeData = powerpress_get_enclosure_data(get_the_ID());
161 ?>
162 <item>
163 <title><?php the_title_rss(); ?></title>
164 <link><?php the_permalink_rss(); ?></link>
165 <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
166 <guid isPermaLink="false"><?php the_guid(); ?></guid>
167 <?php
168 // If feed maximizer off
169 if (empty($GLOBALS['powerpress_feed']['feed_maximizer_on'])) {
170 if (empty($GeneralSettings['feed_accel'])) {
171 // feed comments
172 echo "\t\t<comments>"; comments_link_feed(); echo "</comments>\n";
173 echo "\t\t<wfw:commentRss>" . esc_url(get_post_comments_feed_link(null, 'rss2')) . "</wfw:commentRss>\n";
174 echo "\t\t<slash:comments>" . get_comments_number() . "</slash:comments>\n";
175 // category
176 the_category_rss('rss2');
177 }
178
179 // show_notes override: use if available, fall back to legacy summary, then excerpt/content
180 if ( !empty($EpisodeData['show_notes']) ) {
181 echo "\t\t<description>" . powerpress_format_itunes_value(wpautop($EpisodeData['show_notes']), 'description') . "</description>\n";
182 } else if ( !empty($EpisodeData['summary']) ) {
183 // legacy itunes:summary data - preserve for existing episodes
184 echo "\t\t<description>" . powerpress_format_itunes_value($EpisodeData['summary'], 'description') . "</description>\n";
185 } else if (get_option('rss_use_excerpt')) {
186 echo "\t\t<description>" . powerpress_format_itunes_value(powerpress_get_the_excerpt_rss(!empty($GeneralSettings['feed_action_hook'])), 'description') . "</description>\n";
187 } else {
188 $content = powerpress_get_the_content_feed('rss2', !empty($GeneralSettings['feed_action_hook']));
189 if (strlen($content) > 0) {
190 echo "\t\t<description><![CDATA[" . rtrim($content) . "]]></description>\n";
191 } else {
192 echo "\t\t<description><![CDATA[" . rtrim(powerpress_get_the_excerpt_rss(!empty($GeneralSettings['feed_action_hook']))) . "]]></description>\n";
193 }
194 }
195 }
196 // If feed maximizer on
197 else {
198 // show_notes override: use if available, fall back to legacy summary, then excerpt
199 if ( !empty($EpisodeData['show_notes']) ) {
200 echo "\t\t<description>" . powerpress_format_itunes_value(wpautop($EpisodeData['show_notes']), 'description') . "</description>\n";
201 } else if ( !empty($EpisodeData['summary']) ) {
202 // legacy itunes:summary data - preserve for existing episodes
203 echo "\t\t<description>" . powerpress_format_itunes_value($EpisodeData['summary'], 'description') . "</description>\n";
204 } else {
205 echo "\t\t<description>" . powerpress_format_itunes_value(powerpress_get_the_excerpt_rss(!empty($GeneralSettings['feed_action_hook'])), 'description') . "</description>\n";
206 }
207 }
208 rss_enclosure();
209 apply_filters('rss2_item'.$FeedActionHook, '');
210
211 $ItemCount++;
212
213 if( empty($GLOBALS['powerpress_feed']['feed_maximizer_on']) && $ItemCount >= 10 && !empty($GLOBALS['powerpress_feed']['maximize_feed']) )
214 $GLOBALS['powerpress_feed']['feed_maximizer_on'] = true;
215 ?>
216 </item>
217 <?php
218 endwhile;
219 ?>
220 </channel>
221 </rss>
222 <?php
223
224 if( defined('POWERPRESS_DEBUG_QUERIES') ) {
225 if( !empty($wpdb->queries) ) {
226 echo "<!--\n";
227 echo "SQL Queries for this feed:\n";
228 print_r($wpdb->queries);
229 echo "\n-->";
230 }
231 }
232 ?>
233 <?php exit; // exit feed to prevent possible notices ?>