Add post_types field to the template REST API response
We want to use post_type for filtering email templates. There is a PR that adds this property https://github.com/WordPress/wordpress-develop/pull/7530 but it is not merged. This commit added the property and also future compatibility check so that we don't attempt to add it after the PR is merged. [MAILPOET-6356]
This commit is contained in:
committed by
Rostislav Wolný
parent
ddd2108109
commit
a5db2564c8
@@ -248,10 +248,9 @@ export const getEmailTemplates = createRegistrySelector(
|
||||
} )
|
||||
// We still need to filter the templates because, in some cases, the API also returns custom templates
|
||||
// ignoring the post_type filter in the query
|
||||
?.filter(
|
||||
( template ) =>
|
||||
// @ts-expect-error Missing property in type
|
||||
template.plugin === 'mailpoet'
|
||||
?.filter( ( template ) =>
|
||||
// @ts-expect-error Missing property in type
|
||||
template.post_types.includes( 'mailpoet_email' )
|
||||
)
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user