WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/08/2016 03:02:34 AM (3 years ago)
Author:
jeremyfelt
Message:

Multisite: Deprecate wp_get_sites()

Defer to the new get_sites() replacement, offering fresh (...or cached) WP_Site objects via the new WP_Site_Query.

Props flixos90.
Fixes #36994.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-functions.php

    r37652 r37653  
    24252425}
    24262426
    2427 
    2428 /**
    2429  * Return an array of sites for a network or networks.
    2430  *
    2431  * @since 3.7.0
    2432  *
    2433  * @global wpdb $wpdb WordPress database abstraction object.
    2434  *
    2435  * @param array $args {
    2436  *     Array of default arguments. Optional.
    2437  *
    2438  *     @type int|array $network_id A network ID or array of network IDs. Set to null to retrieve sites
    2439  *                                 from all networks. Defaults to current network ID.
    2440  *     @type int       $public     Retrieve public or non-public sites. Default null, for any.
    2441  *     @type int       $archived   Retrieve archived or non-archived sites. Default null, for any.
    2442  *     @type int       $mature     Retrieve mature or non-mature sites. Default null, for any.
    2443  *     @type int       $spam       Retrieve spam or non-spam sites. Default null, for any.
    2444  *     @type int       $deleted    Retrieve deleted or non-deleted sites. Default null, for any.
    2445  *     @type int       $limit      Number of sites to limit the query to. Default 100.
    2446  *     @type int       $offset     Exclude the first x sites. Used in combination with the $limit parameter. Default 0.
    2447  * }
    2448  * @return array An empty array if the install is considered "large" via wp_is_large_network(). Otherwise,
    2449  *               an associative array of site data arrays, each containing the site (network) ID, blog ID,
    2450  *               site domain and path, dates registered and modified, and the language ID. Also, boolean
    2451  *               values for whether the site is public, archived, mature, spam, and/or deleted.
    2452  */
    2453 function wp_get_sites( $args = array() ) {
    2454     global $wpdb;
    2455 
    2456     if ( wp_is_large_network() )
    2457         return array();
    2458 
    2459     $defaults = array(
    2460         'network_id' => $wpdb->siteid,
    2461         'public'     => null,
    2462         'archived'   => null,
    2463         'mature'     => null,
    2464         'spam'       => null,
    2465         'deleted'    => null,
    2466         'limit'      => 100,
    2467         'offset'     => 0,
    2468     );
    2469 
    2470     $args = wp_parse_args( $args, $defaults );
    2471 
    2472     // Backwards compatibility
    2473     if( is_array( $args['network_id'] ) ){
    2474         $args['network__in'] = $args['network_id'];
    2475         $args['network_id'] = null;
    2476     }
    2477 
    2478     if( is_numeric( $args['limit'] ) ){
    2479         $args['number'] = $args['limit'];
    2480         $args['limit'] = null;
    2481     }
    2482 
    2483     // Make sure count is disabled.
    2484     $args['count'] = false;
    2485 
    2486     $_sites  = get_sites( $args );
    2487 
    2488     $results = array();
    2489 
    2490     foreach ( $_sites as $_site ) {
    2491         $results[] = (array) get_site( $_site );
    2492     }
    2493 
    2494     return $results;
    2495 }
    2496 
    24972427/**
    24982428 * Retrieves a list of reserved site on a sub-directory Multisite install.
Note: See TracChangeset for help on using the changeset viewer.