Cleanup admin_notice_feed(). Props nacin. Fixes #12138

git-svn-id: http://svn.automattic.com/wordpress/trunk@12965 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-02-05 14:00:18 +00:00
parent dede5d2f46
commit 4430afb179
1 changed files with 11 additions and 15 deletions

View File

@ -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 = "<h3>" . esc_html( $title ) . "</h3>\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 .= "<p>" . $content . " <a href='$link'>" . __( 'Read More' ) . "</a> <a href='index.php?feed_dismiss=" . md5( $title ) . "'>" . __( "Dismiss" ) . "</a></p>";
$content = $content ? wp_html_excerpt( $content, 200 ) . ' &hellip; ' : '';
$link = esc_url( strip_tags( $item->get_link() ) );
$msg .= "<p>" . $content . "<a href='$link'>" . __( 'Read More' ) . "</a> <a href='index.php?feed_dismiss=" . md5( $title ) . "'>" . __( 'Dismiss' ) . "</a></p>";
echo "<div class='updated fade'>$msg</div>";
} elseif ( is_super_admin() ) {
printf("<div id='update-nag'>" . __("Your feed at %s is empty.") . "</div>", wp_specialchars( $url ));
printf( '<div id="update-nag">' . __( 'Your feed at %s is empty.' ) . '</div>', esc_html( $url ) );
}
}
add_action( 'admin_notices', 'admin_notice_feed' );