Customizer: Call _doing_it_wrong() if widgets or nav_menus are manually removed via WP_Customize_Manager::remove_panel().

Advise that the `customize_loaded_components` filter should be used instead.

Props voldemortensen.
See #33552.
Fixes #35242.


git-svn-id: https://develop.svn.wordpress.org/trunk@36216 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter 2016-01-07 06:05:07 +00:00
parent e49c8b425c
commit e5707af429

View File

@ -1198,6 +1198,18 @@ final class WP_Customize_Manager {
* @param string $id Panel ID to remove.
*/
public function remove_panel( $id ) {
$core_panels = array(
'widgets',
'nav_menus',
);
if ( in_array( $id, $core_panels, true ) ) {
$url = 'https://core.trac.wordpress.org/ticket/33552#comment:12';
_doing_it_wrong(
__METHOD__,
sprintf( __( 'Removing %1$s manually will cause PHP warnings. Use the <code>customize_loaded_components</code> filter instead. See <a href="%2$s">%2$s</a>.' ), $id, $url ),
'4.5'
);
}
unset( $this->panels[ $id ] );
}