Options, Meta APIs: Avoid bypassing the option_page_capability_options filter.

This ensures that the filter is available when `wp-admin/options.php` is accessed directly.

Follow-up to [13627], [17986], [25372].

Props amibe.
Fixes #58761.
Built from https://develop.svn.wordpress.org/trunk@61325


git-svn-id: http://core.svn.wordpress.org/trunk@60637 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov
2025-11-30 15:16:33 +00:00
parent 01db8ebedc
commit 588188b2c6
2 changed files with 14 additions and 14 deletions

View File

@@ -31,21 +31,21 @@ $capability = 'manage_options';
// This is for back compat and will eventually be removed.
if ( empty( $option_page ) ) {
$option_page = 'options';
} else {
/**
* Filters the capability required when using the Settings API.
*
* By default, the options groups for all registered settings require the manage_options capability.
* This filter is required to change the capability required for a certain options page.
*
* @since 3.2.0
*
* @param string $capability The capability used for the page, which is manage_options by default.
*/
$capability = apply_filters( "option_page_capability_{$option_page}", $capability );
}
/**
* Filters the capability required when using the Settings API.
*
* By default, the options groups for all registered settings require the manage_options capability.
* This filter is required to change the capability required for a certain options page.
*
* @since 3.2.0
* @since 7.0.0 Applied when `wp-admin/options.php` is accessed directly.
*
* @param string $capability The capability used for the page, which is manage_options by default.
*/
$capability = apply_filters( "option_page_capability_{$option_page}", $capability );
if ( ! current_user_can( $capability ) ) {
wp_die(
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '7.0-alpha-61324';
$wp_version = '7.0-alpha-61325';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.