[wp-trac] [WordPress Trac] #41488: Customize: uncaught JS error with namespaced nav menu fallbacks
WordPress Trac
noreply at wordpress.org
Sun Jul 30 19:21:04 UTC 2017
#41488: Customize: uncaught JS error with namespaced nav menu fallbacks
--------------------------+-----------------------------
Reporter: dlh | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Customize | Version:
Severity: normal | Keywords: has-patch
Focuses: |
--------------------------+-----------------------------
A `wp_nav_menu()` call with a namespaced `fallback_cb` can generate a
JavaScript error if the backslash creates invalid JSON. For example:
{{{#!php
wp_nav_menu( [
'fallback_cb' => '\WordPress\my_callback,
'theme_location' => 'menu-1',
'menu_id' => 'primary-menu',
] );
}}}
throws an error at
https://github.com/WordPress/WordPress/blob/82d0a53e77f0eb6a8de60b67a2b5266c4f042741
/wp-includes/js/customize-preview-nav-menus.js#L113.
If the fallback happens to generate escape characters, like
`\birdpress\bird_callback`, then the error doesn't occur, but the value of
`navMenuArgs.fallback_cb` is mangled.
The attached patch takes a conservative approach by checking for a `\`
before determining a nav menu supports partial refresh.
I also tested what happens if the backslashes are padded to `\\\\` in
`$exported_args`. It fixed the issue as far as I could tell, but the
potential for side-effects seems greater.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41488>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list