WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/25/2021 08:38:04 AM (8 months ago)
Author:
noisysocks
Message:

Adds the widgets block editor to widgets.php and customize.php

Moves the widgets block editor from Gutenberg into WordPress Core.

  • Adds @wordpress/edit-widgets, @wordpress/customize-widgets and @wordpress/widgets.
  • Modifies wp-admin/widgets.php to branch between the old editor and new editor depending on wp_use_widgets_block_editor().
  • Modifies WP_Customize_Widgets to branch between the old editor control and new editor control depending on wp_use_widgets_block_editor().

Fixes #51506.
Props isabel_brison, TimothyBlynJacobs, andraganescu, kevin940726, talldanwp.

File:
1 edited

Legend:

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

    r50995 r50996  
    18021802    register_widget( 'WP_Widget_Block' );
    18031803
     1804    add_theme_support( 'widgets-block-editor' );
     1805
    18041806    /**
    18051807     * Fires after all default WordPress widgets have been registered.
     
    18081810     */
    18091811    do_action( 'widgets_init' );
     1812}
     1813
     1814/**
     1815 * Whether or not to use the block editor to manage widgets. Defaults to true
     1816 * unless a theme has removed support for widgets-block-editor or a plugin has
     1817 * filtered the return value of this function.
     1818 *
     1819 * @since 5.8.0
     1820 *
     1821 * @return boolean Whether or not to use the block editor to manage widgets.
     1822 */
     1823function wp_use_widgets_block_editor() {
     1824    /**
     1825     * Filters whether or not to use the block editor to manage widgets.
     1826     *
     1827     * @param boolean $use_widgets_block_editor Whether or not to use the block editor to manage widgets.
     1828     */
     1829    return apply_filters(
     1830        'use_widgets_block_editor',
     1831        get_theme_support( 'widgets-block-editor' )
     1832    );
    18101833}
    18111834
     
    19721995    return ob_get_clean();
    19731996}
     1997
     1998// Needed until src/blocks/legacy-widget/index.php in @wordpress/block-library
     1999// is updated to use the 'wp_' functions.
     2000function gutenberg_find_widgets_sidebar( $widget_id ) {
     2001    return wp_find_widgets_sidebar( $widget_id );
     2002}
     2003function gutenberg_render_widget( $widget_id, $sidebar_id ) {
     2004    return wp_render_widget( $widget_id, $sidebar_id );
     2005}
     2006function gutenberg_get_widget_object( $id_base ) {
     2007    global $wp_widget_factory;
     2008    return $wp_widget_factory->get_widget_object( $id_base );
     2009}
Note: See TracChangeset for help on using the changeset viewer.