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

Site editor: update custom post types with _edit_link #50563

Merged
merged 1 commit into from
May 13, 2023

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented May 12, 2023

What?

Resolves: #48065

Hello!

This PR backports the following functionality from Core:

  • adds an _edit_link property to wp_global_styles, wp_template, and wp_template-part custom post type schemata via filter
  • uses the _edit_link value to create an edit link via the get_edit_post_link hook

Why?

A revisions link was added to view revisions for templates and template parts.

Screenshot 2023-05-12 at 12 59 36 pm

This link takes the user to the WordPress revision.php screen. Here there are two links that should link back to the editor.

Screenshot 2023-05-12 at 12 55 48 pm

But since the custom post types schemata did not contain an _edit_link property, the links were broken.

wp_global_styles was covered for the sake of completion.

This was recently fixed in Core and already has test coverage:

But 6.3 won't be out until later in the year. August?

How?

register_post_type_args and get_edit_post_link filters

Testing Instructions

  1. Spin up this branch and head over to the site editor.
  2. Make a few (more than 1) changes to a template and also to a template part
  3. In the right-hand-side inspector, select the "Template" menu item and click on the "Revisions" button
  4. You should be taken to revision.php. Now make sure that the two links, e.g., Compare Revisions of “header” and ← Go to editor take you back to the site editor with the right template in edit mode.

@ramonjd ramonjd added [Feature] Template Editing Mode Related to the template editor available in the Block Editor Backport from WordPress Core Pull request that needs to be backported to a Gutenberg release from WordPress Core labels May 12, 2023
@ramonjd ramonjd requested a review from spacedmonkey as a code owner May 12, 2023 03:02
@ramonjd ramonjd self-assigned this May 12, 2023
@ramonjd ramonjd force-pushed the update/get-edit-post-link branch from d4a23a6 to 9317199 Compare May 12, 2023 03:07
- adds an `_edit_link` property to `wp_global_styles`, `wp_template`, and `wp_template-part` custom post type schemata via filter
- uses the `_edit_link` value to create an edit link via the `get_edit_post_link` hook
@ramonjd ramonjd force-pushed the update/get-edit-post-link branch from 9317199 to 1a57107 Compare May 12, 2023 03:08
Copy link
Contributor

@draganescu draganescu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you :) I forgot the links are filterable and I was worried we can't backport the edits to ghe get edit link function. 👏 the power of hooks once again saves the day. Great work @ramonjd 🚢

@ramonjd ramonjd merged commit f32c9a4 into trunk May 13, 2023
@ramonjd ramonjd deleted the update/get-edit-post-link branch May 13, 2023 01:51
@github-actions github-actions bot added this to the Gutenberg 15.9 milestone May 13, 2023
@ramonjd ramonjd added Needs PHP backport Needs PHP backport to Core and removed Needs PHP backport Needs PHP backport to Core labels Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport from WordPress Core Pull request that needs to be backported to a Gutenberg release from WordPress Core [Feature] Template Editing Mode Related to the template editor available in the Block Editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Links to the editor don't work for template and template parts revisions in the revisions screen
2 participants