From 229e0d5300fe6b3c119a433414bde34f3dae99c0 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Thu, 30 Jun 2016 16:58:06 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@37930 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/ms-load.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/wp-includes/ms-load.php b/src/wp-includes/ms-load.php index afacfe0077..536dfb57a5 100644 --- a/src/wp-includes/ms-load.php +++ b/src/wp-includes/ms-load.php @@ -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 );