Make WordPress Core


Ignore:
Timestamp:
07/11/2023 11:31:48 AM (8 months ago)
Author:
mikeschroder
Message:

Toolbar: Make the 'Edit site' link open the editor with the current template.

Adds a global, $_wp_current_template_id, to allow the 'Edit site' link in the admin bar to be aware of the current template and pass it to the Site Editor, so it can load the appropriate one directly.

See https://github.com/WordPress/gutenberg/issues/37850 for further discussion.

Props Mamaduka, poena, abitofmind, audrasjb, mikinc860, alexstine, annezazu, beckej, jameskoster, bacoords, clubkert, paaljoachim, get_dave, priethor, skorasaurus.
Fixes #58746.

File:
1 edited

Legend:

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

    r56060 r56209  
    2424 *
    2525 * @since 5.8.0
     26 * @since 6.3.0 Added `$_wp_current_template_id` global for editing of current template directly from the admin bar.
    2627 *
    2728 * @global string $_wp_current_template_content
     29 * @global string $_wp_current_template_id
    2830 *
    2931 * @param string   $template  Path to the template. See locate_template().
     
    3335 */
    3436function locate_block_template( $template, $type, array $templates ) {
    35     global $_wp_current_template_content;
     37    global $_wp_current_template_content, $_wp_current_template_id;
    3638
    3739    if ( ! current_theme_supports( 'block-templates' ) ) {
     
    6567
    6668    if ( $block_template ) {
     69        $_wp_current_template_id = $block_template->id;
     70
    6771        if ( empty( $block_template->content ) && is_user_logged_in() ) {
    6872            $_wp_current_template_content =
Note: See TracChangeset for help on using the changeset viewer.