Editor: Fix get_block_templates() to get templates for a post type.

When a post type is passed to `get_block_templates()` in the query, return only the templates that match that post type.

Fixes an issue where:
* when a block template provided by a theme has been edited by the user
* and that template has specific defined `postTypes`
* but after editing, the template was available for all post types.

Follow-up to [52062].

Props aljullu, bernhard-reiter, hellofromTonya.
Fixes #55881.

git-svn-id: https://develop.svn.wordpress.org/trunk@54184 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork
2022-09-15 22:26:28 +00:00
parent 14e54b5d20
commit 72178ec839
6 changed files with 213 additions and 115 deletions

View File

@@ -0,0 +1,3 @@
<!-- wp:paragraph -->
<p>Custom Single Post template</p>
<!-- /wp:paragraph -->

View File

@@ -58,6 +58,11 @@
{
"name": "page-home",
"title": "Homepage template"
},
{
"name": "custom-single-post-template",
"title": "Custom Single Post template",
"postTypes": ["post"]
}
],
"templateParts": [