get_most_active_blogs

Deprecated functionality to retrieve a list of the most active sites.

Description

(array) get_most_active_blogs( (int) $num = 10, (bool) $display = true ); 

Returns (array)

List of "most active" sites.

Parameters (2)

0. $num — Optional. (int) => 10
Number of activate blogs to retrieve. Default 10.
1. $display — Optional. (bool) => true
Whether or not to display the most active blogs list. Default true.

Usage

  1. if ( !function_exists( 'get_most_active_blogs' ) ) { 
  2. require_once ABSPATH . WPINC . '/ms-deprecated.php'; 
  3.  
  4. // Optional. Number of activate blogs to retrieve. Default 10. 
  5. $num = 10; 
  6.  
  7. // Optional. Whether or not to display the most active blogs list. Default true. 
  8. $display = true; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = get_most_active_blogs($num, $display); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/ms-deprecated.php  
  1. function get_most_active_blogs( $num = 10, $display = true ) { 
  2. _deprecated_function( __FUNCTION__, '3.0.0' ); 
  3.  
  4. $blogs = get_blog_list( 0, 'all', false ); // $blog_id -> $details 
  5. if ( is_array( $blogs ) ) { 
  6. reset( $blogs ); 
  7. $most_active = array(); 
  8. $blog_list = array(); 
  9. foreach ( (array) $blogs as $key => $details ) { 
  10. $most_active[ $details['blog_id'] ] = $details['postcount']; 
  11. $blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!! 
  12. arsort( $most_active ); 
  13. reset( $most_active ); 
  14. $t = array(); 
  15. foreach ( (array) $most_active as $key => $details ) { 
  16. $t[ $key ] = $blog_list[ $key ]; 
  17. unset( $most_active ); 
  18. $most_active = $t; 
  19.  
  20. if ( $display ) { 
  21. if ( is_array( $most_active ) ) { 
  22. reset( $most_active ); 
  23. foreach ( (array) $most_active as $key => $details ) { 
  24. $url = esc_url('http://' . $details['domain'] . $details['path']); 
  25. echo '<li>' . $details['postcount'] . " <a href='$url'>$url</a></li>"; 
  26. return array_slice( $most_active, 0, $num );