[wp-trac] [WordPress Trac] #59419: Revisions page: how to support varying "Go to editor" link templates
WordPress Trac
noreply at wordpress.org
Tue Nov 21 01:46:00 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 | Resolution:
Keywords: | Focuses:
-----------------------------+------------------------------
Comment (by ramonopoly):
>> It can be done I think without great fuss using the get_edit_post_link
filter. With it we can return whatever we want.
> Have you tried this approach?
Thanks for looking at this issue!
I tested it out in Gutenberg, but I wanted to inquire about a path to Core
migration before committing to any one approach. Specifically, whether the
`_edit_link` remit needs to be widened.
If folks think that hooking into `get_edit_post_link` would be also fine
to go into Core then I'll move ahead.
Here's how I was testing it in Gutenberg.
{{{
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 );
}}}
Source:
https://github.com/WordPress/gutenberg/issues/51343#issuecomment-1709513348
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59419#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list