WordPress.org

Make WordPress Core

Ticket #3884: 3884.patch

File 3884.patch, 10.4 KB (added by Viper007Bond, 5 years ago)
  • wp-includes/default-filters.php

     
    144144add_filter('the_title_rss', 'strip_tags'); 
    145145add_filter('the_title_rss', 'ent2ncr', 8); 
    146146add_filter('the_title_rss', 'esc_html'); 
    147 add_filter('the_content_rss', 'ent2ncr', 8); 
    148147add_filter('the_excerpt_rss', 'convert_chars'); 
    149148add_filter('the_excerpt_rss', 'ent2ncr', 8); 
    150149add_filter('comment_author_rss', 'ent2ncr', 8); 
  • wp-includes/deprecated.php

     
    16901690        the_author_meta('ID'); 
    16911691} 
    16921692 
    1693 ?> 
    1694  No newline at end of file 
     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 * @deprecated 2.9 
     1714 * @uses apply_filters() Calls 'the_content_rss' on the content before processing. 
     1715 * @see get_the_content() For the $more_link_text, $stripteaser, and $more_file 
     1716 *              parameters. 
     1717 * 
     1718 * @param string $more_link_text Optional. Text to display when more content is available but not displayed. 
     1719 * @param int|bool $stripteaser Optional. Default is 0. 
     1720 * @param string $more_file Optional. 
     1721 * @param int $cut Optional. Amount of words to keep for the content. 
     1722 * @param int $encode_html Optional. How to encode the content. 
     1723 */ 
     1724function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) { 
     1725        _deprecated_function(__FUNCTION__, '2.9', 'the_content_feed' ); 
     1726 
     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                $excerpt = ''; 
     1751                for ( $i=0; $i<$k; $i++ ) 
     1752                        $excerpt .= $blah[$i].' '; 
     1753                $excerpt .= ($use_dotdotdot) ? '...' : ''; 
     1754                $content = $excerpt; 
     1755        } 
     1756        $content = str_replace(']]>', ']]&gt;', $content); 
     1757        echo $content; 
     1758} 
     1759add_filter('the_content_rss', 'ent2ncr', 8); 
     1760 No newline at end of file 
  • wp-includes/feed-atom.php

     
    4343                <?php the_category_rss('atom') ?> 
    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() ?>]]></content> 
    4747<?php endif; ?> 
    4848<?php atom_enclosure(); ?> 
    4949<?php do_action('atom_entry'); ?> 
  • wp-includes/feed-rdf.php

     
    4343         <dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', $post->post_date_gmt, false); ?></dc:date> 
    4444        <dc:creator><?php the_author() ?></dc:creator> 
    4545        <?php the_category_rss('rdf') ?> 
    46 <?php if (get_option('rss_use_excerpt')) : ?> 
    47         <description><?php the_excerpt_rss() ?></description> 
     46<?php if ( get_option('rss_use_excerpt') ) : ?> 
     47        <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_content_feed( true ); ?></description> 
     50        <content:encoded><![CDATA[<?php the_content_feed(); ?>]]></content:encoded> 
    5151<?php endif; ?> 
    5252        <?php do_action('rdf_item'); ?> 
    5353</item> 
  • wp-includes/feed-rss.php

     
    2323<?php while (have_posts()) : the_post(); ?> 
    2424        <item> 
    2525                <title><?php the_title_rss() ?></title> 
    26 <?php if (get_option('rss_use_excerpt')) { ?> 
     26<?php if ( get_option('rss_use_excerpt') ) { ?> 
    2727                <description><![CDATA[<?php the_excerpt_rss() ?>]]></description> 
    2828<?php } else { // use content ?> 
    29                 <description><?php the_content_rss('', 0, '', get_option('rss_excerpt_length')) ?></description> 
     29                <description><?php the_content_feed( true ); ?></description> 
    3030<?php } ?> 
    3131                <link><?php the_permalink_rss() ?></link> 
    3232                <?php do_action('rss_item'); ?> 
  • wp-includes/feed-rss2.php

     
    4141                <?php the_category_rss() ?> 
    4242 
    4343                <guid isPermaLink="false"><?php the_guid(); ?></guid> 
    44 <?php if (get_option('rss_use_excerpt')) : ?> 
    4544                <description><![CDATA[<?php the_excerpt_rss() ?>]]></description> 
     45<?php 
     46if ( !get_option('rss_use_excerpt') ) : 
     47        if ( strlen( $post->post_content ) > 0 ) : 
     48?> 
     49                <content:encoded><![CDATA[<?php the_content_feed() ?>]]></content:encoded> 
    4650<?php else : ?> 
    47                 <description><![CDATA[<?php the_excerpt_rss() ?>]]></description> 
    48         <?php if ( strlen( $post->post_content ) > 0 ) : ?> 
    49                 <content:encoded><![CDATA[<?php the_content() ?>]]></content:encoded> 
    50         <?php else : ?> 
    5151                <content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded> 
    52         <?php endif; ?> 
    53 <?php endif; ?> 
     52<?php 
     53        endif; 
     54endif; 
     55?> 
    5456                <wfw:commentRss><?php echo get_post_comments_feed_link(null, 'rss2'); ?></wfw:commentRss> 
    5557                <slash:comments><?php echo get_comments_number(); ?></slash:comments> 
    5658<?php rss_enclosure(); ?> 
  • wp-includes/feed.php

     
    132132/** 
    133133 * Display the post content for the feed. 
    134134 * 
    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  * 
    149135 * @package WordPress 
    150136 * @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. 
     137 * @since 2.9 
     138 * @uses apply_filters() Calls 'the_content' hook on the content. 
     139 * @uses apply_filters() Calls 'the_content_feed' hook on the content. 
    155140 * 
    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. 
     141 * @param boolean $short Optional. Trims the content short if true. 
    161142 */ 
    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                 } 
     143function the_content_feed( $short = false ) { 
     144        $content = get_the_content( '' ); 
    184145 
    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; 
     146        if ( $short ) { 
     147                $content = strip_shortcodes( $content ); 
     148                $content = ent2ncr( $content ); 
     149                $content = str_replace( ']]>', ']]&gt;', $content ); 
     150                $content = strip_tags( $content ); 
     151                $length = (int) get_option( 'rss_excerpt_length' ); 
     152                $words = explode(' ', $content, $length + 1); 
     153                if ( count( $words ) > $length ) { 
     154                        array_pop( $words ); 
     155                        array_push( $words, apply_filters( 'feed_more', '...' ) ); 
     156                        $content = implode( ' ', $words ); 
     157                } 
     158        } else { 
     159                $content = apply_filters( 'the_content', $content ); 
    190160        } 
    191         $content = str_replace(']]>', ']]&gt;', $content); 
    192         echo $content; 
     161 
     162        echo apply_filters( 'the_content_feed', $content, $short ); 
    193163} 
    194164 
    195165/**