Make WordPress Core


Ignore:
Timestamp:
05/27/2014 11:07:32 AM (10 years ago)
Author:
SergeyBiryukov
Message:

Clean up wp_widget_rss_output():

  • Fix appending […] to $summary.
  • Use wp_trim_words() instead of wp_html_excerpt().
  • Trim $title before checking if it's empty. props UmeshSingla.
  • Use correct escaping function for $title.

fixes #28356.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-widgets.php

    r28532 r28586  
    10351035
    10361036    echo '<ul>';
    1037     foreach ( $rss->get_items(0, $items) as $item ) {
     1037    foreach ( $rss->get_items( 0, $items ) as $item ) {
    10381038        $link = $item->get_link();
    1039         while ( stristr($link, 'http') != $link )
    1040             $link = substr($link, 1);
    1041         $link = esc_url(strip_tags($link));
    1042         $title = esc_attr(strip_tags($item->get_title()));
    1043         if ( empty($title) )
    1044             $title = __('Untitled');
     1039        while ( stristr( $link, 'http' ) != $link ) {
     1040            $link = substr( $link, 1 );
     1041        }
     1042        $link = esc_url( strip_tags( $link ) );
     1043
     1044        $title = esc_html( trim( strip_tags( $item->get_title() ) ) );
     1045        if ( empty( $title ) ) {
     1046            $title = __( 'Untitled' );
     1047        }
    10451048
    10461049        $desc = @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) );
    1047         $desc = esc_attr( strip_tags( $desc ) );
    1048         $desc = trim( str_replace( array( "\n", "\r" ), ' ', $desc ) );
    1049         $desc = wp_html_excerpt( $desc, 360 );
     1050        $desc = esc_attr( wp_trim_words( $desc, 55, ' [&hellip;]' ) );
    10501051
    10511052        $summary = '';
     
    10531054            $summary = $desc;
    10541055
    1055             // Append ellipsis. Change existing [...] to [&hellip;].
     1056            // Change existing [...] to [&hellip;].
    10561057            if ( '[...]' == substr( $summary, -5 ) ) {
    10571058                $summary = substr( $summary, 0, -5 ) . '[&hellip;]';
    1058             } elseif ( '[&hellip;]' != substr( $summary, -10 ) && $desc !== $summary ) {
    1059                 $summary .= ' [&hellip;]';
    10601059            }
    10611060
Note: See TracChangeset for help on using the changeset viewer.