Make WordPress Core

Ticket #4671: widgetpatch.patch

File widgetpatch.patch, 2.3 KB (added by brettz95, 18 years ago)

Fix empty <ul> issue in widget.php

  • wp-includes/widgets.php

     
    966966?>
    967967                <?php echo $before_widget; ?>
    968968                        <?php $title ? print($before_title . $title . $after_title) : null; ?>
    969                         <ul>
    970969<?php
    971970        if ( is_array( $rss->items ) ) {
    972971                $rss->items = array_slice($rss->items, 0, $num_items);
    973                 foreach ($rss->items as $item ) {
    974                         while ( strstr($item['link'], 'http') != $item['link'] )
    975                                 $item['link'] = substr($item['link'], 1);
    976                         $link = clean_url(strip_tags($item['link']));
    977                         $title = attribute_escape(strip_tags($item['title']));
    978                         if ( empty($title) )
    979                                 $title = __('Untitled');
    980                         $desc = '';
    981                         if ( $show_summary ) {
    982                                 $summary = '<div class="rssSummary">' . $item['description'] . '</div>';
    983                         } else {
    984                                 if ( isset( $item['description'] ) && is_string( $item['description'] ) )
    985                                         $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['description'], ENT_QUOTES))));
    986                                 $summary = '';
     972                if (!empty($rss->items)) {
     973                        print '<ul>';
     974                        foreach ($rss->items as $item ) {
     975                                while ( strstr($item['link'], 'http') != $item['link'] )
     976                                        $item['link'] = substr($item['link'], 1);
     977                                $link = clean_url(strip_tags($item['link']));
     978                                $title = attribute_escape(strip_tags($item['title']));
     979                                if ( empty($title) )
     980                                        $title = __('Untitled');
     981                                $desc = '';
     982                                if ( $show_summary ) {
     983                                        $summary = '<div class="rssSummary">' . $item['description'] . '</div>';
     984                                } else {
     985                                        if ( isset( $item['description'] ) && is_string( $item['description'] ) )
     986                                                $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['description'], ENT_QUOTES))));
     987                                        $summary = '';
     988                                }
     989                                echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>$summary</li>";
    987990                        }
    988                         echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>$summary</li>";
     991                        print '</ul>';
    989992                }
    990993        } else {
    991                 echo '<li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li>';
     994                echo '<ul><li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li></ul>';
    992995        }
    993996?>
    994                         </ul>
    995997                <?php echo $after_widget; ?>
    996998<?php
    997999}