<?php
/*
Plugin Name: CompleteRSS
Plugin URI: http://neosmart.net/dl.php?id=2
Description: CompleteRSS makes sure your RSS Feeds contain full article text and are fully valid - because your readers deserve it!
Version: 1.1 BETA
Author: Computer Guru
Author URI: http://neosmart.net/blog/
*/

/*  Copyright 2006  NeoSmart Technologies  (site: http://neosmart.net/)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

function NST_CheckRSS( $old_content )
{
	if ( !is_feed() )
		return $old_content;

	remove_filter( 'the_content', 'NST_CheckRSS', -1 ); //To get rid of infinite loops
	$content = NST_get_the_content();
	$content = apply_filters( 'the_content', $content );
	$content = str_replace(']]>', ']]&gt;', $content);  //Make it valid!
	add_filter( 'the_content', 'NST_CheckRSS', -1, 1 ); //To make it work in the future
	echo $content;
}

function NST_get_the_content()
{
    global $post;
    // Password checking copied from get_the_content()
    if ( !empty( $post->post_password ) )
		if ( stripslashes( $_COOKIE['wp-postpass_'.COOKIEHASH] ) !=  $post->post_password )
			return get_the_password_form();
    return $post->post_content;
}

//Integrate into WP
add_filter( 'the_content', 'NST_CheckRSS', -1, 1 ); //After all other filters have loaded...
add_filter( 'option_rss_use_excerpt', create_function( '$a=0', 'return 1;' ) ); //Set RSS options to summary, not full text.
?>
