[wp-trac] [WordPress Trac] #59419: Revisions page: how to support varying "Go to editor" link templates

WordPress Trac noreply at wordpress.org
Thu Sep 21 03:26:10 UTC 2023


#59419: Revisions page: how to support varying "Go to editor" link templates
-----------------------------+-----------------------------
 Reporter:  ramonopoly       |      Owner:  (none)
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Revisions        |    Version:
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 For various post types, the Block Editor redirects to admin/revision.php.

 The page admin/revision.php has a couple of "Go to editor" links, which
 open the the current post in the editor.

 admin/revision.php builds the link by calling `get_edit_post_link()`,
 which uses the link template from `post_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.

 Each page under Site Editor sidebar contains a link to admin/revision.php
 for page revisions.

 However since the "Go to editor" links are constructed using
 `page_object->_edit_link`, they will always link to post editor.

 I would expect the links to return me to the editor from which I last
 came.

 The upshot is that we want the `_edit_link` template to vary depending on
 the origin of the referring URL. For pages, 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.

 The question is "what would be the best way to do this?"

 Challenges:

 1. admin/revision.php 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`. That is very specific and might
 be too narrow.
 2. If 1, what then? 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. If 2, where would we store that pattern? `_edit_link` is taken. Maybe a
 new property on the post object? `_edit_site_link` or something.


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

 We would just have to come up with migration approach for Core and I'm not
 sure what the best option would be.

 Thank you for considering this issue!




 For discussion and context see:
 https://github.com/WordPress/gutenberg/issues/51343#issuecomment-1724580879

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59419>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list