Classic Block: Unwrap experiment to hide it from inserter#77911
Conversation
|
Size Change: -7 B (0%) Total Size: 7.94 MB 📦 View Changed
ℹ️ View Unchanged
|
yuliyan
left a comment
There was a problem hiding this comment.
Looks good from my side and works as expected.
One small question - since this is proposed as the default behavior, should we consider updating the block.json to set "inserter": false under supports?
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in 6c5d3ba. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/25380097502
|
Yeah, we could do that, although I'd prefer not to do it for now - it's easier if we keep the logic in a single place instead of having to change multiple ones. |
There was a problem hiding this comment.
The top-level lib directory file feels a bit odd for block-specific logic. Generally, PHP code should be in a release-specific dir or a block one.
Mamaduka
left a comment
There was a problem hiding this comment.
I think methods in classic-block.php could use a little bit of polish and do things more WP-way.
- Inject inline script via
wp_add_inline_scriptforwp-block-librarypackage. - Use a better asset hook.
admin_print_footer_scriptsruns on every admin page. - See if we can inline filter and use
global $post, which right hook post global is available.
t-hamano
left a comment
There was a problem hiding this comment.
Thanks for the PR!
I would like to confirm the final goal. Will classic blocks be completely abolished in the end, or will there be a way to enable classic blocks via hooks? My understanding is the latter, what are your thoughts?
Indeed - thanks for the great suggestions @Mamaduka! The original experiment code was around for so long that I stopped seeing it with a more critical eye 😉
Done in 3bfba95. Note that I've also used the opportunity to refactor away from
I think
I've also inlined the filter in 7def700 and used the |
Good question @t-hamano. The ultimate end goal would be:
The Classic block and TinyMCE will be in core likely forever for backwards compatibility, but the end goal is to remove them for new WordPress installations, while still allowing anyone who needs them to opt-in to using them. The work we've done here (hiding the Classic block from the inserter) is only the first step towards that goal. |
|
@tyxla, pushed minor change to use The branch also tests well for me ✅ PR needs backport changelog update, but otherwise should be good to merge. |
Thanks a bunch @Mamaduka 🙌
Working on the backport now 👍 |
t-hamano
left a comment
There was a problem hiding this comment.
Looks good to me. A Dev Note might be needed so users who require the classic block can learn how to opt into it.
Dev NoteClassic block: New filter to control inserter availabilityThe Classic block ( New filter:
|
|
Thank you all for the help 🙌 |
* Classic Block: Unwrap experiment to hide it from inserter * Move to 7.1 compat * Use wp_add_inline_script() * Get out of the window.wp namespace * Switch to enqueue_block_editor_assets and use $post * Inline gutenberg_classic_block_supports_inserter() * Use 'wp_' prefixes * Add backport changelog --------- Co-authored-by: George Mamadashvili <[email protected]> Co-authored-by: tyxla <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: yuliyan <[email protected]> Co-authored-by: t-hamano <[email protected]>
|
I just cherry-picked this PR to the release/23.1 branch to get it included in the next release: 2dda7ef |

What?
Promotes the
gutenberg-no-tinymceexperiment to the default behavior. The Classic block will now always be hidden from the block inserter, except when opted in via thegutenberg_classic_block_supports_inserterwp_classic_block_supports_inserterfilter.I'm hoping to land this on time for the next version of Gutenberg.
Why?
The experiment has been available as an opt-in for long enough, with a much more destructive approach (completely preventing TinyMCE from loading). After we recently made it harmless (just hiding the block in the inserter, changing the block and the underlying TinyMCE to always load), proceeding to enable it for everyone is an obvious next step. Also, hiding the Classic block by default aligns the inserter with the block-first editing model.
How?
We're removing the experimental code and moving the filter logic out of the experimental directory. The escape hatch (the filter + global) remains for sites that still rely on classic content.
Testing Instructions
<!-- wp:freeform -->block) and confirm the Classic block renders correctly and is editable.Put this in your code:add_filter( 'gutenberg_classic_block_supports_inserter', '__return_true' );. Alternatively, you can use [this plugin](https://github.com/tyxla/enable-classic-block/archive/refs/tags/v1.0.0.zip) to test it.add_filter( 'wp_classic_block_supports_inserter', '__return_true' );Testing Instructions for Keyboard
Same
Screenshots or screencast
None
Use of AI Tools
Opus 4.7