Make WordPress Core


Ignore:
Timestamp:
06/23/2021 01:07:27 AM (4 years ago)
Author:
desrosj
Message:

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.

File:
1 edited

Legend:

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

    r51107 r51214  
    18021802    register_widget( 'WP_Widget_Block' );
    18031803
    1804     add_theme_support( 'widgets-block-editor' );
    1805 
    18061804    /**
    18071805     * Fires after all default WordPress widgets have been registered.
     
    18101808     */
    18111809    do_action( 'widgets_init' );
     1810}
     1811
     1812/**
     1813 * Enables the widgets block editor. This is hooked into 'after_setup_theme' so
     1814 * that the block editor is enabled by default but can be disabled by themes.
     1815 *
     1816 * @since 5.8.0
     1817 *
     1818 * @access private
     1819 */
     1820function wp_setup_widgets_block_editor() {
     1821    add_theme_support( 'widgets-block-editor' );
    18121822}
    18131823
Note: See TracChangeset for help on using the changeset viewer.