Make WordPress Core

Changeset 11980


Ignore:
Timestamp:
09/28/2009 02:36:48 PM (14 years ago)
Author:
ryan
Message:

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.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/schema.php

    r11955 r11980  
    210210    'comments_notify' => 1,
    211211    'posts_per_rss' => 10,
    212     'rss_excerpt_length' => 50,
    213212    'rss_use_excerpt' => 0,
    214213    'mailserver_url' => 'mail.example.com',
     
    349348    // Delete unused options
    350349    $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',
    351         'page_uris', 'rewrite_rules', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed');
     350        'page_uris', 'rewrite_rules', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed', 'rss_excerpt_length');
    352351    foreach ($unusedoptions as $option)
    353352        delete_option($option);
  • trunk/wp-includes/deprecated.php

    r11450 r11980  
    16911691}
    16921692
     1693/**
     1694 * Display the post content for the feed.
     1695 *
     1696 * For encoding the html or the $encode_html parameter, there are three possible
     1697 * values. '0' will make urls footnotes and use make_url_footnote(). '1' will
     1698 * encode special characters and automatically display all of the content. The
     1699 * value of '2' will strip all HTML tags from the content.
     1700 *
     1701 * Also note that you cannot set the amount of words and not set the html
     1702 * encoding. If that is the case, then the html encoding will default to 2,
     1703 * which will strip all HTML tags.
     1704 *
     1705 * To restrict the amount of words of the content, you can use the cut
     1706 * parameter. If the content is less than the amount, then there won't be any
     1707 * dots added to the end. If there is content left over, then dots will be added
     1708 * and the rest of the content will be removed.
     1709 *
     1710 * @package WordPress
     1711 * @subpackage Feed
     1712 * @since 0.71
     1713 * @uses apply_filters() Calls 'the_content_rss' on the content before processing.
     1714 * @see get_the_content() For the $more_link_text, $stripteaser, and $more_file
     1715 *      parameters.
     1716 *
     1717 * @deprecated 2.9.0
     1718 *
     1719 * @param string $more_link_text Optional. Text to display when more content is available but not displayed.
     1720 * @param int|bool $stripteaser Optional. Default is 0.
     1721 * @param string $more_file Optional.
     1722 * @param int $cut Optional. Amount of words to keep for the content.
     1723 * @param int $encode_html Optional. How to encode the content.
     1724 */
     1725function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
     1726    _deprecated_function(__FUNCTION__, '2.9', 'the_content_feed' );
     1727    $content = get_the_content($more_link_text, $stripteaser, $more_file);
     1728    $content = apply_filters('the_content_rss', $content);
     1729    if ( $cut && !$encode_html )
     1730        $encode_html = 2;
     1731    if ( 1== $encode_html ) {
     1732        $content = esc_html($content);
     1733        $cut = 0;
     1734    } elseif ( 0 == $encode_html ) {
     1735        $content = make_url_footnote($content);
     1736    } elseif ( 2 == $encode_html ) {
     1737        $content = strip_tags($content);
     1738    }
     1739    if ( $cut ) {
     1740        $blah = explode(' ', $content);
     1741        if ( count($blah) > $cut ) {
     1742            $k = $cut;
     1743            $use_dotdotdot = 1;
     1744        } else {
     1745            $k = count($blah);
     1746            $use_dotdotdot = 0;
     1747        }
     1748
     1749        /** @todo Check performance, might be faster to use array slice instead. */
     1750        for ( $i=0; $i<$k; $i++ )
     1751            $excerpt .= $blah[$i].' ';
     1752        $excerpt .= ($use_dotdotdot) ? '...' : '';
     1753        $content = $excerpt;
     1754    }
     1755    $content = str_replace(']]>', ']]&gt;', $content);
     1756    echo $content;
     1757}
     1758
    16931759?>
  • trunk/wp-includes/feed-atom.php

    r11416 r11980  
    4444        <summary type="<?php html_type_rss(); ?>"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>
    4545<?php if ( !get_option('rss_use_excerpt') ) : ?>
    46         <content type="<?php html_type_rss(); ?>" xml:base="<?php the_permalink_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content>
     46        <content type="<?php html_type_rss(); ?>" xml:base="<?php the_permalink_rss() ?>"><![CDATA[<?php the_content_feed('atom') ?>]]></content>
    4747<?php endif; ?>
    4848<?php atom_enclosure(); ?>
  • trunk/wp-includes/feed-rdf.php

    r10952 r11980  
    4747    <description><?php the_excerpt_rss() ?></description>
    4848<?php else : ?>
    49     <description><?php the_content_rss('', 0, '', get_option('rss_excerpt_length'), 2) ?></description>
    50     <content:encoded><![CDATA[<?php the_content('', 0, '') ?>]]></content:encoded>
     49    <description><?php the_excerpt_rss() ?></description>
     50    <content:encoded><![CDATA[<?php the_content_feed('rdf') ?>]]></content:encoded>
    5151<?php endif; ?>
    5252    <?php do_action('rdf_item'); ?>
  • trunk/wp-includes/feed-rss.php

    r11358 r11980  
    2424    <item>
    2525        <title><?php the_title_rss() ?></title>
    26 <?php if (get_option('rss_use_excerpt')) { ?>
    2726        <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
    28 <?php } else { // use content ?>
    29         <description><?php the_content_rss('', 0, '', get_option('rss_excerpt_length')) ?></description>
    30 <?php } ?>
    3127        <link><?php the_permalink_rss() ?></link>
    3228        <?php do_action('rss_item'); ?>
  • trunk/wp-includes/feed-rss2.php

    r11864 r11980  
    4747        <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
    4848    <?php if ( strlen( $post->post_content ) > 0 ) : ?>
    49         <content:encoded><![CDATA[<?php the_content() ?>]]></content:encoded>
     49        <content:encoded><![CDATA[<?php the_content_feed('rss2') ?>]]></content:encoded>
    5050    <?php else : ?>
    5151        <content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
  • trunk/wp-includes/feed.php

    r11453 r11980  
    131131
    132132/**
    133  * Display the post content for the feed.
    134  *
    135  * For encoding the html or the $encode_html parameter, there are three possible
    136  * values. '0' will make urls footnotes and use make_url_footnote(). '1' will
    137  * encode special characters and automatically display all of the content. The
    138  * value of '2' will strip all HTML tags from the content.
    139  *
    140  * Also note that you cannot set the amount of words and not set the html
    141  * encoding. If that is the case, then the html encoding will default to 2,
    142  * which will strip all HTML tags.
    143  *
    144  * To restrict the amount of words of the content, you can use the cut
    145  * parameter. If the content is less than the amount, then there won't be any
    146  * dots added to the end. If there is content left over, then dots will be added
    147  * and the rest of the content will be removed.
    148  *
    149  * @package WordPress
    150  * @subpackage Feed
    151  * @since 0.71
    152  * @uses apply_filters() Calls 'the_content_rss' on the content before processing.
    153  * @see get_the_content() For the $more_link_text, $stripteaser, and $more_file
    154  *      parameters.
    155  *
    156  * @param string $more_link_text Optional. Text to display when more content is available but not displayed.
    157  * @param int|bool $stripteaser Optional. Default is 0.
    158  * @param string $more_file Optional.
    159  * @param int $cut Optional. Amount of words to keep for the content.
    160  * @param int $encode_html Optional. How to encode the content.
    161  */
    162 function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
    163     $content = get_the_content($more_link_text, $stripteaser, $more_file);
    164     $content = apply_filters('the_content_rss', $content);
    165     if ( $cut && !$encode_html )
    166         $encode_html = 2;
    167     if ( 1== $encode_html ) {
    168         $content = esc_html($content);
    169         $cut = 0;
    170     } elseif ( 0 == $encode_html ) {
    171         $content = make_url_footnote($content);
    172     } elseif ( 2 == $encode_html ) {
    173         $content = strip_tags($content);
    174     }
    175     if ( $cut ) {
    176         $blah = explode(' ', $content);
    177         if ( count($blah) > $cut ) {
    178             $k = $cut;
    179             $use_dotdotdot = 1;
    180         } else {
    181             $k = count($blah);
    182             $use_dotdotdot = 0;
    183         }
    184 
    185         /** @todo Check performance, might be faster to use array slice instead. */
    186         for ( $i=0; $i<$k; $i++ )
    187             $excerpt .= $blah[$i].' ';
    188         $excerpt .= ($use_dotdotdot) ? '...' : '';
    189         $content = $excerpt;
    190     }
     133 * Retrieve the post content for feeds.
     134 *
     135 * @package WordPress
     136 * @subpackage Feed
     137 * @since 2.9.0
     138 * @uses apply_filters() Calls 'the_content_feed' on the content before processing.
     139 * @see get_the_content()
     140 *
     141 * @param string $feed_type The type of feed. rss2 | atom | rss | rdf
     142 */
     143function get_the_content_feed($feed_type = null) {
     144    if ( !$feed_type )
     145        $feed_type = get_default_feed();
     146
     147    $content = apply_filters('the_content', get_the_content());
    191148    $content = str_replace(']]>', ']]&gt;', $content);
    192     echo $content;
     149    return apply_filters('the_content_feed', $content, $feed_type);
     150}
     151
     152/**
     153 * Display the post content for feeds.
     154 *
     155 * @package WordPress
     156 * @subpackage Feed
     157 * @since 2.9.0
     158 * @uses apply_filters() Calls 'the_content_feed' on the content before processing.
     159 * @see get_the_content()
     160 *
     161 * @param string $feed_type The type of feed. rss2 | atom | rss | rdf
     162 */
     163function the_content_feed($feed_type = null) {
     164    echo get_the_content_feed();
    193165}
    194166
Note: See TracChangeset for help on using the changeset viewer.