forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the site editor Admin Bar menu item (WordPress#61851)
Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
- Loading branch information
1 parent
f5e479a
commit 23e65ec
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
https://github.com/WordPress/wordpress-develop/pull/6605 | ||
|
||
* https://github.com/WordPress/gutenberg/pull/61851 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
/** | ||
* Changes to the WordPress admin bar. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Adds the "Site Editor" link to the Toolbar. | ||
* | ||
* @since 5.9.0 | ||
* @since 6.3.0 Added `$_wp_current_template_id` global for editing of current template directly from the admin bar. | ||
* @since 6.6.0 Added the canvas argument to the url. | ||
* | ||
* @global string $_wp_current_template_id | ||
* | ||
* @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance. | ||
*/ | ||
function gutenberg_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; | ||
} | ||
|
||
// Don't show for users who can't edit theme options or when in the admin. | ||
if ( ! current_user_can( 'edit_theme_options' ) || is_admin() ) { | ||
return; | ||
} | ||
|
||
$wp_admin_bar->add_node( | ||
array( | ||
'id' => 'site-editor', | ||
'title' => __( 'Site Editor' ), | ||
'href' => add_query_arg( | ||
array( | ||
'postType' => 'wp_template', | ||
'postId' => $_wp_current_template_id, | ||
'canvas' => 'edit', | ||
), | ||
admin_url( 'site-editor.php' ) | ||
), | ||
) | ||
); | ||
} | ||
remove_action( 'admin_bar_menu', 'wp_admin_bar_edit_site_menu', 40 ); | ||
add_action( 'admin_bar_menu', 'gutenberg_admin_bar_edit_site_menu', 41 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters