[wp-trac] [WordPress Trac] #35791: WP_Site_Query class
WordPress Trac
noreply at wordpress.org
Fri Apr 15 19:40:20 UTC 2016
#35791: WP_Site_Query class
-------------------------------------+------------------------
Reporter: spacedmonkey | Owner:
Type: task (blessed) | Status: new
Priority: normal | Milestone: 4.6
Component: Networks and Sites | Version: 4.4
Severity: normal | Resolution:
Keywords: has-patch needs-testing | Focuses: multisite
-------------------------------------+------------------------
Comment (by spacedmonkey):
Something like this is what I had in mind for backwards compatibility
{{{#!php
function wp_get_sites( $args = array(), $output = ARRAY_A ) {
global $wpdb;
$defaults = array(
'network_id' => $wpdb->siteid,
'limit' => 100,
'offset' => 0,
'count' => false,
);
$args = wp_parse_args( $args, $defaults );
$query = new WP_Site_Query();
$_sites = $query->query( $args );
if( !$args['count'] && $output != OBJECT ){
$sites = array();
foreach ( $_sites as $site ) {
if ( $_site = get_site( $site ) ) {
$sites[] = $_site;
}
}
return $sites;
}
return $_sites;
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35791#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list