Make WordPress Core

Changeset 37616


Ignore:
Timestamp:
06/01/2016 11:20:39 PM (9 years ago)
Author:
jeremyfelt
Message:

Multisite: Introduce get_sites()

get_sites() is a wrapper for WP_Site_Query.

Props spacedmonkey, DrewAPicture.
See #35791.

File:
1 edited

Legend:

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

    r37613 r37616  
    562562
    563563/**
     564 * Retrieves a list of sites matching requested arguments.
     565 *
     566 * @since 4.6.0
     567 *
     568 * @see WP_Site_Query::parse_query()
     569 *
     570 * @param string|array $args {
     571 *     Optional. Array or query string of site query parameters. Default empty.
     572 *
     573 *     @type array        $site__in          Array of site IDs to include. Default empty.
     574 *     @type array        $site__not_in      Array of site IDs to exclude. Default empty.
     575 *     @type bool         $count             Whether to return a site count (true) or array of site objects.
     576 *                                           Default false.
     577 *     @type array        $date_query        Date query clauses to limit sites by. See WP_Date_Query.
     578 *                                           Default null.
     579 *     @type string       $fields            Site fields to return. Accepts 'ids' for site IDs only or empty
     580 *                                           for all fields. Default empty.
     581 *     @type int          $ID                A site ID to only return that site. Default empty.
     582 *     @type int          $number            Maximum number of sites to retrieve. Default null (no limit).
     583 *     @type int          $offset            Number of sites to offset the query. Used to build LIMIT clause.
     584 *                                           Default 0.
     585 *     @type bool         $no_found_rows     Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true.
     586 *     @type string|array $orderby           Site status or array of statuses. Accepts 'id', 'domain', 'path',
     587 *                                           'network_id', 'last_updated', 'registered', 'domain_length',
     588 *                                           'path_length', 'site__in' and 'network__in'. Also accepts false,
     589 *                                           an empty array, or 'none' to disable `ORDER BY` clause.
     590 *                                           Default 'id'.
     591 *     @type string       $order             How to order retrieved sites. Accepts 'ASC', 'DESC'. Default 'ASC'.
     592 *     @type int          $network_id        Limit results to those affiliated with a given network ID.
     593 *                                           Default current network ID.
     594 *     @type array        $network__in       Array of network IDs to include affiliated sites for. Default empty.
     595 *     @type array        $network__not_in   Array of network IDs to exclude affiliated sites for. Default empty.
     596 *     @type string       $domain            Limit results to those affiliated with a given domain.
     597 *                                           Default empty.
     598 *     @type array        $domain__in        Array of domains to include affiliated sites for. Default empty.
     599 *     @type array        $domain__not_in    Array of domains to exclude affiliated sites for. Default empty.
     600 *     @type string       $path              Limit results to those affiliated with a given path.
     601 *                                           Default empty.
     602 *     @type array        $path__in          Array of paths to include affiliated sites for. Default empty.
     603 *     @type array        $path__not_in      Array of paths to exclude affiliated sites for. Default empty.
     604 *     @type int          $public            Limit results to public sites. Accepts '1' or '0'. Default empty.
     605 *     @type int          $archived          Limit results to archived sites. Accepts '1' or '0'. Default empty.
     606 *     @type int          $mature            Limit results to mature sites. Accepts '1' or '0'. Default empty.
     607 *     @type int          $spam              Limit results to spam sites. Accepts '1' or '0'. Default empty.
     608 *     @type int          $deleted           Limit results to deleted sites. Accepts '1' or '0'. Default empty.
     609 *     @type string       $search            Search term(s) to retrieve matching sites for. Default empty.
     610 *     @type bool         $update_site_cache Whether to prime the cache for found sites. Default false.
     611 * }
     612 * @return array List of sites.
     613 */
     614function get_sites( $args = array() ) {
     615    $query = new WP_Site_Query();
     616
     617    return $query->query( $args );
     618}
     619
     620/**
    564621 * Retrieve option value for a given blog id based on name of option.
    565622 *
Note: See TracChangeset for help on using the changeset viewer.