Ticket #31148: 31148.diff
File 31148.diff, 5.6 KB (added by , 9 years ago) |
---|
-
wp-includes/ms-functions.php
2364 2364 * @param array $args { 2365 2365 * Array of default arguments. Optional. 2366 2366 * 2367 * @type int|array $network_id A network ID or array of network IDs. Set to null to retrieve sites 2368 * from all networks. Defaults to current network ID. 2369 * @type int $public Retrieve public or non-public sites. Default null, for any. 2370 * @type int $archived Retrieve archived or non-archived sites. Default null, for any. 2371 * @type int $mature Retrieve mature or non-mature sites. Default null, for any. 2372 * @type int $spam Retrieve spam or non-spam sites. Default null, for any. 2373 * @type int $deleted Retrieve deleted or non-deleted sites. Default null, for any. 2374 * @type int $limit Number of sites to limit the query to. Default 100. 2375 * @type int $offset Exclude the first x sites. Used in combination with the $limit parameter. Default 0. 2367 * @type bool $large_networks Allow searches for sites on large networks. Default false. 2368 * @type int|array $network_id A network ID or array of network IDs. Set to null to retrieve sites 2369 * from all networks. Defaults to current network ID. 2370 * @type string $domain Retrieve sites with a specific domain. Default null, for any. 2371 * @type string $path Retrieve sites with a specific path. Default null, for any. 2372 * @type int $public Retrieve public or non-public sites. Default null, for any. 2373 * @type int $archived Retrieve archived or non-archived sites. Default null, for any. 2374 * @type int $mature Retrieve mature or non-mature sites. Default null, for any. 2375 * @type int $spam Retrieve spam or non-spam sites. Default null, for any. 2376 * @type int $deleted Retrieve deleted or non-deleted sites. Default null, for any. 2377 * @type int $limit Number of sites to limit the query to. Default 100. 2378 * @type int $offset Exclude the first x sites. Used in combination with the $limit parameter. Default 0. 2376 2379 * } 2377 * @return array An empty array if the install is considered "large" via wp_is_large_network() . Otherwise,2378 * a n associative array of site data arrays, each containing the site (network) ID, blog ID,2379 * site domain and path, dates registered and modified, and the language ID. Also, boolean2380 * values for whether the site is public, archived, mature, spam, and/or deleted.2380 * @return array An empty array if the install is considered "large" via wp_is_large_network() and the large_network 2381 * argument is set to false. Otherwise, an associative array of site data arrays, each containing the 2382 * site (network) ID, blog ID, site domain and path, dates registered and modified, and the language ID. 2383 * Also, boolean values for whether the site is public, archived, mature, spam, and/or deleted. 2381 2384 */ 2382 2385 function wp_get_sites( $args = array() ) { 2383 2386 global $wpdb; 2384 2387 2385 if ( wp_is_large_network() )2386 return array();2387 2388 2388 $defaults = array( 2389 'network_id' => $wpdb->siteid, 2390 'public' => null, 2391 'archived' => null, 2392 'mature' => null, 2393 'spam' => null, 2394 'deleted' => null, 2395 'limit' => 100, 2396 'offset' => 0, 2389 'large_networks' => false, 2390 'network_id' => $wpdb->siteid, 2391 'domain' => null, 2392 'path' => null, 2393 'public' => null, 2394 'archived' => null, 2395 'mature' => null, 2396 'spam' => null, 2397 'deleted' => null, 2398 'limit' => 100, 2399 'offset' => 0, 2397 2400 ); 2398 2401 2399 2402 $args = wp_parse_args( $args, $defaults ); 2400 2403 2404 if ( ! $args['large_networks'] && wp_is_large_network() ) { 2405 return array(); 2406 } 2407 2401 2408 $query = "SELECT * FROM $wpdb->blogs WHERE 1=1 "; 2402 2409 2403 2410 if ( isset( $args['network_id'] ) && ( is_array( $args['network_id'] ) || is_numeric( $args['network_id'] ) ) ) { … … 2405 2412 $query .= "AND site_id IN ($network_ids) "; 2406 2413 } 2407 2414 2408 if ( isset( $args['public'] ) ) 2415 if ( isset( $args['domain'] ) ) { 2416 $query .= $wpdb->prepare( "AND domain = %s ", $args['domain'] ); 2417 } 2418 2419 if ( isset( $args['path'] ) ) { 2420 $query .= $wpdb->prepare( "AND path = %s ", $args['path'] ); 2421 } 2422 2423 if ( isset( $args['public'] ) ) { 2409 2424 $query .= $wpdb->prepare( "AND public = %d ", $args['public'] ); 2425 } 2410 2426 2411 if ( isset( $args['archived'] ) ) 2427 if ( isset( $args['archived'] ) ) { 2412 2428 $query .= $wpdb->prepare( "AND archived = %d ", $args['archived'] ); 2429 } 2413 2430 2414 if ( isset( $args['mature'] ) ) 2431 if ( isset( $args['mature'] ) ) { 2415 2432 $query .= $wpdb->prepare( "AND mature = %d ", $args['mature'] ); 2433 } 2416 2434 2417 if ( isset( $args['spam'] ) ) 2435 if ( isset( $args['spam'] ) ) { 2418 2436 $query .= $wpdb->prepare( "AND spam = %d ", $args['spam'] ); 2437 } 2419 2438 2420 if ( isset( $args['deleted'] ) ) 2439 if ( isset( $args['deleted'] ) ) { 2421 2440 $query .= $wpdb->prepare( "AND deleted = %d ", $args['deleted'] ); 2441 } 2422 2442 2423 2443 if ( isset( $args['limit'] ) && $args['limit'] ) { 2424 if ( isset( $args['offset'] ) && $args['offset'] ) 2444 if ( isset( $args['offset'] ) && $args['offset'] ) { 2425 2445 $query .= $wpdb->prepare( "LIMIT %d , %d ", $args['offset'], $args['limit'] ); 2426 else2446 } else { 2427 2447 $query .= $wpdb->prepare( "LIMIT %d ", $args['limit'] ); 2448 } 2428 2449 } 2429 2450 2430 2451 $site_results = $wpdb->get_results( $query, ARRAY_A );