diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-05-15 17:43:29 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-05-15 17:43:29 +0000 |
commit | 6eac4cdfd4ce70d0a2cbb37ab9369b0f8b6dfc48 (patch) | |
tree | 0b06bd4dfd7bd9c610a5f635ca2826be35807760 /wp-admin/includes/mu.php | |
parent | 5dbc4a0b5bbf235830a38b2cfab07c46a7a9c2eb (diff) | |
download | wordpress-mu-6eac4cdfd4ce70d0a2cbb37ab9369b0f8b6dfc48.tar.gz wordpress-mu-6eac4cdfd4ce70d0a2cbb37ab9369b0f8b6dfc48.tar.xz wordpress-mu-6eac4cdfd4ce70d0a2cbb37ab9369b0f8b6dfc48.zip |
Admin Notice Feed allows the site_admin to display a feed to all blogs on an MU site. Esp. useful for an announcements blog.
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1292 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/includes/mu.php')
-rw-r--r-- | wp-admin/includes/mu.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/wp-admin/includes/mu.php b/wp-admin/includes/mu.php index f9f565d..8589d24 100644 --- a/wp-admin/includes/mu.php +++ b/wp-admin/includes/mu.php @@ -673,4 +673,40 @@ function profile_update_primary_blog() { } } add_action( 'personal_options_update', 'profile_update_primary_blog' ); + +function admin_notice_feed() { + global $current_user; + if( substr( $_SERVER[ 'PHP_SELF' ], -19 ) != '/wp-admin/index.php' ) + return; + + if( $_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 == '' ) + return; + include_once( ABSPATH . 'wp-includes/rss.php' ); + $rss = @fetch_rss( $url ); + if( isset($rss->items) && 1 <= count($rss->items) ) { + if( md5( $rss->items[0][ 'title' ] ) == get_user_option( 'admin_feed_dismiss', $current_user->id ) ) + return; + $item = $rss->items[0]; + $msg = "<h3>" . wp_specialchars( $item[ 'title' ] ) . "</h3>\n"; + if ( isset($item['description']) ) + $content = $item['description']; + elseif ( isset($item['summary']) ) + $content = $item['summary']; + elseif ( isset($item['atom_content']) ) + $content = $item['atom_content']; + else + $content = __( 'something' ); + $content = wp_html_excerpt($content, 200) . ' ...'; + $link = clean_url( strip_tags( $item['link'] ) ); + $msg .= "<p>" . $content . " <a href='$link'>" . __( 'Read More' ) . "</a> <a href='index.php?feed_dismiss=" . md5( $item[ 'title' ] ) . "'>" . __( "Dismiss" ) . "</a></p>"; + echo "<div class='updated fade'>$msg</div>"; + } elseif( is_site_admin() ) { + echo "<div id='update-nag'>Your feed at " . wp_specialchars( $url ) . " is empty.</div>"; + } +} +add_action( 'admin_notices', 'admin_notice_feed' ); ?> |