Make WordPress Core


Ignore:
Timestamp:
05/25/2021 02:19:14 PM (4 years ago)
Author:
youknowriad
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme.php

    r50810 r51003  
    11831183     *
    11841184     * @since 4.7.0
     1185     * @since 5.8.0 Include block templates.
    11851186     *
    11861187     * @return string[] Array of page templates, keyed by filename and post type,
     
    12171218
    12181219                    $post_templates[ $type ][ $file ] = _cleanup_header_comment( $header[1] );
     1220                }
     1221            }
     1222
     1223            if ( current_theme_supports( 'block-templates' ) ) {
     1224                $block_templates = get_block_templates( array(), 'wp_template' );
     1225                foreach ( get_post_types( array( 'public' => true ) ) as $type ) {
     1226                    foreach ( $block_templates as $block_template ) {
     1227                        $post_templates[ $type ][ $block_template->slug ] = $block_template->title;
     1228                    }
    12191229                }
    12201230            }
Note: See TracChangeset for help on using the changeset viewer.