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:
parent
dede5d2f46
commit
4430afb179
|
@ -614,34 +614,30 @@ function secret_salt_warning() {
|
||||||
add_action( 'admin_notices', 'secret_salt_warning' );
|
add_action( 'admin_notices', 'secret_salt_warning' );
|
||||||
|
|
||||||
function admin_notice_feed() {
|
function admin_notice_feed() {
|
||||||
global $current_user;
|
global $current_user, $current_screen;
|
||||||
if ( substr( $_SERVER[ 'PHP_SELF' ], -19 ) != '/wp-admin/index.php' )
|
if ( $current_screen->id != 'index' )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( isset( $_GET[ 'feed_dismiss' ] ) )
|
if ( !empty( $_GET[ 'feed_dismiss' ] ) )
|
||||||
update_user_option( $current_user->id, 'admin_feed_dismiss', $_GET[ 'feed_dismiss' ], true );
|
update_user_option( $current_user->id, 'admin_feed_dismiss', $_GET[ 'feed_dismiss' ], true );
|
||||||
|
|
||||||
$url = get_site_option( 'admin_notice_feed' );
|
$url = get_site_option( 'admin_notice_feed' );
|
||||||
if ( $url == '' )
|
if ( empty( $url ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$rss = @fetch_feed( $url );
|
$rss = fetch_feed( $url );
|
||||||
$item = $rss->get_item();
|
if ( ! is_wp_error( $rss ) && $item = $rss->get_item() ) {
|
||||||
if ( !is_null( $item ) ) {
|
|
||||||
$title = $item->get_title();
|
$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;
|
return;
|
||||||
$msg = "<h3>" . esc_html( $title ) . "</h3>\n";
|
$msg = "<h3>" . esc_html( $title ) . "</h3>\n";
|
||||||
$content = $item->get_description();
|
$content = $item->get_description();
|
||||||
if ( is_null( $content ) )
|
$content = $content ? wp_html_excerpt( $content, 200 ) . ' … ' : '';
|
||||||
$content = __( 'something' );
|
$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>";
|
||||||
$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>";
|
|
||||||
echo "<div class='updated fade'>$msg</div>";
|
echo "<div class='updated fade'>$msg</div>";
|
||||||
} elseif ( is_super_admin() ) {
|
} 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' );
|
add_action( 'admin_notices', 'admin_notice_feed' );
|
||||||
|
|
Loading…
Reference in New Issue