mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Block Editor: Introduce block templates for classic themes.
With this patch, users will be able to create custom block based templates and assign them to specific pages/posts. Themes can also opt-out of this feature Props bernhard-reiter, carlomanf. Fixes #53176. git-svn-id: https://develop.svn.wordpress.org/trunk@51003 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1182,6 +1182,7 @@ final class WP_Theme implements ArrayAccess {
|
||||
* Returns the theme's post templates.
|
||||
*
|
||||
* @since 4.7.0
|
||||
* @since 5.8.0 Include block templates.
|
||||
*
|
||||
* @return string[] Array of page templates, keyed by filename and post type,
|
||||
* with the value of the translated header name.
|
||||
@@ -1219,6 +1220,15 @@ final class WP_Theme implements ArrayAccess {
|
||||
}
|
||||
}
|
||||
|
||||
if ( current_theme_supports( 'block-templates' ) ) {
|
||||
$block_templates = get_block_templates( array(), 'wp_template' );
|
||||
foreach ( get_post_types( array( 'public' => true ) ) as $type ) {
|
||||
foreach ( $block_templates as $block_template ) {
|
||||
$post_templates[ $type ][ $block_template->slug ] = $block_template->title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache_add( 'post_templates', $post_templates );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user