Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reapply changeset 54184.
After rebasing on top of trunk, the PR reverted some
of the changes in wp-includes/block-template-utils.php
that were added in changest 54184.

This commit reapplies the code from that changeset.

It also cleans up in one test.
  • Loading branch information
hellofromtonya committed Sep 20, 2022
commit 0d2d57ced962aacfac96ff817431c363b05f23a0
12 changes: 10 additions & 2 deletions src/wp-includes/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,8 @@ function _build_block_template_result_from_post( $post ) {
}

$theme = $terms[0]->name;
$has_theme_file = wp_get_theme()->get_stylesheet() === $theme &&
null !== _get_block_template_file( $post->post_type, $post->post_name );
$template_file = _get_block_template_file( $post->post_type, $post->post_name );
$has_theme_file = wp_get_theme()->get_stylesheet() === $theme && null !== $template_file;

$origin = get_post_meta( $post->ID, 'origin', true );
$is_wp_suggestion = get_post_meta( $post->ID, 'is_wp_suggestion', true );
Expand Down Expand Up @@ -680,6 +680,14 @@ function get_block_templates( $query = array(), $template_type = 'wp_template' )
continue;
}

if (
$post_type &&
isset( $template->post_types ) &&
! in_array( $post_type, $template->post_types, true )
) {
continue;
}

$query_result[] = $template;
}

Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/tests/block-templates/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {

public static function wpTearDownAfterClass() {
wp_delete_post( self::$template_post->ID );
wp_delete_post( self::$template_part_post->ID );
}

public function set_up() {
Expand Down