Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add block-based widgets editor #1284

Closed
wants to merge 2 commits into from

Conversation

noisysocks
Copy link
Member

@noisysocks noisysocks commented May 24, 2021

Trac ticket: https://core.trac.wordpress.org/ticket/51506

Supersedes #603.
Requires #1293.

This moves the the block-based widget editors over from Gutenberg into Core.

Broadly speaking, there's four parts to this:

  1. @wordpress/edit-widgets, @wordpress/customize-widgets, and @wordpress/widgets are added as dependencies. These packages contain the block editors.

  2. Supporting infrastructure such as WP_Widget_Block has been copied over from Gutenberg.

  3. wp-admin/widgets.php has been modified to branch between the old form-based editor wp-admin/widgets-form.php and the new block-based editor wp-admin/widgets-form-blocks.php depending on get_theme_support( 'widgets-block-editor' ) and use_widgets_block_editor.

  4. WP_Customize_Widgets has been modified to use WP_Sidebar_Block_Editor_Control which contains the block editor instead of WP_Widget_Area_Customize_Control depending on get_theme_support( 'widgets-block-editor' ) and use_widgets_block_editor.

This PR contains WP_REST_Sidebars_Controller and WP_REST_Widget_Utils_Controller so that it's easier to test, but these parts should be committed separately. @TimothyBJacobs is working on it.

How to test

  1. npm run env:start
  2. npm run env:install
  3. npm run dev
  4. Go to Appearance → Widgets to see the widgets.php block editor.
  5. Go to Appearance → Customize → widgets to see the customize.php block editor.

Tasks remaining

  • REST API changes (Add REST API endpoints #1293) need to be committed separately.
  • Customizer changes are not being saved.
  • Figure out if any of WP_Customize_Widgets::enqueue_scripts can be skipped if block editor is enabled.
  • should_load_block_editor_scripts_and_styles filter is not run in Customizer.

This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@noisysocks noisysocks force-pushed the add/widgets-editor branch 4 times, most recently from 1dc94ed to 2c74335 Compare May 25, 2021 01:07
@noisysocks noisysocks marked this pull request as ready for review May 25, 2021 01:15
@noisysocks noisysocks force-pushed the add/widgets-editor branch 4 times, most recently from 0e59af9 to b62af1c Compare May 25, 2021 04:12
@noisysocks noisysocks force-pushed the add/widgets-editor branch 6 times, most recently from 1116dbd to 7dcbf65 Compare May 25, 2021 06:48
@noisysocks
Copy link
Member Author

Not sure why tests on PHP 8 are hanging. It seems to be happening on all branches. I verified locally that tests pass using PHP 8.

@noisysocks noisysocks force-pushed the add/widgets-editor branch from 7dcbf65 to 3b06789 Compare May 25, 2021 08:07
Copy link
Contributor

@tellthemachines tellthemachines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, and works well ✅ Left a few questions below.

src/wp-admin/admin-header.php Show resolved Hide resolved
src/wp-admin/widgets-form-blocks.php Show resolved Hide resolved
src/wp-admin/widgets-form-blocks.php Show resolved Hide resolved
src/wp-includes/widgets.php Show resolved Hide resolved
Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this landed already but I left a few comments that might or might not result in follow-up commits :)

src/wp-includes/blocks/legacy-widget.php Show resolved Hide resolved
src/wp-admin/edit-form-blocks.php Show resolved Hide resolved
src/wp-includes/widgets.php Show resolved Hide resolved
@noisysocks noisysocks closed this May 27, 2021
@noisysocks noisysocks deleted the add/widgets-editor branch May 27, 2021 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants