Fix saving template associations with emails
The original workaround was not working for templates that have edits saved in the DB. The problem was that when the template is saved in the DB the get_block_templates() returns WP_Block_Template object with post_types as null. It seems this association is not saved to DB in the core. [MAILPOET-6334]
This commit is contained in:
committed by
Rostislav Wolný
parent
91f90a03d1
commit
132ffde58f
@@ -144,7 +144,9 @@ class Templates {
|
||||
}
|
||||
$block_templates = get_block_templates();
|
||||
foreach ( $block_templates as $block_template ) {
|
||||
if ( ! is_array( $block_template->post_types ) || ! array_intersect( $this->post_types, $block_template->post_types ) ) {
|
||||
// Ideally we could check for supported post_types but there seems to be a bug and once a template has some edits and is stored in DB
|
||||
// the core returns null for post_types.
|
||||
if ( $block_template->plugin !== $this->template_prefix ) {
|
||||
continue;
|
||||
}
|
||||
$templates[ $block_template->slug ] = $block_template;
|
||||
|
Reference in New Issue
Block a user