Changeset 37628
- Timestamp:
- 06/02/2016 09:45:20 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ms-load.php
r37518 r37628 155 155 * 156 156 * @since 3.9.0 157 * @since 4.6.0 Converted to use get_sites() 157 158 * 158 159 * @global wpdb $wpdb WordPress database abstraction object. … … 164 165 */ 165 166 function get_site_by_path( $domain, $path, $segments = null ) { 166 global $wpdb;167 168 167 $path_segments = array_filter( explode( '/', trim( $path, '/' ) ) ); 169 168 … … 232 231 if ( 'www.' === substr( $domain, 0, 4 ) ) { 233 232 $domains[] = substr( $domain, 4 ); 234 $search_domains = "'" . implode( "', '", $wpdb->_escape( $domains ) ) . "'"; 235 } 236 237 if ( count( $paths ) > 1 ) { 238 $search_paths = "'" . implode( "', '", $wpdb->_escape( $paths ) ) . "'"; 239 } 233 } 234 235 $args = array( 236 'domain__in' => $domains, 237 'path__in' => $paths, 238 'number' => 1, 239 ); 240 240 241 241 if ( count( $domains ) > 1 && count( $paths ) > 1 ) { 242 $site = $wpdb->get_row( "SELECT * FROM $wpdb->blogs WHERE domain IN ($search_domains) AND path IN ($search_paths) ORDER BY CHAR_LENGTH(domain) DESC, CHAR_LENGTH(path) DESC LIMIT 1" ); 242 $args['orderby'] = 'domain_length path_length'; 243 $args['order'] = 'DESC DESC'; 243 244 } elseif ( count( $domains ) > 1 ) { 244 $sql = $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE path = %s", $paths[0] ); 245 $sql .= " AND domain IN ($search_domains) ORDER BY CHAR_LENGTH(domain) DESC LIMIT 1"; 246 $site = $wpdb->get_row( $sql ); 245 $args['orderby'] = 'domain_length'; 246 $args['order'] = 'DESC'; 247 247 } elseif ( count( $paths ) > 1 ) { 248 $ sql = $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $domains[0] );249 $ sql .= " AND path IN ($search_paths) ORDER BY CHAR_LENGTH(path) DESC LIMIT 1";250 $site = $wpdb->get_row( $sql );251 } else { 252 $site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $domains[0], $paths[0] ));253 }248 $args['orderby'] = 'path_length'; 249 $args['order'] = 'DESC'; 250 } 251 252 $result = get_sites( $args ); 253 $site = array_shift( $result ); 254 254 255 255 if ( $site ) {
Note: See TracChangeset
for help on using the changeset viewer.