Make WordPress Core

Ticket #15828: 15828.patch

File 15828.patch, 1.1 KB (added by jakub.tyrcha, 13 years ago)
  • wp-includes/user.php

     
    648648 * @param bool $all Whether to retrieve all blogs or only blogs that are not marked as deleted, archived, or spam.
    649649 * @return array A list of the user's blogs. False if the user was not found or an empty array if the user has no blogs.
    650650 */
    651 function get_blogs_of_user( $id, $all = false ) {
     651function get_blogs_of_user( $id, $all = false, $order_by = false ) {
    652652        global $wpdb;
    653653
    654654        if ( !is_multisite() ) {
     
    710710                        $blog_deets[ $blog_id ]->siteurl                = $blog->siteurl;
    711711                }
    712712        }
     713       
     714        if( false !== $order_by && in_array( $order_by, array( 'userblog_id', 'blogname', 'domain', 'path', 'site_id', 'siteurl' ) ) ) {
     715                function bloglist_compare( $a, $b ){
     716                        if ( $a->$order_by == $b->$order_by )
     717                                return 0;
     718                        else
     719                                return ( $a->$order_by < $b->$order_by ) ? -1 : 1;
     720                }
     721                uasort($blog_deets, 'bloglist_compare');
     722        }
    713723
    714724        return apply_filters( 'get_blogs_of_user', $blog_deets, $id, $all );
    715725}