summaryrefslogtreecommitdiffstatshomepage
path: root/src/wp-includes/ms-functions.php
diff options
context:
space:
mode:
authorJeremy Felt <jeremyfelt@git.wordpress.org>2016-06-01 23:38:40 +0000
committerJeremy Felt <jeremyfelt@git.wordpress.org>2016-06-01 23:38:40 +0000
commitcaf0e9a151cc113f4d365edab8989e67edf3b6a0 (patch)
tree9e5b0b9d37f821dc102f2e33bec789b1efffa5a4 /src/wp-includes/ms-functions.php
parente97e6bce7055b58057300a34cf385037eba9edb8 (diff)
downloadwordpress-caf0e9a151cc113f4d365edab8989e67edf3b6a0.tar.gz
wordpress-caf0e9a151cc113f4d365edab8989e67edf3b6a0.zip
Multisite: Replace `wp_get_sites()` internals with `get_sites()`
`get_sites()` should be considered a replacement for `wp_get_sites()`. Backward compatibility is maintained in the meantime by using `get_site()` to populate the return data with associative arrays rather than `WP_Site` objects. Props spacedmonkey, flixos90. See #35791. git-svn-id: https://develop.svn.wordpress.org/trunk@37617 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'src/wp-includes/ms-functions.php')
-rw-r--r--src/wp-includes/ms-functions.php39
1 files changed, 15 insertions, 24 deletions
diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php
index 2e17efe5f3..84a4063488 100644
--- a/src/wp-includes/ms-functions.php
+++ b/src/wp-includes/ms-functions.php
@@ -2447,38 +2447,29 @@ function wp_get_sites( $args = array() ) {
$args = wp_parse_args( $args, $defaults );
- $query = "SELECT * FROM $wpdb->blogs WHERE 1=1 ";
-
- if ( isset( $args['network_id'] ) && ( is_array( $args['network_id'] ) || is_numeric( $args['network_id'] ) ) ) {
- $network_ids = implode( ',', wp_parse_id_list( $args['network_id'] ) );
- $query .= "AND site_id IN ($network_ids) ";
+ // Backwards compatibility
+ if( is_array( $args['network_id'] ) ){
+ $args['network__in'] = $args['network_id'];
+ $args['network_id'] = null;
}
- if ( isset( $args['public'] ) )
- $query .= $wpdb->prepare( "AND public = %d ", $args['public'] );
-
- if ( isset( $args['archived'] ) )
- $query .= $wpdb->prepare( "AND archived = %d ", $args['archived'] );
+ if( is_numeric( $args['limit'] ) ){
+ $args['number'] = $args['limit'];
+ $args['limit'] = null;
+ }
- if ( isset( $args['mature'] ) )
- $query .= $wpdb->prepare( "AND mature = %d ", $args['mature'] );
+ // Make sure count is disabled.
+ $args['count'] = false;
- if ( isset( $args['spam'] ) )
- $query .= $wpdb->prepare( "AND spam = %d ", $args['spam'] );
+ $_sites = get_sites( $args );
- if ( isset( $args['deleted'] ) )
- $query .= $wpdb->prepare( "AND deleted = %d ", $args['deleted'] );
+ $results = array();
- if ( isset( $args['limit'] ) && $args['limit'] ) {
- if ( isset( $args['offset'] ) && $args['offset'] )
- $query .= $wpdb->prepare( "LIMIT %d , %d ", $args['offset'], $args['limit'] );
- else
- $query .= $wpdb->prepare( "LIMIT %d ", $args['limit'] );
+ foreach ( $_sites as $_site ) {
+ $results[] = get_site( $_site, ARRAY_A );
}
- $site_results = $wpdb->get_results( $query, ARRAY_A );
-
- return $site_results;
+ return $results;
}
/**