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. Built from https://develop.svn.wordpress.org/trunk@51235 git-svn-id: http://core.svn.wordpress.org/trunk@50844 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4b17d6b3e9
commit
dc710243a3
|
@ -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.
|
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
|
||||||
*/
|
*/
|
||||||
public function get_items( $request ) {
|
public function get_items( $request ) {
|
||||||
|
retrieve_widgets();
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
foreach ( (array) wp_get_sidebars_widgets() as $id => $widgets ) {
|
foreach ( wp_get_sidebars_widgets() as $id => $widgets ) {
|
||||||
$sidebar = $this->get_sidebar( $id );
|
$sidebar = $this->get_sidebar( $id );
|
||||||
|
|
||||||
if ( ! $sidebar ) {
|
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.
|
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
|
||||||
*/
|
*/
|
||||||
public function get_item( $request ) {
|
public function get_item( $request ) {
|
||||||
|
retrieve_widgets();
|
||||||
|
|
||||||
$sidebar = $this->get_sidebar( $request['id'] );
|
$sidebar = $this->get_sidebar( $request['id'] );
|
||||||
|
|
||||||
if ( ! $sidebar ) {
|
if ( ! $sidebar ) {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.8-beta3-51234';
|
$wp_version = '5.8-beta3-51235';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue