Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/wp-admin/network/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@

define( 'WP_NETWORK_ADMIN', true );

/** Load WordPress Administration Bootstrap */
require_once dirname( __DIR__ ) . '/admin.php';

if ( ! defined( 'ABSPATH' ) ) {
/** Load WordPress Bootstrap */
require_once dirname( __DIR__, 2 ) . '/wp-load.php';
}
// Do not remove this check. It is required by individual network admin pages.
if ( ! is_multisite() ) {
wp_die( __( 'Multisite support is not enabled.' ) );
}

/** Load WordPress Administration Bootstrap */
require_once dirname( __DIR__ ) . '/admin.php';
$redirect_network_admin_request = ( 0 !== strcasecmp( $current_blog->domain, $current_site->domain ) || 0 !== strcasecmp( $current_blog->path, $current_site->path ) );

/**
Expand Down
55 changes: 55 additions & 0 deletions tests/phpunit/tests/admin/wpNetworkAdmin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/**
* Tests for the network administration bootstrap.
*
* @package WordPress
* @subpackage Administration
*/

/**
* Tests for the network administration bootstrap.
*/
class Tests_Admin_NetworkAdmin extends WP_UnitTestCase {

/**
* Tests that plugin pages are not loaded on a single site.
*
* @ticket 38076
*
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function test_plugin_pages_are_not_loaded_on_a_single_site() {
if ( is_multisite() ) {
$this->markTestSkipped( 'This test is for single site installations.' );
}

$plugin_page_loaded = false;
add_action(
'network_admin_menu',
function () use ( &$plugin_page_loaded ) {
add_menu_page(
'Test Plugin Page',
'Test Plugin Page',
'manage_options',
'test-plugin-page',
function () use ( &$plugin_page_loaded ) {
$plugin_page_loaded = true;
}
);
}
);

$_GET['page'] = 'test-plugin-page';

try {
require ABSPATH . 'wp-admin/network/admin.php';
$this->fail( 'The network administration bootstrap should stop on a single site.' );
} catch ( WPDieException $exception ) {
$this->assertSame( 'Multisite support is not enabled.', $exception->getMessage() );
}

$this->assertFalse( $plugin_page_loaded );
}
}
Loading