Opened 13 months ago
#60559 new defect (bug)
Widgets moved by calling the sidebars endpoint
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Widgets | Keywords: | |
Focuses: | rest-api | Cc: |
Description
The GET /wp/v2/sidebars endpoint moves the widgets permanently, if for some reasons, one or more sidebars are not registered for WP REST. Moreover, it does it even if it returns a 401 status code.
To reproduce the issue:
- Have Gutenberg disable with the "Disable Gutenberg" plugin
- Add this code to theme's functions.php
function test_register_sidebars() { if ( strpos( $_SERVER['REQUEST_URI'], '/wp-json/' ) === false ) { register_sidebar( [ 'name' => 'Sidebar 1 - not registered on WP REST', 'id' => 'sidebar-1', 'before_widget' => '<section id="%1$s" class="widget %2$s">', 'after_widget' => '</section>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2>', ] ); } register_sidebar( [ 'name' => 'Sidebar 2', 'id' => 'sidebar-2', 'before_widget' => '<section id="%1$s" class="widget %2$s">', 'after_widget' => '</section>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2>', ] ); } add_action( 'widgets_init', 'test_register_sidebars' );
- Add widgets to "Sidebar 1"
- Visit GET /wp-json/wp/v2/sidebars
Attachments (1)
Note: See
TracTickets for help on using
tickets.