Changeset 41241
- Timestamp:
- 08/12/2017 12:47:38 PM (7 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ms.php
r41219 r41241 788 788 * Whether or not we can edit this network from this page. 789 789 * 790 * By default editing of network is restricted to the Network Admin for that `$ site_id`791 * thisallows for this to be overridden.790 * By default editing of network is restricted to the Network Admin for that `$network_id`. 791 * This function allows for this to be overridden. 792 792 * 793 793 * @since 3.1.0 … … 795 795 * @global wpdb $wpdb WordPress database abstraction object. 796 796 * 797 * @param int $ site_id The network/siteID to check.797 * @param int $network_id The network ID to check. 798 798 * @return bool True if network can be edited, otherwise false. 799 799 */ 800 function can_edit_network( $ site_id ) {800 function can_edit_network( $network_id ) { 801 801 global $wpdb; 802 802 803 if ( $ site_id == $wpdb->siteid )803 if ( $network_id == $wpdb->siteid ) 804 804 $result = true; 805 805 else … … 811 811 * @since 3.1.0 812 812 * 813 * @param bool $result Whether the network can be edited from this page.814 * @param int $ site_id The network/siteID to check.813 * @param bool $result Whether the network can be edited from this page. 814 * @param int $network_id The network ID to check. 815 815 */ 816 return apply_filters( 'can_edit_network', $result, $ site_id );816 return apply_filters( 'can_edit_network', $result, $network_id ); 817 817 } 818 818 -
trunk/src/wp-includes/ms-deprecated.php
r41200 r41241 421 421 * @global wpdb $wpdb WordPress database abstraction object. 422 422 * 423 * @param string $ sitedomain Optional. Sitedomain.424 * @param string $path Optional. Sitepath.425 * @return array|false The network admins 426 */ 427 function get_admin_users_for_domain( $ sitedomain = '', $path = '' ) {423 * @param string $domain Optional. Network domain. 424 * @param string $path Optional. Network path. 425 * @return array|false The network admins. 426 */ 427 function get_admin_users_for_domain( $domain = '', $path = '' ) { 428 428 _deprecated_function( __FUNCTION__, '4.4.0' ); 429 429 430 430 global $wpdb; 431 431 432 if ( ! $ sitedomain )433 $ site_id = $wpdb->siteid;432 if ( ! $domain ) 433 $network_id = $wpdb->siteid; 434 434 else 435 $ site_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE domain = %s AND path = %s", $sitedomain, $path ) );436 437 if ( $ site_id )438 return $wpdb->get_results( $wpdb->prepare( "SELECT u.ID, u.user_login, u.user_pass FROM $wpdb->users AS u, $wpdb->sitemeta AS sm WHERE sm.meta_key = 'admin_user_id' AND u.ID = sm.meta_value AND sm.site_id = %d", $ site_id ), ARRAY_A );435 $network_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE domain = %s AND path = %s", $domain, $path ) ); 436 437 if ( $network_id ) 438 return $wpdb->get_results( $wpdb->prepare( "SELECT u.ID, u.user_login, u.user_pass FROM $wpdb->users AS u, $wpdb->sitemeta AS sm WHERE sm.meta_key = 'admin_user_id' AND u.ID = sm.meta_value AND sm.site_id = %d", $network_id ), ARRAY_A ); 439 439 440 440 return false; -
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; -
trunk/src/wp-includes/option.php
r41013 r41241 215 215 * @global wpdb $wpdb WordPress database abstraction object. 216 216 * 217 * @param int $ site_id Optional site ID for which to query the options. Defaults to the current site.218 */ 219 function wp_load_core_site_options( $ site_id = null ) {217 * @param int $network_id Optional site ID for which to query the options. Defaults to the current site. 218 */ 219 function wp_load_core_site_options( $network_id = null ) { 220 220 global $wpdb; 221 221 … … 223 223 return; 224 224 225 if ( empty($ site_id) )226 $ site_id = $wpdb->siteid;225 if ( empty($network_id) ) 226 $network_id = $wpdb->siteid; 227 227 228 228 $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' ); 229 229 230 230 $core_options_in = "'" . implode("', '", $core_options) . "'"; 231 $options = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) );231 $options = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $network_id ) ); 232 232 233 233 foreach ( $options as $option ) { 234 234 $key = $option->meta_key; 235 $cache_key = "{$ site_id}:$key";235 $cache_key = "{$network_id}:$key"; 236 236 $option->meta_value = maybe_unserialize( $option->meta_value ); 237 237 -
trunk/src/wp-includes/wp-db.php
r41162 r41241 894 894 * 895 895 * @param int $blog_id 896 * @param int $ site_id Optional.896 * @param int $network_id Optional. 897 897 * @return int previous blog id 898 898 */ 899 public function set_blog_id( $blog_id, $site_id = 0 ) { 900 if ( ! empty( $site_id ) ) 901 $this->siteid = $site_id; 899 public function set_blog_id( $blog_id, $network_id = 0 ) { 900 if ( ! empty( $network_id ) ) { 901 $this->siteid = $network_id; 902 } 902 903 903 904 $old_blog_id = $this->blogid;
Note: See TracChangeset
for help on using the changeset viewer.