Widgets: Revert [51705].
While the new name is much better, it doesn't fully tell what will happen when invoked nor does it fully solve the root problems. Why? The function is doing too much. And naming is hard. Props azaozz, desrosj, andraganescu, zieladam, hellofromTonya. See #53811. Built from https://develop.svn.wordpress.org/trunk@51791 git-svn-id: http://core.svn.wordpress.org/trunk@51398 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1d0e1397fd
commit
07139653b9
|
@ -1773,7 +1773,7 @@ function upgrade_330() {
|
|||
|
||||
// Intentional fall-through to upgrade to the next version.
|
||||
case 2:
|
||||
$sidebars_widgets = sync_registered_widgets();
|
||||
$sidebars_widgets = retrieve_widgets();
|
||||
$sidebars_widgets['array_version'] = 3;
|
||||
update_option( 'sidebars_widgets', $sidebars_widgets );
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ register_sidebar(
|
|||
)
|
||||
);
|
||||
|
||||
sync_registered_widgets();
|
||||
retrieve_widgets();
|
||||
|
||||
// We're saving a widget without JS.
|
||||
if ( isset( $_POST['savewidget'] ) || isset( $_POST['removewidget'] ) ) {
|
||||
|
|
|
@ -275,9 +275,9 @@ final class WP_Customize_Widgets {
|
|||
add_filter( 'customize_value_old_sidebars_widgets_data', array( $this, 'filter_customize_value_old_sidebars_widgets_data' ) );
|
||||
$this->manager->set_post_value( 'old_sidebars_widgets_data', $this->old_sidebars_widgets ); // Override any value cached in changeset.
|
||||
|
||||
// sync_registered_widgets() looks at the global $sidebars_widgets.
|
||||
// retrieve_widgets() looks at the global $sidebars_widgets.
|
||||
$sidebars_widgets = $this->old_sidebars_widgets;
|
||||
$sidebars_widgets = sync_registered_widgets( 'customize' );
|
||||
$sidebars_widgets = retrieve_widgets( 'customize' );
|
||||
add_filter( 'option_sidebars_widgets', array( $this, 'filter_option_sidebars_widgets_for_theme_switch' ), 1 );
|
||||
// Reset global cache var used by wp_get_sidebars_widgets().
|
||||
unset( $GLOBALS['_wp_sidebars_widgets'] );
|
||||
|
@ -287,7 +287,7 @@ final class WP_Customize_Widgets {
|
|||
* Filters old_sidebars_widgets_data Customizer setting.
|
||||
*
|
||||
* When switching themes, filter the Customizer setting old_sidebars_widgets_data
|
||||
* to supply initial $sidebars_widgets before they were overridden by sync_registered_widgets().
|
||||
* to supply initial $sidebars_widgets before they were overridden by retrieve_widgets().
|
||||
* The value for old_sidebars_widgets_data gets set in the old theme's sidebars_widgets
|
||||
* theme_mod.
|
||||
*
|
||||
|
@ -305,7 +305,7 @@ final class WP_Customize_Widgets {
|
|||
/**
|
||||
* Filters sidebars_widgets option for theme switch.
|
||||
*
|
||||
* When switching themes, the sync_registered_widgets() function is run when the Customizer initializes,
|
||||
* When switching themes, the retrieve_widgets() function is run when the Customizer initializes,
|
||||
* and then the new sidebars_widgets here get supplied as the default value for the sidebars_widgets
|
||||
* option.
|
||||
*
|
||||
|
|
|
@ -98,7 +98,7 @@ 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 ) {
|
||||
sync_registered_widgets();
|
||||
retrieve_widgets();
|
||||
|
||||
$data = array();
|
||||
foreach ( wp_get_sidebars_widgets() as $id => $widgets ) {
|
||||
|
@ -137,7 +137,7 @@ 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 ) {
|
||||
sync_registered_widgets();
|
||||
retrieve_widgets();
|
||||
|
||||
$sidebar = $this->get_sidebar( $request['id'] );
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ class WP_REST_Widgets_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 ) {
|
||||
sync_registered_widgets();
|
||||
retrieve_widgets();
|
||||
|
||||
$prepared = array();
|
||||
|
||||
|
@ -151,7 +151,7 @@ class WP_REST_Widgets_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 ) {
|
||||
sync_registered_widgets();
|
||||
retrieve_widgets();
|
||||
|
||||
$widget_id = $request['id'];
|
||||
$sidebar_id = wp_find_widgets_sidebar( $widget_id );
|
||||
|
@ -237,7 +237,7 @@ class WP_REST_Widgets_Controller extends WP_REST_Controller {
|
|||
global $wp_widget_factory;
|
||||
|
||||
/*
|
||||
* sync_registered_widgets() contains logic to move "hidden" or "lost" widgets to the
|
||||
* retrieve_widgets() contains logic to move "hidden" or "lost" widgets to the
|
||||
* wp_inactive_widgets sidebar based on the contents of the $sidebars_widgets global.
|
||||
*
|
||||
* When batch requests are processed, this global is not properly updated by previous
|
||||
|
@ -248,7 +248,7 @@ class WP_REST_Widgets_Controller extends WP_REST_Controller {
|
|||
*/
|
||||
wp_get_sidebars_widgets();
|
||||
|
||||
sync_registered_widgets();
|
||||
retrieve_widgets();
|
||||
|
||||
$widget_id = $request['id'];
|
||||
$sidebar_id = wp_find_widgets_sidebar( $widget_id );
|
||||
|
@ -313,7 +313,7 @@ class WP_REST_Widgets_Controller extends WP_REST_Controller {
|
|||
global $wp_widget_factory, $wp_registered_widget_updates;
|
||||
|
||||
/*
|
||||
* sync_registered_widgets() contains logic to move "hidden" or "lost" widgets to the
|
||||
* retrieve_widgets() contains logic to move "hidden" or "lost" widgets to the
|
||||
* wp_inactive_widgets sidebar based on the contents of the $sidebars_widgets global.
|
||||
*
|
||||
* When batch requests are processed, this global is not properly updated by previous
|
||||
|
@ -324,7 +324,7 @@ class WP_REST_Widgets_Controller extends WP_REST_Controller {
|
|||
*/
|
||||
wp_get_sidebars_widgets();
|
||||
|
||||
sync_registered_widgets();
|
||||
retrieve_widgets();
|
||||
|
||||
$widget_id = $request['id'];
|
||||
$sidebar_id = wp_find_widgets_sidebar( $widget_id );
|
||||
|
|
|
@ -805,7 +805,7 @@ function switch_theme( $stylesheet ) {
|
|||
add_option( "theme_mods_$stylesheet", $default_theme_mods );
|
||||
} else {
|
||||
/*
|
||||
* Since sync_registered_widgets() is called when initializing a theme in the Customizer,
|
||||
* Since retrieve_widgets() is called when initializing a theme in the Customizer,
|
||||
* we need to remove the theme mods to avoid overwriting changes made via
|
||||
* the Customizer when accessing wp-admin/widgets.php.
|
||||
*/
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.9-alpha-51790';
|
||||
$wp_version = '5.9-alpha-51791';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
|
@ -1251,30 +1251,13 @@ function _wp_sidebars_changed() {
|
|||
$sidebars_widgets = wp_get_sidebars_widgets();
|
||||
}
|
||||
|
||||
sync_registered_widgets( true );
|
||||
retrieve_widgets( true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use, deprecated.
|
||||
*
|
||||
* Use sync_registered_widgets() instead.
|
||||
* Look for "lost" widgets, this has to run at least on each theme change.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @deprecated 5.8.1 Use sync_registered_widgets()
|
||||
* @see sync_registered_widgets()
|
||||
*
|
||||
* @param string|bool $theme_changed
|
||||
* @return array
|
||||
*/
|
||||
function retrieve_widgets( $theme_changed = false ) {
|
||||
return sync_registered_widgets( $theme_changed );
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for "lost" widgets and Updates widgets-to-sidebars allocation.
|
||||
* This has to run at least on each theme change.
|
||||
*
|
||||
* @since 5.8.1
|
||||
*
|
||||
* @global array $wp_registered_sidebars Registered sidebars.
|
||||
* @global array $sidebars_widgets
|
||||
|
@ -1284,7 +1267,7 @@ function retrieve_widgets( $theme_changed = false ) {
|
|||
* of 'customize' defers updates for the Customizer.
|
||||
* @return array Updated sidebars widgets.
|
||||
*/
|
||||
function sync_registered_widgets( $theme_changed = false ) {
|
||||
function retrieve_widgets( $theme_changed = false ) {
|
||||
global $wp_registered_sidebars, $sidebars_widgets, $wp_registered_widgets;
|
||||
|
||||
$registered_sidebars_keys = array_keys( $wp_registered_sidebars );
|
||||
|
|
Loading…
Reference in New Issue