Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try adding support for child themes in FSE/GS #27305

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion lib/full-site-editing.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @return boolean Whether the current theme is an FSE theme or not.
*/
function gutenberg_is_fse_theme() {
return is_readable( get_stylesheet_directory() . '/block-templates/index.html' );
return is_readable( locate_template( 'block-templates/index.html' ) );
}

/**
Expand All @@ -21,6 +21,7 @@ function gutenberg_full_site_editing_notice() {
if ( ! gutenberg_is_fse_theme() ) {
return;
}

?>
<div class="notice notice-warning">
<p><?php _e( 'You\'re using an experimental Full Site Editing theme. Full Site Editing is an experimental feature and potential API changes are to be expected!', 'gutenberg' ); ?></p>
Expand Down
20 changes: 20 additions & 0 deletions lib/template-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,32 @@ function gutenberg_resolve_template( $template_type, $template_hierarchy = array
'orderby' => 'post_name__in',
'posts_per_page' => -1,
'no_found_rows' => true,
// Templates that either:
//
// - the active theme has declared (stylesheet)
// - its parent theme (template) has declared but there's not an equivalent in the active theme
//
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'wp_theme',
'field' => 'slug',
'terms' => wp_get_theme()->get_stylesheet(),
),
array(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on how complex this PR gets it may make sense to split into two PR's: One that adds child theme support for FSE and another that adds it to Global Styles.

'relation' => 'AND',
array(
'taxonomy' => 'wp_theme',
'field' => 'slug',
'terms' => wp_get_theme()->get_template(),
),
array(
'taxonomy' => 'wp_theme',
'field' => 'slug',
'terms' => wp_get_theme()->get_stylesheet(),
'operator' => 'NOT IN'
),
),
),
)
);
Expand Down