mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-06 23:58:03 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@56209 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -419,9 +419,14 @@ function wp_admin_bar_site_menu( $wp_admin_bar ) {
|
||||
*
|
||||
* @since 5.9.0
|
||||
*
|
||||
* @global string $_wp_current_template_id
|
||||
* @since 6.3.0 Added `$_wp_current_template_id` global for editing of current template directly from the admin bar.
|
||||
*
|
||||
* @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
|
||||
*/
|
||||
function wp_admin_bar_edit_site_menu( $wp_admin_bar ) {
|
||||
global $_wp_current_template_id;
|
||||
|
||||
// Don't show if a block theme is not activated.
|
||||
if ( ! wp_is_block_theme() ) {
|
||||
return;
|
||||
@@ -436,7 +441,13 @@ function wp_admin_bar_edit_site_menu( $wp_admin_bar ) {
|
||||
array(
|
||||
'id' => 'site-editor',
|
||||
'title' => __( 'Edit site' ),
|
||||
'href' => admin_url( 'site-editor.php' ),
|
||||
'href' => add_query_arg(
|
||||
array(
|
||||
'postType' => 'wp_template',
|
||||
'postId' => $_wp_current_template_id,
|
||||
),
|
||||
admin_url( 'site-editor.php' )
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user