Changeset 43548 for trunk/src/wp-includes/ms-functions.php
- Timestamp:
- 08/01/2018 01:05:44 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ms-functions.php
r42976 r43548 1274 1274 $meta = wp_parse_args( $meta, $defaults ); 1275 1275 1276 $domain = preg_replace( '/\s+/', '', sanitize_user( $domain, true ) );1277 1278 if ( is_subdomain_install() ) {1279 $domain = str_replace( '@', '', $domain );1280 }1281 1282 1276 $title = strip_tags( $title ); 1283 1277 $user_id = (int) $user_id; 1284 1285 if ( empty( $path ) ) {1286 $path = '/';1287 }1288 1278 1289 1279 // Check if the domain has been used already. We should return an error message. … … 1296 1286 } 1297 1287 1298 if ( ! $blog_id = insert_blog( $domain, $path, $network_id ) ) { 1299 return new WP_Error( 'insert_blog', __( 'Could not create site.' ) ); 1288 $site_data_whitelist = array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ); 1289 1290 $site_data = array_merge( 1291 array( 1292 'domain' => $domain, 1293 'path' => $path, 1294 'network_id' => $network_id, 1295 ), 1296 array_intersect_key( 1297 $meta, 1298 array_flip( $site_data_whitelist ) 1299 ) 1300 ); 1301 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 ); 1307 1308 if ( is_wp_error( $blog_id ) ) { 1309 return $blog_id; 1300 1310 } 1301 1311 … … 1307 1317 1308 1318 foreach ( $meta as $key => $value ) { 1309 if ( in_array( $key, array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ) ) ) { 1310 update_blog_status( $blog_id, $key, $value ); 1311 } else { 1312 update_option( $key, $value ); 1313 } 1314 } 1315 1316 update_option( 'blog_public', (int) $meta['public'] ); 1319 update_option( $key, $value ); 1320 } 1321 1322 update_option( 'blog_public', (int) $site_data['public'] ); 1317 1323 1318 1324 if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) ) { … … 1321 1327 1322 1328 restore_current_blog(); 1329 1330 $site = get_site( $blog_id ); 1331 1323 1332 /** 1324 1333 * Fires immediately after a new site is created. … … 1333 1342 * @param array $meta Meta data. Used to set initial site options. 1334 1343 */ 1335 do_action( 'wpmu_new_blog', $blog_id, $user_id, $ domain, $path, $network_id, $meta );1344 do_action( 'wpmu_new_blog', $blog_id, $user_id, $site->domain, $site->path, $site->network_id, $meta ); 1336 1345 1337 1346 wp_cache_set( 'last_changed', microtime(), 'sites' ); … … 1487 1496 1488 1497 /** 1489 * Store basic site info in the blogs table.1490 *1491 * This function creates a row in the wp_blogs table and returns1492 * the new blog's ID. It is the first step in creating a new blog.1493 *1494 * @since MU (3.0.0)1495 *1496 * @global wpdb $wpdb WordPress database abstraction object.1497 *1498 * @param string $domain The domain of the new site.1499 * @param string $path The path of the new site.1500 * @param int $network_id Unless you're running a multi-network installation, be sure to set this value to 1.1501 * @return int|false The ID of the new row1502 */1503 function insert_blog( $domain, $path, $network_id ) {1504 global $wpdb;1505 1506 $path = trailingslashit( $path );1507 $network_id = (int) $network_id;1508 1509 $result = $wpdb->insert(1510 $wpdb->blogs, array(1511 'site_id' => $network_id,1512 'domain' => $domain,1513 'path' => $path,1514 'registered' => current_time( 'mysql' ),1515 )1516 );1517 if ( ! $result ) {1518 return false;1519 }1520 1521 $blog_id = $wpdb->insert_id;1522 clean_blog_cache( $blog_id );1523 1524 wp_maybe_update_network_site_counts( $network_id );1525 1526 return $blog_id;1527 }1528 1529 /**1530 1498 * Install an empty blog. 1531 1499 * … … 1539 1507 * @global WP_Roles $wp_roles 1540 1508 * 1541 * @param int $blog_id The value returned by insert_blog().1509 * @param int $blog_id The value returned by wp_insert_site(). 1542 1510 * @param string $blog_title The title of the new site. 1543 1511 */
Note: See TracChangeset
for help on using the changeset viewer.