Editor: Fix how the Site Editor is linked to

- Add 'Edit site' to the top admin bar.
- Link to the Template and Template Part CPTs.
- Add deep link to the Global Styles UI.

Follows [52069].
See #54337.


git-svn-id: https://develop.svn.wordpress.org/trunk@52158 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Robert Anderson
2021-11-15 03:42:08 +00:00
parent 91c3f80355
commit 5d64794e6f
4 changed files with 45 additions and 11 deletions
+32 -5
View File
@@ -408,6 +408,33 @@ function wp_admin_bar_site_menu( $wp_admin_bar ) {
}
}
/**
* Adds the "Edit site" link to the Toolbar.
*
* @since 5.9.0
*
* @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
*/
function wp_admin_bar_edit_site_menu( $wp_admin_bar ) {
// Don't show if a block theme is not activated.
if ( ! wp_is_block_template_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' => __( 'Edit site' ),
'href' => admin_url( 'site-editor.php' ),
)
);
}
/**
* Adds the "Customize" link to the Toolbar.
*
@@ -419,6 +446,11 @@ function wp_admin_bar_site_menu( $wp_admin_bar ) {
function wp_admin_bar_customize_menu( $wp_admin_bar ) {
global $wp_customize;
// Don't show if a block theme is activated.
if ( wp_is_block_template_theme() ) {
return;
}
// Don't show for users who can't access the customizer or when in the admin.
if ( ! current_user_can( 'customize' ) || is_admin() ) {
return;
@@ -431,11 +463,6 @@ function wp_admin_bar_customize_menu( $wp_admin_bar ) {
return;
}
// Don't show if a block theme is activated.
if ( wp_is_block_template_theme() ) {
return;
}
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
if ( is_customize_preview() && $wp_customize->changeset_uuid() ) {
$current_url = remove_query_arg( 'customize_changeset_uuid', $current_url );