Changeset 21979 for trunk/wp-includes/ms-blogs.php
- Timestamp:
- 09/24/2012 07:31:37 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/ms-blogs.php
r21595 r21979 85 85 86 86 /** 87 * Given a blog's (subdomain or directory) name, retrieve it's id.88 * 89 * @since MU 90 * 91 * @param string $ name87 * Given a blog's (subdomain or directory) slug, retrieve it's id. 88 * 89 * @since MU 90 * 91 * @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 . '/'; 106 } 108 $path = $current_site->path . $slug . '/'; 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 } … … 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. … … 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 );
Note: See TracChangeset
for help on using the changeset viewer.