From 6eac4cdfd4ce70d0a2cbb37ab9369b0f8b6dfc48 Mon Sep 17 00:00:00 2001 From: donncha Date: Thu, 15 May 2008 17:43:29 +0000 Subject: 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 --- wp-admin/includes/mu.php | 36 ++++++++++++++++++++++++++++++++++++ wp-admin/wpmu-edit.php | 1 + wp-admin/wpmu-options.php | 7 +++++++ 3 files changed, 44 insertions(+) (limited to 'wp-admin') 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 = "

" . wp_specialchars( $item[ 'title' ] ) . "

\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 .= "

" . $content . " " . __( 'Read More' ) . " " . __( "Dismiss" ) . "

"; + echo "
$msg
"; + } elseif( is_site_admin() ) { + echo "
Your feed at " . wp_specialchars( $url ) . " is empty.
"; + } +} +add_action( 'admin_notices', 'admin_notice_feed' ); ?> diff --git a/wp-admin/wpmu-edit.php b/wp-admin/wpmu-edit.php index 173286f..baec3a3 100644 --- a/wp-admin/wpmu-edit.php +++ b/wp-admin/wpmu-edit.php @@ -67,6 +67,7 @@ switch( $_GET['action'] ) { update_site_option( "first_post", $_POST['first_post'] ); update_site_option( "welcome_email", $_POST['welcome_email'] ); update_site_option( "fileupload_maxk", $_POST['fileupload_maxk'] ); + update_site_option( "admin_notice_feed", clean_url( $_POST['admin_notice_feed'] ) ); $site_admins = explode( ' ', str_replace( ",", " ", $_POST['site_admins'] ) ); if ( is_array( $site_admins ) ) { diff --git a/wp-admin/wpmu-options.php b/wp-admin/wpmu-options.php index 6466071..720c100 100644 --- a/wp-admin/wpmu-options.php +++ b/wp-admin/wpmu-options.php @@ -130,6 +130,13 @@ if (isset($_GET['updated'])) { KB + + +
+
+ domain . $current_site->path . 'feed/' ) + echo __( "A good one to use would be the feed from your main blog: " ) . 'http://' . $current_site->domain . $current_site->path . 'feed/'; ?> +

-- cgit