Make WordPress Core

Changeset 33131


Ignore:
Timestamp:
07/08/2015 08:17:52 PM (9 years ago)
Author:
westonruter
Message:

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.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-nav-menus.php

    r33094 r33131  
    772772        $args['can_partial_refresh'] = $can_partial_refresh;
    773773
     774        $hashed_args = $args;
     775
    774776        if ( ! $can_partial_refresh ) {
    775             $args['fallback_cb'] = '';
    776             $args['walker'] = '';
    777         }
    778 
    779         ksort( $args );
    780         $args['args_hash'] = $this->hash_nav_menu_args( $args );
    781 
    782         $this->preview_nav_menu_instance_args[ $this->preview_nav_menu_instance_number ] = $args;
     777            $hashed_args['fallback_cb'] = '';
     778            $hashed_args['walker'] = '';
     779        }
     780
     781        ksort( $hashed_args );
     782        $hashed_args['args_hash'] = $this->hash_nav_menu_args( $hashed_args );
     783
     784        $this->preview_nav_menu_instance_args[ $this->preview_nav_menu_instance_number ] = $hashed_args;
    783785        return $args;
    784786    }
  • trunk/tests/phpunit/tests/customize/nav-menus.php

    r33089 r33131  
    359359        $expected = array(
    360360            'echo',
    361             'args_hash',
    362361            'can_partial_refresh',
    363362            'fallback_cb',
     
    371370        ) );
    372371        $this->assertEqualSets( $expected, array_keys( $results ) );
    373         $this->assertEquals( '', $results['fallback_cb'] );
    374         $this->assertEquals( '', $results['walker'] );
     372        $this->assertEquals( 'wp_page_menu', $results['fallback_cb'] );
    375373        $this->assertEquals( 0, $results['can_partial_refresh'] );
     374
     375        $this->assertNotEmpty( $menus->preview_nav_menu_instance_args[ $results['instance_number'] ] );
     376        $preview_nav_menu_instance_args = $menus->preview_nav_menu_instance_args[ $results['instance_number'] ];
     377        $this->assertEquals( '', $preview_nav_menu_instance_args['fallback_cb'] );
     378        $this->assertEquals( '', $preview_nav_menu_instance_args['walker'] );
     379        $this->assertNotEmpty( $preview_nav_menu_instance_args['args_hash'] );
    376380    }
    377381
Note: See TracChangeset for help on using the changeset viewer.