mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
REST API: Retrieve latest widgets before loading sidebars.
This fixes issues where sidebars would be unexpectedly missing from the new widgets screen. Running retrieve_widgets syncs sidebars that were registered after the last theme switch. Props walbo, hellofromTonya, noisysocks. Fixes #53489. git-svn-id: https://develop.svn.wordpress.org/trunk@51235 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -98,8 +98,10 @@ class WP_REST_Sidebars_Controller extends WP_REST_Controller {
|
||||
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
|
||||
*/
|
||||
public function get_items( $request ) {
|
||||
retrieve_widgets();
|
||||
|
||||
$data = array();
|
||||
foreach ( (array) wp_get_sidebars_widgets() as $id => $widgets ) {
|
||||
foreach ( wp_get_sidebars_widgets() as $id => $widgets ) {
|
||||
$sidebar = $this->get_sidebar( $id );
|
||||
|
||||
if ( ! $sidebar ) {
|
||||
@@ -135,6 +137,8 @@ class WP_REST_Sidebars_Controller extends WP_REST_Controller {
|
||||
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
|
||||
*/
|
||||
public function get_item( $request ) {
|
||||
retrieve_widgets();
|
||||
|
||||
$sidebar = $this->get_sidebar( $request['id'] );
|
||||
|
||||
if ( ! $sidebar ) {
|
||||
|
||||
Reference in New Issue
Block a user