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. git-svn-id: https://develop.svn.wordpress.org/trunk@28586 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9599dd9705
commit
6bca1ca960
|
@ -1036,27 +1036,26 @@ function wp_widget_rss_output( $rss, $args = array() ) {
|
||||||
echo '<ul>';
|
echo '<ul>';
|
||||||
foreach ( $rss->get_items( 0, $items ) as $item ) {
|
foreach ( $rss->get_items( 0, $items ) as $item ) {
|
||||||
$link = $item->get_link();
|
$link = $item->get_link();
|
||||||
while ( stristr($link, 'http') != $link )
|
while ( stristr( $link, 'http' ) != $link ) {
|
||||||
$link = substr( $link, 1 );
|
$link = substr( $link, 1 );
|
||||||
|
}
|
||||||
$link = esc_url( strip_tags( $link ) );
|
$link = esc_url( strip_tags( $link ) );
|
||||||
$title = esc_attr(strip_tags($item->get_title()));
|
|
||||||
if ( empty($title) )
|
$title = esc_html( trim( strip_tags( $item->get_title() ) ) );
|
||||||
|
if ( empty( $title ) ) {
|
||||||
$title = __( 'Untitled' );
|
$title = __( 'Untitled' );
|
||||||
|
}
|
||||||
|
|
||||||
$desc = @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) );
|
$desc = @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) );
|
||||||
$desc = esc_attr( strip_tags( $desc ) );
|
$desc = esc_attr( wp_trim_words( $desc, 55, ' […]' ) );
|
||||||
$desc = trim( str_replace( array( "\n", "\r" ), ' ', $desc ) );
|
|
||||||
$desc = wp_html_excerpt( $desc, 360 );
|
|
||||||
|
|
||||||
$summary = '';
|
$summary = '';
|
||||||
if ( $show_summary ) {
|
if ( $show_summary ) {
|
||||||
$summary = $desc;
|
$summary = $desc;
|
||||||
|
|
||||||
// Append ellipsis. Change existing [...] to […].
|
// Change existing [...] to […].
|
||||||
if ( '[...]' == substr( $summary, -5 ) ) {
|
if ( '[...]' == substr( $summary, -5 ) ) {
|
||||||
$summary = substr( $summary, 0, -5 ) . '[…]';
|
$summary = substr( $summary, 0, -5 ) . '[…]';
|
||||||
} elseif ( '[…]' != substr( $summary, -10 ) && $desc !== $summary ) {
|
|
||||||
$summary .= ' […]';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$summary = '<div class="rssSummary">' . esc_html( $summary ) . '</div>';
|
$summary = '<div class="rssSummary">' . esc_html( $summary ) . '</div>';
|
||||||
|
|
Loading…
Reference in New Issue