From 23de0ed686bc074110a8eeb4199cda23dd070f7d Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Fri, 5 Feb 2010 14:00:18 +0000 Subject: [PATCH] Cleanup admin_notice_feed(). Props nacin. Fixes #12138 git-svn-id: https://develop.svn.wordpress.org/trunk@12965 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/ms.php | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/wp-admin/includes/ms.php b/wp-admin/includes/ms.php index bad0993948..ed9f6f4957 100644 --- a/wp-admin/includes/ms.php +++ b/wp-admin/includes/ms.php @@ -614,34 +614,30 @@ function secret_salt_warning() { add_action( 'admin_notices', 'secret_salt_warning' ); function admin_notice_feed() { - global $current_user; - if ( substr( $_SERVER[ 'PHP_SELF' ], -19 ) != '/wp-admin/index.php' ) + global $current_user, $current_screen; + if ( $current_screen->id != 'index' ) return; - if ( isset( $_GET[ 'feed_dismiss' ] ) ) + if ( !empty( $_GET[ 'feed_dismiss' ] ) ) update_user_option( $current_user->id, 'admin_feed_dismiss', $_GET[ 'feed_dismiss' ], true ); $url = get_site_option( 'admin_notice_feed' ); - if ( $url == '' ) + if ( empty( $url ) ) return; - $rss = @fetch_feed( $url ); - $item = $rss->get_item(); - if ( !is_null( $item ) ) { + $rss = fetch_feed( $url ); + if ( ! is_wp_error( $rss ) && $item = $rss->get_item() ) { $title = $item->get_title(); - if ( md5( $title ) == get_user_option( 'admin_feed_dismiss', $current_user->id ) ) + if ( md5( $title ) == get_user_option( 'admin_feed_dismiss' ) ) return; $msg = "

" . esc_html( $title ) . "

\n"; $content = $item->get_description(); - if ( is_null( $content ) ) - $content = __( 'something' ); - - $content = wp_html_excerpt($content, 200) . ' ...'; - $link = clean_url( strip_tags( $item->get_link() ) ); - $msg .= "

" . $content . " " . __( 'Read More' ) . " " . __( "Dismiss" ) . "

"; + $content = $content ? wp_html_excerpt( $content, 200 ) . ' … ' : ''; + $link = esc_url( strip_tags( $item->get_link() ) ); + $msg .= "

" . $content . "" . __( 'Read More' ) . " " . __( 'Dismiss' ) . "

"; echo "
$msg
"; } elseif ( is_super_admin() ) { - printf("
" . __("Your feed at %s is empty.") . "
", wp_specialchars( $url )); + printf( '
' . __( 'Your feed at %s is empty.' ) . '
', esc_html( $url ) ); } } add_action( 'admin_notices', 'admin_notice_feed' );