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. Built from https://develop.svn.wordpress.org/trunk@28586 git-svn-id: http://core.svn.wordpress.org/trunk@28411 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fd16ae485b
commit
f4a6632200
|
@ -1034,29 +1034,28 @@ function wp_widget_rss_output( $rss, $args = array() ) {
|
|||
}
|
||||
|
||||
echo '<ul>';
|
||||
foreach ( $rss->get_items(0, $items) as $item ) {
|
||||
foreach ( $rss->get_items( 0, $items ) as $item ) {
|
||||
$link = $item->get_link();
|
||||
while ( stristr($link, 'http') != $link )
|
||||
$link = substr($link, 1);
|
||||
$link = esc_url(strip_tags($link));
|
||||
$title = esc_attr(strip_tags($item->get_title()));
|
||||
if ( empty($title) )
|
||||
$title = __('Untitled');
|
||||
while ( stristr( $link, 'http' ) != $link ) {
|
||||
$link = substr( $link, 1 );
|
||||
}
|
||||
$link = esc_url( strip_tags( $link ) );
|
||||
|
||||
$title = esc_html( trim( strip_tags( $item->get_title() ) ) );
|
||||
if ( empty( $title ) ) {
|
||||
$title = __( 'Untitled' );
|
||||
}
|
||||
|
||||
$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 );
|
||||
$desc = esc_attr( wp_trim_words( $desc, 55, ' […]' ) );
|
||||
|
||||
$summary = '';
|
||||
if ( $show_summary ) {
|
||||
$summary = $desc;
|
||||
|
||||
// Append ellipsis. Change existing [...] to […].
|
||||
// Change existing [...] to […].
|
||||
if ( '[...]' == substr( $summary, -5 ) ) {
|
||||
$summary = substr( $summary, 0, -5 ) . '[…]';
|
||||
} elseif ( '[…]' != substr( $summary, -10 ) && $desc !== $summary ) {
|
||||
$summary .= ' […]';
|
||||
}
|
||||
|
||||
$summary = '<div class="rssSummary">' . esc_html( $summary ) . '</div>';
|
||||
|
|
Loading…
Reference in New Issue