Changeset 1292

Show
Ignore:
Timestamp:
05/15/08 17:43:29 (4 months ago)
Author:
donncha
Message:

Admin Notice Feed allows the site_admin to display a feed to all blogs on an MU site. Esp. useful for an announcements blog.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/includes/mu.php

    r1271 r1292  
    674674} 
    675675add_action( 'personal_options_update', 'profile_update_primary_blog' ); 
     676 
     677function admin_notice_feed() { 
     678        global $current_user; 
     679        if( substr( $_SERVER[ 'PHP_SELF' ], -19 ) != '/wp-admin/index.php' ) 
     680                return; 
     681 
     682        if( $_GET[ 'feed_dismiss' ] ) 
     683                update_user_option( $current_user->id, 'admin_feed_dismiss', $_GET[ 'feed_dismiss' ], true ); 
     684 
     685        $url = get_site_option( 'admin_notice_feed' ); 
     686        if( $url == '' ) 
     687                return; 
     688        include_once( ABSPATH . 'wp-includes/rss.php' ); 
     689        $rss = @fetch_rss( $url ); 
     690        if( isset($rss->items) && 1 <= count($rss->items) ) { 
     691                if( md5( $rss->items[0][ 'title' ] ) == get_user_option( 'admin_feed_dismiss', $current_user->id ) ) 
     692                        return; 
     693                $item = $rss->items[0]; 
     694                $msg = "<h3>" . wp_specialchars( $item[ 'title' ] ) . "</h3>\n"; 
     695                if ( isset($item['description']) ) 
     696                        $content = $item['description']; 
     697                elseif ( isset($item['summary']) ) 
     698                        $content = $item['summary']; 
     699                elseif ( isset($item['atom_content']) ) 
     700                        $content = $item['atom_content']; 
     701                else 
     702                        $content = __( 'something' ); 
     703                $content = wp_html_excerpt($content, 200) . ' ...'; 
     704                $link = clean_url( strip_tags( $item['link'] ) ); 
     705                $msg .= "<p>" . $content . " <a href='$link'>" . __( 'Read More' ) . "</a> <a href='index.php?feed_dismiss=" . md5( $item[ 'title' ] ) . "'>" . __( "Dismiss" ) . "</a></p>"; 
     706                echo "<div class='updated fade'>$msg</div>"; 
     707        } elseif( is_site_admin() ) { 
     708                echo "<div id='update-nag'>Your feed at " . wp_specialchars( $url ) . " is empty.</div>"; 
     709        } 
     710} 
     711add_action( 'admin_notices', 'admin_notice_feed' ); 
    676712?> 
  • trunk/wp-admin/wpmu-edit.php

    r1289 r1292  
    6868                update_site_option( "welcome_email", $_POST['welcome_email'] ); 
    6969                update_site_option( "fileupload_maxk", $_POST['fileupload_maxk'] ); 
     70                update_site_option( "admin_notice_feed", clean_url( $_POST['admin_notice_feed'] ) ); 
    7071 
    7172                $site_admins = explode( ' ', str_replace( ",", " ", $_POST['site_admins'] ) ); 
  • trunk/wp-admin/wpmu-options.php

    r1289 r1292  
    130130                                <th scope="row"><?php _e('Max upload file size') ?></th>  
    131131                                <td><input name="fileupload_maxk" type="text" id="fileupload_maxk" value="<?php echo get_site_option('fileupload_maxk', 300) ?>" size="5" /> KB</td> 
     132                        </tr>  
     133                        <tr valign="top">  
     134                                <th scope="row"><?php _e('Admin Notice Feed') ?></th>  
     135                                <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 /> 
     136                                <?php _e( 'Display the latest post from this RSS or Atom feed on all blog dashboards. Leave blank to disable.' ); ?><br /> 
     137                                <?php if( get_site_option( 'admin_notice_feed' ) != 'http://' . $current_site->domain . $current_site->path . 'feed/' ) 
     138                                        echo __( "A good one to use would be the feed from your main blog: " ) . 'http://' . $current_site->domain . $current_site->path . 'feed/'; ?></td> 
    132139                        </tr>  
    133140                </table>