-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Block-based template parts for Classic themes #42729
Conversation
isNavigationOpen: isNavigationOpened(), | ||
isTemplatePartsMode: supportsTemplatePartsMode, |
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.
I need a better name for this. Maybe templatePartsEnabled
?
Size Change: +255 B (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
This is already looking ✨ fabulous ✨ Thank you for working on it :) As far as your open questions go here are my thoughts:
I'm not even sure whether we want to enable the Global Styles Sidebar at all, even for themes that have
I'm torn on this one. I think that the alignment of the outermost element most likely should be determined by the theme that creates the template part and therefore that we shouldn't have the alignment options on the top level items.
I think we also discussed this in the actual issue for this feature and came to the conclusion that users should not be able to create new template parts in the editor since these templates would not get rendered anywhere. Which would be a more confusing experience. See #37943 (comment) |
I also want to mention this issue, which also touches on the problem of missing alignments in template parts focus mode - #34010. Cc. @richtabor. |
I agree with the above, I don't think that the global styles or adding new template parts should be enabled: Or not until there has been more discussions and exploring around it. |
This comment was marked as outdated.
This comment was marked as outdated.
This part concerns me because the classification of themes is already complicated enough before introducing yet another subcategory. If a theme has a The use of a theme support like this also raises some questions about borderline cases:
While the reasoning here makes sense, it creates a notable disparity between the behaviour of the existing |
@carlomanf thanks for your detailed notes :) I can see that disparity. However, I think the main difference to consider here, is that templates have the template picker which also is the main entry point for users to create new templates. So you always know where the template you are creating is going to be used. This is not the case for these template parts as themes manually render these parts within their traditional templates. |
@fabiankaegy I'm not saying the behaviour should be re-aligned with block templates. The reasoning you put forward makes sense, as I noted. I'm saying that it would be very easy for theme authors to get confused and wrongly think that the two theme supports work in the same way, when they don't and can't. |
Thanks for the feedback, @carlomanf. The theme support name or the method of how we enable the feature isn't final, and I'm open to suggestions here. I decided to go with the support flag because scanning directories for template parts can sometimes yield false results. |
Thanks for that context. I miss read the original note :) |
Also just noting that the |
Pushed the following changes:
@carlomanf, I'm unsure if we want to make the @fabiankaegy, it might be better to handle locking enhancements separately. Maybe something like we did for Group and Columns blocks #26128. |
@fabiankaegy @Mamaduka Thanks so much for the Dev Note Draft link. When you are finished drafting, please add it as Draft to the Make core blog (see #42961) |
This is great news, I'll test it and implement this on our classic theme for sure. |
Allows Classic / Hybrid themes to use block-based template parts without using complete block-based templates. * Exposes the Site Editor's template parts UI * Adds Appearance > "Template Parts" menu * Enabled within the theme via adding a theme support for `'block-template-parts'` {{{#!php add_theme_support( 'block-template-parts' ); }}} This is a backport from Gutenberg.[WordPress/gutenberg#42729 See WordPress/gutenberg PR 42729]. Follow-up to [52330], [52069], [52178]. Props mamaduka, fabiankaegy, poena, scruffian, manfcarlo, bernhard-reiter, hellofromTonya. See #56467. git-svn-id: https://develop.svn.wordpress.org/trunk@54176 602fd350-edb4-49c9-b593-d223f7449a82
Allows Classic / Hybrid themes to use block-based template parts without using complete block-based templates. * Exposes the Site Editor's template parts UI * Adds Appearance > "Template Parts" menu * Enabled within the theme via adding a theme support for `'block-template-parts'` {{{#!php add_theme_support( 'block-template-parts' ); }}} This is a backport from Gutenberg.[WordPress/gutenberg#42729 See WordPress/gutenberg PR 42729]. Follow-up to [52330], [52069], [52178]. Props mamaduka, fabiankaegy, poena, scruffian, manfcarlo, bernhard-reiter, hellofromTonya. See #56467. Built from https://develop.svn.wordpress.org/trunk@54176 git-svn-id: http://core.svn.wordpress.org/trunk@53735 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Allows Classic / Hybrid themes to use block-based template parts without using complete block-based templates. * Exposes the Site Editor's template parts UI * Adds Appearance > "Template Parts" menu * Enabled within the theme via adding a theme support for `'block-template-parts'` {{{#!php add_theme_support( 'block-template-parts' ); }}} This is a backport from Gutenberg.[WordPress/gutenberg#42729 See WordPress/gutenberg PR 42729]. Follow-up to [52330], [52069], [52178]. Props mamaduka, fabiankaegy, poena, scruffian, manfcarlo, bernhard-reiter, hellofromTonya. See #56467. Built from https://develop.svn.wordpress.org/trunk@54176 git-svn-id: https://core.svn.wordpress.org/trunk@53735 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Allows Classic / Hybrid themes to use block-based template parts without using complete block-based templates. * Exposes the Site Editor's template parts UI * Adds Appearance > "Template Parts" menu * Enabled within the theme via adding a theme support for `'block-template-parts'` {{{#!php add_theme_support( 'block-template-parts' ); }}} This is a backport from Gutenberg.[WordPress/gutenberg#42729 See WordPress/gutenberg PR 42729]. Follow-up to [52330], [52069], [52178]. Props mamaduka, fabiankaegy, poena, scruffian, manfcarlo, bernhard-reiter, hellofromTonya. See #56467. Built from https://develop.svn.wordpress.org/trunk@54176
@Mamaduka Nice work on this one. In testing this today, I noticed the Navigation button is present in this mode: Is this intentional or not? I don't see it as a big problem, it just shows "no navigation menus", but let me know if this needs a ticket or not. |
@jasmussen, not intentional. I left the sidebars as they were. Also, the template parts can use the Navigation block, so I think that can be useful. What do you think? |
I think let's keep it as is for now and just have an ear to the ground on any confusion! |
I am removing the "Needs Dev Note" label. Thank you @fabiankaegy for writing and publishing the post on the make blog 🙇 |
thanks @Mamaduka I think I put a check mark next to the PR in the DEV Note tracking issue . Don't remove the label, unless you also add |
I'm giving this a spin and it's possible I'm doing something wrong, but it seems like any |
Do you mean on the front end or in Editor? |
I see the same behavior @ethanclevenger91 mentioned in both the editor and the front end. I (maybe wrongly) assumed that was intentional behavior when editing Template Parts to ignore To get the |
Allows Classic / Hybrid themes to use block-based template parts without using complete block-based templates. * Exposes the Site Editor's template parts UI * Adds Appearance > "Template Parts" menu * Enabled within the theme via adding a theme support for `'block-template-parts'` {{{#!php add_theme_support( 'block-template-parts' ); }}} This is a backport from Gutenberg.[WordPress/gutenberg#42729 See WordPress/gutenberg PR 42729]. Follow-up to [52330], [52069], [52178]. Props mamaduka, fabiankaegy, poena, scruffian, manfcarlo, bernhard-reiter, hellofromTonya. See #56467. git-svn-id: https://develop.svn.wordpress.org/trunk@54176 602fd350-edb4-49c9-b593-d223f7449a82
To display a list of block-based template parts for classic themes, this changeset adds a `path` query arg to the Appearance > Template Parts menu URL. This change is necessary due to recent changes to Site Editor's client-side routing. Reference: * [WordPress/gutenberg#48343 Gutenberg PR 48343] * [WordPress/gutenberg#42729 Gutenberg PR 42729] Follow-up to [55392], [54176]. Props mamaduka, audrasjb, fabiankaegy, hellofromTonya, kevin940726, mukesh27, youknowriad. Fixes #57819. git-svn-id: https://develop.svn.wordpress.org/trunk@55435 602fd350-edb4-49c9-b593-d223f7449a82
To display a list of block-based template parts for classic themes, this changeset adds a `path` query arg to the Appearance > Template Parts menu URL. This change is necessary due to recent changes to Site Editor's client-side routing. Reference: * [WordPress/gutenberg#48343 Gutenberg PR 48343] * [WordPress/gutenberg#42729 Gutenberg PR 42729] Follow-up to [55392], [54176]. Props mamaduka, audrasjb, fabiankaegy, hellofromTonya, kevin940726, mukesh27, youknowriad. Fixes #57819. Built from https://develop.svn.wordpress.org/trunk@55435 git-svn-id: http://core.svn.wordpress.org/trunk@54968 1a063a9b-81f0-0310-95a4-ce76da25c4cd
To display a list of block-based template parts for classic themes, this changeset adds a `path` query arg to the Appearance > Template Parts menu URL. This change is necessary due to recent changes to Site Editor's client-side routing. Reference: * [WordPress/gutenberg#48343 Gutenberg PR 48343] * [WordPress/gutenberg#42729 Gutenberg PR 42729] Follow-up to [55392], [54176]. Props mamaduka, audrasjb, fabiankaegy, hellofromTonya, kevin940726, mukesh27, youknowriad. Fixes #57819. Built from https://develop.svn.wordpress.org/trunk@55435 git-svn-id: https://core.svn.wordpress.org/trunk@54968 1a063a9b-81f0-0310-95a4-ce76da25c4cd
To display a list of block-based template parts for classic themes, this changeset adds a `path` query arg to the Appearance > Template Parts menu URL. This change is necessary due to recent changes to Site Editor's client-side routing. Reference: * [WordPress/gutenberg#48343 Gutenberg PR 48343] * [WordPress/gutenberg#42729 Gutenberg PR 42729] Follow-up to [55392], [54176]. Props mamaduka, audrasjb, fabiankaegy, hellofromTonya, kevin940726, mukesh27, youknowriad. Fixes #57819. Built from https://develop.svn.wordpress.org/trunk@55435 git-svn-id: http://core.svn.wordpress.org/trunk@54968 1a063a9b-81f0-0310-95a4-ce76da25c4cd
} | ||
} | ||
|
||
$active_global_styles_id = WP_Theme_JSON_Resolver::get_user_global_styles_post_id(); |
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.
@Mamaduka @scruffian @fabiankaegy @Soean We should use the WP_Theme_JSON_Resolver_Gutenberg
class instead of the core one. Fix for this at #49198
What?
See #37943
PR allows Classic / Hybrid themes to use block-based template parts without using complete block-based templates. These can be rendered in PHP templates using the
block_template_part
method.Why?
The feature should make it easier to transition between Classic, Hybrid, and Block themes.
How?
PR alters Site Editor to allow only listing and editing template parts. It can be enabled for Classic themes using new
add_theme_support( 'block-template-parts' )
theme feature (not a final name). Once the feature is enabled new "Template Parts" menu is visible under "Appearance," which displays a list of template parts.The changes in
template-parts-screen.php
will be absorbed bysite-editor.php
. Inline comments have notes about migration paths.Open Questions
Do we want to display the Global Styles sidebar if a theme doesn't have atheme.json
file?Do we want to allow users to add new template parts via UI?Testing Instructions
Screenshots or screencast
CleanShot.2022-07-27.at.13.08.45.mp4