Untitled

 avatar
unknown
plain_text
a year ago
4.2 kB
12
Indexable
<?php
/**
 * The plugin bootstrap file
 *
 * This file is read by WordPress to generate the plugin information in the plugin
 * admin area. This file also includes all of the dependencies used by the plugin,
 * registers the activation and deactivation functions, and defines a function
 * that starts the plugin.
 *
 * @link              https://larasantaella.es
 * @since             1.0.0
 * @package           Flipboard Feed
 *
 * @wordpress-plugin
 * Plugin Name:       Flipboard Feed
 * Plugin URI:        https://www.larasantaella.es
 * Description:       Add a custom Full-Text RSS Feed
 * Version:           1.0.0
 * Author:            Lara Santaella
 * Author URI:        https://larasantaella.es
 * License:           GPL-2.0+
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
 * Text Domain:       flipboard-feed
 * Domain Path:       /languages
 */
add_action('init', 'customRSS2');
function customRSS2(){
        add_feed('fulltextflip', 'customRSSFlipboard');
}
function customRSSFlipboard(){
$posts = query_posts(array( 
        'posts_per_page' => 30,
        'date_query'    => array(
                'column' => 'post_date_gmt',
                'after' => '1 year ago',
				'cat' => '-25685'
            )
        ) );
header('Content-Type: '.feed_content_type('rss-http').'; charset='.get_option('blog_charset'), true);
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
global $post;
?>
<rss version="2.0"
        xmlns:content="http://purl.org/rss/1.0/modules/content/"
        xmlns:media="http://search.yahoo.com/mrss/"
        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'); ?> - Fulltext Feed</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>en-US</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 while(have_posts()) : the_post(); 
                          $imageCaption = get_post( get_post_thumbnail_id() )->post_excerpt;
                          $unfiltered_content = str_replace( '<!--more-->', '', $post->post_content );
                          $image = get_the_post_thumbnail_url(get_the_id(), 'full');
                          $imagesize = get_headers(get_the_post_thumbnail_url(get_the_id(), 'full'));
                                // If you need filtered content returned
                                $filtered_content = apply_filters( 'the_content', $unfiltered_content );
                ?>
                <item>
                        <title><?php the_title_rss(); ?></title>
                        <link><?php the_permalink_rss(); ?></link>
                        <guid isPermaLink="false"><?php the_guid(); ?></guid>
                        <pubDate><?php echo mysql2date('D, d M Y H:i:s', get_post_time('Y-m-d H:i:s', true), false) . ' GMT'; ?></pubDate>
                        <dc:creator><?php the_author(); ?></dc:creator>
                        <description><![CDATA[<?php echo $filtered_content; ?>]]></description>
                        <?php if(get_the_post_thumbnail_url(get_the_id(), 'full')){ ?>
                                <enclosure url="<?php echo $image; ?>" length="<?php echo $imagesize["Content-Length"] ?>" type="image/jpeg" />
                        <?php } ?>
                        <?php rss_enclosure(); ?>
                        <?php do_action('rss2_item'); ?>
                </item>
        <?php endwhile; ?>
</channel>
</rss>
<?php } ?>
Editor is loading...