]> scripts.mit.edu Git - autoinstallsdev/wordpress.git/blobdiff - wp-includes/ms-blogs.php
WordPress 3.7.2-scripts
[autoinstallsdev/wordpress.git] / wp-includes / ms-blogs.php
index a1f70a40bdbadedfdedf92529acec382d609fa4a..25baf15f68b544765dd30171e2f3cf47220edb76 100644 (file)
@@ -43,14 +43,12 @@ function get_blogaddress_by_id( $blog_id ) {
  * @return string
  */
 function get_blogaddress_by_name( $blogname ) {
-       global $current_site;
-
        if ( is_subdomain_install() ) {
                if ( $blogname == 'main' )
                        $blogname = 'www';
                $url = rtrim( network_home_url(), '/' );
                if ( !empty( $blogname ) )
-                       $url = preg_replace( '|^([^\.]+://)|', '$1' . $blogname . '.', $url );
+                       $url = preg_replace( '|^([^\.]+://)|', "\${1}" . $blogname . '.', $url );
        } else {
                $url = network_home_url( $blogname );
        }
@@ -58,33 +56,7 @@ function get_blogaddress_by_name( $blogname ) {
 }
 
 /**
- * Get a full blog URL, given a domain and a path.
- *
- * @since MU
- *
- * @param string $domain
- * @param string $path
- * @return string
- */
-function get_blogaddress_by_domain( $domain, $path ) {
-       if ( is_subdomain_install() ) {
-               $url = "http://" . $domain.$path;
-       } else {
-               if ( $domain != $_SERVER['HTTP_HOST'] ) {
-                       $blogname = substr( $domain, 0, strpos( $domain, '.' ) );
-                       $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path;
-                       // we're not installing the main blog
-                       if ( $blogname != 'www.' )
-                               $url .= $blogname . '/';
-               } else { // main blog
-                       $url = 'http://' . $domain . $path;
-               }
-       }
-       return esc_url( $url );
-}
-
-/**
- * Given a blog's (subdomain or directory) slug, retrieve it's id.
+ * Given a blog's (subdomain or directory) slug, retrieve its id.
  *
  * @since MU
  *
@@ -254,6 +226,16 @@ function get_blog_details( $fields = null, $get_all = true ) {
 function refresh_blog_details( $blog_id ) {
        $blog_id = (int) $blog_id;
        $details = get_blog_details( $blog_id, false );
+       if ( ! $details ) {
+               // Make sure clean_blog_cache() gets the blog ID
+               // when the blog has been previously cached as
+               // non-existent.
+               $details = (object) array(
+                       'blog_id' => $blog_id,
+                       'domain' => null,
+                       'path' => null
+               );
+       }
 
        clean_blog_cache( $details );
 
@@ -461,7 +443,7 @@ function delete_blog_option( $id, $option ) {
  * @param int $id The blog id
  * @param string $option The option key
  * @param mixed $value The option value
- * @return bool True on success, false on failrue.
+ * @return bool True on success, false on failure.
  */
 function update_blog_option( $id, $option, $value, $deprecated = null ) {
        $id = (int) $id;
@@ -516,7 +498,7 @@ function switch_to_blog( $new_blog, $deprecated = null ) {
        }
 
        $wpdb->set_blog_id( $new_blog );
-       $GLOBALS['table_prefix'] = $wpdb->prefix;
+       $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();
        $prev_blog_id = $GLOBALS['blog_id'];
        $GLOBALS['blog_id'] = $new_blog;
 
@@ -579,7 +561,7 @@ function restore_current_blog() {
        $wpdb->set_blog_id( $blog );
        $prev_blog_id = $GLOBALS['blog_id'];
        $GLOBALS['blog_id'] = $blog;
-       $GLOBALS['table_prefix'] = $wpdb->prefix;
+       $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();
 
        if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
                wp_cache_switch_to_blog( $blog );
@@ -687,6 +669,8 @@ function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) {
                ( $value == 1 ) ? do_action( 'archive_blog', $blog_id ) : do_action( 'unarchive_blog', $blog_id );
        elseif ( 'deleted' == $pref )
                ( $value == 1 ) ? do_action( 'make_delete_blog', $blog_id ) : do_action( 'make_undelete_blog', $blog_id );
+       elseif ( 'public' == $pref )
+               do_action( 'update_blog_public', $blog_id, $value ); // Moved here from update_blog_public().
 
        return $value;
 }