Skip to content

Commit

Permalink
Revert "Always display Customizer menu item (#36168)"
Browse files Browse the repository at this point in the history
This reverts commit 1bbc66d.
  • Loading branch information
noisysocks authored Nov 4, 2021
1 parent 1b0ff7e commit 0a6cd78
Showing 1 changed file with 17 additions and 32 deletions.
49 changes: 17 additions & 32 deletions lib/full-site-editing/full-site-editing.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ function gutenberg_remove_legacy_pages() {
if ( isset( $submenu['themes.php'] ) ) {
$indexes_to_remove = array();
foreach ( $submenu['themes.php'] as $index => $menu_item ) {
if ( false !== strpos( $menu_item[2], 'customize.php' ) && ! gutenberg_site_requires_customizer() ) {
$indexes_to_remove[] = $index;
}

if ( false !== strpos( $menu_item[2], 'gutenberg-widgets' ) ) {
$indexes_to_remove[] = $index;
}
Expand All @@ -60,11 +64,13 @@ function gutenberg_adminbar_items( $wp_admin_bar ) {
return;
}

// Remove customizer links.
$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' );
// Remove customizer link, if this site does not rely on them for plugins or theme options.
if ( ! gutenberg_site_requires_customizer() ) {
$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' ) ) {
Expand All @@ -81,38 +87,17 @@ function gutenberg_adminbar_items( $wp_admin_bar ) {
add_action( 'admin_bar_menu', 'gutenberg_adminbar_items', 50 );

/**
* Removes the legacy core components from the Customizer.
*
* @param array $components Core Customizer components list.
* @return array Modified components list.
*/
function gutenberg_remove_customizer_components( $components ) {
if ( ! gutenberg_is_fse_theme() ) {
return $components;
}

$index = array_search( 'nav_menus', $components, true );
if ( false !== $index ) {
unset( $components[ $index ] );
}

return $components;
}
add_filter( 'customize_loaded_components', 'gutenberg_remove_customizer_components' );

/**
* Removes lagecy Customizer sections for FSE themes.
* Check if any plugin, or theme features, are using the Customizer.
*
* @param WP_Customize_Manager $wp_customize The customize manager instance.
* @return bool A boolean value indicating if Customizer support is needed.
*/
function gutenberg_remove_customizer_sections( $wp_customize ) {
if ( ! gutenberg_is_fse_theme() ) {
return;
function gutenberg_site_requires_customizer() {
if ( has_action( 'customize_register' ) ) {
return true;
}

$wp_customize->remove_control( 'custom_css' );
return false;
}
add_action( 'customize_register', 'gutenberg_remove_customizer_sections', 50 );

/**
* Tells the script loader to load the scripts and styles of custom block on site editor screen.
Expand Down

0 comments on commit 0a6cd78

Please sign in to comment.