Ticket #20950: 20950.diff
File 20950.diff, 2.2 KB (added by , 11 years ago) |
---|
-
wp-includes/ms-blogs.php
84 84 } 85 85 86 86 /** 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. 88 88 * 89 89 * @since MU 90 90 * 91 * @param string $ name91 * @param string $slug 92 92 * @return int A blog id 93 93 */ 94 function get_id_from_blogname( $ name) {94 function get_id_from_blogname( $slug ) { 95 95 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' ); 97 100 if ( $blog_id ) 98 101 return $blog_id; 99 102 100 103 if ( is_subdomain_install() ) { 101 $domain = $ name. '.' . $current_site->domain;104 $domain = $slug . '.' . $current_site->domain; 102 105 $path = $current_site->path; 103 106 } else { 104 107 $domain = $current_site->domain; 105 $path = $current_site->path . $ name. '/';108 $path = $current_site->path . $slug . '/'; 106 109 } 110 107 111 $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' ); 109 113 return $blog_id; 110 114 } 111 115 … … 114 118 * 115 119 * @since MU 116 120 * 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. 118 122 * @param bool $get_all Whether to retrieve all details or only the details in the blogs table. Default is true. 119 123 * @return object Blog details. 120 124 */ … … 254 258 wp_cache_delete( md5( $details->domain . $details->path ) , 'blog-lookup' ); 255 259 wp_cache_delete( 'current_blog_' . $details->domain, 'site-options' ); 256 260 wp_cache_delete( 'current_blog_' . $details->domain . $details->path, 'site-options' ); 261 wp_cache_delete( 'get_id_from_blogname_' . trim( $details->path, '/' ), 'blog-details' ); 257 262 258 263 do_action( 'refresh_blog_details', $blog_id ); 259 264 }