Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always display Customizer menu item #36168

Merged
merged 3 commits into from
Nov 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 32 additions & 17 deletions lib/full-site-editing/full-site-editing.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ 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 @@ -64,13 +60,11 @@ function gutenberg_adminbar_items( $wp_admin_bar ) {
return;
}

// 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' );
}
// 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' );

// Add site-editor link.
if ( ! is_admin() && current_user_can( 'edit_theme_options' ) ) {
Expand All @@ -87,17 +81,38 @@ function gutenberg_adminbar_items( $wp_admin_bar ) {
add_action( 'admin_bar_menu', 'gutenberg_adminbar_items', 50 );

/**
* Check if any plugin, or theme features, are using the Customizer.
* 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.
*
* @return bool A boolean value indicating if Customizer support is needed.
* @param WP_Customize_Manager $wp_customize The customize manager instance.
*/
function gutenberg_site_requires_customizer() {
if ( has_action( 'customize_register' ) ) {
return true;
function gutenberg_remove_customizer_sections( $wp_customize ) {
if ( ! gutenberg_is_fse_theme() ) {
return;
}

return false;
$wp_customize->remove_control( 'custom_css' );
}
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