Make WordPress Core

Ticket #14511: 14511.diff

File 14511.diff, 1.5 KB (added by jeremyfelt, 12 years ago)
  • src/wp-includes/ms-functions.php

     
    19831983        $count = get_blog_count();
    19841984        return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count );
    19851985}
     1986
     1987/**
     1988 * Return an array of sites on the specified network. If no network is specified,
     1989 * use the current network.
     1990 *
     1991 * @since 3.7.0
     1992 *
     1993 * @param int $network_id Optional. The id for the network of sites being retrieved.
     1994 * @param array|string $args Optional. Specify the status of the sites to return.
     1995 * @return array An array of site data containing blog_id, domain, and path for each site.
     1996 */
     1997function wp_get_sites( $network_id = null, $args = array() ) {
     1998        global $wpdb;
     1999
     2000        if( null === $network_id )
     2001                $network_id = get_current_site()->id;
     2002
     2003        $defaults = array(
     2004                'public'        => '1',
     2005                'archived'      => '0',
     2006                'mature'        => '0',
     2007                'spam'          => '0',
     2008                'deleted'       => '0',
     2009        );
     2010
     2011        $args = wp_parse_args( $args, $defaults );
     2012
     2013        $site_results = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, domain, path FROM $wpdb->blogs
     2014                WHERE site_id = %d AND public = %s AND archived = %s AND mature = %s AND spam = %s AND deleted = %s",
     2015                $network_id, $args['public'], $args['archived'], $args['mature'], $args['spam'], $args['deleted'] ) );
     2016
     2017        $sites = Array();
     2018
     2019        foreach ( $site_results as $site ) {
     2020                $sites[ $site->blog_id ] = $site;
     2021        }
     2022
     2023        return $sites;
     2024}