PluginProbe
WebberZone Top 10 — Popular Posts / 4.3.2
WebberZone Top 10 — Popular Posts v4.3.2
4.5.1 4.5.0 4.4.3 4.4.2 4.4.1 4.4.0 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 trunk 1.0 1.0.1 1.1 1.2 1.3 1.4 1.4.1 1.5 1.5.1 1.5.2 1.5.3 1.6 1.6.1 All 117 releases
top-10 / includes / frontend / feed-rss2-popular-posts.php

feed-rss2-popular-posts.php in WebberZone Top 10 — Popular Posts 4.3.2, at includes/frontend/feed-rss2-popular-posts.php

146 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * RSS2 Feed Template for displaying RSS2 Posts feed for the Top 10 Popular posts.
4 *
5 * @package TOP_TEN
6 */
7
8 $settings = array(
9 'daily' => $daily,
10 'daily_range' => tptn_get_option( 'feed_daily_range' ),
11 'limit' => tptn_get_option( 'feed_limit' ),
12 );
13
14 /**
15 * Filter the RSS feed settings.
16 *
17 * @since 4.1.0
18 *
19 * @param array $settings Array of RSS feed settings.
20 */
21 $settings = apply_filters( 'tptn_rss_feed_settings', $settings );
22
23 // Initialize Top_Ten_Query with our settings.
24 $query = new Top_Ten_Query( $settings );
25
26 header( 'Content-Type: ' . feed_content_type( 'rss2' ) . '; charset=' . get_option( 'blog_charset' ), true );
27 $more = 1; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
28
29 echo '<?xml version="1.0" encoding="' . esc_attr( get_option( 'blog_charset' ) ) . '"?' . '>';
30
31 /**
32 * Fires between the xml and rss tags in a feed.
33 *
34 * @since 4.0.0
35 *
36 * @param string $context Type of feed. Possible values include 'rss2', 'rss2-comments',
37 * 'rdf', 'atom', and 'atom-comments'.
38 */
39 do_action( 'rss_tag_pre', 'rss2' );
40 ?>
41 <rss version="2.0"
42 xmlns:content="http://purl.org/rss/1.0/modules/content/"
43 xmlns:wfw="http://wellformedweb.org/CommentAPI/"
44 xmlns:dc="http://purl.org/dc/elements/1.1/"
45 xmlns:atom="http://www.w3.org/2005/Atom"
46 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
47 xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
48 <?php
49 /**
50 * Fires at the end of the RSS root to add namespaces.
51 *
52 * @since 2.0.0
53 */
54 do_action( 'rss2_ns' );
55 ?>
56 >
57
58 <channel>
59 <title><?php wp_title_rss(); ?> <?php esc_html_e( 'Popular Posts', 'top-10' ); ?> - <?php echo esc_html( $settings['daily'] ? sprintf( _n( 'Last %d day', 'Last %d days', $settings['daily_range'], 'top-10' ), $settings['daily_range'] ) : __( 'Overall', 'top-10' ) ); // phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment ?></title>
60 <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
61 <link><?php bloginfo_rss( 'url' ); ?></link>
62 <description><?php bloginfo_rss( 'description' ); ?></description>
63 <lastBuildDate><?php echo get_feed_build_date( 'r' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></lastBuildDate>
64 <language><?php bloginfo_rss( 'language' ); ?></language>
65 <sy:updatePeriod>
66 <?php
67 $duration = 'hourly';
68
69 /**
70 * Filters how often to update the RSS feed.
71 *
72 * @since 2.1.0
73 *
74 * @param string $duration The update period. Accepts 'hourly', 'daily', 'weekly', 'monthly',
75 * 'yearly'. Default 'hourly'.
76 */
77 echo apply_filters( 'rss_update_period', $duration ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
78 ?>
79 </sy:updatePeriod>
80 <sy:updateFrequency>
81 <?php
82 $frequency = '1';
83
84 /**
85 * Filters the RSS update frequency.
86 *
87 * @since 2.1.0
88 *
89 * @param string $frequency An integer passed as a string representing the frequency
90 * of RSS updates within the update period. Default '1'.
91 */
92 echo apply_filters( 'rss_update_frequency', $frequency ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
93 ?>
94 </sy:updateFrequency>
95 <?php
96 /**
97 * Fires at the end of the RSS2 Feed Header.
98 *
99 * @since 2.0.0
100 */
101 do_action( 'rss2_head' );
102
103 while ( $query->have_posts() ) :
104 $query->the_post();
105 ?>
106 <item>
107 <title><?php the_title_rss(); ?></title>
108 <link><?php the_permalink_rss(); ?></link>
109 <?php if ( get_comments_number() || comments_open() ) : ?>
110 <comments><?php comments_link_feed(); ?></comments>
111 <?php endif; ?>
112 <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></pubDate>
113 <dc:creator><![CDATA[<?php the_author(); ?>]]></dc:creator>
114 <?php the_category_rss( 'rss2' ); ?>
115
116 <guid isPermaLink="false"><?php the_guid(); ?></guid>
117 <?php if ( get_option( 'rss_use_excerpt' ) ) : ?>
118 <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
119 <?php else : ?>
120 <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
121 <?php $content = get_the_content_feed( 'rss2' ); ?>
122 <?php if ( strlen( $content ) > 0 ) : ?>
123 <content:encoded><![CDATA[<?php echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>]]></content:encoded>
124 <?php else : ?>
125 <content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded>
126 <?php endif; ?>
127 <?php endif; ?>
128 <?php if ( get_comments_number() || comments_open() ) : ?>
129 <wfw:commentRss><?php echo esc_url( get_post_comments_feed_link( get_the_ID(), 'rss2' ) ); ?></wfw:commentRss>
130 <slash:comments><?php echo get_comments_number(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></slash:comments>
131 <?php endif; ?>
132 <?php rss_enclosure(); ?>
133 <?php
134 /**
135 * Fires at the end of each RSS2 feed item.
136 *
137 * @since 2.0.0
138 */
139 do_action( 'rss2_item' );
140 ?>
141 </item>
142 <?php endwhile; ?>
143 <?php wp_reset_postdata(); ?>
144 </channel>
145 </rss>
146