Make WordPress Core

Changeset 27691


Ignore:
Timestamp:
03/24/2014 09:07:10 PM (11 years ago)
Author:
nacin
Message:

RSS widgets: Omit the title attribute when the summary is shown.

Trim the title attribute to ensure whitespace isn't rendered.

props SergeyBiryukov.
fixes #26520. see #26552.

File:
1 edited

Legend:

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

    r27561 r27691  
    867867            $title = __('Untitled');
    868868
    869         $desc = str_replace( array("\n", "\r"), ' ', esc_attr( strip_tags( @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option('blog_charset') ) ) ) );
    870         $excerpt = wp_html_excerpt( $desc, 360 );
    871 
    872         // Append ellipsis. Change existing [...] to […].
    873         if ( '[...]' == substr( $excerpt, -5 ) )
    874             $excerpt = substr( $excerpt, 0, -5 ) . '[…]';
    875         elseif ( '[…]' != substr( $excerpt, -10 ) && $desc != $excerpt )
    876             $excerpt .= ' […]';
    877 
    878         $excerpt = esc_html( $excerpt );
    879 
     869        $desc = @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) );
     870        $desc = esc_attr( strip_tags( $desc ) );
     871        $desc = trim( str_replace( array( "\n", "\r" ), ' ', $desc ) );
     872        $desc = wp_html_excerpt( $desc, 360 );
     873
     874        $summary = '';
    880875        if ( $show_summary ) {
    881             $summary = "<div class='rssSummary'>$excerpt</div>";
    882         } else {
    883             $summary = '';
     876            $summary = $desc;
     877
     878            // Append ellipsis. Change existing [...] to [&hellip;].
     879            if ( '[...]' == substr( $summary, -5 ) ) {
     880                $summary = substr( $summary, 0, -5 ) . '[&hellip;]';
     881            } elseif ( '[&hellip;]' != substr( $summary, -10 ) && $desc !== $summary ) {
     882                $summary .= ' [&hellip;]';
     883            }
     884
     885            $summary = '<div class="rssSummary">' . esc_html( $summary ) . '</div>';
    884886        }
    885887
     
    904906        if ( $link == '' ) {
    905907            echo "<li>$title{$date}{$summary}{$author}</li>";
     908        } elseif ( $show_summary ) {
     909            echo "<li><a class='rsswidget' href='$link'>$title</a>{$date}{$summary}{$author}</li>";
    906910        } else {
    907             echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>";
     911            echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$author}</li>";
    908912        }
    909913    }
Note: See TracChangeset for help on using the changeset viewer.