[wp-trac] [WordPress Trac] #14142: Custom Walker class for navigation menus
WordPress Trac
noreply at wordpress.org
Fri Apr 19 18:31:41 UTC 2019
#14142: Custom Walker class for navigation menus
---------------------------+-----------------------------
Reporter: dennis.winter | Owner: (none)
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: Future Release
Component: Menus | Version: 3.0
Severity: normal | Resolution:
Keywords: needs-patch | Focuses:
---------------------------+-----------------------------
Comment (by saas):
Custom walker won't be to utilize "Partial Refresh", if walker object is
passed.
So after reading reviewing
https://github.com/WordPress/WordPress/blob/4f35907147df1afdc99143af3813604967807a40
/wp-includes/class-wp-customize-nav-menus.php#L1369
I passed "Walker Class name as string" and it didn't worked either, was
throwing
```
PHP Fatal error: Using $this when not in object context
```
Then I saw this post
https://wordpress.stackexchange.com/q/295461/8521
And in combination with passing walker as string and applying this filter
solves my issue.
So patching this function
https://github.com/WordPress/WordPress/blob/7d74080b80bf0fee57de5f9c7137c9b4e31e3953
/wp-includes/nav-menu-template.php#L576
as
{{{
function walk_nav_menu_tree( $items, $depth, $r ) {
$walker = $r->walker;
if ( ! empty( $r->walker ) && is_string( $r->walker ) ) {
$walker = new $walker;
} else {
$walker = new Walker_Nav_Menu;
}
$args = array( $items, $depth, $r );
return call_user_func_array( array( $walker, 'walk' ), $args );
}
}}}
solves the issue.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/14142#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list