PluginProbe
WebberZone Top 10 — Popular Posts / 4.3.4
WebberZone Top 10 — Popular Posts v4.3.4
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 / class-feed.php

class-feed.php in WebberZone Top 10 — Popular Posts 4.3.4, at includes/frontend/class-feed.php

96 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Feed class.
4 *
5 * @package WebberZone\Top_Ten\Frontend
6 */
7
8 namespace WebberZone\Top_Ten\Frontend;
9
10 use WebberZone\Top_Ten\Util\Hook_Registry;
11
12 if ( ! defined( 'WPINC' ) ) {
13 die;
14 }
15
16 /**
17 * Admin Columns Class.
18 *
19 * @since 3.3.0
20 */
21 class Feed {
22
23 /**
24 * Constructor class.
25 *
26 * @since 3.3.0
27 */
28 public function __construct() {
29 Hook_Registry::add_action( 'init', array( $this, 'pop_posts_feed' ) );
30 }
31
32 /**
33 * Add custom feeds for the overall and daily popular posts.
34 *
35 * @since 2.8.0
36 *
37 * @return void
38 */
39 public function pop_posts_feed() {
40
41 $popular_posts_overall = \tptn_get_option( 'feed_permalink_overall' );
42 $popular_posts_daily = \tptn_get_option( 'feed_permalink_daily' );
43
44 if ( ! empty( $popular_posts_overall ) ) {
45 add_feed( $popular_posts_overall, array( $this, 'pop_posts_feed_overall' ) );
46 }
47 if ( ! empty( $popular_posts_daily ) ) {
48 add_feed( $popular_posts_daily, array( $this, 'pop_posts_feed_daily' ) );
49 }
50 }
51
52 /**
53 * Callback for overall popular posts.
54 *
55 * @since 2.8.0
56 *
57 * @return void
58 */
59 public function pop_posts_feed_overall() {
60 $this->pop_posts_feed_callback( false );
61 }
62
63 /**
64 * Callback for daily popular posts.
65 *
66 * @since 2.8.0
67 *
68 * @return void
69 */
70 public function pop_posts_feed_daily() {
71 $this->pop_posts_feed_callback( true );
72 }
73
74 /**
75 * Callback function for add_feed to locate the correct template.
76 *
77 * @since 2.8.0
78 *
79 * @param bool $daily Daily posts flag.
80 *
81 * @return void
82 */
83 public function pop_posts_feed_callback( $daily = false ) {
84
85 set_query_var( 'daily', $daily );
86
87 $template = locate_template( 'feed-rss2-popular-posts.php' );
88
89 if ( ! $template ) {
90 $template = TOP_TEN_PLUGIN_DIR . 'includes/frontend/feed-rss2-popular-posts.php';
91 }
92
93 load_template( $template );
94 }
95 }
96