Make WordPress Core

Ticket #20950: 20950.diff

File 20950.diff, 2.2 KB (added by ryan, 11 years ago)

Rename $name to $slug for some clarity.

  • wp-includes/ms-blogs.php

     
    8484}
    8585
    8686/**
    87  * Given a blog's (subdomain or directory) name, retrieve it's id.
     87 * Given a blog's (subdomain or directory) slug, retrieve it's id.
    8888 *
    8989 * @since MU
    9090 *
    91  * @param string $name
     91 * @param string $slug
    9292 * @return int A blog id
    9393 */
    94 function get_id_from_blogname( $name ) {
     94function get_id_from_blogname( $slug ) {
    9595        global $wpdb, $current_site;
    96         $blog_id = wp_cache_get( 'get_id_from_blogname_' . $name, 'blog-details' );
     96
     97        $slug = trim( $slug, '/' );
     98
     99        $blog_id = wp_cache_get( 'get_id_from_blogname_' . $slug, 'blog-details' );
    97100        if ( $blog_id )
    98101                return $blog_id;
    99102
    100103        if ( is_subdomain_install() ) {
    101                 $domain = $name . '.' . $current_site->domain;
     104                $domain = $slug . '.' . $current_site->domain;
    102105                $path = $current_site->path;
    103106        } else {
    104107                $domain = $current_site->domain;
    105                 $path = $current_site->path . $name . '/';
     108                $path = $current_site->path . $slug . '/';
    106109        }
     110
    107111        $blog_id = $wpdb->get_var( $wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $domain, $path) );
    108         wp_cache_set( 'get_id_from_blogname_' . $name, $blog_id, 'blog-details' );
     112        wp_cache_set( 'get_id_from_blogname_' . $slug, $blog_id, 'blog-details' );
    109113        return $blog_id;
    110114}
    111115
     
    114118 *
    115119 * @since MU
    116120 *
    117  * @param int|string|array $fields A blog ID, a blog name, or an array of fields to query against.
     121 * @param int|string|array $fields A blog ID, a blog slug, or an array of fields to query against.
    118122 * @param bool $get_all Whether to retrieve all details or only the details in the blogs table. Default is true.
    119123 * @return object Blog details.
    120124 */
     
    254258        wp_cache_delete( md5( $details->domain . $details->path )  , 'blog-lookup' );
    255259        wp_cache_delete( 'current_blog_' . $details->domain, 'site-options' );
    256260        wp_cache_delete( 'current_blog_' . $details->domain . $details->path, 'site-options' );
     261        wp_cache_delete( 'get_id_from_blogname_' . trim( $details->path, '/' ), 'blog-details' );
    257262
    258263        do_action( 'refresh_blog_details', $blog_id );
    259264}