From 4aaa1803ecab841bdd2cdc3f3bcebf20a62b8b6e Mon Sep 17 00:00:00 2001 From: noisysocks Date: Mon, 24 Jan 2022 05:34:04 +0000 Subject: [PATCH] Customizer: Remove Menus panel when a theme does not support menus By overriding check_capabilities(), we can ensure that the Menus panel is removed if a theme does not have support for 'menus' nor 'widgets'. This ensures that the Menus panel does not appear when using a block theme, which is confusing to users. See #54888. Props hellofromTonya, costdev, peterwilsoncc. Built from https://develop.svn.wordpress.org/trunk@52621 git-svn-id: http://core.svn.wordpress.org/trunk@52209 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-customize-panel.php | 3 ++- .../class-wp-customize-nav-menus-panel.php | 23 +++++++++++++++++++ wp-includes/version.php | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/wp-includes/class-wp-customize-panel.php b/wp-includes/class-wp-customize-panel.php index 02c46ed695..6ec6cd55e0 100644 --- a/wp-includes/class-wp-customize-panel.php +++ b/wp-includes/class-wp-customize-panel.php @@ -232,10 +232,11 @@ class WP_Customize_Panel { * feature support required by the panel. * * @since 4.0.0 + * @since 5.9.0 Method was marked non-final. * * @return bool False if theme doesn't support the panel or the user doesn't have the capability. */ - final public function check_capabilities() { + public function check_capabilities() { if ( $this->capability && ! current_user_can( $this->capability ) ) { return false; } diff --git a/wp-includes/customize/class-wp-customize-nav-menus-panel.php b/wp-includes/customize/class-wp-customize-nav-menus-panel.php index c0d098bc7d..18328e5d3f 100644 --- a/wp-includes/customize/class-wp-customize-nav-menus-panel.php +++ b/wp-includes/customize/class-wp-customize-nav-menus-panel.php @@ -98,4 +98,27 @@ class WP_Customize_Nav_Menus_Panel extends WP_Customize_Panel {