Make WordPress Core


Ignore:
Timestamp:
05/10/2023 05:34:13 PM (19 months ago)
Author:
davidbaumwald
Message:

Revisions: Add edit link functionality for the wp_template and wp_template_part post types.

In preparation for viewing revisions of templates and template parts in the editor, this set changes adds the _edit_link argument when registering the wp_template and wp_template_part post types. This commit also updates get_edit_post_link to account for the unique edit URLs for these post types.

Finally, this commit also adds new unit tests for the get_edit_post_link function, including tests for the post, wp_template, and wp_template_part post types.

Fixes #57709.
Props andraganescu, spacedmonkey, antonvlasenko, youknowriad, ramonopoly, ironprogrammer, annezazu.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r55732 r55743  
    333333    );
    334334
     335    $template_edit_link = 'site-editor.php?' . build_query(
     336        array(
     337            'postType' => '%s',
     338            'postId'   => '%s',
     339            'canvas'   => 'edit',
     340        )
     341    );
     342
    335343    register_post_type(
    336344        'wp_template',
     
    359367            'public'                => false,
    360368            '_builtin'              => true, /* internal use only. don't use this when registering your own post type. */
     369            '_edit_link'            => $template_edit_link, /* internal use only. don't use this when registering your own post type. */
    361370            'has_archive'           => false,
    362371            'show_ui'               => false,
     
    419428            'public'                => false,
    420429            '_builtin'              => true, /* internal use only. don't use this when registering your own post type. */
     430            '_edit_link'            => $template_edit_link, /* internal use only. don't use this when registering your own post type. */
    421431            'has_archive'           => false,
    422432            'show_ui'               => false,
     
    459469            'public'       => false,
    460470            '_builtin'     => true, /* internal use only. don't use this when registering your own post type. */
     471            '_edit_link'   => '/site-editor.php?canvas=edit', /* internal use only. don't use this when registering your own post type. */
    461472            'show_ui'      => false,
    462473            'show_in_rest' => false,
Note: See TracChangeset for help on using the changeset viewer.