Make WordPress Core

#58746 closed task (blessed) (fixed)

Toolbar: Make the 'Edit site' link aware of the current template

Reported by: mamaduka's profile Mamaduka Owned by: kirasong's profile kirasong
Milestone: 6.3 Priority: normal
Severity: normal Version: 5.9
Component: Toolbar Keywords: has-patch commit
Focuses: Cc:

Description

Original Gutenberg issue: https://github.com/WordPress/gutenberg/issues/37850.

Update the 'Edit site" link in the toolbar and make it aware of the current template.

Why?

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.

Attachments (1)

Site Editor shall know from which ID it got invoked and select template type and content sample accordingly.png (72.6 KB) - added by abitofmind 11 months ago.
Site Editor shall know from which ID it got invoked and select template type and content sample accordingly

Download all attachments as: .zip

Change History (11)

This ticket was mentioned in PR #4810 on WordPress/wordpress-develop by @Mamaduka.


11 months ago
#1

  • Keywords has-patch added

PR makes the 'Edit site' link in the toolbar contextually aware of the current template.

## How

Introduces a new global $_wp_current_template_id that stores the current template ID during the template resolution.

We can't use the existing $_wp_current_template_content global as it only stores template contents.

## Refs

Gutenberg issue: https://github.com/WordPress/gutenberg/issues/37850

#2 @poena
11 months ago

Test Report

This report validates that the indicated patch addresses the issue.

Patch tested: PR #4810

Environment

  • OS: macOS 13.4.1
  • Web Server: nginx/1.23.1
  • PHP: 7.4.29
  • WordPress: 6.3-beta3-56130-src
  • Browser: Chrome Version 114.0.5735.198
  • Theme: Twenty Twenty-three, twenty twenty-two, Twenty Ten (classic)
  • Active Plugins:
    • I tested with and without WooCommerce, as this is the only plugin I know of that adds custom block theme templates.

Actual Results

  • ✅ Works as expected with patch.

#3 @Mamaduka
11 months ago

  • Milestone changed from Awaiting Review to 6.3
  • Type changed from enhancement to task (blessed)

I am tentatively marking it as a "blessed" task targeting WP 6.3. The Gutenberg issue is in the 6.3 milestone.

@abitofmind
11 months ago

Site Editor shall know from which ID it got invoked and select template type and content sample accordingly

#4 @audrasjb
11 months ago

This looks like something we can handle in 6.3.
The PR looks good to me, however I left a comment concerning two needed docblock changes.

@Mamaduka commented on PR #4810:


11 months ago
#5

Thank you, @audrasjb! I added DocBlocks in 447fba8.

#6 @mikinc860
11 months ago

This looks good to me as well.

#7 @Mamaduka
11 months ago

@audrasjb, should we update the keywords and mark this ready for commit?

#8 @audrasjb
11 months ago

  • Keywords commit added

Yeah, sure :)

#9 @kirasong
11 months ago

I tested the current patch, and it works as expected.

TL;DR:
Thinking to commit, along with this additional documentation added to each function that is changed, so that it's clearer what the new global is used for:

@since 6.3.0 Added `$_wp_current_template_id` global for editing of current template directly from the admin bar.

Some further feedback:

I think the user experience of opening an editor that almost, but not quite the same contents was unexpected, but that it's much improved from the current behavior of opening Home every time.

To explain a little more (all with the patch applied):
When "Edit Site" is clicked from the Home/index, a lot of the site's contents are present on the Home template in the editor, and it feels like "my site".

If I click "Edit Site" from a page / post, at least on my theme, I am brought to the current template, but it does not reflect the contents of the page I was on.

I think this is intentional / expected, but I figured I'd note my experience here so that if we want to improve on it later, it's here!

#10 @kirasong
11 months ago

  • Owner set to mikeschroder
  • Resolution set to fixed
  • Status changed from new to closed

In 56209:

Toolbar: Make the 'Edit site' link open the editor with the current template.

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 https://github.com/WordPress/gutenberg/issues/37850 for further discussion.

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

Note: See TracTickets for help on using tickets.