This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfeed-podcast.php
158 lines (145 loc) · 5.37 KB
/
feed-podcast.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
/**
* RSS2 Podcast Feed Template for displaying RSS2 Podcast Posts feed.
*
* @package WordPress
*/
function powerpress_get_the_excerpt_rss()
{
global $post;
if ( post_password_required() ) {
return __( 'There is no excerpt because this is a protected post.' );
}
$output = strip_tags($post->post_excerpt);
if ( $output == '') {
$output = strip_shortcodes( $post->post_content );
$output = str_replace(']]>', ']]>', $output);
$output = strip_tags($output);
}
return apply_filters('the_excerpt_rss', $output);
}
$FeaturedPodcastID = 0;
$iTunesFeatured = get_option('powerpress_itunes_featured');
$feed_slug = get_query_var('feed');
if( !empty($iTunesFeatured[ $feed_slug ]) )
{
$FeaturedPodcastID = $iTunesFeatured[ $feed_slug ];
$GLOBALS['powerpress_feed']['itunes_feature'] = true; // So any custom order value is not used when looping through the feeds.
}
$iTunesOrderNumber = 2; // One reserved for featured episode
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
$more = 1;
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
<?php do_action('rss2_ns'); ?>
>
<channel>
<title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
<link><?php bloginfo_rss('url') ?></link>
<description><?php bloginfo_rss("description") ?></description>
<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
<language><?php bloginfo_rss( 'language' ); ?></language>
<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
<?php do_action('rss2_head'); ?>
<?php
$ItemCount = 0;
?>
<?php while( have_posts()) : the_post(); ?>
<item>
<title><?php the_title_rss() ?></title>
<link><?php the_permalink_rss() ?></link>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
<guid isPermaLink="false"><?php the_guid(); ?></guid>
<?php
if( empty($GLOBALS['powerpress_feed']['feed_maximizer_on']) ) // If feed maximizer off
{
?>
<comments><?php comments_link_feed(); ?></comments>
<dc:creator><?php the_author() ?></dc:creator>
<?php the_category_rss('rss2') ?>
<?php if (get_option('rss_use_excerpt')) : ?>
<description><?php echo powerpress_format_itunes_value( powerpress_get_the_excerpt_rss(), 'description' ); ?></description>
<?php else : ?>
<description><?php echo powerpress_format_itunes_value( powerpress_get_the_excerpt_rss(), 'description' ); ?></description>
<?php if ( strlen( $post->post_content ) > 0 ) : ?>
<content:encoded><![CDATA[<?php the_content_feed('rss2') ?>]]></content:encoded>
<?php else : ?>
<content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
<?php endif; ?>
<?php endif; ?>
<wfw:commentRss><?php echo esc_url( get_post_comments_feed_link(null, 'rss2') ); ?></wfw:commentRss>
<slash:comments><?php echo get_comments_number(); ?></slash:comments>
<?php
}
else // If feed maximizer on
{ // itunes does not like CDATA, so we're changing it to the other method...
?>
<description><?php echo powerpress_format_itunes_value( powerpress_get_the_excerpt_rss(), 'description' ); ?></description>
<?php
}
?>
<?php rss_enclosure(); ?>
<?php do_action('rss2_item'); ?>
<?php
if( !empty($iTunesFeatured[ $feed_slug ]) )
{
echo "\t<itunes:order>";
if( $FeaturedPodcastID == get_the_ID() )
{
echo 1;
$FeaturedPodcastID = 0;
}
else
{
echo $iTunesOrderNumber;
$iTunesOrderNumber++;
}
echo "</itunes:order>\n";
}
// Decide based on count if we want to flip on the feed maximizer...
$ItemCount++;
if( empty($GLOBALS['powerpress_feed']['feed_maximizer_on']) && $ItemCount >= 10 && !empty($GLOBALS['powerpress_feed']['maximize_feed']) )
{
$GLOBALS['powerpress_feed']['feed_maximizer_on'] = true; // All future items will be minimized in order to maximize episode count
}
?>
</item>
<?php endwhile; ?>
<?php
if( !empty($FeaturedPodcastID) )
{
query_posts( array('p'=>$FeaturedPodcastID) );
if( have_posts())
{
the_post();
// Featured podcast epiosde, give it the highest itunes:order value...
?>
<item>
<title><?php the_title_rss() ?></title>
<link><?php the_permalink_rss() ?></link>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
<guid isPermaLink="false"><?php the_guid(); ?></guid>
<description><?php echo powerpress_format_itunes_value( powerpress_get_the_excerpt_rss(), 'description' ); ?></description>
<?php rss_enclosure(); ?>
<?php do_action('rss2_item'); ?>
<?php
echo "\t<itunes:order>";
echo 1;
echo "</itunes:order>\n";
?>
</item>
<?php
}
wp_reset_query();
}
?>
</channel>
</rss>