From 5224680c4db43b419978c83e0914230567823112 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 28 Sep 2009 14:36:48 +0000 Subject: [PATCH] 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 --- wp-admin/includes/schema.php | 3 +- wp-includes/deprecated.php | 66 ++++++++++++++++++++++++++++++ wp-includes/feed-atom.php | 2 +- wp-includes/feed-rdf.php | 4 +- wp-includes/feed-rss.php | 4 -- wp-includes/feed-rss2.php | 2 +- wp-includes/feed.php | 78 ++++++++++++------------------------ 7 files changed, 96 insertions(+), 63 deletions(-) diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index 2cebeb169e..eae2cbbf0c 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -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); } diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index 010eb78ee1..4bcd3fceec 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -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(']]>', ']]>', $content); + echo $content; +} + ?> \ No newline at end of file diff --git a/wp-includes/feed-atom.php b/wp-includes/feed-atom.php index 17b7833b7a..da3eeb467d 100644 --- a/wp-includes/feed-atom.php +++ b/wp-includes/feed-atom.php @@ -43,7 +43,7 @@ echo ''; ?> ]]> - ]]> + ]]> diff --git a/wp-includes/feed-rdf.php b/wp-includes/feed-rdf.php index eee132edb4..946f370a51 100644 --- a/wp-includes/feed-rdf.php +++ b/wp-includes/feed-rdf.php @@ -46,8 +46,8 @@ echo ''; ?> - - ]]> + + ]]> diff --git a/wp-includes/feed-rss.php b/wp-includes/feed-rss.php index e5c2fe830a..90eeab05e1 100644 --- a/wp-includes/feed-rss.php +++ b/wp-includes/feed-rss.php @@ -23,11 +23,7 @@ echo ''; ?> <?php the_title_rss() ?> - ]]> - - - diff --git a/wp-includes/feed-rss2.php b/wp-includes/feed-rss2.php index 7187fe2e22..12286da287 100644 --- a/wp-includes/feed-rss2.php +++ b/wp-includes/feed-rss2.php @@ -46,7 +46,7 @@ echo ''; ?> ]]> post_content ) > 0 ) : ?> - ]]> + ]]> ]]> diff --git a/wp-includes/feed.php b/wp-includes/feed.php index 0226356419..7598695062 100644 --- a/wp-includes/feed.php +++ b/wp-includes/feed.php @@ -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(']]>', ']]>', $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(); } /**