CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Allow registering PHP-only blocks #71794
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
Conversation
9fcc3c5
to
9aa6ac3
Compare
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. |
Size Change: +65 B (0%) Total Size: 1.95 MB
ℹ️ View Unchanged
|
packages/block-library/src/index.js
Outdated
registerBlockType( blockName, { | ||
title: blockName, | ||
category: 'text', | ||
edit: ( { attributes } ) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While discussing this with @jorgefilipecosta he proposed a nice idea that we could try to explore separately:
- Add a "default edit" setting to
BlockEditorSettings
that could be built into theeditor
package. - Have
unstable__bootstrapServerSideBlockDefinitions
auto register the blocks that have the "auto-register" flag set to true.
We might remove the need for the global variable with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this a lot, can we add documentation to the handbook or is this a task we should reserve for later?
Let's check which documentation places need to be updated with this.
I'd also love an e2e test that registers a block like that and ensure it loads and can be used properly.
…on the php-only part
I like this feature, but note that it's not recommended to use the Additionally, we may need to enable See #44491 for more details. |
@t-hamano Can you speak a bit more about this, does that mean that we can't have automatic support for all these block supports automatically in these php only blocks? |
No. I'm happy to move forward with this PR, but I'm saying that we may need to change our policy for the If this PR is shipped, more developers may create blocks that use the
I would like to resolve this contradiction somehow. One way to do this would be to remove the above note from the |
Yeah! this is fine for me I think. I think for these php only registered blocks, I think ServerSideRender is fine but if you're writing a specific |
I also think both things can be true at the same time. Using the This new method for registering blocks using only PHP will never be the default for building rich, interactive blocks. But it is a nice entry way for simple blocks. |
Any limitations for Examples:
I'm sure more shortcomings of SSR rendering will come to light when folks start using this method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than some documentation. This is working fine for me as a first iteration. I'm pondering whether we should keep this for WP 7.0 (so plugin only for now without php backport)
I also think there is no rush for this, and it could make sense to target 7.0 so that we include some followups |
Flaky tests detected in e35eab1. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/17982357960
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add some documentation about this.
Good catch @t-hamano , there is a double border (although no double padding): |
What?
Closes #71792 by allowing PHP-only block registration with automatic ServerSideRender integration.
Why?
Enables developers to create blocks using only PHP without needing JavaScript knowledge, which brings the benefits mentioned in #71792.
How?
Adding a new
auto_ssr
support flag to block registration. When a block registered in PHP withregister_block_type
has both this flag and a render callback defined, it will be automatically registered in the client to be server-side rendered.Testing Instructions
auto_ssr
flag and a render callback: