Cleanup admin_notice_feed(). Props nacin. Fixes #12138
git-svn-id: https://develop.svn.wordpress.org/trunk@12965 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f9361ef7f5
commit
23de0ed686
@ -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 ) . ' … ' : '';
|
||||
$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' );
|
||||
|
Loading…
Reference in New Issue
Block a user