Skip to content

Commit

Permalink
Replace adminbar customize link with site-editor in FSE themes (#27135)
Browse files Browse the repository at this point in the history
* Remove the adminbad Customizer link

* add FSE condition

* rename function

* Add site-editor link

* Change wording

* Check if user can edit_theme_options
  • Loading branch information
aristath authored Nov 23, 2020
1 parent 55bf177 commit 5a90a57
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions lib/full-site-editing.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,38 @@ function gutenberg_remove_legacy_pages() {

add_action( 'admin_menu', 'gutenberg_remove_legacy_pages' );

/**
* Removes legacy adminbar items from FSE themes.
*
* @param WP_Admin_Bar $wp_admin_bar The admin-bar instance.
*/
function gutenberg_adminbar_items( $wp_admin_bar ) {

// Early exit if not an FSE theme.
if ( ! gutenberg_is_fse_theme() ) {
return;
}

// Remove customizer link.
$wp_admin_bar->remove_node( 'customize' );
$wp_admin_bar->remove_node( 'customize-background' );
$wp_admin_bar->remove_node( 'customize-header' );
$wp_admin_bar->remove_node( 'widgets' );

// Add site-editor link.
if ( ! is_admin() && current_user_can( 'edit_theme_options' ) ) {
$wp_admin_bar->add_node(
array(
'id' => 'site-editor',
'title' => __( 'Edit site', 'gutenberg' ),
'href' => admin_url( 'admin.php?page=gutenberg-edit-site' ),
)
);
}
}

add_action( 'admin_bar_menu', 'gutenberg_adminbar_items', 50 );

/**
* Activates the 'menu_order' filter and then hooks into 'menu_order'
*/
Expand Down

0 comments on commit 5a90a57

Please sign in to comment.