/** * Display feed items on the front end (via shortcode or function) * * @since 2.0 */ function wprss_display_feed_items($args = array()) { $settings = get_option('wprss_settings_general'); $display_settings = wprss_get_display_settings($settings); $args = wprss_get_shortcode_default_args($args); $args = apply_filters('wprss_shortcode_args', $args); $query_args = $settings; if (isset($args['limit'])) { $query_args['feed_limit'] = filter_var($args['limit'], FILTER_VALIDATE_INT, array('options' => array('min_range' => 1, 'default' => $query_args['feed_limit']))); } if (isset($args['pagination'])) { $query_args['pagination'] = $args['pagination']; } if (isset($args['source'])) { $query_args['source'] = $args['source']; } elseif (isset($args['exclude'])) { $query_args['exclude'] = $args['exclude']; } $query_args = apply_filters('wprss_process_shortcode_args', $query_args, $args); $feed_items = wprss_get_feed_items_query($query_args); do_action('wprss_display_template', $display_settings, $args, $feed_items); }
/** * Generate the feed * * @since 3.3 */ function wprss_addfeed_do_feed($in) { // Prepare the post query /* $wprss_custom_feed_query = apply_filters( 'wprss_custom_feed_query', array( 'post_type' => 'wprss_feed_item', 'post_status' => 'publish', 'cache_results' => false, // disable caching ) );*/ $wprss_custom_feed_query = wprss_get_feed_items_query(apply_filters('wprss_custom_feed_query', array('get-args' => TRUE, 'no-paged' => TRUE, 'feed_limit' => 0))); // Suppress caching $wprss_custom_feed_query['cache_results'] = FALSE; // Get options $options = get_option('wprss_settings_general'); if ($options !== FALSE) { // If options exist, get the limit $limit = $options['custom_feed_limit']; if ($limit !== FALSE) { // if limit exists, set the query limit $wprss_custom_feed_query['posts_per_page'] = $limit; } } // Submit the query to get latest feed items query_posts($wprss_custom_feed_query); $custom_feed_title = wprss_get_general_setting('custom_feed_title'); $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; header("{$protocol} 200 OK"); // Send content header and start ATOM output header('Content-Type: application/rss+xml'); // Disabling caching header('Cache-Control: no-cache, no-store, must-revalidate'); // HTTP 1.1. header('Pragma: no-cache'); // HTTP 1.0. header('Expires: 0'); // Proxies. 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/" xmlns:media="http://search.yahoo.com/mrss/" > <channel> <title><?php echo $custom_feed_title; ?> </title> <description></description> <link><?php echo get_site_url(); ?> </link> <atom:link href="<?php echo $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; ?> " rel="self" type="application/rss+xml" /> <?php // Start the Loop while (have_posts()) { the_post(); $source = get_post_meta(get_the_ID(), 'wprss_feed_id', TRUE); $permalink = get_post_meta(get_the_ID(), 'wprss_item_permalink', true); ?> <item> <title><![CDATA[<?php the_title_rss(); ?> ]]></title> <link><?php echo $permalink; ?> </link> <guid isPermaLink="true"><?php echo $permalink; ?> </guid> <pubDate><?php echo get_post_time(DATE_RSS); ?> </pubDate> <description><![CDATA[<?php the_content(); ?> ]]></description> <content:encoded><![CDATA[<?php the_content(); ?> ]]></content:encoded> <source url="<?php echo get_post_meta($source, 'wprss_url', TRUE); ?> "><?php echo get_the_title($source); ?> </source> <?php do_action('wprss_custom_feed_entry', get_the_ID()); ?> </item> <?php } // END OF LOOP ?> </channel> </rss> <?php }
/** * Generate the feed * * @since 3.3 */ function wprss_addfeed_do_feed($in) { // Prepare the post query /* $wprss_custom_feed_query = apply_filters( 'wprss_custom_feed_query', array( 'post_type' => 'wprss_feed_item', 'post_status' => 'publish', 'cache_results' => false, // disable caching ) );*/ $wprss_custom_feed_query = wprss_get_feed_items_query(apply_filters('wprss_custom_feed_query', array('get-args' => TRUE, 'no-paged' => TRUE, 'feed_limit' => 0))); // Suppress caching $wprss_custom_feed_query['cache_results'] = FALSE; // Get options $options = get_option('wprss_settings_general'); if ($options !== FALSE) { // If options exist, get the limit $limit = $options['custom_feed_limit']; if ($limit !== FALSE) { // if limit exists, set the query limit $wprss_custom_feed_query['posts_per_page'] = $limit; } } // Submit the query to get latest feed items query_posts($wprss_custom_feed_query); $custom_feed_title = wprss_get_general_setting('custom_feed_title'); // Send content header and start ATOM output header('Content-Type: text/xml'); // Disabling caching header('Cache-Control: no-cache, no-store, must-revalidate'); // HTTP 1.1. header('Pragma: no-cache'); // HTTP 1.0. header('Expires: 0'); // Proxies. echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>'; ?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" > <title type="text"><?php echo $custom_feed_title; ?> </title> <?php // Start the Loop while (have_posts()) { the_post(); $permalink = get_post_meta(get_the_ID(), 'wprss_item_permalink', true); ?> <entry> <title><![CDATA[<?php the_title_rss(); ?> ]]></title> <link href="<?php echo $permalink; ?> " /> <?php // Enable below to link to post on our site rather than original source ?> <!--<link href="<?php the_permalink_rss(); ?> " />--> <published><?php echo get_post_time('Y-m-d\\TH:i:s\\Z'); ?> </published> <content type="html"><![CDATA[<?php the_content(); ?> ]]></content> <?php do_action('wprss_custom_feed_entry', get_the_ID()); ?> </entry> <?php // End of the Loop } ?> </feed> <?php }