-
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
[Site Editor]: Expand the template types that can be added - single custom post type and specific posts templates #41189
Conversation
Size Change: +2.55 kB (0%) Total Size: 1.24 MB
ℹ️ View Unchanged
|
Imo we can just append them to the existing list (though we may want to tweak the order). We can explore ways to better scale the list separately.
Agree.
Yes in these cases we can just skip the first step in the modal, the "Single Post" label on the button still makes sense in both cases. |
In terms of the current state of this PR: The labels in the template list should read:
The Modal title should read "Add single post template". I'll see if I can fix the styling issues :) |
There might be more nuances with the labels because there are no existing
Have in mind that the PR is rough now and I didn't even think much about the elements/tags used(ex. p, h3, etc..). We might also want to change that. |
2cf90c8
to
a0bd405
Compare
e6d9775
to
addbd61
Compare
This is coming together :)
|
ee28950
to
ad10d0c
Compare
ad10d0c
to
e33d24b
Compare
@jameskoster if you find some time can you help a bit with these? Some mockup or even push directly.
This PR will handle that.
This is an unrelated issue and should be handled separately. I think there is a PR already for that. |
Typo:
For the archive template, I got a bit tripped up – I expected to see the general / specific options and had to question why I didn't. Perhaps updating the description a bit would help?
For the Single Post template could we use the I don't actually find the modal dimensions changing to be too problematic. In any case I wonder if min / max height and width should be properties of the modal component itself. As far as this PR goes I think we can leave it as-is. It would however be good to avoid the search input disappearing when you scroll through results. I'll try some options there, as well as some styles for Finally, do you think we should include the publish date in the post list when choosing a post to create a template for? Just in case there are multiple posts with the same title. |
Can't we reuse the link UI for displaying posts / post types / taxonomies / pages? Also #38121 |
Oh yeah, that would be much better. |
d7c9de6
to
f2eb487
Compare
When I first started implementing this, I choose not to try with Yesterday I looked into this more per @mtias' suggestion and here are my thoughts and observations.. While
These are just the things for
Maybe there are more, but after exploring this for a while yesterday, I thought I would post here and see how we'll move forward. So, is our intent to just have the same styles with LinkControl? If yes, we can do this and keep the existing implementation(which is ready in this PR). We could even revisit this after a while, especially after implementing the other template options(like author, taxonomies, etc...). In that case we would have to keep in sync the styles between the two. If we were to use |
I wont comment on the tech side, but I do think the styles should match. I'm happy to work on that if we decide to continue with the current implementation. |
a759339
to
72f9f83
Compare
Exciting to see this merged! :) I wonder if "Entry" might be a better term than "Item"? |
I'll. quickly iterate on the other templates, so we can revisit there 😄 |
Thanks for all the tweaks along the way :) |
Is it okay to leave a comment saying I'm so glad this was added? |
Added the Needs Dev Note label in case this needs a dev note (either individual or as part of a "misc" dev note) for WP 6.1 release. |
…e content. This commit improves site editor templates by: * Adds a post meta `is_wp_suggestion` to templates created from the site editor. Why? To differentiate the templates created from the post editor in the Template panel in inspector controls and the templates suggested in site editor. See [WordPress/gutenberg#41387 Gutenberg PR 41387] for more details. * Expands the template types that can be added to the site editor to include single custom post type and specific posts templates. See [WordPress/gutenberg#41189 Gutenberg PR 41189] for more details. * Adds fallback template content on creation in site editor: * Introduces `get_template_hierarchy()` to get the template hierarchy for a given template slug to be created. * Adds a `lookup` route to `WP_REST_Templates_Controller` to get the fallback template content. See [WordPress/gutenberg#42520 Gutenberg PR 42520] for more details. * Fixes a typo in default category template's description within `get_default_block_template_types()`. See [WordPress/gutenberg#42586 Gutenberg PR 42586] for more details. * Changes field checks from `in_array()` to `rest_is_field_included()` in `WP_REST_Post_Types_Controller`. * Adds an `icon` field to `WP_REST_Post_Types_Controller` Follow-up to [53129], [52331], [52275], [52062], [51962], [43087]. Props ntsekouras, spacedmonkey, mamaduka, mburridge, jameskoster, bernhard-reiter, mcsf, hellofromTonya. See #56467. git-svn-id: https://develop.svn.wordpress.org/trunk@54269 602fd350-edb4-49c9-b593-d223f7449a82
…e content. This commit improves site editor templates by: * Adds a post meta `is_wp_suggestion` to templates created from the site editor. Why? To differentiate the templates created from the post editor in the Template panel in inspector controls and the templates suggested in site editor. See [WordPress/gutenberg#41387 Gutenberg PR 41387] for more details. * Expands the template types that can be added to the site editor to include single custom post type and specific posts templates. See [WordPress/gutenberg#41189 Gutenberg PR 41189] for more details. * Adds fallback template content on creation in site editor: * Introduces `get_template_hierarchy()` to get the template hierarchy for a given template slug to be created. * Adds a `lookup` route to `WP_REST_Templates_Controller` to get the fallback template content. See [WordPress/gutenberg#42520 Gutenberg PR 42520] for more details. * Fixes a typo in default category template's description within `get_default_block_template_types()`. See [WordPress/gutenberg#42586 Gutenberg PR 42586] for more details. * Changes field checks from `in_array()` to `rest_is_field_included()` in `WP_REST_Post_Types_Controller`. * Adds an `icon` field to `WP_REST_Post_Types_Controller` Follow-up to [53129], [52331], [52275], [52062], [51962], [43087]. Props ntsekouras, spacedmonkey, mamaduka, mburridge, jameskoster, bernhard-reiter, mcsf, hellofromTonya. See #56467. Built from https://develop.svn.wordpress.org/trunk@54269 git-svn-id: http://core.svn.wordpress.org/trunk@53828 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…e content. This commit improves site editor templates by: * Adds a post meta `is_wp_suggestion` to templates created from the site editor. Why? To differentiate the templates created from the post editor in the Template panel in inspector controls and the templates suggested in site editor. See [WordPress/gutenberg#41387 Gutenberg PR 41387] for more details. * Expands the template types that can be added to the site editor to include single custom post type and specific posts templates. See [WordPress/gutenberg#41189 Gutenberg PR 41189] for more details. * Adds fallback template content on creation in site editor: * Introduces `get_template_hierarchy()` to get the template hierarchy for a given template slug to be created. * Adds a `lookup` route to `WP_REST_Templates_Controller` to get the fallback template content. See [WordPress/gutenberg#42520 Gutenberg PR 42520] for more details. * Fixes a typo in default category template's description within `get_default_block_template_types()`. See [WordPress/gutenberg#42586 Gutenberg PR 42586] for more details. * Changes field checks from `in_array()` to `rest_is_field_included()` in `WP_REST_Post_Types_Controller`. * Adds an `icon` field to `WP_REST_Post_Types_Controller` Follow-up to [53129], [52331], [52275], [52062], [51962], [43087]. Props ntsekouras, spacedmonkey, mamaduka, mburridge, jameskoster, bernhard-reiter, mcsf, hellofromTonya. See #56467. Built from https://develop.svn.wordpress.org/trunk@54269 git-svn-id: https://core.svn.wordpress.org/trunk@53828 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…e content. This commit improves site editor templates by: * Adds a post meta `is_wp_suggestion` to templates created from the site editor. Why? To differentiate the templates created from the post editor in the Template panel in inspector controls and the templates suggested in site editor. See [WordPress/gutenberg#41387 Gutenberg PR 41387] for more details. * Expands the template types that can be added to the site editor to include single custom post type and specific posts templates. See [WordPress/gutenberg#41189 Gutenberg PR 41189] for more details. * Adds fallback template content on creation in site editor: * Introduces `get_template_hierarchy()` to get the template hierarchy for a given template slug to be created. * Adds a `lookup` route to `WP_REST_Templates_Controller` to get the fallback template content. See [WordPress/gutenberg#42520 Gutenberg PR 42520] for more details. * Fixes a typo in default category template's description within `get_default_block_template_types()`. See [WordPress/gutenberg#42586 Gutenberg PR 42586] for more details. * Changes field checks from `in_array()` to `rest_is_field_included()` in `WP_REST_Post_Types_Controller`. * Adds an `icon` field to `WP_REST_Post_Types_Controller` Follow-up to [53129], [52331], [52275], [52062], [51962], [43087]. Props ntsekouras, spacedmonkey, mamaduka, mburridge, jameskoster, bernhard-reiter, mcsf, hellofromTonya. See #56467. git-svn-id: https://develop.svn.wordpress.org/trunk@54269 602fd350-edb4-49c9-b593-d223f7449a82
What?
Part of: #37407
After exploring the end goal for many new templates from the issue, it become clear to me that we need to do this incrementally. This is why there would be too many changes to review/test properly.
This first iteration handles custom
post types
only. The approach taken here is the one that we intent to use onTaxonomies, Authors
etc..In this PR if you have registered custom post types you are shown a new menu item in the available templates in site editor.
If this menu item is clicked can show different things depending on some conditions:
single-$post_type
and we have available posts that don't have a specific template created, it will show a modal with two options to create either of them. You can search through the available posts to create a specific template for it.single-$post_type
and we don't have available posts that don't have a specific template created, clicking the menu item will just create thesingle-$post_type
.single-$post_type
and we have available posts that don't have a specific template created, it will show the UI for searching the available posts.single-$post_type
and we don't have available posts that don't have a specific template created, the menu item will not be added.There are many special case we need to take into account and for this PR is just that we can't have
archive-post
so we have explicit exclusion. Similar cases will be in the follow ups forpage
post type, some prioritized specific templates over the generic ones, likecategory.php, tag.php
etc...Notes
In its current state this PR appends the newly added items at the bottom of the list.
Testing instructions
Screen.Recording.2022-06-14.at.12.55.26.PM.mov