WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#34468 closed defect (bug) (invalid)

Don't enqueue nav menu scripts or templates in Customizer when panel isn't present

Reported by: danielbachhuber Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Customize Keywords:
Focuses: Cc:
PR Number:

Description

I've removed the panel:

private function setup_actions() {
		add_action( 'customize_register', array( $this, 'action_customizer_register_remove_default_controls' ), 11 );
	}

	public function action_customizer_register_remove_default_controls( $customizer ) {
		$customizer->remove_panel( 'nav_menus' );
	}

In doing so, I get error notices in my logs:

[27-Oct-2015 11:48:36 America/New_York] PHP Notice:  Trying to get property of non-object in /srv/www/site.dev/wp-includes/class-wp-customize-nav-menus.php on line 340
[27-Oct-2015 11:48:36 America/New_York] PHP Notice:  Trying to get property of non-object in /srv/www/site.dev/wp-includes/class-wp-customize-nav-menus.php on line 709

Attachments (1)

34468.1.diff (899 bytes) - added by danielbachhuber 4 years ago.

Download all attachments as: .zip

Change History (3)

#1 @westonruter
4 years ago

@danielbachhuber I think the problem is that it is not fully removing the nav menus functionality from being run. Please see #33552 for the code needed in 4.3 and the new code for 4.4:

<?php
add_filter( 'customize_loaded_components', function( $components ) {
    return array_filter( $components, function ( $component ) { 
         return 'nav_menus' !== $component; 
    } );
} );

#2 @danielbachhuber
4 years ago

  • Keywords has-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Ok, I'll use that workaround.

Note: See TracTickets for help on using tickets.