[wp-trac] [WordPress Trac] #60559: Widgets moved by calling the sidebars endpoint
WordPress Trac
noreply at wordpress.org
Fri Feb 16 10:02:07 UTC 2024
#60559: Widgets moved by calling the sidebars endpoint
--------------------------+-----------------------------
Reporter: davit16 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Widgets | Version:
Severity: normal | Keywords:
Focuses: rest-api |
--------------------------+-----------------------------
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:
1. Have Gutenberg disable with the "Disable Gutenberg" plugin
2. Add this code to theme's functions.php
{{{#!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' );
}}}
3. Add widgets to "Sidebar 1"
4. Visit GET /wp-json/wp/v2/sidebars
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60559>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list