--- a/wp/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php Fri Sep 05 18:40:08 2025 +0200
@@ -261,8 +261,10 @@
* @return true|WP_Error True if the request has read access, WP_Error object otherwise.
*/
protected function do_permissions_check() {
- // Verify if the current user has edit_theme_options capability.
- // This capability is required to access the widgets screen.
+ /*
+ * Verify if the current user has edit_theme_options capability.
+ * This capability is required to access the widgets screen.
+ */
if ( ! current_user_can( 'edit_theme_options' ) ) {
return new WP_Error(
'rest_cannot_manage_widgets',
@@ -318,8 +320,9 @@
// Restores the more descriptive, specific name for use within this method.
$raw_sidebar = $item;
- $id = $raw_sidebar['id'];
- $sidebar = array( 'id' => $id );
+
+ $id = $raw_sidebar['id'];
+ $sidebar = array( 'id' => $id );
if ( isset( $wp_registered_sidebars[ $id ] ) ) {
$registered_sidebar = $wp_registered_sidebars[ $id ];
@@ -339,6 +342,10 @@
$sidebar['class'] = '';
}
+ if ( wp_is_block_theme() ) {
+ $sidebar['status'] = 'inactive';
+ }
+
$fields = $this->get_fields_for_response( $request );
if ( rest_is_field_included( 'widgets', $fields ) ) {
$sidebars = wp_get_sidebars_widgets();
@@ -368,7 +375,9 @@
$response = rest_ensure_response( $data );
- $response->add_links( $this->prepare_links( $sidebar ) );
+ if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) {
+ $response->add_links( $this->prepare_links( $sidebar ) );
+ }
/**
* Filters the REST API response for a sidebar.