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/admin-bar.php

    r55881 r56209  
    420420 * @since 5.9.0
    421421 *
     422 * @global string $_wp_current_template_id
     423 * @since 6.3.0 Added `$_wp_current_template_id` global for editing of current template directly from the admin bar.
     424 *
    422425 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
    423426 */
    424427function wp_admin_bar_edit_site_menu( $wp_admin_bar ) {
     428    global $_wp_current_template_id;
     429
    425430    // Don't show if a block theme is not activated.
    426431    if ( ! wp_is_block_theme() ) {
     
    437442            'id'    => 'site-editor',
    438443            'title' => __( 'Edit site' ),
    439             'href'  => admin_url( 'site-editor.php' ),
     444            'href'  => add_query_arg(
     445                array(
     446                    'postType' => 'wp_template',
     447                    'postId'   => $_wp_current_template_id,
     448                ),
     449                admin_url( 'site-editor.php' )
     450            ),
    440451        )
    441452    );
Note: See TracChangeset for help on using the changeset viewer.