Customizer: Prevent loss of walker
and fallback_cb
args for wp_nav_menu
.
These args only need to be cleared out when exported to JavaScript, when they are not JSON-serializable. So the filter now clears these when gathering args for exporting to JS, but otherwise now leaves the original values to be passed through to `wp_nav_menu()`. Fixes #32781. git-svn-id: https://develop.svn.wordpress.org/trunk@33131 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f5043ab022
commit
3c0e4d3860
@ -771,15 +771,17 @@ final class WP_Customize_Nav_Menus {
|
||||
);
|
||||
$args['can_partial_refresh'] = $can_partial_refresh;
|
||||
|
||||
$hashed_args = $args;
|
||||
|
||||
if ( ! $can_partial_refresh ) {
|
||||
$args['fallback_cb'] = '';
|
||||
$args['walker'] = '';
|
||||
$hashed_args['fallback_cb'] = '';
|
||||
$hashed_args['walker'] = '';
|
||||
}
|
||||
|
||||
ksort( $args );
|
||||
$args['args_hash'] = $this->hash_nav_menu_args( $args );
|
||||
ksort( $hashed_args );
|
||||
$hashed_args['args_hash'] = $this->hash_nav_menu_args( $hashed_args );
|
||||
|
||||
$this->preview_nav_menu_instance_args[ $this->preview_nav_menu_instance_number ] = $args;
|
||||
$this->preview_nav_menu_instance_args[ $this->preview_nav_menu_instance_number ] = $hashed_args;
|
||||
return $args;
|
||||
}
|
||||
|
||||
|
@ -358,7 +358,6 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
|
||||
$expected = array(
|
||||
'echo',
|
||||
'args_hash',
|
||||
'can_partial_refresh',
|
||||
'fallback_cb',
|
||||
'instance_number',
|
||||
@ -370,9 +369,14 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
'walker' => new Walker_Nav_Menu(),
|
||||
) );
|
||||
$this->assertEqualSets( $expected, array_keys( $results ) );
|
||||
$this->assertEquals( '', $results['fallback_cb'] );
|
||||
$this->assertEquals( '', $results['walker'] );
|
||||
$this->assertEquals( 'wp_page_menu', $results['fallback_cb'] );
|
||||
$this->assertEquals( 0, $results['can_partial_refresh'] );
|
||||
|
||||
$this->assertNotEmpty( $menus->preview_nav_menu_instance_args[ $results['instance_number'] ] );
|
||||
$preview_nav_menu_instance_args = $menus->preview_nav_menu_instance_args[ $results['instance_number'] ];
|
||||
$this->assertEquals( '', $preview_nav_menu_instance_args['fallback_cb'] );
|
||||
$this->assertEquals( '', $preview_nav_menu_instance_args['walker'] );
|
||||
$this->assertNotEmpty( $preview_nav_menu_instance_args['args_hash'] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user