Make WordPress Core

Ticket #29415: 29415.patch

File 29415.patch, 1.6 KB (added by ethitter, 9 years ago)
  • src/wp-includes/ms-functions.php

     
    23982398        return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count );
    23992399}
    24002400
     2401/**
     2402 * Return array of networks.
     2403 *
     2404 * @since 4.1.0
     2405 *
     2406 * @param array $args {
     2407 *     Array of default arguments. Optional.
     2408 *
     2409 *     @type string    $domain     Domain name of networks to retrieve.
     2410 *     @type string    $path       Path of networks to retrieve.
     2411 *     @type int       $limit      Number of sites to limit the query to. Default 100.
     2412 *     @type int       $offset     Exclude the first x sites. Used in combination with the $limit parameter. Default 0.
     2413 * }
     2414 * @return array Associative array of network data arrays
     2415 */
     2416function wp_get_networks( $args = array() ) {
     2417        global $wpdb;
    24012418
     2419        $defaults = array(
     2420                'domain' => '',
     2421                'path'   => '',
     2422                'limit'  => 100,
     2423                'offset' => 0,
     2424        );
     2425
     2426        $args = wp_parse_args( $args, $defaults );
     2427
     2428        $query = "SELECT * FROM $wpdb->site WHERE 1=1 ";
     2429
     2430        if ( $args['domain'] ) {
     2431                $query .= $wpdb->prepare( "AND domain = '%s' ", $args['domain'] );
     2432        }
     2433
     2434        if ( $args['path'] ) {
     2435                $query .= $wpdb->prepare( "AND path = '%s' ", $args['path'] );
     2436        }
     2437
     2438        if ( $args['limit'] ) {
     2439                if ( $args['offset'] ) {
     2440                        $query .= $wpdb->prepare( "LIMIT %d , %d ", $args['offset'], $args['limit'] );
     2441                } else {
     2442                        $query .= $wpdb->prepare( "LIMIT %d ", $args['limit'] );
     2443                }
     2444        }
     2445
     2446        return $wpdb->get_results( $query, ARRAY_A );
     2447}
     2448
    24022449/**
    24032450 * Return an array of sites for a network or networks.
    24042451 *