-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add preview logic to enable pattern caching as .html
files and subsequent load from the cache
#4
Comments
Requirements
The challenges with working with .php files in the theme are:
This can possibly be addressed by tricking the theme into registering the block pattern categories and patterns by loading the theme's function's php and rerunning the Another way to do this is to temporarily activate the theme and implement a process that checks the cached version with the current version. If there's a new theme version then the patterns would be re-exported. This second option appears to be easier? How do we temporarily activate a theme? By an AJAX request or something? |
Proposed directory usage for cacheing theme's patternsWordPress uses the
|
I've developed the first pass of the logic.
Let's see what we can do with the |
The |
I'm going to change the title of this from "Try loading patterns from .html files in a patterns folder and/or subfolders in FSE themes" oik-patterns would provide the following services:
|
patterns
folder and/or subfolders in FSE themes.html
files and subsequent load from the cache
Additional requirements for child theme preview.
The validation is performed at |
This is now installed in blocks.wp-a2z.org.
Notes:
|
A number of FSE themes in the wordpress.org directory load a whole host of patterns from
.php
files.See bobbingwide/oik-themes#11 particularly bobbingwide/oik-themes#11 (comment)
In #2, I developed logic to load patterns from
.htm
files in theblock-template-parts
folder.These were template parts that didn't make it into the official templates.
Having seen Nick Diego's presentation at https://www.meetup.com/SF-WordPress-Users/events/283096780/ I'm encouraged to continue to develop my solution for Internationalization and Localization of FSE themes.
My approach is to continue to use
.html files
rather than.php
for the translation. I believe this will produce a better product in the long run.I propose to develop a prototype solution that will enable previewing of any theme's patterns from blocks.wp-a2z.org without having to activate the theme at runtime.
There are several stages
.html
file or.php
file.en_US
version of each pattern into a plain.html
file.html
version.en_US
version where the strings are extracted directly from the.html
.Proposed solution
Develop step 1 first: Extend the basic solution in #2 to support loading of patterns from the
patterns
folder and its subfolders.Notes:
register_block_pattern_category( $category_name, $category_properties )
register_block_pattern( $pattern_name, $pattern_properties)
where $pattern_properties include:
There are other properties but these are not necessarily required for front-end previewing.
Example: with a pattern from the Fizzie theme
fizzie/patterns/plugins-blocks-catalogued.html
This solution works fine for themes delivering
.html
patterns.For themes with
.php
files it loads files which are not patterns.Implementing stage 2. should resolve this issue.
The text was updated successfully, but these errors were encountered: