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 → Page Details: Link 'Last modified' detail to revisions #51343

Closed
1 of 2 tasks
jameskoster opened this issue Jun 8, 2023 · 10 comments · Fixed by #54082
Closed
1 of 2 tasks

Site Editor → Page Details: Link 'Last modified' detail to revisions #51343

jameskoster opened this issue Jun 8, 2023 · 10 comments · Fixed by #54082
Assignees
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Type] Enhancement A suggestion for improvement.

Comments

@jameskoster
Copy link
Contributor

jameskoster commented Jun 8, 2023

Follow-up to #50390.

Here's the Page details panel in the site editor:

Screenshot 2023-06-08 at 14 27 59

The 'Last modified' detail could be more useful if it linked to revisions, as it does in the Styles panel:

Screenshot 2023-06-08 at 14 31 34

The revisions page in wp-admin includes a "Go to editor" link:

Screenshot 2023-06-08 at 14 32 44

Ideally that link can be updated to conditionally return you to the correct view.

  • Update "Last modified" detail in Page panel to link to revisions
  • Update "Go to editor" link on Revisions page so that it returns you to the site editor
@jameskoster jameskoster added [Type] Enhancement A suggestion for improvement. Needs Dev Ready for, and needs developer efforts [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") labels Jun 8, 2023
@ndiego
Copy link
Member

ndiego commented Jul 3, 2023

@jameskoster is this safe to punt to 6.4, or is this being actively worked on? Just trying to tidy up the 6.3 Board 😅

@jameskoster
Copy link
Contributor Author

Fine to punt 👍

@jameskoster
Copy link
Contributor Author

@ramonjd Thanks for adding the revisions link but I don't think we can quite close this issue yet as the second part ("Update 'Go to editor' link on Revisions page so that it returns you to the site editor") is not implemented.

@jameskoster jameskoster reopened this Sep 5, 2023
@ramonjd
Copy link
Member

ramonjd commented Sep 5, 2023

Thanks for adding the revisions link but I don't think we can quite close this issue yet as the second part ("Update 'Go to editor' link on Revisions page so that it returns you to the site editor") is not implemented

No worries. The issue was probably auto-closed by the PR merged.

I thought the link would be best left for another PR as it will involve some PHP changes, and potential Core patches.

@ramonjd
Copy link
Member

ramonjd commented Sep 7, 2023

I thought the link would be best left for another PR as it will involve some PHP changes, and potential Core patches.

I've been investigating this, and am a bit unsure how to proceed. So I'll post my thoughts first 😄

The return to post links on the revisions page is generated from a template, unique to each post type object.

Currently, admin/revision.php builds the link by calling get_edit_post_link(), which uses the link template from page_object->_edit_link.

For most post types, including pages and posts, the _edit_link_ template looks something like this: post.php?post=%d.

get_edit_post_link() replaces the placeholder %d with the correct post id to build the edit post link.

Now we want to that template to vary depending on the origin of the referring URL. That means, if we're coming from the Site Editor, the return template should be something similar to what the wp_template post object uses, which is site-editor.php?postType=%s&postId=%d&canvas=edit.

I see a few challenges:

  1. the revisions page does not know where the revision is coming from, that is Post Editor vs Site Editor, but we could use some sort of$_GET query param on revisions.php to solve that. E.g., let's call it editor: revision.php?revision=150&editor=site
  2. Whether we grab the query param on the revision page and pass it to get_edit_post_link (thereby changing the function signature), or modify get_edit_post_link to do the lot internally, we'd still have to build the link accordingly to some pattern.
  3. Where would we store that pattern? _edit_link_ is taken. Maybe a new property on the post object? _edit_site_link or something.

I'm not sure if any of this is a good idea. 🤷🏻

In the plugin it can be done I think without great fuss using the get_edit_post_link filter. With it we can return whatever we want.

function gutenberg_update_get_edit_post_link_page_from_site_editor( $link, $post_id ) {
	$post = get_post( $post_id );

	if ( 'page' === $post->post_type && 'revision' === get_current_screen()->base && isset( $_GET['editor'] ) ) {
		if ( 'site' === sanitize_text_field( $_GET['editor'] ) ) {
			$post_edit_link = 'site-editor.php?' . build_query(
					array(
						'postType' => '%s',
						'postId'   => '%s',
						'canvas'   => 'edit',
					)
				);
			return admin_url( sprintf( $post_edit_link, $post->post_type, $post_id ) );;
		}
	}

	return $link;
}
add_filter( 'get_edit_post_link', 'gutenberg_update_get_edit_post_link_page_from_site_editor', 10, 2 );

We would just have to come up with migration approach for Core.

cc @draganescu if he has time since he worked on https://core.trac.wordpress.org/ticket/57709

@jameskoster
Copy link
Contributor Author

@ramonjd possibly a dumb idea, but could the 'Go to editor' link behave like the browser back button when there is an internal referrer?

@ramonjd
Copy link
Member

ramonjd commented Sep 8, 2023

but could the 'Go to editor' link behave like the browser back button when there is an internal referrer?

Very good question! That crossed my mind, but we'd also want to be able to build the link from wherever we are (and from wherever we've come).

get_edit_post_link(), the function that builds these links, is used in a bunch of places and I think the main purpose is to specifically fetch the edit link, regardless of the referrer.

@jameskoster
Copy link
Contributor Author

I suppose we can close this after all since it's a core issue. Feel free to re-open if you prefer.

@ramonjd
Copy link
Member

ramonjd commented Sep 18, 2023

I suppose we can close this after all since it's a core issue. Feel free to re-open if you prefer.

Thanks! I'll make a note to create a trac issue. Hopefully folks will contribute some interesting suggestions as to how we can build this into core.

@ramonjd
Copy link
Member

ramonjd commented Sep 21, 2023

Trac ticket: https://core.trac.wordpress.org/ticket/59419

@mikachan mikachan removed the Needs Dev Ready for, and needs developer efforts label Sep 29, 2023
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") [Type] Enhancement A suggestion for improvement.
Projects
Status: Done
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants