From df344773089004477910f60e19ae2a9f67ad0894 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 19 Sep 2013 01:47:09 +0000 Subject: [PATCH] Introduce 'offset' parameter for wp_get_sites(). props jamescollins. see #14511. Built from https://develop.svn.wordpress.org/trunk@25488 git-svn-id: http://core.svn.wordpress.org/trunk@25409 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/ms-functions.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index fb60dd9ae5..c46e4b4cb1 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -2007,6 +2007,7 @@ function wp_is_large_network( $using = 'sites' ) { * @type int 'spam' Retrieve spam or non-spam sites. Default null, for any. * @type int 'deleted' Retrieve deleted or non-deleted sites. Default null, for any. * @type int 'limit' Number of sites to limit the query to. Default 100. + * @type int 'offset' Exclude the first x sites. Used in combination with the limit parameter. Default 0. * } * * @return array An array of site data @@ -2025,6 +2026,7 @@ function wp_get_sites( $args = array() ) { 'spam' => null, 'deleted' => null, 'limit' => 100, + 'offset' => 0, ); $args = wp_parse_args( $args, $defaults ); @@ -2051,8 +2053,12 @@ function wp_get_sites( $args = array() ) { if ( isset( $args['deleted'] ) ) $query .= $wpdb->prepare( "AND deleted = %d ", $args['deleted'] ); - if ( isset( $args['limit'] ) ) - $query .= $wpdb->prepare( "LIMIT %d ", $args['limit'] ); + 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'] ); + } $site_results = $wpdb->get_results( $query, ARRAY_A );