Make WordPress Core

Ticket #41333: 41333.diff

File 41333.diff, 20.6 KB (added by flixos90, 6 years ago)
  • src/wp-admin/includes/ms.php

     
    119119        }
    120120
    121121        if ( $drop ) {
    122                 $uploads = wp_get_upload_dir();
    123 
    124                 $tables = $wpdb->tables( 'blog' );
    125                 /**
    126                  * Filters the tables to drop when the site is deleted.
    127                  *
    128                  * @since MU (3.0.0)
    129                  *
    130                  * @param string[] $tables  Array of names of the site tables to be dropped.
    131                  * @param int      $blog_id The ID of the site to drop tables for.
    132                  */
    133                 $drop_tables = apply_filters( 'wpmu_drop_tables', $tables, $blog_id );
    134 
    135                 foreach ( (array) $drop_tables as $table ) {
    136                         $wpdb->query( "DROP TABLE IF EXISTS `$table`" );
    137                 }
    138 
    139                 if ( is_site_meta_supported() ) {
    140                         $blog_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->blogmeta WHERE blog_id = %d ", $blog_id ) );
    141                         foreach ( $blog_meta_ids as $mid ) {
    142                                 delete_metadata_by_mid( 'blog', $mid );
    143                         }
    144                 }
    145 
    146122                wp_delete_site( $blog_id );
    147 
    148                 /**
    149                  * Filters the upload base directory to delete when the site is deleted.
    150                  *
    151                  * @since MU (3.0.0)
    152                  *
    153                  * @param string $uploads['basedir'] Uploads path without subdirectory. @see wp_upload_dir()
    154                  * @param int    $blog_id            The site ID.
    155                  */
    156                 $dir     = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id );
    157                 $dir     = rtrim( $dir, DIRECTORY_SEPARATOR );
    158                 $top_dir = $dir;
    159                 $stack   = array( $dir );
    160                 $index   = 0;
    161 
    162                 while ( $index < count( $stack ) ) {
    163                         // Get indexed directory from stack
    164                         $dir = $stack[ $index ];
    165 
    166                         $dh = @opendir( $dir );
    167                         if ( $dh ) {
    168                                 while ( ( $file = @readdir( $dh ) ) !== false ) {
    169                                         if ( $file == '.' || $file == '..' ) {
    170                                                 continue;
    171                                         }
    172 
    173                                         if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) ) {
    174                                                 $stack[] = $dir . DIRECTORY_SEPARATOR . $file;
    175                                         } elseif ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) ) {
    176                                                 @unlink( $dir . DIRECTORY_SEPARATOR . $file );
    177                                         }
    178                                 }
    179                                 @closedir( $dh );
    180                         }
    181                         $index++;
    182                 }
    183 
    184                 $stack = array_reverse( $stack ); // Last added dirs are deepest
    185                 foreach ( (array) $stack as $dir ) {
    186                         if ( $dir != $top_dir ) {
    187                                 @rmdir( $dir );
    188                         }
    189                 }
    190 
    191                 clean_blog_cache( $blog );
    192123        }
    193124
    194125        /**
  • src/wp-admin/includes/schema.php

     
    356356 * Create WordPress options and set the default values.
    357357 *
    358358 * @since 1.5.0
     359 * @since 5.0.0 The $options parameter has been added.
    359360 *
    360361 * @global wpdb $wpdb WordPress database abstraction object.
    361362 * @global int  $wp_db_version
    362363 * @global int  $wp_current_db_version
     364 *
     365 * @param array $options Optional. Custom option $key => $value pairs to use. Default empty array.
    363366 */
    364 function populate_options() {
     367function populate_options( array $options = array() ) {
    365368        global $wpdb, $wp_db_version, $wp_current_db_version;
    366369
    367370        $guessurl = wp_guess_url();
     
    406409                        $timezone_string = $offset_or_tz;
    407410        }
    408411
    409         $options = array(
     412        $options = wp_parse_args( $options, array(
    410413                'siteurl'                         => $guessurl,
    411414                'home'                            => $guessurl,
    412415                'blogname'                        => __( 'My Site' ),
     
    538541
    539542                // 4.9.8
    540543                'show_comments_cookies_opt_in'    => 0,
    541         );
     544        ) );
    542545
    543546        // 3.3
    544547        if ( ! is_multisite() ) {
  • src/wp-includes/ms-blogs.php

     
    442442                'lang_id'      => 0,
    443443        );
    444444
     445        // Extract the passed arguments that may be relevant for site installation.
     446        $args = array_diff_key( $data, $defaults );
     447        if ( isset( $args['site_id'] ) ) {
     448                unset( $args['site_id'] );
     449        }
     450
    445451        $data = wp_prepare_site_data( $data, $defaults );
    446452        if ( is_wp_error( $data ) ) {
    447453                return $data;
     
    455461
    456462        clean_blog_cache( $new_site );
    457463
     464        remove_action( 'update_blog_public', 'wp_update_blog_public_option_on_site_update', 1 );
     465
    458466        /**
    459467         * Fires once a site has been inserted into the database.
    460468         *
     
    464472         */
    465473        do_action( 'wp_insert_site', $new_site );
    466474
     475        add_action( 'update_blog_public', 'wp_update_blog_public_option_on_site_update', 1, 2 );
     476
     477        /**
     478         * Fires when a site's installation routine should be executed.
     479         *
     480         * @since 5.0.0
     481         *
     482         * @param WP_Site $new_site New site object.
     483         * @param array   $args     Arguments for the installation.
     484         */
     485        do_action( 'wp_install_site', $new_site, $args );
     486
    467487        return (int) $new_site->id;
    468488}
    469489
     
    543563                return new WP_Error( 'site_not_exist', __( 'Site does not exist.' ) );
    544564        }
    545565
     566        /**
     567         * Fires when a site's uninstallation routine should be executed.
     568         *
     569         * @since 5.0.0
     570         *
     571         * @param WP_Site $old_site Deleted site object.
     572         */
     573        do_action( 'wp_uninstall_site', $old_site );
     574
     575        if ( is_site_meta_supported() ) {
     576                $blog_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->blogmeta WHERE blog_id = %d ", $old_site->id ) );
     577                foreach ( $blog_meta_ids as $mid ) {
     578                        delete_metadata_by_mid( 'blog', $mid );
     579                }
     580        }
     581
    546582        if ( false === $wpdb->delete( $wpdb->blogs, array( 'blog_id' => $old_site->id ) ) ) {
    547583                return new WP_Error( 'db_delete_error', __( 'Could not delete site from the database.' ), $wpdb->last_error );
    548584        }
     
    913949}
    914950
    915951/**
     952 * Runs the installation routine for a given site.
     953 *
     954 * This process includes creating the site's database tables and
     955 * populating them with defaults.
     956 *
     957 * @since 5.0.0
     958 *
     959 * @global wpdb     $wpdb     WordPress database abstraction object.
     960 * @global WP_Roles $wp_roles WordPress role management object.
     961 *
     962 * @param int|WP_Site $site_id Site ID or object.
     963 * @param array       $args    {
     964 *     Optional. Arguments to modify the installation behavior.
     965 *
     966 *     @type int    $user_id Required. User ID for the site administrator.
     967 *     @type string $title   Site title. Default is 'Site %d' where %d is the
     968 *                           site ID.
     969 *     @type array  $options Custom option $key => $value pairs to use. Default
     970 *                           empty array.
     971 * }
     972 * @return bool|WP_Error True on success, or error object on failure.
     973 */
     974function wp_install_site( $site_id, array $args = array() ) {
     975        global $wpdb, $wp_roles;
     976
     977        if ( empty( $site_id ) ) {
     978                return new WP_Error( 'site_empty_id', __( 'Site ID must not be empty.' ) );
     979        }
     980
     981        $site = get_site( $site_id );
     982        if ( ! $site ) {
     983                return new WP_Error( 'site_invalid_id', __( 'Site with the ID does not exist.' ) );
     984        }
     985
     986        $network = get_network( $site->network_id );
     987        if ( ! $network ) {
     988                $network = get_network();
     989        }
     990
     991        $args = wp_parse_args( $args, array(
     992                'user_id' => 0,
     993                /* translators: %d: site ID */
     994                'title'   => sprintf( __( 'Site %d' ), $site->id ),
     995                'options' => array(),
     996        ) );
     997
     998        if ( empty( $args['user_id'] ) ) {
     999                return new WP_Error( 'site_empty_user_id', __( 'A user ID must be specified for the site administrator.' ) );
     1000        }
     1001
     1002        if ( ! wp_installing() ) {
     1003                wp_installing( true );
     1004        }
     1005
     1006        switch_to_blog( $site->id );
     1007
     1008        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     1009
     1010        $suppress = $wpdb->suppress_errors();
     1011        if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) {
     1012                $wpdb->suppress_errors( $suppress );
     1013                restore_current_blog();
     1014                return new WP_Error( 'site_already_installed', __( 'Database tables for the site appear to be already installed.' ) );
     1015        }
     1016        $wpdb->suppress_errors( $suppress );
     1017
     1018        // Set up the database tables.
     1019        make_db_current_silent( 'blog' );
     1020
     1021        $home_scheme    = 'http';
     1022        $siteurl_scheme = 'http';
     1023        if ( ! is_subdomain_install() ) {
     1024                if ( 'https' === parse_url( get_home_url( $network->site_id ), PHP_URL_SCHEME ) ) {
     1025                        $home_scheme = 'https';
     1026                }
     1027                if ( 'https' === parse_url( get_network_option( $network->id, 'siteurl' ), PHP_URL_SCHEME ) ) {
     1028                        $siteurl_scheme = 'https';
     1029                }
     1030        }
     1031
     1032        // Populate the site's options.
     1033        populate_options( array(
     1034                'home'        => untrailingslashit( $home_scheme . '://' . $site->domain . $site->path ),
     1035                'siteurl'     => untrailingslashit( $siteurl_scheme . '://' . $site->domain . $site->path ),
     1036                'blogname'    => wp_unslash( $args['title'] ),
     1037                'admin_email' => '',
     1038                'upload_path' => get_network_option( $network->id, 'ms_files_rewriting' ) ? UPLOADBLOGSDIR . "/{$site->id}/files" : get_blog_option( $network->site_id, 'upload_path' ),
     1039                'blog_public' => (int) $site->public,
     1040                'WPLANG'      => get_network_option( $network->id, 'WPLANG' ),
     1041        ) );
     1042
     1043        // Populate the site's roles.
     1044        populate_roles();
     1045        $wp_roles = new WP_Roles();
     1046
     1047        // Remove all permissions that may exist for the site.
     1048        $table_prefix = $wpdb->get_blog_prefix();
     1049        delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // delete all
     1050        delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // delete all
     1051
     1052        // Install default site content.
     1053        wp_install_defaults( $args['user_id'] );
     1054
     1055        // Set the site administrator.
     1056        add_user_to_blog( $site->id, $args['user_id'], 'administrator' );
     1057        if ( ! user_can( $args['user_id'], 'manage_network' ) && ! get_user_meta( $args['user_id'], 'primary_blog', true ) ) {
     1058                update_user_meta( $args['user_id'], 'primary_blog', $site->id );
     1059        }
     1060
     1061        // Override any specified options with custom values.
     1062        foreach ( $args['options'] as $key => $value ) {
     1063                update_option( $key, $value );
     1064        }
     1065
     1066        restore_current_blog();
     1067
     1068        return true;
     1069}
     1070
     1071/**
     1072 * Runs the uninstallation routine for a given site.
     1073 *
     1074 * This process includes dropping the site's database tables.
     1075 *
     1076 * @since 5.0.0
     1077 *
     1078 * @global wpdb $wpdb WordPress database abstraction object.
     1079 *
     1080 * @param int|WP_Site $site_id Site ID or object.
     1081 * @return bool|WP_Error True on success, or error object on failure.
     1082 */
     1083function wp_uninstall_site( $site_id ) {
     1084        global $wpdb;
     1085
     1086        if ( empty( $site_id ) ) {
     1087                return new WP_Error( 'site_empty_id', __( 'Site ID must not be empty.' ) );
     1088        }
     1089
     1090        $site = get_site( $site_id );
     1091        if ( ! $site ) {
     1092                return new WP_Error( 'site_invalid_id', __( 'Site with the ID does not exist.' ) );
     1093        }
     1094
     1095        $users = get_users( array(
     1096                'blog_id' => $site->id,
     1097                'fields'  => 'ids',
     1098        ) );
     1099
     1100        // Remove users from the site.
     1101        if ( ! empty( $users ) ) {
     1102                foreach ( $users as $user_id ) {
     1103                        remove_user_from_blog( $user_id, $site->id );
     1104                }
     1105        }
     1106
     1107        switch_to_blog( $site->id );
     1108
     1109        $uploads = wp_get_upload_dir();
     1110
     1111        $tables = $wpdb->tables( 'blog' );
     1112
     1113        /**
     1114         * Filters the tables to drop when the site is deleted.
     1115         *
     1116         * @since MU (3.0.0)
     1117         *
     1118         * @param string[] $tables  Array of names of the site tables to be dropped.
     1119         * @param int      $site_id The ID of the site to drop tables for.
     1120         */
     1121        $drop_tables = apply_filters( 'wpmu_drop_tables', $tables, $site->id );
     1122
     1123        foreach ( (array) $drop_tables as $table ) {
     1124                $wpdb->query( "DROP TABLE IF EXISTS `$table`" );
     1125        }
     1126
     1127        /**
     1128         * Filters the upload base directory to delete when the site is deleted.
     1129         *
     1130         * @since MU (3.0.0)
     1131         *
     1132         * @param string $uploads['basedir'] Uploads path without subdirectory. @see wp_upload_dir()
     1133         * @param int    $site_id            The site ID.
     1134         */
     1135        $dir     = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $site->id );
     1136        $dir     = rtrim( $dir, DIRECTORY_SEPARATOR );
     1137        $top_dir = $dir;
     1138        $stack   = array( $dir );
     1139        $index   = 0;
     1140
     1141        while ( $index < count( $stack ) ) {
     1142                // Get indexed directory from stack
     1143                $dir = $stack[ $index ];
     1144
     1145                $dh = @opendir( $dir );
     1146                if ( $dh ) {
     1147                        while ( ( $file = @readdir( $dh ) ) !== false ) {
     1148                                if ( $file == '.' || $file == '..' ) {
     1149                                        continue;
     1150                                }
     1151
     1152                                if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) ) {
     1153                                        $stack[] = $dir . DIRECTORY_SEPARATOR . $file;
     1154                                } elseif ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) ) {
     1155                                        @unlink( $dir . DIRECTORY_SEPARATOR . $file );
     1156                                }
     1157                        }
     1158                        @closedir( $dh );
     1159                }
     1160                $index++;
     1161        }
     1162
     1163        $stack = array_reverse( $stack ); // Last added dirs are deepest
     1164        foreach ( (array) $stack as $dir ) {
     1165                if ( $dir != $top_dir ) {
     1166                        @rmdir( $dir );
     1167                }
     1168        }
     1169
     1170        restore_current_blog();
     1171
     1172        return true;
     1173}
     1174
     1175/**
    9161176 * Retrieve option value for a given blog id based on name of option.
    9171177 *
    9181178 * If the option does not exist or does not have a value, then the return value
  • src/wp-includes/ms-default-filters.php

     
    4949add_action( 'wp_insert_site', 'wp_maybe_transition_site_statuses_on_update', 10, 1 );
    5050add_action( 'wp_update_site', 'wp_maybe_transition_site_statuses_on_update', 10, 2 );
    5151add_action( 'wp_update_site', 'wp_maybe_clean_new_site_cache_on_update', 10, 2 );
     52add_action( 'wp_install_site', 'wp_install_site', 10, 2 );
     53add_action( 'wp_uninstall_site', 'wp_uninstall_site', 10, 1 );
    5254add_action( 'update_blog_public', 'wp_update_blog_public_option_on_site_update', 1, 2 );
    5355
    5456// Register Nonce
  • src/wp-includes/ms-deprecated.php

     
    580580
    581581        return $site_id;
    582582}
     583
     584/**
     585 * Install an empty blog.
     586 *
     587 * Creates the new blog tables and options. If calling this function
     588 * directly, be sure to use switch_to_blog() first, so that $wpdb
     589 * points to the new blog.
     590 *
     591 * @since MU (3.0.0)
     592 * @deprecated 5.0.0
     593 *
     594 * @global wpdb     $wpdb
     595 * @global WP_Roles $wp_roles
     596 *
     597 * @param int    $blog_id    The value returned by wp_insert_site().
     598 * @param string $blog_title The title of the new site.
     599 */
     600function install_blog( $blog_id, $blog_title = '' ) {
     601        global $wpdb, $wp_roles;
     602
     603        _deprecated_function( __FUNCTION__, '5.0.0' );
     604
     605        // Cast for security
     606        $blog_id = (int) $blog_id;
     607
     608        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     609
     610        $suppress = $wpdb->suppress_errors();
     611        if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) {
     612                die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' );
     613        }
     614        $wpdb->suppress_errors( $suppress );
     615
     616        $url = get_blogaddress_by_id( $blog_id );
     617
     618        // Set everything up
     619        make_db_current_silent( 'blog' );
     620        populate_options();
     621        populate_roles();
     622
     623        // populate_roles() clears previous role definitions so we start over.
     624        $wp_roles = new WP_Roles();
     625
     626        $siteurl = $home = untrailingslashit( $url );
     627
     628        if ( ! is_subdomain_install() ) {
     629
     630                if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
     631                        $siteurl = set_url_scheme( $siteurl, 'https' );
     632                }
     633                if ( 'https' === parse_url( get_home_url( get_network()->site_id ), PHP_URL_SCHEME ) ) {
     634                        $home = set_url_scheme( $home, 'https' );
     635                }
     636        }
     637
     638        update_option( 'siteurl', $siteurl );
     639        update_option( 'home', $home );
     640
     641        if ( get_site_option( 'ms_files_rewriting' ) ) {
     642                update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
     643        } else {
     644                update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) );
     645        }
     646
     647        update_option( 'blogname', wp_unslash( $blog_title ) );
     648        update_option( 'admin_email', '' );
     649
     650        // remove all perms
     651        $table_prefix = $wpdb->get_blog_prefix();
     652        delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // delete all
     653        delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // delete all
     654}
     655
     656/**
     657 * Set blog defaults.
     658 *
     659 * This function creates a row in the wp_blogs table.
     660 *
     661 * @since MU (3.0.0)
     662 * @deprecated MU
     663 * @deprecated Use wp_install_defaults()
     664 *
     665 * @global wpdb $wpdb WordPress database abstraction object.
     666 *
     667 * @param int $blog_id Ignored in this function.
     668 * @param int $user_id
     669 */
     670function install_blog_defaults( $blog_id, $user_id ) {
     671        global $wpdb;
     672
     673        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     674
     675        $suppress = $wpdb->suppress_errors();
     676
     677        wp_install_defaults( $user_id );
     678
     679        $wpdb->suppress_errors( $suppress );
     680}
  • src/wp-includes/ms-functions.php

     
    12691269function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $network_id = 1 ) {
    12701270        $defaults = array(
    12711271                'public' => 0,
    1272                 'WPLANG' => get_network_option( $network_id, 'WPLANG' ),
    12731272        );
    12741273        $meta     = wp_parse_args( $meta, $defaults );
    12751274
     
    12991298                )
    13001299        );
    13011300
    1302         $meta = array_diff_key( $meta, array_flip( $site_data_whitelist ) );
    1303 
    1304         remove_action( 'update_blog_public', 'wp_update_blog_public_option_on_site_update', 1 );
    1305         $blog_id = wp_insert_site( $site_data );
    1306         add_action( 'update_blog_public', 'wp_update_blog_public_option_on_site_update', 1, 2 );
     1301        $blog_id = wp_insert_site( array_merge( $site_data, array(
     1302                'title'   => $title,
     1303                'user_id' => $user_id,
     1304                'options' => array_diff_key( $meta, array_flip( $site_data_whitelist ) ),
     1305        ) ) );
    13071306
    13081307        if ( is_wp_error( $blog_id ) ) {
    13091308                return $blog_id;
    13101309        }
    13111310
    1312         switch_to_blog( $blog_id );
    1313         install_blog( $blog_id, $title );
    1314         wp_install_defaults( $user_id );
    1315 
    1316         add_user_to_blog( $blog_id, $user_id, 'administrator' );
    1317 
    1318         foreach ( $meta as $key => $value ) {
    1319                 update_option( $key, $value );
    1320         }
    1321 
    1322         update_option( 'blog_public', (int) $site_data['public'] );
    1323 
    1324         if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) ) {
    1325                 update_user_meta( $user_id, 'primary_blog', $blog_id );
    1326         }
    1327 
    1328         restore_current_blog();
    1329 
    13301311        $site = get_site( $blog_id );
    13311312
    13321313        /**
     
    14951476}
    14961477
    14971478/**
    1498  * Install an empty blog.
    1499  *
    1500  * Creates the new blog tables and options. If calling this function
    1501  * directly, be sure to use switch_to_blog() first, so that $wpdb
    1502  * points to the new blog.
    1503  *
    1504  * @since MU (3.0.0)
    1505  *
    1506  * @global wpdb     $wpdb
    1507  * @global WP_Roles $wp_roles
    1508  *
    1509  * @param int    $blog_id    The value returned by wp_insert_site().
    1510  * @param string $blog_title The title of the new site.
    1511  */
    1512 function install_blog( $blog_id, $blog_title = '' ) {
    1513         global $wpdb, $wp_roles;
    1514 
    1515         // Cast for security
    1516         $blog_id = (int) $blog_id;
    1517 
    1518         require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    1519 
    1520         $suppress = $wpdb->suppress_errors();
    1521         if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) {
    1522                 die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' );
    1523         }
    1524         $wpdb->suppress_errors( $suppress );
    1525 
    1526         $url = get_blogaddress_by_id( $blog_id );
    1527 
    1528         // Set everything up
    1529         make_db_current_silent( 'blog' );
    1530         populate_options();
    1531         populate_roles();
    1532 
    1533         // populate_roles() clears previous role definitions so we start over.
    1534         $wp_roles = new WP_Roles();
    1535 
    1536         $siteurl = $home = untrailingslashit( $url );
    1537 
    1538         if ( ! is_subdomain_install() ) {
    1539 
    1540                 if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
    1541                         $siteurl = set_url_scheme( $siteurl, 'https' );
    1542                 }
    1543                 if ( 'https' === parse_url( get_home_url( get_network()->site_id ), PHP_URL_SCHEME ) ) {
    1544                         $home = set_url_scheme( $home, 'https' );
    1545                 }
    1546         }
    1547 
    1548         update_option( 'siteurl', $siteurl );
    1549         update_option( 'home', $home );
    1550 
    1551         if ( get_site_option( 'ms_files_rewriting' ) ) {
    1552                 update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
    1553         } else {
    1554                 update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) );
    1555         }
    1556 
    1557         update_option( 'blogname', wp_unslash( $blog_title ) );
    1558         update_option( 'admin_email', '' );
    1559 
    1560         // remove all perms
    1561         $table_prefix = $wpdb->get_blog_prefix();
    1562         delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // delete all
    1563         delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // delete all
    1564 }
    1565 
    1566 /**
    1567  * Set blog defaults.
    1568  *
    1569  * This function creates a row in the wp_blogs table.
    1570  *
    1571  * @since MU (3.0.0)
    1572  * @deprecated MU
    1573  * @deprecated Use wp_install_defaults()
    1574  *
    1575  * @global wpdb $wpdb WordPress database abstraction object.
    1576  *
    1577  * @param int $blog_id Ignored in this function.
    1578  * @param int $user_id
    1579  */
    1580 function install_blog_defaults( $blog_id, $user_id ) {
    1581         global $wpdb;
    1582 
    1583         require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    1584 
    1585         $suppress = $wpdb->suppress_errors();
    1586 
    1587         wp_install_defaults( $user_id );
    1588 
    1589         $wpdb->suppress_errors( $suppress );
    1590 }
    1591 
    1592 /**
    15931479 * Notify a user that their blog activation has been successful.
    15941480 *
    15951481 * Filter {@see 'wpmu_welcome_notification'} to disable or bypass.