Draft
Conversation
cbravobernal
commented
Jun 4, 2025
| } | ||
| ); | ||
| }, | ||
| canUserEditValue: () => true, |
Contributor
Author
There was a problem hiding this comment.
This should check permissions.
Member
|
This is a very interesting experiment. I'm not entirely sure how I feel about the idea of coding the block pattern using HTML and helper functions. I'm more inclined to explore how to build patterns in the editor interface. However, all the necessary pieces are in place for that use case, so this is an excellent start. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This past week, I’ve been experimenting with different approaches for creating patterns. My requirements were:
The Experiment
I decided to go with the PHP route—it’s simpler and handles loops and conditionals easily. But there are caveats:
We don’t have post context available when registering a pattern.
ACF creates custom blocks as entire patterns and treats each field as an “editable part.” We want to stick with standard blocks inside standard patterns.
I am avoiding parsing the PHP file content. If I was to do that, I'd need to parse the HTML, process the PHP, and then merge everything. That way I could:
Instead, I went for a “just use PHP functions” approach. For example:
This outputs:
This code:
Outputs:
While this works, the developer experience still isn’t as smooth as classic themes.
We can now use the full power of block bindings with our new source, scf/experimental-field. That means fields can be edited directly in the editor UI.
Better yet, those inputs can live in the post sidebar (instead of being buried in metaboxes).
patterns_demo.mov