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 | |
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
-rw-r--r-- | wp-admin/includes/mu.php | 36 | ||||
-rw-r--r-- | wp-admin/wpmu-edit.php | 1 | ||||
-rw-r--r-- | wp-admin/wpmu-options.php | 7 |
3 files changed, 44 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' ); ?> 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'])) { <th scope="row"><?php _e('Max upload file size') ?></th> <td><input name="fileupload_maxk" type="text" id="fileupload_maxk" value="<?php echo get_site_option('fileupload_maxk', 300) ?>" size="5" /> KB</td> </tr> + <tr valign="top"> + <th scope="row"><?php _e('Admin Notice Feed') ?></th> + <td><input name="admin_notice_feed" style="width: 95%" type="text" id="admin_notice_feed" value="<?php echo get_site_option( 'admin_notice_feed' ) ?>" size="80" /><br /> + <?php _e( 'Display the latest post from this RSS or Atom feed on all blog dashboards. Leave blank to disable.' ); ?><br /> + <?php if( get_site_option( 'admin_notice_feed' ) != 'http://' . $current_site->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/'; ?></td> + </tr> </table> <h3><?php _e('Administration Settings') ?></h3> |