Skip to content

Commit 142e7ee

Browse files
committed
General: Unify direct file-access guards to use exit.
Previously, files used three different patterns to block direct access: `die( '-1' )`, `die()`, and `exit()`. They also lacked the explanatory comment or had inconsistent wording. This normalizes all 40 affected files under `src/` to the canonical `exit;` form recommended by the Plugin Developer Handbook. Each is preceded by a consistent `// Don't load directly.` comment. The `-1` return value carried no meaning in a direct file-access context, where no JavaScript AJAX handler exists to interpret it; it was only ever relevant inside `admin-ajax.php` responses, which are left untouched. Developed in WordPress#12340. Follow-up to r11768, r59678, r59688. Props masteradhoc, presskopp, rajinsharwar, mukeshpanchal27, westonruter. Fixes #58987. git-svn-id: https://develop.svn.wordpress.org/trunk@62649 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 578d09b commit 142e7ee

40 files changed

Lines changed: 44 additions & 41 deletions

src/wp-admin/admin-footer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// Don't load directly.
1010
if ( ! defined( 'ABSPATH' ) ) {
11-
die( '-1' );
11+
exit;
1212
}
1313

1414
/**

src/wp-admin/admin-functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
// Don't load directly.
1313
if ( ! defined( 'ABSPATH' ) ) {
14-
die( '-1' );
14+
exit;
1515
}
1616

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

src/wp-admin/admin-header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// Don't load directly.
1010
if ( ! defined( 'ABSPATH' ) ) {
11-
die( '-1' );
11+
exit;
1212
}
1313

1414
header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );

src/wp-admin/custom-background.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
// Don't load directly.
1313
if ( ! defined( 'ABSPATH' ) ) {
14-
die( '-1' );
14+
exit;
1515
}
1616

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

src/wp-admin/custom-header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
// Don't load directly.
1313
if ( ! defined( 'ABSPATH' ) ) {
14-
die( '-1' );
14+
exit;
1515
}
1616

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

src/wp-admin/edit-form-advanced.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// Don't load directly.
1010
if ( ! defined( 'ABSPATH' ) ) {
11-
die( '-1' );
11+
exit;
1212
}
1313

1414
/**

src/wp-admin/edit-form-blocks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// Don't load directly.
1212
if ( ! defined( 'ABSPATH' ) ) {
13-
die( '-1' );
13+
exit;
1414
}
1515

1616
/**

src/wp-admin/edit-form-comment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// Don't load directly.
1010
if ( ! defined( 'ABSPATH' ) ) {
11-
die( '-1' );
11+
exit;
1212
}
1313

1414
/**

src/wp-admin/edit-link-form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// Don't load directly.
1010
if ( ! defined( 'ABSPATH' ) ) {
11-
die( '-1' );
11+
exit;
1212
}
1313

1414
if ( ! empty( $link_id ) ) {

src/wp-admin/edit-tag-form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// Don't load directly.
1010
if ( ! defined( 'ABSPATH' ) ) {
11-
die( '-1' );
11+
exit;
1212
}
1313

1414
// Back compat hooks.

0 commit comments

Comments
 (0)