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.


git-svn-id: https://develop.svn.wordpress.org/trunk@52621 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Robert Anderson
2022-01-24 05:32:28 +00:00
parent 1283afc6f7
commit 141815988a
2 changed files with 25 additions and 1 deletions
+2 -1
View File
@@ -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;
}