Skip to content

Commit

Permalink
Make use of new methods in page-templates.php
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Feb 4, 2021
1 parent b8f9af7 commit 342faeb
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions lib/full-site-editing/page-templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@ function gutenberg_load_block_page_templates( $templates, $theme, $post ) {
if ( ! gutenberg_is_fse_theme() ) {
return $templates;
}
$config_file = locate_template( 'experimental-theme.json' );
if ( ! file_exists( $config_file ) ) {
return $templates;
}
$data = json_decode(
file_get_contents( $config_file ),
true
);

$resolver = new WP_Theme_JSON_Resolver();
$data = $resolver->get_theme_data()->get_page_templates();
$page_templates = array();
if ( isset( $data['pageTemplates'] ) ) {
foreach ( $data['pageTemplates'] as $key => $page_template ) {
if ( isset( $data ) ) {
foreach ( $data as $key => $page_template ) {
if ( ( ! isset( $page_template['postTypes'] ) && 'page' === $post->post_type ) ||
( isset( $page_template['postTypes'] ) && in_array( $post->post_type, $page_template['postTypes'], true ) )
) {
Expand Down

0 comments on commit 342faeb

Please sign in to comment.