Error message

Deprecated function: Function ereg_replace() is deprecated in _simpleblogroll_set_feeds() (line 287 of /home/agerson/agerson.net/sites/all/modules/simpleblogroll/simpleblogroll.module).

Wordpress Multi-Site (WPMU): Adding a custom post counter dashboard widget on the "Network Admin" page



  <?php
  add_action
('wp_network_dashboard_setup''my_custom_network_dashboard_widgets');

  function 
my_custom_network_dashboard_widgets() {
    global 
$wp_meta_boxes;
    
wp_add_dashboard_widget('custom_mu_post_count_widget''MU Post Counter'
      
'mu_post_count_widget');
  }

  function 
mu_post_count_widget() {
    global 
$wpdb;
    
$wpdb->show_errors();
    
$res $wpdb->get_results('select blog_id from wp_blogs'ARRAY_A);
    
$total 0;
    foreach (
$res as $result) {
       
$wpdb->set_blog_id($result['blog_id']);
       
$sql ="
         SELECT $wpdb->options.option_value, 
           count($wpdb->posts.id) as countofposts, 
           max($wpdb->posts.post_modified) as maxdate 
         FROM $wpdb->posts, $wpdb->options 
         WHERE $wpdb->posts.post_status = 'publish' 
         AND $wpdb->options.option_name = 'blogname'
         AND $wpdb->posts.post_type = 'post' 
       "
;   
       
$pageposts $wpdb->get_results($sql);
       foreach ( 
$pageposts as $pagepost ) {
           echo 
$pagepost->option_value.",";
           echo 
$pagepost->maxdate.",";
           echo 
$pagepost->countofposts."<br>";
       }
    }
  }
?>
© 2011 Adam Gerson.