Changeset 41241 for trunk/src/wp-includes/ms-functions.php
- Timestamp:
- 08/12/2017 12:47:38 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ms-functions.php
r41230 r41241 1172 1172 * @since MU (3.0.0) 1173 1173 * 1174 * @param string $domain The new site's domain.1175 * @param string $path The new site's path.1176 * @param string $title The new site's title.1177 * @param int $user_id The user ID of the new site's admin.1178 * @param array $meta Optional. Array of key=>value pairs used to set initial site options.1179 * If valid status keys are included ('public', 'archived', 'mature',1180 * 'spam', 'deleted', or 'lang_id') the given site status(es) will be1181 * updated. Otherwise, keys and values will be used to set options for1182 * the new site. Default empty array.1183 * @param int $ site_id Optional. Network ID. Only relevant on multi-network installs.1174 * @param string $domain The new site's domain. 1175 * @param string $path The new site's path. 1176 * @param string $title The new site's title. 1177 * @param int $user_id The user ID of the new site's admin. 1178 * @param array $meta Optional. Array of key=>value pairs used to set initial site options. 1179 * If valid status keys are included ('public', 'archived', 'mature', 1180 * 'spam', 'deleted', or 'lang_id') the given site status(es) will be 1181 * updated. Otherwise, keys and values will be used to set options for 1182 * the new site. Default empty array. 1183 * @param int $network_id Optional. Network ID. Only relevant on multi-network installs. 1184 1184 * @return int|WP_Error Returns WP_Error object on failure, the new site ID on success. 1185 1185 */ 1186 function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $ site_id = 1 ) {1186 function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $network_id = 1 ) { 1187 1187 $defaults = array( 1188 1188 'public' => 0, 1189 'WPLANG' => get_network_option( $ site_id, 'WPLANG' ),1189 'WPLANG' => get_network_option( $network_id, 'WPLANG' ), 1190 1190 ); 1191 1191 $meta = wp_parse_args( $meta, $defaults ); … … 1203 1203 1204 1204 // Check if the domain has been used already. We should return an error message. 1205 if ( domain_exists($domain, $path, $ site_id) )1205 if ( domain_exists($domain, $path, $network_id) ) 1206 1206 return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) ); 1207 1207 … … 1210 1210 } 1211 1211 1212 if ( ! $blog_id = insert_blog($domain, $path, $ site_id) )1212 if ( ! $blog_id = insert_blog($domain, $path, $network_id) ) 1213 1213 return new WP_Error('insert_blog', __('Could not create site.')); 1214 1214 … … 1237 1237 * @since MU (3.0.0) 1238 1238 * 1239 * @param int $blog_id Site ID.1240 * @param int $user_id User ID.1241 * @param string $domain Site domain.1242 * @param string $path Site path.1243 * @param int $ site_id Network ID. Only relevant on multi-network installs.1244 * @param array $meta Meta data. Used to set initial site options.1245 */ 1246 do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $ site_id, $meta );1239 * @param int $blog_id Site ID. 1240 * @param int $user_id User ID. 1241 * @param string $domain Site domain. 1242 * @param string $path Site path. 1243 * @param int $network_id Network ID. Only relevant on multi-network installs. 1244 * @param array $meta Meta data. Used to set initial site options. 1245 */ 1246 do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $network_id, $meta ); 1247 1247 1248 1248 wp_cache_set( 'last_changed', microtime(), 'sites' ); … … 1351 1351 * @global wpdb $wpdb WordPress database abstraction object. 1352 1352 * 1353 * @param string $domain The domain to be checked.1354 * @param string $path The path to be checked.1355 * @param int $ site_id Optional. Relevant only on multi-network installs.1353 * @param string $domain The domain to be checked. 1354 * @param string $path The path to be checked. 1355 * @param int $network_id Optional. Network ID. Relevant only on multi-network installs. 1356 1356 * @return int 1357 1357 */ 1358 function domain_exists( $domain, $path, $site_id = 1) {1358 function domain_exists( $domain, $path, $network_id = 1 ) { 1359 1359 $path = trailingslashit( $path ); 1360 1360 $args = array( 1361 'network_id' => $ site_id,1362 'domain' => $domain,1363 'path' => $path,1364 'fields' => 'ids',1361 'network_id' => $network_id, 1362 'domain' => $domain, 1363 'path' => $path, 1364 'fields' => 'ids', 1365 1365 ); 1366 1366 $result = get_sites( $args ); … … 1372 1372 * @since 3.5.0 1373 1373 * 1374 * @param int|null $result The blog_id if the blogname exists, null otherwise.1375 * @param string $domain Domain to be checked.1376 * @param string $path Path to be checked.1377 * @param int $ site_id SiteID. Relevant only on multi-network installs.1378 */ 1379 return apply_filters( 'domain_exists', $result, $domain, $path, $ site_id );1374 * @param int|null $result The blog_id if the blogname exists, null otherwise. 1375 * @param string $domain Domain to be checked. 1376 * @param string $path Path to be checked. 1377 * @param int $network_id Network ID. Relevant only on multi-network installs. 1378 */ 1379 return apply_filters( 'domain_exists', $result, $domain, $path, $network_id ); 1380 1380 } 1381 1381 … … 1390 1390 * @global wpdb $wpdb WordPress database abstraction object. 1391 1391 * 1392 * @param string $domain The domain of the new site.1393 * @param string $path The path of the new site.1394 * @param int $ site_id Unless you're running a multi-network install, be sure to set this value to 1.1392 * @param string $domain The domain of the new site. 1393 * @param string $path The path of the new site. 1394 * @param int $network_id Unless you're running a multi-network install, be sure to set this value to 1. 1395 1395 * @return int|false The ID of the new row 1396 1396 */ 1397 function insert_blog($domain, $path, $ site_id) {1397 function insert_blog($domain, $path, $network_id) { 1398 1398 global $wpdb; 1399 1399 1400 1400 $path = trailingslashit($path); 1401 $ site_id = (int) $site_id;1402 1403 $result = $wpdb->insert( $wpdb->blogs, array('site_id' => $ site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) );1401 $network_id = (int) $network_id; 1402 1403 $result = $wpdb->insert( $wpdb->blogs, array('site_id' => $network_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) ); 1404 1404 if ( ! $result ) 1405 1405 return false; … … 1408 1408 refresh_blog_details( $blog_id ); 1409 1409 1410 wp_maybe_update_network_site_counts( $ site_id );1410 wp_maybe_update_network_site_counts( $network_id ); 1411 1411 1412 1412 return $blog_id;
Note: See TracChangeset
for help on using the changeset viewer.