Deprecates the_content_rss(). Add the_content_feed() and get_the_content_feed(). Convert places that called the_content_rss() with an excerpt length to the_excerpt_rss(). Remove the rss_excerpt_length option. Use the_content_feed() where the_content() was previously used in feeds. Props Viper007Bond.

git-svn-id: http://svn.automattic.com/wordpress/trunk@11980 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2009-09-28 14:36:48 +00:00
parent 7a86ba7cf9
commit 5224680c4d
7 changed files with 96 additions and 63 deletions

View File

@ -209,7 +209,6 @@ function populate_options() {
'require_name_email' => 1,
'comments_notify' => 1,
'posts_per_rss' => 10,
'rss_excerpt_length' => 50,
'rss_use_excerpt' => 0,
'mailserver_url' => 'mail.example.com',
'mailserver_login' => 'login@example.com',
@ -348,7 +347,7 @@ function populate_options() {
// Delete unused options
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins', 'can_compress_scripts',
'page_uris', 'rewrite_rules', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed');
'page_uris', 'rewrite_rules', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed', 'rss_excerpt_length');
foreach ($unusedoptions as $option)
delete_option($option);
}

View File

@ -1690,4 +1690,70 @@ function the_author_ID() {
the_author_meta('ID');
}
/**
* Display the post content for the feed.
*
* For encoding the html or the $encode_html parameter, there are three possible
* values. '0' will make urls footnotes and use make_url_footnote(). '1' will
* encode special characters and automatically display all of the content. The
* value of '2' will strip all HTML tags from the content.
*
* Also note that you cannot set the amount of words and not set the html
* encoding. If that is the case, then the html encoding will default to 2,
* which will strip all HTML tags.
*
* To restrict the amount of words of the content, you can use the cut
* parameter. If the content is less than the amount, then there won't be any
* dots added to the end. If there is content left over, then dots will be added
* and the rest of the content will be removed.
*
* @package WordPress
* @subpackage Feed
* @since 0.71
* @uses apply_filters() Calls 'the_content_rss' on the content before processing.
* @see get_the_content() For the $more_link_text, $stripteaser, and $more_file
* parameters.
*
* @deprecated 2.9.0
*
* @param string $more_link_text Optional. Text to display when more content is available but not displayed.
* @param int|bool $stripteaser Optional. Default is 0.
* @param string $more_file Optional.
* @param int $cut Optional. Amount of words to keep for the content.
* @param int $encode_html Optional. How to encode the content.
*/
function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
_deprecated_function(__FUNCTION__, '2.9', 'the_content_feed' );
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content_rss', $content);
if ( $cut && !$encode_html )
$encode_html = 2;
if ( 1== $encode_html ) {
$content = esc_html($content);
$cut = 0;
} elseif ( 0 == $encode_html ) {
$content = make_url_footnote($content);
} elseif ( 2 == $encode_html ) {
$content = strip_tags($content);
}
if ( $cut ) {
$blah = explode(' ', $content);
if ( count($blah) > $cut ) {
$k = $cut;
$use_dotdotdot = 1;
} else {
$k = count($blah);
$use_dotdotdot = 0;
}
/** @todo Check performance, might be faster to use array slice instead. */
for ( $i=0; $i<$k; $i++ )
$excerpt .= $blah[$i].' ';
$excerpt .= ($use_dotdotdot) ? '...' : '';
$content = $excerpt;
}
$content = str_replace(']]>', ']]&gt;', $content);
echo $content;
}
?>

View File

@ -43,7 +43,7 @@ echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<?php the_category_rss('atom') ?>
<summary type="<?php html_type_rss(); ?>"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>
<?php if ( !get_option('rss_use_excerpt') ) : ?>
<content type="<?php html_type_rss(); ?>" xml:base="<?php the_permalink_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content>
<content type="<?php html_type_rss(); ?>" xml:base="<?php the_permalink_rss() ?>"><![CDATA[<?php the_content_feed('atom') ?>]]></content>
<?php endif; ?>
<?php atom_enclosure(); ?>
<?php do_action('atom_entry'); ?>

View File

@ -46,8 +46,8 @@ echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<?php if (get_option('rss_use_excerpt')) : ?>
<description><?php the_excerpt_rss() ?></description>
<?php else : ?>
<description><?php the_content_rss('', 0, '', get_option('rss_excerpt_length'), 2) ?></description>
<content:encoded><![CDATA[<?php the_content('', 0, '') ?>]]></content:encoded>
<description><?php the_excerpt_rss() ?></description>
<content:encoded><![CDATA[<?php the_content_feed('rdf') ?>]]></content:encoded>
<?php endif; ?>
<?php do_action('rdf_item'); ?>
</item>

View File

@ -23,11 +23,7 @@ echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<?php while (have_posts()) : the_post(); ?>
<item>
<title><?php the_title_rss() ?></title>
<?php if (get_option('rss_use_excerpt')) { ?>
<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<?php } else { // use content ?>
<description><?php the_content_rss('', 0, '', get_option('rss_excerpt_length')) ?></description>
<?php } ?>
<link><?php the_permalink_rss() ?></link>
<?php do_action('rss_item'); ?>
</item>

View File

@ -46,7 +46,7 @@ echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<?php else : ?>
<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<?php if ( strlen( $post->post_content ) > 0 ) : ?>
<content:encoded><![CDATA[<?php the_content() ?>]]></content:encoded>
<content:encoded><![CDATA[<?php the_content_feed('rss2') ?>]]></content:encoded>
<?php else : ?>
<content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
<?php endif; ?>

View File

@ -130,66 +130,38 @@ function the_title_rss() {
}
/**
* Display the post content for the feed.
*
* For encoding the html or the $encode_html parameter, there are three possible
* values. '0' will make urls footnotes and use make_url_footnote(). '1' will
* encode special characters and automatically display all of the content. The
* value of '2' will strip all HTML tags from the content.
*
* Also note that you cannot set the amount of words and not set the html
* encoding. If that is the case, then the html encoding will default to 2,
* which will strip all HTML tags.
*
* To restrict the amount of words of the content, you can use the cut
* parameter. If the content is less than the amount, then there won't be any
* dots added to the end. If there is content left over, then dots will be added
* and the rest of the content will be removed.
* Retrieve the post content for feeds.
*
* @package WordPress
* @subpackage Feed
* @since 0.71
* @uses apply_filters() Calls 'the_content_rss' on the content before processing.
* @see get_the_content() For the $more_link_text, $stripteaser, and $more_file
* parameters.
* @since 2.9.0
* @uses apply_filters() Calls 'the_content_feed' on the content before processing.
* @see get_the_content()
*
* @param string $more_link_text Optional. Text to display when more content is available but not displayed.
* @param int|bool $stripteaser Optional. Default is 0.
* @param string $more_file Optional.
* @param int $cut Optional. Amount of words to keep for the content.
* @param int $encode_html Optional. How to encode the content.
* @param string $feed_type The type of feed. rss2 | atom | rss | rdf
*/
function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content_rss', $content);
if ( $cut && !$encode_html )
$encode_html = 2;
if ( 1== $encode_html ) {
$content = esc_html($content);
$cut = 0;
} elseif ( 0 == $encode_html ) {
$content = make_url_footnote($content);
} elseif ( 2 == $encode_html ) {
$content = strip_tags($content);
}
if ( $cut ) {
$blah = explode(' ', $content);
if ( count($blah) > $cut ) {
$k = $cut;
$use_dotdotdot = 1;
} else {
$k = count($blah);
$use_dotdotdot = 0;
}
function get_the_content_feed($feed_type = null) {
if ( !$feed_type )
$feed_type = get_default_feed();
/** @todo Check performance, might be faster to use array slice instead. */
for ( $i=0; $i<$k; $i++ )
$excerpt .= $blah[$i].' ';
$excerpt .= ($use_dotdotdot) ? '...' : '';
$content = $excerpt;
}
$content = apply_filters('the_content', get_the_content());
$content = str_replace(']]>', ']]&gt;', $content);
echo $content;
return apply_filters('the_content_feed', $content, $feed_type);
}
/**
* Display the post content for feeds.
*
* @package WordPress
* @subpackage Feed
* @since 2.9.0
* @uses apply_filters() Calls 'the_content_feed' on the content before processing.
* @see get_the_content()
*
* @param string $feed_type The type of feed. rss2 | atom | rss | rdf
*/
function the_content_feed($feed_type = null) {
echo get_the_content_feed();
}
/**