From ce41df6dd667fbe00aea9385bcf2929589948ff2 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 8 Jun 2010 13:56:20 +0000 Subject: [PATCH] Resurrect get_blog_list() and get_most_active_blogs() but leave deprecated. Props ocean90. fixes #13773 git-svn-id: https://develop.svn.wordpress.org/trunk@15170 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/ms-deprecated.php | 53 ++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/wp-includes/ms-deprecated.php b/wp-includes/ms-deprecated.php index 291362945a..8436426b14 100644 --- a/wp-includes/ms-deprecated.php +++ b/wp-includes/ms-deprecated.php @@ -151,18 +151,63 @@ function validate_email( $email, $check_domain = true) { /** * @since MU * @deprecated 3.0.0 + * @deprecated Don't use this, really. */ function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) { - _deprecated_function( __FUNCTION__, '3.0' ); - return 0; + _deprecated_function( __FUNCTION__, '3.0', "Don't use this, really." ); + + global $wpdb; + $blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb->siteid), ARRAY_A ); + + foreach ( (array) $blogs as $details ) { + $blog_list[ $details['blog_id'] ] = $details; + $blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT COUNT(ID) FROM " . $wpdb->get_blog_prefix( $details['blog_id'] ). "posts WHERE post_status='publish' AND post_type='post'" ); + } + unset( $blogs ); + $blogs = $blog_list; + + if ( false == is_array( $blogs ) ) + return array(); + + if ( $num == 'all' ) + return array_slice( $blogs, $start, count( $blogs ) ); + else + return array_slice( $blogs, $start, $num ); } /** * @since MU * @deprecated 3.0.0 + * @deprecated Don't use this, really. */ function get_most_active_blogs( $num = 10, $display = true ) { - _deprecated_function( __FUNCTION__, '3.0' ); - return 0; + _deprecated_function( __FUNCTION__, '3.0', "Don't use this, really." ); + + $blogs = get_blog_list( 0, 'all', false ); // $blog_id -> $details + if ( is_array( $blogs ) ) { + reset( $blogs ); + foreach ( (array) $blogs as $key => $details ) { + $most_active[ $details['blog_id'] ] = $details['postcount']; + $blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!! + } + arsort( $most_active ); + reset( $most_active ); + foreach ( (array) $most_active as $key => $details ) + $t[ $key ] = $blog_list[ $key ]; + + unset( $most_active ); + $most_active = $t; + } + + if ( $display == true ) { + if ( is_array( $most_active ) ) { + reset( $most_active ); + foreach ( (array) $most_active as $key => $details ) { + $url = esc_url('http://' . $details['domain'] . $details['path']); + echo '
  • ' . $details['postcount'] . " $url
  • "; + } + } + } + return array_slice( $most_active, 0, $num ); } ?>