-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Pattern render hooks no longer run #61454
Comments
I'm curious why you chose to apply this content filtering at the pattern level, rather than somewhere else. |
It seemed to be the best place for it, for our use case. On WordPress.org, the content is output via patterns, not post content (so that it can be translated and publicly version-controlled). For example, the front page template has just a header, footer, and pattern. The pattern contains all the page content. The same process is true for all pages on wp.org — About page template, content pattern; Features page template, content pattern; etc. This way, the same theme can be used to render all the Rosetta sites: https://es.wordpress.org/, https://fr.wordpress.org/, and so on. So hooking into |
Thanks, that helps. Is it possible to apply these content filters on |
It looks like that applies to the template content before the blocks are parsed and rendered, so it wouldn't catch the markup from any of our server-side blocks. The nice thing about
Yeah, that's pretty much what I'm looking for. In fact, |
I've refreshed the filter approach in WordPress/wordpress-develop#6533. |
There's also #61212 which proposes a filter for the entire HTML response (down to the |
Just came here to note that this has broken a conditional/visibility system that I have in place, which I use when calling |
Could you elaborate? |
I commented on my own PR here about running the filters: #61711 (comment) I don't understand how this isn't a problem already: once you load patterns in the editor, they'll be resolved, and disappear on the next save. It sounds like you want to preserve these patterns on the front-end. Maybe there's a way to only replace them when getting patterns for the editor? Maybe we need to remove the resolving from |
Here's my new proposal: #61757 |
@ellatrix - The new proposal looks like it'd resolve the issue. Yes, this is for a system that's on the front end only when used for patterns. Templates in this case are not saved in the database. I can work around it by adding the conditional feature to a wrapping Group block around the pattern, but my main concern is for folks who have deployed it on existing sites using the Pattern block. |
For my case, these are patterns that are not enabled in the editor. They're only called from templates, which are never generated from the database, only theme files. The pattern hooks were just a convenient place to run some code. That said, I believe we've moved away from switching out pattern slugs in favor of filtering the template hierarchy (which seems more in line with how it "should" work). For the other things we've attached to the pattern render hook, However until that merges, #61757 looks good and should let wp.org update gutenberg again. |
There's also the potential for the |
It sounds like we should go ahead with that fix. Could anyone approve? |
Prior to #60349, pattern blocks would run the
render_block
,render_block_core/pattern
, and related rendering hooks. I've used those to filter over pattern content (see WordPress/wporg-parent-2021#136 for specific details). Since patterns no longer render, the hooks never run, and so my functions don't run.To reproduce, here's one example from WordPress.org's code (code example below).
On Gutenberg 18.0.1, the filter should run — in this case, wrap the arrows with spans.
With GB 18.1+, the filter no longer runs, so the arrows are not wrapped.
Filter code:
Excerpt from a pattern:
We have a similar function running to handle inline styles on RTL locales.
I'm open to doing this a different way, but ideally we need some top-level filter that can be run over the rendered block content once and the pattern render hook was perfect for that.
The text was updated successfully, but these errors were encountered: