mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Multisite: Rename internal $site_id variables referencing networks to $network_id.
This change improves code clarity by using the current naming conventions for networks. Props lemacarl. Fixes #41510. git-svn-id: https://develop.svn.wordpress.org/trunk@41241 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1171,22 +1171,22 @@ function wpmu_create_user( $user_name, $password, $email ) {
|
||||
*
|
||||
* @since MU (3.0.0)
|
||||
*
|
||||
* @param string $domain The new site's domain.
|
||||
* @param string $path The new site's path.
|
||||
* @param string $title The new site's title.
|
||||
* @param int $user_id The user ID of the new site's admin.
|
||||
* @param array $meta Optional. Array of key=>value pairs used to set initial site options.
|
||||
* If valid status keys are included ('public', 'archived', 'mature',
|
||||
* 'spam', 'deleted', or 'lang_id') the given site status(es) will be
|
||||
* updated. Otherwise, keys and values will be used to set options for
|
||||
* the new site. Default empty array.
|
||||
* @param int $site_id Optional. Network ID. Only relevant on multi-network installs.
|
||||
* @param string $domain The new site's domain.
|
||||
* @param string $path The new site's path.
|
||||
* @param string $title The new site's title.
|
||||
* @param int $user_id The user ID of the new site's admin.
|
||||
* @param array $meta Optional. Array of key=>value pairs used to set initial site options.
|
||||
* If valid status keys are included ('public', 'archived', 'mature',
|
||||
* 'spam', 'deleted', or 'lang_id') the given site status(es) will be
|
||||
* updated. Otherwise, keys and values will be used to set options for
|
||||
* the new site. Default empty array.
|
||||
* @param int $network_id Optional. Network ID. Only relevant on multi-network installs.
|
||||
* @return int|WP_Error Returns WP_Error object on failure, the new site ID on success.
|
||||
*/
|
||||
function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $site_id = 1 ) {
|
||||
function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $network_id = 1 ) {
|
||||
$defaults = array(
|
||||
'public' => 0,
|
||||
'WPLANG' => get_network_option( $site_id, 'WPLANG' ),
|
||||
'WPLANG' => get_network_option( $network_id, 'WPLANG' ),
|
||||
);
|
||||
$meta = wp_parse_args( $meta, $defaults );
|
||||
|
||||
@@ -1202,14 +1202,14 @@ function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $s
|
||||
$path = '/';
|
||||
|
||||
// Check if the domain has been used already. We should return an error message.
|
||||
if ( domain_exists($domain, $path, $site_id) )
|
||||
if ( domain_exists($domain, $path, $network_id) )
|
||||
return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) );
|
||||
|
||||
if ( ! wp_installing() ) {
|
||||
wp_installing( true );
|
||||
}
|
||||
|
||||
if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
|
||||
if ( ! $blog_id = insert_blog($domain, $path, $network_id) )
|
||||
return new WP_Error('insert_blog', __('Could not create site.'));
|
||||
|
||||
switch_to_blog($blog_id);
|
||||
@@ -1236,14 +1236,14 @@ function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $s
|
||||
*
|
||||
* @since MU (3.0.0)
|
||||
*
|
||||
* @param int $blog_id Site ID.
|
||||
* @param int $user_id User ID.
|
||||
* @param string $domain Site domain.
|
||||
* @param string $path Site path.
|
||||
* @param int $site_id Network ID. Only relevant on multi-network installs.
|
||||
* @param array $meta Meta data. Used to set initial site options.
|
||||
* @param int $blog_id Site ID.
|
||||
* @param int $user_id User ID.
|
||||
* @param string $domain Site domain.
|
||||
* @param string $path Site path.
|
||||
* @param int $network_id Network ID. Only relevant on multi-network installs.
|
||||
* @param array $meta Meta data. Used to set initial site options.
|
||||
*/
|
||||
do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta );
|
||||
do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $network_id, $meta );
|
||||
|
||||
wp_cache_set( 'last_changed', microtime(), 'sites' );
|
||||
|
||||
@@ -1350,18 +1350,18 @@ Disable these notifications: %3$s'), $user->user_login, wp_unslash( $_SERVER['RE
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param string $domain The domain to be checked.
|
||||
* @param string $path The path to be checked.
|
||||
* @param int $site_id Optional. Relevant only on multi-network installs.
|
||||
* @param string $domain The domain to be checked.
|
||||
* @param string $path The path to be checked.
|
||||
* @param int $network_id Optional. Network ID. Relevant only on multi-network installs.
|
||||
* @return int
|
||||
*/
|
||||
function domain_exists($domain, $path, $site_id = 1) {
|
||||
function domain_exists( $domain, $path, $network_id = 1 ) {
|
||||
$path = trailingslashit( $path );
|
||||
$args = array(
|
||||
'network_id' => $site_id,
|
||||
'domain' => $domain,
|
||||
'path' => $path,
|
||||
'fields' => 'ids',
|
||||
'network_id' => $network_id,
|
||||
'domain' => $domain,
|
||||
'path' => $path,
|
||||
'fields' => 'ids',
|
||||
);
|
||||
$result = get_sites( $args );
|
||||
$result = array_shift( $result );
|
||||
@@ -1371,12 +1371,12 @@ function domain_exists($domain, $path, $site_id = 1) {
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param int|null $result The blog_id if the blogname exists, null otherwise.
|
||||
* @param string $domain Domain to be checked.
|
||||
* @param string $path Path to be checked.
|
||||
* @param int $site_id Site ID. Relevant only on multi-network installs.
|
||||
* @param int|null $result The blog_id if the blogname exists, null otherwise.
|
||||
* @param string $domain Domain to be checked.
|
||||
* @param string $path Path to be checked.
|
||||
* @param int $network_id Network ID. Relevant only on multi-network installs.
|
||||
*/
|
||||
return apply_filters( 'domain_exists', $result, $domain, $path, $site_id );
|
||||
return apply_filters( 'domain_exists', $result, $domain, $path, $network_id );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1389,25 +1389,25 @@ function domain_exists($domain, $path, $site_id = 1) {
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param string $domain The domain of the new site.
|
||||
* @param string $path The path of the new site.
|
||||
* @param int $site_id Unless you're running a multi-network install, be sure to set this value to 1.
|
||||
* @param string $domain The domain of the new site.
|
||||
* @param string $path The path of the new site.
|
||||
* @param int $network_id Unless you're running a multi-network install, be sure to set this value to 1.
|
||||
* @return int|false The ID of the new row
|
||||
*/
|
||||
function insert_blog($domain, $path, $site_id) {
|
||||
function insert_blog($domain, $path, $network_id) {
|
||||
global $wpdb;
|
||||
|
||||
$path = trailingslashit($path);
|
||||
$site_id = (int) $site_id;
|
||||
$network_id = (int) $network_id;
|
||||
|
||||
$result = $wpdb->insert( $wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) );
|
||||
$result = $wpdb->insert( $wpdb->blogs, array('site_id' => $network_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) );
|
||||
if ( ! $result )
|
||||
return false;
|
||||
|
||||
$blog_id = $wpdb->insert_id;
|
||||
refresh_blog_details( $blog_id );
|
||||
|
||||
wp_maybe_update_network_site_counts( $site_id );
|
||||
wp_maybe_update_network_site_counts( $network_id );
|
||||
|
||||
return $blog_id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user