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. Built from https://develop.svn.wordpress.org/trunk@38814 git-svn-id: http://core.svn.wordpress.org/trunk@38757 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -87,7 +87,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
header( 'Content-Type: text/html; charset=utf-8' );
|
||||
}
|
||||
|
||||
if ( $current_site->blog_id == $id ) {
|
||||
if ( get_network()->site_id == $id ) {
|
||||
wp_die( __( 'Sorry, you are not allowed to change the current site.' ) );
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
wp_die( __( 'Sorry, you are not allowed to access this page.' ), '', array( 'response' => 403 ) );
|
||||
|
||||
$updated_action = 'not_deleted';
|
||||
if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) {
|
||||
if ( $id != '0' && $id != get_network()->site_id && current_user_can( 'delete_site', $id ) ) {
|
||||
wpmu_delete_blog( $id, true );
|
||||
$updated_action = 'delete';
|
||||
}
|
||||
@@ -137,7 +137,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
$doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
|
||||
|
||||
foreach ( (array) $_POST['allblogs'] as $key => $val ) {
|
||||
if ( $val != '0' && $val != $current_site->blog_id ) {
|
||||
if ( $val != '0' && $val != get_network()->site_id ) {
|
||||
switch ( $doaction ) {
|
||||
case 'delete':
|
||||
if ( ! current_user_can( 'delete_site', $val ) )
|
||||
|
||||
Reference in New Issue
Block a user