Block theme: Dynamic pattern includes broken with GB 18.1 #662
Labels
[Component] Core/Gutenberg
Changes that should happen in the core editor (tracking issues only)
[Component] Theme
The frontend of the pattern directory, pattern lists UI
In the new Pattern Directory theme, there is code to swap out a pattern based on the current page context. For example, viewing a single pattern uses the
single.html
template, which contains<!-- wp:pattern {"slug":"wporg-pattern-directory-2024/single-pattern"} /-->
. We use patterns like template parts so that we can use PHP i18n functions.In a
render_block_data
hook, there's a check for pattern ownership, and if the current user owns the pattern, we swap out the slug to show thewporg-pattern-directory-2024/single-my-pattern
pattern. This is also done for showing logged out messaging on the "my patterns" and "favorites" pages.pattern-directory/public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php
Lines 524 to 558 in 1ced0d9
What's the problem?
In Gutenberg 18.1, some code was added to replace the patterns earlier WordPress/gutenberg#60349. This seems to not run
render_block_data
anymore, so the pattern conditional never kicks in. This means users don't see the correct actions on a pattern they own.Currently wp.org is pinned to 17.8.1 (though I'm going to try updating it to 18.0 on monday), so this won't affect us immediately.GB was unpinned, so this does impact us now.More details
We do something similar in the Developer theme, but with the template-part block, so that should continue to work.
An alternate solution could be to add a new template into the hierarchy for logged in, but the current pattern-swap approach lets us update discrete content, rather than duplicating entire templates.
The text was updated successfully, but these errors were encountered: