Make WordPress Core

Ticket #14511: 14511.3.diff

File 14511.3.diff, 1.9 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 * return all sites, regardless of network.
     1990 *
     1991 * @since 3.7.0
     1992 *
     1993 * @param array|string $args Optional. Specify the status of the sites to return.
     1994 * @return array An array of site data
     1995 */
     1996function wp_get_sites( $args = array() ) {
     1997        global $wpdb;
     1998
     1999        if ( wp_is_large_network() )
     2000                return;
     2001
     2002        $defaults = array( 'network_id' => null );
     2003
     2004        $args = wp_parse_args( $args, $defaults );
     2005
     2006        $query = "SELECT * FROM $wpdb->blogs WHERE 1=1 ";
     2007
     2008        if ( isset( $args['network_id'] ) && ( is_array( $args['network_id'] ) || is_numeric( $args['network_id'] ) ) ) {
     2009                $network_ids = array_map('intval', (array) $args['network_id'] );
     2010                $network_ids = implode( ',', $network_ids );
     2011                $query .= "AND site_id IN ($network_ids) ";
     2012        }
     2013
     2014        if ( isset( $args['public'] ) )
     2015                $query .= $wpdb->prepare( "AND public = %s ", $args['public'] );
     2016
     2017        if ( isset( $args['archived'] ) )
     2018                $query .= $wpdb->prepare( "AND archived = %s ", $args['archived'] );
     2019
     2020        if ( isset( $args['mature'] ) )
     2021                $query .= $wpdb->prepare( "AND mature = %s ", $args['mature'] );
     2022
     2023        if ( isset( $args['spam'] ) )
     2024                $query .= $wpdb->prepare( "AND spam = %s ", $args['spam'] );
     2025
     2026        if ( isset( $args['deleted'] ) )
     2027                $query .= $wpdb->prepare( "AND deleted = %s ", $args['deleted'] );
     2028
     2029        $key = 'wp_get_sites:' . md5( $query );
     2030
     2031        if ( ! $site_results = wp_cache_get( $key, 'site-id-cache' ) ) {
     2032                $site_results = (array) $wpdb->get_results( $query );
     2033                wp_cache_set( $key, $site_results, 'site-id-cache' );
     2034        }
     2035
     2036        return $site_results;
     2037}