Widgets: Add support for the Widgets Editor on `after_setup_theme` instead of `widgets_init`.
This better aligns with developer expectations, as `add_theme_support()` and `remove_theme_support()` are meant to be called within functions attached to the `after_setup_theme` hook. This also adds the `widgets-block-editor` feature to the docblock for `add_theme_support()`. Props kevin940726, caseymilne, jamesros161, noisysocks, Mamaduka, audrasjb, zieladam, hellofromTonya, desrosj. Fixes #53424. Built from https://develop.svn.wordpress.org/trunk@51214 git-svn-id: http://core.svn.wordpress.org/trunk@50823 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
821327ca70
commit
94c655c892
|
@ -597,6 +597,7 @@ add_filter( 'plupload_default_settings', 'wp_show_heic_upload_error' );
|
|||
add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );
|
||||
|
||||
// Widgets.
|
||||
add_action( 'after_setup_theme', 'wp_setup_widgets_block_editor', 1 );
|
||||
add_action( 'init', 'wp_widgets_init', 1 );
|
||||
|
||||
// Admin Bar.
|
||||
|
|
|
@ -2479,6 +2479,7 @@ function get_theme_starter_content() {
|
|||
* @since 5.5.0 The `core-block-patterns` feature was added and is enabled by default.
|
||||
* @since 5.5.0 The `custom-logo` feature now also accepts 'unlink-homepage-logo'.
|
||||
* @since 5.6.0 The `post-formats` feature warns if no array is passed.
|
||||
* @since 5.8.0 The `widgets-block-editor` enables the Widgets block editor.
|
||||
*
|
||||
* @global array $_wp_theme_features
|
||||
*
|
||||
|
@ -2511,6 +2512,7 @@ function get_theme_starter_content() {
|
|||
* - 'title-tag'
|
||||
* - 'wp-block-styles'
|
||||
* - 'widgets'
|
||||
* - 'widgets-block-editor'
|
||||
* @param mixed ...$args Optional extra arguments to pass along with certain features.
|
||||
* @return void|false Void on success, false on failure.
|
||||
*/
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.8-beta2-51213';
|
||||
$wp_version = '5.8-beta2-51214';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
|
@ -1801,8 +1801,6 @@ function wp_widgets_init() {
|
|||
|
||||
register_widget( 'WP_Widget_Block' );
|
||||
|
||||
add_theme_support( 'widgets-block-editor' );
|
||||
|
||||
/**
|
||||
* Fires after all default WordPress widgets have been registered.
|
||||
*
|
||||
|
@ -1811,6 +1809,18 @@ function wp_widgets_init() {
|
|||
do_action( 'widgets_init' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the widgets block editor. This is hooked into 'after_setup_theme' so
|
||||
* that the block editor is enabled by default but can be disabled by themes.
|
||||
*
|
||||
* @since 5.8.0
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function wp_setup_widgets_block_editor() {
|
||||
add_theme_support( 'widgets-block-editor' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not to use the block editor to manage widgets. Defaults to true
|
||||
* unless a theme has removed support for widgets-block-editor or a plugin has
|
||||
|
|
Loading…
Reference in New Issue