Customize: Prevent PHP notice in Customizer when using block theme.
Use the `customize_panel_active` filter to deactivate the Menus panel instead of overriding the `check_capabilities` method. This ensures the panel remains registered but is still hidden. See #54888. Fixes #54905. Built from https://develop.svn.wordpress.org/trunk@54419 git-svn-id: http://core.svn.wordpress.org/trunk@53978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d8175f4121
commit
6d7dd31236
|
@ -98,27 +98,4 @@ class WP_Customize_Nav_Menus_Panel extends WP_Customize_Panel {
|
||||||
<li class="customize-control-title customize-section-title-nav_menus-heading"><?php _e( 'Menus' ); ?></li>
|
<li class="customize-control-title customize-section-title-nav_menus-heading"><?php _e( 'Menus' ); ?></li>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks required user capabilities and whether the theme has the
|
|
||||||
* feature support required by the panel.
|
|
||||||
*
|
|
||||||
* @since 5.9.0
|
|
||||||
*
|
|
||||||
* @return bool False if theme doesn't support the panel or the user doesn't have the capability.
|
|
||||||
*/
|
|
||||||
public function check_capabilities() {
|
|
||||||
/*
|
|
||||||
* WP_Customize_Panel::$theme_supports only supports checking one
|
|
||||||
* theme_supports, so instead we override check_capabilities().
|
|
||||||
*/
|
|
||||||
if (
|
|
||||||
! current_theme_supports( 'menus' ) &&
|
|
||||||
! current_theme_supports( 'widgets' )
|
|
||||||
) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::check_capabilities();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4257,4 +4257,23 @@ function _add_default_theme_supports() {
|
||||||
add_theme_support( 'automatic-feed-links' );
|
add_theme_support( 'automatic-feed-links' );
|
||||||
|
|
||||||
add_filter( 'should_load_separate_core_block_assets', '__return_true' );
|
add_filter( 'should_load_separate_core_block_assets', '__return_true' );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Remove the Customizer's Menus panel when block theme is active.
|
||||||
|
*/
|
||||||
|
add_filter(
|
||||||
|
'customize_panel_active',
|
||||||
|
static function ( $active, WP_Customize_Panel $panel ) {
|
||||||
|
if (
|
||||||
|
'nav_menus' === $panel->id &&
|
||||||
|
! current_theme_supports( 'menus' ) &&
|
||||||
|
! current_theme_supports( 'widgets' )
|
||||||
|
) {
|
||||||
|
$active = false;
|
||||||
|
}
|
||||||
|
return $active;
|
||||||
|
},
|
||||||
|
10,
|
||||||
|
2
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.1-beta3-54418';
|
$wp_version = '6.1-beta3-54419';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue