Multisite: Simplify logic assigning orderby in get_site_by_path().

Before [37628], there were 3 separate conditions for ordering by domain and/or path in `get_site_by_path()` that each resulted in it's own query. Now that `get_sites()` is used and supports `WP_Site_Query`, this can be simplified.

Props spacedmonkey.
Fixes #37215.

Built from https://develop.svn.wordpress.org/trunk@37930


git-svn-id: http://core.svn.wordpress.org/trunk@37871 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Jeremy Felt 2016-06-30 16:59:29 +00:00
parent f4d46f0235
commit 4789f30c40
2 changed files with 7 additions and 10 deletions

View File

@ -239,15 +239,12 @@ function get_site_by_path( $domain, $path, $segments = null ) {
'number' => 1,
);
if ( count( $domains ) > 1 && count( $paths ) > 1 ) {
$args['orderby'] = 'domain_length path_length';
$args['order'] = 'DESC DESC';
} elseif ( count( $domains ) > 1 ) {
$args['orderby'] = 'domain_length';
$args['order'] = 'DESC';
} elseif ( count( $paths ) > 1 ) {
$args['orderby'] = 'path_length';
$args['order'] = 'DESC';
if ( count( $domains ) > 1 ) {
$args['orderby']['domain_length'] = 'DESC';
}
if ( count( $paths ) > 1 ) {
$args['orderby']['path_length'] = 'DESC';
}
$result = get_sites( $args );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.6-beta1-37929';
$wp_version = '4.6-beta1-37930';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.