WordPress.org

Make WordPress Core

Ticket #13773: for_frumph.patch

File for_frumph.patch, 2.5 KB (added by ocean90, 8 years ago)
  • wp-includes/ms-deprecated.php

     
    151151/**
    152152 * @since MU
    153153 * @deprecated 3.0.0
     154 * @deprecated Don't use this, really.
    154155 */
    155156function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) {
    156         _deprecated_function( __FUNCTION__, '3.0' );
    157         return 0;
     157        _deprecated_function( __FUNCTION__, '3.0', "Don't use this, really." );
     158
     159        global $wpdb;
     160        $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 );
     161
     162        foreach ( (array) $blogs as $details ) {
     163                $blog_list[ $details['blog_id'] ] = $details;
     164                $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'" );
     165        }
     166        unset( $blogs );
     167        $blogs = $blog_list;
     168
     169        if ( false == is_array( $blogs ) )
     170                return array();
     171
     172        if ( $num == 'all' )
     173                return array_slice( $blogs, $start, count( $blogs ) );
     174        else
     175                return array_slice( $blogs, $start, $num );
    158176}
    159177
    160178/**
    161179 * @since MU
    162180 * @deprecated 3.0.0
     181 * @deprecated Don't use this, really.
    163182 */
    164183function get_most_active_blogs( $num = 10, $display = true ) {
    165         _deprecated_function( __FUNCTION__, '3.0' );
    166         return 0;
     184        _deprecated_function( __FUNCTION__, '3.0', "Don't use this, really." );
     185
     186        $blogs = get_blog_list( 0, 'all', false ); // $blog_id -> $details
     187        if ( is_array( $blogs ) ) {
     188                reset( $blogs );
     189                foreach ( (array) $blogs as $key => $details ) {
     190                        $most_active[ $details['blog_id'] ] = $details['postcount'];
     191                        $blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!!
     192                }
     193                arsort( $most_active );
     194                reset( $most_active );
     195                foreach ( (array) $most_active as $key => $details )
     196                        $t[ $key ] = $blog_list[ $key ];
     197
     198                unset( $most_active );
     199                $most_active = $t;
     200        }
     201
     202        if ( $display == true ) {
     203                if ( is_array( $most_active ) ) {
     204                        reset( $most_active );
     205                        foreach ( (array) $most_active as $key => $details ) {
     206                                $url = esc_url('http://' . $details['domain'] . $details['path']);
     207                                echo '<li>' . $details['postcount'] . " <a href='$url'>$url</a></li>";
     208                        }
     209                }
     210        }
     211        return array_slice( $most_active, 0, $num );
    167212}
    168213?>