Add support for adding templates and template parts for plugins #42362
Labels
[Feature] Extensibility
The ability to extend blocks or the editing experience
[Feature] Site Editor
Related to the overarching Site Editor (formerly "full site editing")
[Feature] Templates API
Related to API powering block template functionality in the Site Editor
Needs Technical Feedback
Needs testing from a developer perspective.
[Type] Enhancement
A suggestion for improvement.
What problem does this address?
Currently, templates are defined within the theme (source theme) and can be edited in the site editor (source custom). There are some use cases where plugins could also use the possibility to add a template. WooCommerce blocks plugin already adds templates for Product Catalog page, Product Page, etc. At MailPoet, we are considering using templates and templates parts for email templates.
WooCommerce Blocks developers documented how they added the templates. As you can see from the docs, adding a template is currently cumbersome.
What is your proposed solution?
This could be solved by adding an API for registering a template. I don't know the internals in detail, so I struggle with proposing the solution.
I was thinking about a function like:
or maybe just
The
$args
would cover parameters for defining the block template.It could be used for both templates and template_parts.
The text was updated successfully, but these errors were encountered: