Make WordPress Core

Changeset 12965


Ignore:
Timestamp:
02/05/2010 02:00:18 PM (15 years ago)
Author:
dd32
Message:

Cleanup admin_notice_feed(). Props nacin. Fixes #12138

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/ms.php

    r12955 r12965  
    615615
    616616function admin_notice_feed() {
    617     global $current_user;
    618     if ( substr( $_SERVER[ 'PHP_SELF' ], -19 ) != '/wp-admin/index.php' )
     617    global $current_user, $current_screen;
     618    if ( $current_screen->id != 'index' )
    619619        return;
    620620
    621     if ( isset( $_GET[ 'feed_dismiss' ] ) )
     621    if ( !empty( $_GET[ 'feed_dismiss' ] ) )
    622622        update_user_option( $current_user->id, 'admin_feed_dismiss', $_GET[ 'feed_dismiss' ], true );
    623623
    624624    $url = get_site_option( 'admin_notice_feed' );
    625     if ( $url == '' )
     625    if ( empty( $url ) )
    626626        return;
    627627
    628     $rss = @fetch_feed( $url );
    629     $item = $rss->get_item();
    630     if ( !is_null( $item ) ) {
     628    $rss = fetch_feed( $url );
     629    if ( ! is_wp_error( $rss ) && $item = $rss->get_item() ) {
    631630        $title = $item->get_title();
    632         if ( md5( $title ) == get_user_option( 'admin_feed_dismiss', $current_user->id ) )
     631        if ( md5( $title ) == get_user_option( 'admin_feed_dismiss' ) )
    633632            return;
    634633        $msg = "<h3>" . esc_html( $title ) . "</h3>\n";
    635634        $content = $item->get_description();
    636         if ( is_null( $content ) )
    637             $content = __( 'something' );
    638 
    639         $content = wp_html_excerpt($content, 200) . ' ...';
    640         $link = clean_url( strip_tags( $item->get_link() ) );
    641         $msg .= "<p>" . $content . " <a href='$link'>" . __( 'Read More' ) . "</a> <a href='index.php?feed_dismiss=" . md5( $title ) . "'>" . __( "Dismiss" ) . "</a></p>";
     635        $content = $content ? wp_html_excerpt( $content, 200 ) . ' &hellip; ' : '';
     636        $link = esc_url( strip_tags( $item->get_link() ) );
     637        $msg .= "<p>" . $content . "<a href='$link'>" . __( 'Read More' ) . "</a> <a href='index.php?feed_dismiss=" . md5( $title ) . "'>" . __( 'Dismiss' ) . "</a></p>";
    642638        echo "<div class='updated fade'>$msg</div>";
    643639    } elseif ( is_super_admin() ) {
    644         printf("<div id='update-nag'>" . __("Your feed at %s is empty.") . "</div>", wp_specialchars( $url ));
     640        printf( '<div id="update-nag">' . __( 'Your feed at %s is empty.' ) . '</div>', esc_html( $url ) );
    645641    }
    646642}
Note: See TracChangeset for help on using the changeset viewer.