Skip to content

Commit b931715

Browse files
committed
Admin bar: Update the "Edit Site" link to 6.7 destination.
This reverts [59910] and changes the "Edit Site" link to be the current template rather than the top-level screen of the Site Editor. Reviewed by SergeyBiryukov, desrosj. Merges [60193] to the 6.8 branch. Props wildworks, joemcgill, poena, westonruter, nickwilmot, marktimemedia, eduwass, lilgames, codeamp, jeffr0, jorbin. Fixes #63358. See #62368. git-svn-id: https://develop.svn.wordpress.org/branches/6.8@60194 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 0faec76 commit b931715

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/wp-includes/admin-bar.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,27 +458,36 @@ function wp_admin_bar_site_menu( $wp_admin_bar ) {
458458
* @since 5.9.0
459459
* @since 6.3.0 Added `$_wp_current_template_id` global for editing of current template directly from the admin bar.
460460
* @since 6.6.0 Added the `canvas` query arg to the Site Editor link.
461-
* @since 6.8.0 Removed the query args to ensure that the link opens the starting screen of the Site Editor.
461+
*
462+
* @global string $_wp_current_template_id
462463
*
463464
* @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
464465
*/
465466
function wp_admin_bar_edit_site_menu( $wp_admin_bar ) {
467+
global $_wp_current_template_id;
466468

467469
// Don't show if a block theme is not activated.
468470
if ( ! wp_is_block_theme() ) {
469471
return;
470472
}
471473

472-
// Don't show for users who can't edit theme options.
473-
if ( ! current_user_can( 'edit_theme_options' ) ) {
474+
// Don't show for users who can't edit theme options or when in the admin.
475+
if ( ! current_user_can( 'edit_theme_options' ) || is_admin() ) {
474476
return;
475477
}
476478

477479
$wp_admin_bar->add_node(
478480
array(
479481
'id' => 'site-editor',
480482
'title' => __( 'Edit Site' ),
481-
'href' => admin_url( 'site-editor.php' ),
483+
'href' => add_query_arg(
484+
array(
485+
'postType' => 'wp_template',
486+
'postId' => $_wp_current_template_id,
487+
'canvas' => 'edit',
488+
),
489+
admin_url( 'site-editor.php' )
490+
),
482491
)
483492
);
484493
}

0 commit comments

Comments
 (0)