Skip to content

Commit

Permalink
General: Stop direct loading of files in /wp-admin that should only…
Browse files Browse the repository at this point in the history
… be included.

This changeset restricts direct access call in `/wp-admin` and its sub directories.

Follow-up to [11768].

Props deepakrohilla.
See #61314.




git-svn-id: https://develop.svn.wordpress.org/trunk@59678 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
audrasjb committed Jan 22, 2025
1 parent 0f2334d commit c7cd04c
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/wp-admin/admin-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
* @subpackage Administration
*/

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}

_deprecated_file( basename( __FILE__ ), '2.5.0', 'wp-admin/includes/admin.php' );

/** WordPress Administration API: Includes all Administration functions. */
Expand Down
5 changes: 5 additions & 0 deletions src/wp-admin/admin-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* @subpackage Administration
*/

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}

header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
if ( ! defined( 'WP_ADMIN' ) ) {
require_once __DIR__ . '/admin.php';
Expand Down
5 changes: 5 additions & 0 deletions src/wp-admin/custom-background.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
* @subpackage Administration
*/

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}

_deprecated_file( basename( __FILE__ ), '5.3.0', 'wp-admin/includes/class-custom-background.php' );

/** Custom_Background class */
Expand Down
5 changes: 5 additions & 0 deletions src/wp-admin/custom-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
* @subpackage Administration
*/

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}

_deprecated_file( basename( __FILE__ ), '5.3.0', 'wp-admin/includes/class-custom-image-header.php' );

/** Custom_Image_Header class */
Expand Down
5 changes: 5 additions & 0 deletions src/wp-admin/menu-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* @subpackage Administration
*/

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}

/**
* The current page.
*
Expand Down
5 changes: 5 additions & 0 deletions src/wp-admin/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* @subpackage Administration
*/

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}

/**
* Constructs the admin menu.
*
Expand Down
5 changes: 5 additions & 0 deletions src/wp-admin/network/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
* @since 3.1.0
*/

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}

/* translators: Network menu item. */
$menu[2] = array( __( 'Dashboard' ), 'manage_network', 'index.php', '', 'menu-top menu-top-first menu-icon-dashboard', 'menu-dashboard', 'dashicons-dashboard' );

Expand Down
5 changes: 5 additions & 0 deletions src/wp-admin/options-head.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
* @subpackage Administration
*/

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}

$action = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';

if ( isset( $_GET['updated'] ) && isset( $_GET['page'] ) ) {
Expand Down
5 changes: 5 additions & 0 deletions src/wp-admin/user/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
* @since 3.1.0
*/

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}

$menu[2] = array( __( 'Dashboard' ), 'exist', 'index.php', '', 'menu-top menu-top-first menu-icon-dashboard', 'menu-dashboard', 'dashicons-dashboard' );

$menu[4] = array( '', 'exist', 'separator1', '', 'wp-menu-separator' );
Expand Down

0 comments on commit c7cd04c

Please sign in to comment.