Skip to content

Commit 8326c1b

Browse files
authored
FSE: Add basic support for child themes (#34354)
1 parent 4fd2129 commit 8326c1b

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

lib/class-wp-theme-json-resolver-gutenberg.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -493,16 +493,8 @@ public static function theme_has_support() {
493493
* @return string The whole file path or empty if the file doesn't exist.
494494
*/
495495
private static function get_file_path_from_theme( $file_name ) {
496-
// This used to be a locate_template call.
497-
// However, that method proved problematic
498-
// due to its use of constants (STYLESHEETPATH)
499-
// that threw errors in some scenarios.
500-
//
501-
// When the theme.json merge algorithm properly supports
502-
// child themes, this should also fallback
503-
// to the template path, as locate_template did.
504496
$located = '';
505-
$candidate = get_stylesheet_directory() . '/' . $file_name;
497+
$candidate = get_theme_file_path( $file_name );
506498
if ( is_readable( $candidate ) ) {
507499
$located = $candidate;
508500
}

lib/full-site-editing/full-site-editing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @return boolean Whether the current theme is an FSE theme or not.
1212
*/
1313
function gutenberg_is_fse_theme() {
14-
return is_readable( get_stylesheet_directory() . '/block-templates/index.html' );
14+
return is_readable( get_theme_file_path( '/block-templates/index.html' ) );
1515
}
1616

1717
/**

packages/block-library/src/template-part/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function render_block_core_template_part( $attributes ) {
5353
} else {
5454
// Else, if the template part was provided by the active theme,
5555
// render the corresponding file content.
56-
$template_part_file_path = get_stylesheet_directory() . '/block-template-parts/' . $attributes['slug'] . '.html';
56+
$template_part_file_path = get_theme_file_path( '/block-template-parts/' . $attributes['slug'] . '.html' );
5757
if ( 0 === validate_file( $attributes['slug'] ) && file_exists( $template_part_file_path ) ) {
5858
$content = _gutenberg_inject_theme_attribute_in_content( file_get_contents( $template_part_file_path ) );
5959
}

0 commit comments

Comments
 (0)