-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Feature: Block-based template parts for Classic themes #3234
Feature: Block-based template parts for Classic themes #3234
Conversation
'styles' => get_block_editor_theme_styles(), | ||
'defaultTemplateTypes' => $indexed_template_types, | ||
'defaultTemplatePartAreas' => get_allowed_block_template_part_areas(), | ||
'supportsLayout' => WP_Theme_JSON_Resolver::theme_has_support(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before, the Site Editor always assumed layout support.
@@ -5261,7 +5261,7 @@ function wp_widgets_add_menu() { | |||
} | |||
|
|||
$menu_name = __( 'Widgets' ); | |||
if ( wp_is_block_theme() ) { | |||
if ( wp_is_block_theme() || current_theme_supports( 'block-template-parts' ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need this to avoid conflicts between the Customize
and Widgets
menu positions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @Mamaduka! LGTM
@ockham what is the status of the Warning in the description?
|
Ah, my bad, I should've elaborated on that. I was indeed able to test and confirm everything except for
As @Mamaduka said, we'll only be able to verify this once we've synced In any case, we can easily test this separately once we sync packages. Does that sound okay? |
Testing Report Env:
Results: Classic theme - TT1
Block theme - TT2
Themes with block-based templates part enabled
Observations:
@Mamaduka @ockham Is this something that will be fixed with another backport? Or a known issue? |
@@ -19,7 +19,7 @@ | |||
); | |||
} | |||
|
|||
if ( ! wp_is_block_theme() ) { | |||
if ( ! ( current_theme_supports( 'block-template-parts' ) || wp_is_block_theme() ) ) { | |||
wp_die( __( 'The theme you are currently using is not compatible with Full Site Editing.' ) ); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hellofromtonya I belive something like this would solve the case you uncovered in your testing here: #3234 (comment)
With the block-fragments (classic theme with block-based templates) enabled, I am able to directly access /wp-admin/site-editor.php but it's a white screen. No errors in the browser's console or error logs.
$is_template_part_editor = isset( $_GET['postType'] ) && 'wp_template_part' === sanitize_key( $_GET['postType'] ); | |
if ( ! wp_is_block_theme() && ! $is_template_part_editor ) { | |
wp_die( __( 'The theme you are currently using is not compatible with the Site Editor.' ) ); | |
} | |
As far as I'm aware that was not a known issue and no patch for it had been created.
@Mamaduka asked me to keep an eye on this PR since he is out traveling. I will create a PR on the Gutenberg Repo to fix the issue there aswell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually in looking at the code in Gutenberg it was handled as a completely separate admin page. So this issue only exists in this PR and only needs to get fixed here. No backport to Gutenberg is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to make it easier to test, I have also created a separate PR against @Mamaduka's branch which applies the same fix as the one I have shown in the suggestion above: Mamaduka#48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that does resolve it. Well done @fabiankaegy - thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
non block themes that support block based template parts should only be allowed to access the site-editor.php file if the query parameter to access the template part editor is set correctly
…-parts-mode-fix fix prevent unwanted access of site-editor.php
@@ -406,7 +407,7 @@ public function test_get_item_schema() { | |||
$this->assertArrayHasKey( 'responsive-embeds', $theme_supports ); | |||
$this->assertArrayHasKey( 'title-tag', $theme_supports ); | |||
$this->assertArrayHasKey( 'wp-block-styles', $theme_supports ); | |||
$this->assertCount( 21, $theme_supports ); | |||
$this->assertCount( 22, $theme_supports ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot, @fabiankaegy! Looks like this PR is good to go, except for failing unit tests, which I think are due to this: https://github.com/WordPress/wordpress-develop/pull/3234/files#r971773508. @Mamaduka If you're around, could you rebase and change that number to |
Thank you everyone for your contributions! Committed PR 3258 (finalization of this PR) via https://core.trac.wordpress.org/ticket/56467. |
PR backports changes are required for using block-based template parts in classic themes - WordPress/gutenberg#42729.
Gutenberg tracking issue: WordPress/gutenberg#43440
Trac ticket: https://core.trac.wordpress.org/ticket/56467
Testing Instructions
Classic theme - TT1
/wp-admin/site-editor.php
path directly.Block theme - TT2
Themes with block-based templates part enabled
You can grab the testing theme from this repo - https://github.com/Mamaduka/block-fragments
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.