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

Admin bar: Edit site link should open the current template #37850

Closed
carolinan opened this issue Jan 11, 2022 · 19 comments
Closed

Admin bar: Edit site link should open the current template #37850

carolinan opened this issue Jan 11, 2022 · 19 comments
Assignees
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended [Type] Feedback Issues that relate purely to feedback on a feature that isn't necessarily actionable

Comments

@carolinan
Copy link
Contributor

Description

Often when I use the "Edit site" link in the WordPress admin bar, it is because I want to edit the current template.
This can be a post/page or an archive (they should all work the same).

Instead, the link opens the index/home/front-page, and I have to find a way to navigate to the template I wanted to edit.

Step-by-step reproduction instructions

With a full site editing theme active:

  1. Login.
  2. Navigate to an archive page.
  3. Click on the edit site link in the WordPress admin bar.
  4. See that the home page opens, not the page you were viewing.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@carolinan carolinan added the [Type] Feedback Issues that relate purely to feedback on a feature that isn't necessarily actionable label Jan 11, 2022
@alexstine
Copy link
Contributor

Makes sense to me. Less clicks for sure. Would make it work the same as Edit Post/Page/other post type. I would not be happy if I clicked Edit Post and got taken to the list of posts vs. the post I wanted to edit.

@carolinan
Copy link
Contributor Author

Alternatively, let this menu have two links, "Edit site" and "Edit template" which would lead to the current template, either in the site editor (for site templates) or the template editor (for single post/pages).

@annezazu annezazu added the Needs Design Feedback Needs general design feedback. label Apr 19, 2022
@beckej13820
Copy link

beckej13820 commented Apr 19, 2022

Just dropping by to add a +1. I have found myself doing a lot of clicking around going into and out of Full Site Editing. The two biggest issues are the preview button not working in FSE, and not being able to get directly back to the template I am looking at from the front end.

@annezazu
Copy link
Contributor

annezazu commented Jul 16, 2022

This was noted in the fifteenth call for testing for the FSE Outreach Program, which has a focus on creating and editing the categories template:

After visiting the newly created categories template, I went to the Site Editor again to fix a mistake I made earlier. However, when you click on “Edit site” in the admin bar, instead of loading the template you were just on, the home page template gets loaded. It would be better if the template you’re currently on, so in this case when I hit the “Edit site” button while I’m on a category page, I’d like to be directly taken to the Category template.

& again in a separate comment:

It is a bit odd to me that the toolbar on the frontend of the site has an “edit page” option sometimes, but not for all pages. I wonder if still having an edit page, there could be an “edit template” button or something if it’s a template and not a page?

& even more in an additional comment:

It would also be nice if the Edit Site button, would bring you to the template you were currently viewing. For now it seems to always just bring you to the homepage by default, then you have to go to templates and load the template you want to edit. Would be a lot easier to have the edit site be context aware.

@jameskoster
Copy link
Contributor

jameskoster commented Aug 8, 2022

I think a single 'Edit template' link could make sense as an accompaniment to 'Edit post'. We might even combine them into a single dropdown.

  • Edit
    • Post
    • Template

One other thing to consider is when to pass context to base templates. For example if I'm viewing my 'Hello World!' post and it uses the single template, what do I see when I click 'Edit template'? If we populate the template with the post content, folks might be misled into thinking the template only serves that one post. If we don't, would the transition be too abrupt, or confusing?

@bacoords
Copy link
Contributor

Because this is a UX pattern that we see pretty consistently in other page builders, I built a simple plugin (unaware of this open issue) to tackle this for myself. There's some holes in how we can determine the templates, so I think the final approach would require some better infrastructure to determine the active templates/template parts ( #32309 being a good example).

I'm just including a link to my repo as a functional design proof of concept. I basically added some dropdown nodes under the "Edit site" link with more specific links to the templates that are visible. So a user could still select 'Edit Site' or they could navigate to a specific template/part by selecting one of the dropdown links.

https://github.com/bacoords/site-editor-links

@clubkert
Copy link
Contributor

I think a single 'Edit template' link could make sense as an accompaniment to 'Edit post'. We might even combine them into a single dropdown.

  • Edit
    • Post
    • Template

This is an interesting idea when looking to edit a template for a post.

There are also times when there would only be an option to edit the template (i.e. there is not post), like the 404 page. In the below example, if I click "edit site" it just takes me to the main site editor (not the 404 template).

Screen Shot 2022-08-26 at 9 00 23 AM

@carolinan carolinan self-assigned this Mar 15, 2023
@carolinan
Copy link
Contributor Author

carolinan commented Mar 15, 2023

I made an attempt at this:

  • A new menu item needs to be added to wp_admin_bar_edit_site_menu in wp-includes/admin-bar.php.
  • The link needs to include the theme slug and the template slug
    'href' => admin_url( 'site-editor.php?postType=wp_template&postId=' . $theme . '%2F%2F' . $template . '&canvas=edit' ),
  • For singles, it is possible to get the custom page template slug from the _wp_page_template post meta.
  • Basic templates in the template hierarchy needed to be checked with is_404, is_search and so on. This created a long list of if statements which doesn't seem like the best solution.
  • This leaves how to get the correct template slug for single archives, single terms, etc.
  • Getting the slug for custom post types was untested.
  • And what if the page is the search results, but a template for it has not been created? There needs to be checks in place.

@porg
Copy link

porg commented Jun 14, 2023

@annezazu and @getdave — Continuing here as you recommended.

@carolinan — The essence of my issue #49438 was a duplicate of this your very issue here.

  • Mine has some graphics with a user story. Please feel free to copy it into your issue text on top (to aid quick understanding & attention).

@ALL

@paaljoachim
Copy link
Contributor

It is really good to see this issue being worked on! I have met the same thing as well. Clicking Edit Site only goes to the Front Page Template. I expected it to open the template related to the page that I am on.

@getdave
Copy link
Contributor

getdave commented Jun 15, 2023

It's my understanding that this would eventually require a Core patch for the Edit link in the admin bar. It would also require that all the routes in the Site Editor are stable as public APIs (I'm not sure whether this is the case yet).

I could not personally commit to working on this feature at this point in the release cycle. However, it is open for contributions should anyone like to take a look.

The work @bacoords did in his Plugin looks like a good starting point. It could land initially in Gutenberg via the hooks API and thus won't need a Core patch.

@priethor
Copy link
Contributor

Opening the current template is the only logical outcome and what most users might expect. We should address this malfunction sooner rather than later.

@priethor priethor added [Type] Bug An existing feature does not function as intended [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Priority] High Used to indicate top priority items that need quick attention labels Jun 27, 2023
@priethor priethor added this to Polish Jun 27, 2023
@priethor priethor moved this to Needs development in Polish Jun 27, 2023
@priethor priethor added Needs Dev Ready for, and needs developer efforts and removed Needs Design Feedback Needs general design feedback. labels Jun 27, 2023
@skorasaurus
Copy link
Member

If this is resolved; there probably should be a hook exposed so that developers can obtain what template(s) are currently being rendered; solving #32309

@porg
Copy link

porg commented Jun 27, 2023

@carolinan — Please copy my graphics from #49438 to your issue description on top.

  • If we link this very Gutenberg issue here in a corresponding WordPress Core Issue, visuals likely aid exposure.

@Mamaduka
Copy link
Member

Mamaduka commented Jul 7, 2023

I just created a core PR for this enhancement.

Links

@porg, do you mind attaching your visual aid graphs to the core ticket - https://core.trac.wordpress.org/ticket/58746?

@porg
Copy link

porg commented Jul 7, 2023

@Mamaduka

  • Very glad that someone picked this low hanging UX improvement fruit eventually!
  • I attached the graphic to the linked WP Core ticket.

@carolinan and everyone

  • Feel free to copy the graphic it to where-ever it helps! (on top of this very issue here too ofc).

@priethor priethor added [Status] In Progress Tracking issues with work in progress and removed Needs Dev Ready for, and needs developer efforts labels Jul 7, 2023
@priethor priethor moved this from Needs development to Needs review in Polish Jul 7, 2023
@priethor priethor moved this from 📥 Todo to 🔎 Needs Review in WordPress 6.3.x Editor Tasks Jul 7, 2023
@priethor priethor changed the title Feature request: Admin bar: Edit site link should open the current template Admin bar: Edit site link should open the current template Jul 7, 2023
pento pushed a commit to WordPress/wordpress-develop that referenced this issue Jul 11, 2023
…emplate.

Adds a global, `$_wp_current_template_id`, to allow the 'Edit site' link in the admin bar to be aware of the current template and pass it to the Site Editor, so it can load the appropriate one directly.

See WordPress/gutenberg#37850 for further discussion.

Props Mamaduka, poena, abitofmind, audrasjb, mikinc860, alexstine, annezazu, beckej, jameskoster, bacoords, clubkert, paaljoachim, get_dave, priethor, skorasaurus.
Fixes #58746.

git-svn-id: https://develop.svn.wordpress.org/trunk@56209 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to WordPress/WordPress that referenced this issue Jul 11, 2023
…emplate.

Adds a global, `$_wp_current_template_id`, to allow the 'Edit site' link in the admin bar to be aware of the current template and pass it to the Site Editor, so it can load the appropriate one directly.

See WordPress/gutenberg#37850 for further discussion.

Props Mamaduka, poena, abitofmind, audrasjb, mikinc860, alexstine, annezazu, beckej, jameskoster, bacoords, clubkert, paaljoachim, get_dave, priethor, skorasaurus.
Fixes #58746.
Built from https://develop.svn.wordpress.org/trunk@56209


git-svn-id: http://core.svn.wordpress.org/trunk@55721 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@getsource
Copy link
Member

Thanks so much everyone!

I'm going to close this, as it should be fixed in this commit:
https://core.trac.wordpress.org/changeset/56209

If you notice this is not the case, please feel free to reopen!

@github-project-automation github-project-automation bot moved this from 🔎 Needs Review to ✅ Done in WordPress 6.3.x Editor Tasks Jul 11, 2023
github-actions bot pushed a commit to gilzow/wordpress-performance that referenced this issue Jul 11, 2023
…emplate.

Adds a global, `$_wp_current_template_id`, to allow the 'Edit site' link in the admin bar to be aware of the current template and pass it to the Site Editor, so it can load the appropriate one directly.

See WordPress/gutenberg#37850 for further discussion.

Props Mamaduka, poena, abitofmind, audrasjb, mikinc860, alexstine, annezazu, beckej, jameskoster, bacoords, clubkert, paaljoachim, get_dave, priethor, skorasaurus.
Fixes #58746.
Built from https://develop.svn.wordpress.org/trunk@56209


git-svn-id: https://core.svn.wordpress.org/trunk@55721 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@priethor priethor moved this from Needs review to Done in Polish Jul 11, 2023
@autumnfjeld
Copy link

For clarity, just confirming this the wordpress admin bar, yes?
image

@annezazu
Copy link
Contributor

Yes. What you are showing appears to be something related to WordPress.com and not WordPress Core functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended [Type] Feedback Issues that relate purely to feedback on a feature that isn't necessarily actionable
Projects
Status: Done
Development

No branches or pull requests