| 592 | | function admin_notice_feed() { |
| 593 | | global $current_screen; |
| 594 | | if ( $current_screen->id != 'dashboard' ) |
| 595 | | return; |
| 596 | | |
| 597 | | if ( !empty( $_GET['feed_dismiss'] ) ) { |
| 598 | | update_user_option( get_current_user_id(), 'admin_feed_dismiss', $_GET['feed_dismiss'], true ); |
| 599 | | return; |
| 600 | | } |
| 601 | | |
| 602 | | $url = get_site_option( 'admin_notice_feed' ); |
| 603 | | if ( empty( $url ) ) |
| 604 | | return; |
| 605 | | |
| 606 | | $rss = fetch_feed( $url ); |
| 607 | | if ( ! is_wp_error( $rss ) && $item = $rss->get_item() ) { |
| 608 | | $title = $item->get_title(); |
| 609 | | if ( md5( $title ) == get_user_option( 'admin_feed_dismiss' ) ) |
| 610 | | return; |
| 611 | | $msg = "<h3>" . esc_html( $title ) . "</h3>\n"; |
| 612 | | $content = $item->get_description(); |
| 613 | | $content = $content ? wp_html_excerpt( $content, 200 ) . ' … ' : ''; |
| 614 | | $link = esc_url( strip_tags( $item->get_link() ) ); |
| 615 | | $msg .= "<p>" . $content . "<a href='$link'>" . __( 'Read More' ) . "</a> <a href='index.php?feed_dismiss=" . md5( $title ) . "'>" . __( 'Dismiss' ) . "</a></p>"; |
| 616 | | echo "<div class='updated'>$msg</div>"; |
| 617 | | } elseif ( is_super_admin() ) { |
| 618 | | printf( '<div class="update-nag">' . __( 'Your feed at %s is empty.' ) . '</div>', esc_html( $url ) ); |
| 619 | | } |
| 620 | | } |
| 621 | | add_action( 'admin_notices', 'admin_notice_feed' ); |
| 622 | | |