From 3ffc6dd5594c369b66f226087edb0412da3c8849 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Mon, 24 Mar 2014 21:08:15 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@27691 git-svn-id: http://core.svn.wordpress.org/trunk@27530 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/default-widgets.php | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/wp-includes/default-widgets.php b/wp-includes/default-widgets.php index 9495ea1b6b..2cc34dd4fb 100644 --- a/wp-includes/default-widgets.php +++ b/wp-includes/default-widgets.php @@ -866,21 +866,23 @@ function wp_widget_rss_output( $rss, $args = array() ) { if ( empty($title) ) $title = __('Untitled'); - $desc = str_replace( array("\n", "\r"), ' ', esc_attr( strip_tags( @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option('blog_charset') ) ) ) ); - $excerpt = wp_html_excerpt( $desc, 360 ); - - // Append ellipsis. Change existing [...] to […]. - if ( '[...]' == substr( $excerpt, -5 ) ) - $excerpt = substr( $excerpt, 0, -5 ) . '[…]'; - elseif ( '[…]' != substr( $excerpt, -10 ) && $desc != $excerpt ) - $excerpt .= ' […]'; - - $excerpt = esc_html( $excerpt ); + $desc = @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ); + $desc = esc_attr( strip_tags( $desc ) ); + $desc = trim( str_replace( array( "\n", "\r" ), ' ', $desc ) ); + $desc = wp_html_excerpt( $desc, 360 ); + $summary = ''; if ( $show_summary ) { - $summary = "
$excerpt
"; - } else { - $summary = ''; + $summary = $desc; + + // Append ellipsis. Change existing [...] to […]. + if ( '[...]' == substr( $summary, -5 ) ) { + $summary = substr( $summary, 0, -5 ) . '[…]'; + } elseif ( '[…]' != substr( $summary, -10 ) && $desc !== $summary ) { + $summary .= ' […]'; + } + + $summary = '
' . esc_html( $summary ) . '
'; } $date = ''; @@ -903,8 +905,10 @@ function wp_widget_rss_output( $rss, $args = array() ) { if ( $link == '' ) { echo "
  • $title{$date}{$summary}{$author}
  • "; + } elseif ( $show_summary ) { + echo "
  • $title{$date}{$summary}{$author}
  • "; } else { - echo "
  • $title{$date}{$summary}{$author}
  • "; + echo "
  • $title{$date}{$author}
  • "; } } echo '';