mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-30 23:30:05 +00:00
Multisite: Use get_network() and get_current_network_id() for current network data.
`get_network()` falls back to the current network when called without any arguments. Between this and `get_current_network_id()`, we can replace almost all instances of the global `$current_site` and all instances of `get_current_site()`. This effectively deprecates `get_current_site()`, something that we'll do in a future ticket. Props flixos90. Fixes #37414. git-svn-id: https://develop.svn.wordpress.org/trunk@38814 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -312,10 +312,10 @@ function wp_admin_bar_site_menu( $wp_admin_bar ) {
|
||||
|
||||
if ( is_network_admin() ) {
|
||||
/* translators: %s: site name */
|
||||
$blogname = sprintf( __( 'Network Admin: %s' ), esc_html( get_current_site()->site_name ) );
|
||||
$blogname = sprintf( __( 'Network Admin: %s' ), esc_html( get_network()->site_name ) );
|
||||
} elseif ( is_user_admin() ) {
|
||||
/* translators: %s: site name */
|
||||
$blogname = sprintf( __( 'User Dashboard: %s' ), esc_html( get_current_site()->site_name ) );
|
||||
$blogname = sprintf( __( 'User Dashboard: %s' ), esc_html( get_network()->site_name ) );
|
||||
}
|
||||
|
||||
$title = wp_html_excerpt( $blogname, 40, '…' );
|
||||
|
||||
@@ -628,7 +628,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
foreach ( $blogs as $blog ) {
|
||||
// Don't include blogs that aren't hosted at this site.
|
||||
if ( $blog->site_id != get_current_site()->id )
|
||||
if ( $blog->site_id != get_current_network_id() )
|
||||
continue;
|
||||
|
||||
$blog_id = $blog->userblog_id;
|
||||
|
||||
@@ -4302,23 +4302,18 @@ function wp_suspend_cache_invalidation( $suspend = true ) {
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @global object $current_site
|
||||
*
|
||||
* @param int $site_id Optional. Site ID to test. Defaults to current site.
|
||||
* @return bool True if $site_id is the main site of the network, or if not
|
||||
* running Multisite.
|
||||
*/
|
||||
function is_main_site( $site_id = null ) {
|
||||
// This is the current network's information; 'site' is old terminology.
|
||||
global $current_site;
|
||||
|
||||
if ( ! is_multisite() )
|
||||
return true;
|
||||
|
||||
if ( ! $site_id )
|
||||
$site_id = get_current_blog_id();
|
||||
|
||||
return (int) $site_id === (int) $current_site->blog_id;
|
||||
return (int) $site_id === (int) get_network()->site_id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4334,10 +4329,8 @@ function is_main_network( $network_id = null ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$current_network_id = (int) get_current_site()->id;
|
||||
|
||||
if ( null === $network_id ) {
|
||||
$network_id = $current_network_id;
|
||||
$network_id = get_current_network_id();
|
||||
}
|
||||
|
||||
$network_id = (int) $network_id;
|
||||
@@ -4357,11 +4350,11 @@ function get_main_network_id() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
$current_site = get_current_site();
|
||||
$current_network = get_network();
|
||||
|
||||
if ( defined( 'PRIMARY_NETWORK_ID' ) ) {
|
||||
$main_network_id = PRIMARY_NETWORK_ID;
|
||||
} elseif ( isset( $current_site->id ) && 1 === (int) $current_site->id ) {
|
||||
} elseif ( isset( $current_network->id ) && 1 === (int) $current_network->id ) {
|
||||
// If the current network has an ID of 1, assume it is the main network.
|
||||
$main_network_id = 1;
|
||||
} else {
|
||||
|
||||
@@ -617,7 +617,7 @@ function ms_allowed_http_request_hosts( $is_external, $host ) {
|
||||
static $queried = array();
|
||||
if ( $is_external )
|
||||
return $is_external;
|
||||
if ( $host === get_current_site()->domain )
|
||||
if ( $host === get_network()->domain )
|
||||
return true;
|
||||
if ( isset( $queried[ $host ] ) )
|
||||
return $queried[ $host ];
|
||||
|
||||
@@ -3255,12 +3255,12 @@ function network_site_url( $path = '', $scheme = null ) {
|
||||
if ( ! is_multisite() )
|
||||
return site_url($path, $scheme);
|
||||
|
||||
$current_site = get_current_site();
|
||||
$current_network = get_network();
|
||||
|
||||
if ( 'relative' == $scheme )
|
||||
$url = $current_site->path;
|
||||
$url = $current_network->path;
|
||||
else
|
||||
$url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme );
|
||||
$url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme );
|
||||
|
||||
if ( $path && is_string( $path ) )
|
||||
$url .= ltrim( $path, '/' );
|
||||
@@ -3297,16 +3297,16 @@ function network_home_url( $path = '', $scheme = null ) {
|
||||
if ( ! is_multisite() )
|
||||
return home_url($path, $scheme);
|
||||
|
||||
$current_site = get_current_site();
|
||||
$current_network = get_network();
|
||||
$orig_scheme = $scheme;
|
||||
|
||||
if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) )
|
||||
$scheme = is_ssl() && ! is_admin() ? 'https' : 'http';
|
||||
|
||||
if ( 'relative' == $scheme )
|
||||
$url = $current_site->path;
|
||||
$url = $current_network->path;
|
||||
else
|
||||
$url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme );
|
||||
$url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme );
|
||||
|
||||
if ( $path && is_string( $path ) )
|
||||
$url .= ltrim( $path, '/' );
|
||||
|
||||
@@ -814,8 +814,6 @@ function get_current_blog_id() {
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @global WP_Network $current_site The current network.
|
||||
*
|
||||
* @return int The ID of the current network.
|
||||
*/
|
||||
function get_current_network_id() {
|
||||
@@ -823,13 +821,13 @@ function get_current_network_id() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
$current_site = get_current_site();
|
||||
$current_network = get_network();
|
||||
|
||||
if ( ! isset( $current_site->id ) ) {
|
||||
if ( ! isset( $current_network->id ) ) {
|
||||
return get_main_network_id();
|
||||
}
|
||||
|
||||
return absint( $current_site->id );
|
||||
return absint( $current_network->id );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -81,15 +81,15 @@ function get_blogaddress_by_name( $blogname ) {
|
||||
* @return int|null The site ID, or null if no site is found for the given slug.
|
||||
*/
|
||||
function get_id_from_blogname( $slug ) {
|
||||
$current_site = get_current_site();
|
||||
$current_network = get_network();
|
||||
$slug = trim( $slug, '/' );
|
||||
|
||||
if ( is_subdomain_install() ) {
|
||||
$domain = $slug . '.' . preg_replace( '|^www\.|', '', $current_site->domain );
|
||||
$path = $current_site->path;
|
||||
$domain = $slug . '.' . preg_replace( '|^www\.|', '', $current_network->domain );
|
||||
$path = $current_network->path;
|
||||
} else {
|
||||
$domain = $current_site->domain;
|
||||
$path = $current_site->path . $slug . '/';
|
||||
$domain = $current_network->domain;
|
||||
$path = $current_network->path . $slug . '/';
|
||||
}
|
||||
|
||||
$site_ids = get_sites( array(
|
||||
|
||||
@@ -47,19 +47,19 @@ function ms_upload_constants() {
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function ms_cookie_constants( ) {
|
||||
$current_site = get_current_site();
|
||||
$current_network = get_network();
|
||||
|
||||
/**
|
||||
* @since 1.2.0
|
||||
*/
|
||||
if ( !defined( 'COOKIEPATH' ) )
|
||||
define( 'COOKIEPATH', $current_site->path );
|
||||
define( 'COOKIEPATH', $current_network->path );
|
||||
|
||||
/**
|
||||
* @since 1.5.0
|
||||
*/
|
||||
if ( !defined( 'SITECOOKIEPATH' ) )
|
||||
define( 'SITECOOKIEPATH', $current_site->path );
|
||||
define( 'SITECOOKIEPATH', $current_network->path );
|
||||
|
||||
/**
|
||||
* @since 2.6.0
|
||||
@@ -76,10 +76,10 @@ function ms_cookie_constants( ) {
|
||||
* @since 2.0.0
|
||||
*/
|
||||
if ( !defined('COOKIE_DOMAIN') && is_subdomain_install() ) {
|
||||
if ( !empty( $current_site->cookie_domain ) )
|
||||
define('COOKIE_DOMAIN', '.' . $current_site->cookie_domain);
|
||||
if ( !empty( $current_network->cookie_domain ) )
|
||||
define('COOKIE_DOMAIN', '.' . $current_network->cookie_domain);
|
||||
else
|
||||
define('COOKIE_DOMAIN', '.' . $current_site->domain);
|
||||
define('COOKIE_DOMAIN', '.' . $current_network->domain);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ function get_dashboard_blog() {
|
||||
if ( $blog = get_site_option( 'dashboard_blog' ) )
|
||||
return get_blog_details( $blog );
|
||||
|
||||
return get_blog_details( get_current_site()->blog_id );
|
||||
return get_blog_details( get_network()->site_id );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -546,8 +546,8 @@ function wpmu_validate_user_signup($user_name, $user_email) {
|
||||
function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
|
||||
global $wpdb, $domain;
|
||||
|
||||
$current_site = get_current_site();
|
||||
$base = $current_site->path;
|
||||
$current_network = get_network();
|
||||
$base = $current_network->path;
|
||||
|
||||
$blog_title = strip_tags( $blog_title );
|
||||
|
||||
@@ -580,7 +580,7 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
|
||||
$errors->add('blogname', __( 'Site name must be at least 4 characters.' ) );
|
||||
|
||||
// do not allow users to create a blog that conflicts with a page on the main blog.
|
||||
if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_site->blog_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) )
|
||||
if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_network->site_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) )
|
||||
$errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) );
|
||||
|
||||
// all numeric?
|
||||
@@ -612,7 +612,7 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
|
||||
$mydomain = "$domain";
|
||||
$path = $base.$blogname.'/';
|
||||
}
|
||||
if ( domain_exists($mydomain, $path, $current_site->id) )
|
||||
if ( domain_exists($mydomain, $path, $current_network->id) )
|
||||
$errors->add( 'blogname', __( 'Sorry, that site already exists!' ) );
|
||||
|
||||
if ( username_exists( $blogname ) ) {
|
||||
@@ -789,7 +789,7 @@ function wpmu_signup_blog_notification( $domain, $path, $title, $user, $user_ema
|
||||
}
|
||||
|
||||
// Send email with activation link.
|
||||
if ( !is_subdomain_install() || get_current_site()->id != 1 )
|
||||
if ( !is_subdomain_install() || get_current_network_id() != 1 )
|
||||
$activate_url = network_site_url("wp-activate.php?key=$key");
|
||||
else
|
||||
$activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo use *_url() API
|
||||
@@ -1334,7 +1334,7 @@ function insert_blog($domain, $path, $site_id) {
|
||||
* @param string $blog_title The title of the new site.
|
||||
*/
|
||||
function install_blog( $blog_id, $blog_title = '' ) {
|
||||
global $wpdb, $wp_roles, $current_site;
|
||||
global $wpdb, $wp_roles;
|
||||
|
||||
// Cast for security
|
||||
$blog_id = (int) $blog_id;
|
||||
@@ -1363,7 +1363,7 @@ function install_blog( $blog_id, $blog_title = '' ) {
|
||||
if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
|
||||
$siteurl = set_url_scheme( $siteurl, 'https' );
|
||||
}
|
||||
if ( 'https' === parse_url( get_home_url( $current_site->blog_id ), PHP_URL_SCHEME ) ) {
|
||||
if ( 'https' === parse_url( get_home_url( get_network()->site_id ), PHP_URL_SCHEME ) ) {
|
||||
$home = set_url_scheme( $home, 'https' );
|
||||
}
|
||||
|
||||
@@ -1375,7 +1375,7 @@ function install_blog( $blog_id, $blog_title = '' ) {
|
||||
if ( get_site_option( 'ms_files_rewriting' ) )
|
||||
update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
|
||||
else
|
||||
update_option( 'upload_path', get_blog_option( get_current_site()->blog_id, 'upload_path' ) );
|
||||
update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) );
|
||||
|
||||
update_option( 'blogname', wp_unslash( $blog_title ) );
|
||||
update_option( 'admin_email', '' );
|
||||
@@ -1430,7 +1430,7 @@ function install_blog_defaults($blog_id, $user_id) {
|
||||
* @return bool
|
||||
*/
|
||||
function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = array() ) {
|
||||
$current_site = get_current_site();
|
||||
$current_network = get_network();
|
||||
|
||||
/**
|
||||
* Filters whether to bypass the welcome email after site activation.
|
||||
@@ -1470,7 +1470,7 @@ We hope you enjoy your new site. Thanks!
|
||||
$url = get_blogaddress_by_id($blog_id);
|
||||
$user = get_userdata( $user_id );
|
||||
|
||||
$welcome_email = str_replace( 'SITE_NAME', $current_site->site_name, $welcome_email );
|
||||
$welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email );
|
||||
$welcome_email = str_replace( 'BLOG_TITLE', $title, $welcome_email );
|
||||
$welcome_email = str_replace( 'BLOG_URL', $url, $welcome_email );
|
||||
$welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
|
||||
@@ -1500,8 +1500,8 @@ We hope you enjoy your new site. Thanks!
|
||||
$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
|
||||
$message = $welcome_email;
|
||||
|
||||
if ( empty( $current_site->site_name ) )
|
||||
$current_site->site_name = 'WordPress';
|
||||
if ( empty( $current_network->site_name ) )
|
||||
$current_network->site_name = 'WordPress';
|
||||
|
||||
/**
|
||||
* Filters the subject of the welcome email after site activation.
|
||||
@@ -1510,7 +1510,7 @@ We hope you enjoy your new site. Thanks!
|
||||
*
|
||||
* @param string $subject Subject of the email.
|
||||
*/
|
||||
$subject = apply_filters( 'update_welcome_subject', sprintf( __( 'New %1$s Site: %2$s' ), $current_site->site_name, wp_unslash( $title ) ) );
|
||||
$subject = apply_filters( 'update_welcome_subject', sprintf( __( 'New %1$s Site: %2$s' ), $current_network->site_name, wp_unslash( $title ) ) );
|
||||
wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
|
||||
return true;
|
||||
}
|
||||
@@ -1531,7 +1531,7 @@ We hope you enjoy your new site. Thanks!
|
||||
* @return bool
|
||||
*/
|
||||
function wpmu_welcome_user_notification( $user_id, $password, $meta = array() ) {
|
||||
$current_site = get_current_site();
|
||||
$current_network = get_network();
|
||||
|
||||
/**
|
||||
* Filters whether to bypass the welcome email after user activation.
|
||||
@@ -1564,7 +1564,7 @@ function wpmu_welcome_user_notification( $user_id, $password, $meta = array() )
|
||||
* @param array $meta Signup meta data.
|
||||
*/
|
||||
$welcome_email = apply_filters( 'update_welcome_user_email', $welcome_email, $user_id, $password, $meta );
|
||||
$welcome_email = str_replace( 'SITE_NAME', $current_site->site_name, $welcome_email );
|
||||
$welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email );
|
||||
$welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
|
||||
$welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );
|
||||
$welcome_email = str_replace( 'LOGINLINK', wp_login_url(), $welcome_email );
|
||||
@@ -1578,8 +1578,8 @@ function wpmu_welcome_user_notification( $user_id, $password, $meta = array() )
|
||||
$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
|
||||
$message = $welcome_email;
|
||||
|
||||
if ( empty( $current_site->site_name ) )
|
||||
$current_site->site_name = 'WordPress';
|
||||
if ( empty( $current_network->site_name ) )
|
||||
$current_network->site_name = 'WordPress';
|
||||
|
||||
/**
|
||||
* Filters the subject of the welcome email after user activation.
|
||||
@@ -1588,7 +1588,7 @@ function wpmu_welcome_user_notification( $user_id, $password, $meta = array() )
|
||||
*
|
||||
* @param string $subject Subject of the email.
|
||||
*/
|
||||
$subject = apply_filters( 'update_welcome_user_subject', sprintf( __( 'New %1$s User: %2$s' ), $current_site->site_name, $user->user_login) );
|
||||
$subject = apply_filters( 'update_welcome_user_subject', sprintf( __( 'New %1$s User: %2$s' ), $current_network->site_name, $user->user_login) );
|
||||
wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
|
||||
return true;
|
||||
}
|
||||
@@ -1877,7 +1877,7 @@ function global_terms( $term_id, $deprecated = '' ) {
|
||||
* @return array The current site's domain
|
||||
*/
|
||||
function redirect_this_site( $deprecated = '' ) {
|
||||
return array( get_current_site()->domain );
|
||||
return array( get_network()->domain );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2024,7 +2024,7 @@ function add_new_user_to_blog( $user_id, $password, $meta ) {
|
||||
if ( !empty( $meta[ 'add_to_blog' ] ) ) {
|
||||
$blog_id = $meta[ 'add_to_blog' ];
|
||||
$role = $meta[ 'new_role' ];
|
||||
remove_user_from_blog($user_id, get_current_site()->blog_id); // remove user from main blog.
|
||||
remove_user_from_blog($user_id, get_network()->site_id); // remove user from main blog.
|
||||
add_user_to_blog( $blog_id, $user_id, $role );
|
||||
update_user_meta( $user_id, 'primary_blog', $blog_id );
|
||||
}
|
||||
@@ -2038,7 +2038,7 @@ function add_new_user_to_blog( $user_id, $password, $meta ) {
|
||||
* @param PHPMailer $phpmailer The PHPMailer instance, passed by reference.
|
||||
*/
|
||||
function fix_phpmailer_messageid( $phpmailer ) {
|
||||
$phpmailer->Hostname = get_current_site()->domain;
|
||||
$phpmailer->Hostname = get_network()->domain;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -97,7 +97,7 @@ function ms_site_check() {
|
||||
if ( file_exists( WP_CONTENT_DIR . '/blog-inactive.php' ) ) {
|
||||
return WP_CONTENT_DIR . '/blog-inactive.php';
|
||||
} else {
|
||||
$admin_email = str_replace( '@', ' AT ', get_site_option( 'admin_email', 'support@' . get_current_site()->domain ) );
|
||||
$admin_email = str_replace( '@', ' AT ', get_site_option( 'admin_email', 'support@' . get_network()->domain ) );
|
||||
wp_die(
|
||||
/* translators: %s: admin email link */
|
||||
sprintf( __( 'This site has not been activated yet. If you are having problems activating your site, please contact %s.' ),
|
||||
|
||||
@@ -1069,8 +1069,7 @@ function update_site_option( $option, $value ) {
|
||||
*
|
||||
* @see get_option()
|
||||
*
|
||||
* @global wpdb $wpdb
|
||||
* @global object $current_site
|
||||
* @global wpdb $wpdb
|
||||
*
|
||||
* @param int $network_id ID of the network. Can be null to default to the current network ID.
|
||||
* @param string $option Name of option to retrieve. Expected to not be SQL-escaped.
|
||||
@@ -1078,7 +1077,7 @@ function update_site_option( $option, $value ) {
|
||||
* @return mixed Value set for the option.
|
||||
*/
|
||||
function get_network_option( $network_id, $option, $default = false ) {
|
||||
global $wpdb, $current_site;
|
||||
global $wpdb;
|
||||
|
||||
if ( $network_id && ! is_numeric( $network_id ) ) {
|
||||
return false;
|
||||
@@ -1087,8 +1086,8 @@ function get_network_option( $network_id, $option, $default = false ) {
|
||||
$network_id = (int) $network_id;
|
||||
|
||||
// Fallback to the current network if a network ID is not specified.
|
||||
if ( ! $network_id && is_multisite() ) {
|
||||
$network_id = $current_site->id;
|
||||
if ( ! $network_id ) {
|
||||
$network_id = get_current_network_id();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1186,8 +1185,7 @@ function get_network_option( $network_id, $option, $default = false ) {
|
||||
*
|
||||
* @see add_option()
|
||||
*
|
||||
* @global wpdb $wpdb
|
||||
* @global object $current_site
|
||||
* @global wpdb $wpdb
|
||||
*
|
||||
* @param int $network_id ID of the network. Can be null to default to the current network ID.
|
||||
* @param string $option Name of option to add. Expected to not be SQL-escaped.
|
||||
@@ -1195,7 +1193,7 @@ function get_network_option( $network_id, $option, $default = false ) {
|
||||
* @return bool False if option was not added and true if option was added.
|
||||
*/
|
||||
function add_network_option( $network_id, $option, $value ) {
|
||||
global $wpdb, $current_site;
|
||||
global $wpdb;
|
||||
|
||||
if ( $network_id && ! is_numeric( $network_id ) ) {
|
||||
return false;
|
||||
@@ -1204,8 +1202,8 @@ function add_network_option( $network_id, $option, $value ) {
|
||||
$network_id = (int) $network_id;
|
||||
|
||||
// Fallback to the current network if a network ID is not specified.
|
||||
if ( ! $network_id && is_multisite() ) {
|
||||
$network_id = $current_site->id;
|
||||
if ( ! $network_id ) {
|
||||
$network_id = get_current_network_id();
|
||||
}
|
||||
|
||||
wp_protect_special_option( $option );
|
||||
@@ -1296,15 +1294,14 @@ function add_network_option( $network_id, $option, $value ) {
|
||||
*
|
||||
* @see delete_option()
|
||||
*
|
||||
* @global wpdb $wpdb
|
||||
* @global object $current_site
|
||||
* @global wpdb $wpdb
|
||||
*
|
||||
* @param int $network_id ID of the network. Can be null to default to the current network ID.
|
||||
* @param string $option Name of option to remove. Expected to not be SQL-escaped.
|
||||
* @return bool True, if succeed. False, if failure.
|
||||
*/
|
||||
function delete_network_option( $network_id, $option ) {
|
||||
global $wpdb, $current_site;
|
||||
global $wpdb;
|
||||
|
||||
if ( $network_id && ! is_numeric( $network_id ) ) {
|
||||
return false;
|
||||
@@ -1313,8 +1310,8 @@ function delete_network_option( $network_id, $option ) {
|
||||
$network_id = (int) $network_id;
|
||||
|
||||
// Fallback to the current network if a network ID is not specified.
|
||||
if ( ! $network_id && is_multisite() ) {
|
||||
$network_id = $current_site->id;
|
||||
if ( ! $network_id ) {
|
||||
$network_id = get_current_network_id();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1378,8 +1375,7 @@ function delete_network_option( $network_id, $option ) {
|
||||
*
|
||||
* @see update_option()
|
||||
*
|
||||
* @global wpdb $wpdb
|
||||
* @global object $current_site
|
||||
* @global wpdb $wpdb
|
||||
*
|
||||
* @param int $network_id ID of the network. Can be null to default to the current network ID.
|
||||
* @param string $option Name of option. Expected to not be SQL-escaped.
|
||||
@@ -1387,7 +1383,7 @@ function delete_network_option( $network_id, $option ) {
|
||||
* @return bool False if value was not updated and true if value was updated.
|
||||
*/
|
||||
function update_network_option( $network_id, $option, $value ) {
|
||||
global $wpdb, $current_site;
|
||||
global $wpdb;
|
||||
|
||||
if ( $network_id && ! is_numeric( $network_id ) ) {
|
||||
return false;
|
||||
@@ -1396,8 +1392,8 @@ function update_network_option( $network_id, $option, $value ) {
|
||||
$network_id = (int) $network_id;
|
||||
|
||||
// Fallback to the current network if a network ID is not specified.
|
||||
if ( ! $network_id && is_multisite() ) {
|
||||
$network_id = $current_site->id;
|
||||
if ( ! $network_id ) {
|
||||
$network_id = get_current_network_id();
|
||||
}
|
||||
|
||||
wp_protect_special_option( $option );
|
||||
|
||||
Reference in New Issue
Block a user