Make WordPress Core


Ignore:
Timestamp:
02/03/2023 12:13:52 AM (17 months ago)
Author:
hellofromTonya
Message:

Widgets: Preserve classic sidebars when switching to a block theme.

When switching to a block theme, classic sidebars were orphaned and their widgets remapping to the 'wp_inactive_widgets' sidebar . This changeset preserves the sidebars and their widgets, providing a migration path to a block theme without losing the widgets.

Classic sidebars are now:

  • Stored in a new theme mod called 'wp_classic_sidebars';
  • Restored to the $wp_registered_sidebars global variable when the 'widgets_init' action fires (via a new internal function called _wp_block_theme_register_classic_sidebars());
  • And marked as 'inactive' when interacting with sidebars REST API endpoint.

References:

Follow-up to [50995], [6334].

Props mamaduka, audrasjb, hellofromTonya, ironprogrammer, jameskoster, joen, matveb, mukesh27, noisysocks, poena, youknowriad.
Fixes #57531.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-filters.php

    r55192 r55200  
    627627add_action( 'init', 'wp_widgets_init', 1 );
    628628add_action( 'change_locale', array( 'WP_Widget_Media', 'reset_default_labels' ) );
     629add_action( 'widgets_init', '_wp_block_theme_register_classic_sidebars', 1 );
    629630
    630631// Admin Bar.
Note: See TracChangeset for help on using the changeset viewer.