Make WordPress Core

Ticket #42091: 42091.diff

File 42091.diff, 985 bytes (added by jeremyfelt, 7 years ago)
  • src/wp-includes/ms-blogs.php

     
    7979 * @return int|null The site ID, or null if no site is found for the given slug.
    8080 */
    8181function get_id_from_blogname( $slug ) {
    82         $current_network = get_network();
    83         $slug = trim( $slug, '/' );
     82        $result = get_site_by( 'slug', $slug );
    8483
    85         if ( is_subdomain_install() ) {
    86                 $domain = $slug . '.' . preg_replace( '|^www\.|', '', $current_network->domain );
    87                 $path = $current_network->path;
    88         } else {
    89                 $domain = $current_network->domain;
    90                 $path = $current_network->path . $slug . '/';
    91         }
    92 
    93         $site_ids = get_sites( array(
    94                 'number' => 1,
    95                 'fields' => 'ids',
    96                 'domain' => $domain,
    97                 'path' => $path,
    98         ) );
    99 
    100         if ( empty( $site_ids ) ) {
     84        if ( ! $result ) {
    10185                return null;
    10286        }
    10387
    104         return array_shift( $site_ids );
     88        return $result->id;
    10589}
    10690
    10791/**