Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* This is a temporary fix needed to repair the issue mentioned here:
* https://core.trac.wordpress.org/ticket/40090
*/
add_filter( 'wp_nav_menu_args', 'replace_default_menu_walker', 10, 1 );
function replace_default_menu_walker( $args ) {
if ( empty($args['walker']) )
$args['walker'] = new Walker_Nav_Menu_40090;
return $args;
}
class Walker_Nav_Menu_40090 extends Walker_Nav_Menu {
public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
if ( ! $element )
return;
$id_field = $this->db_fields['id'];
if ( isset( $args[0] ) && is_object( $args[0] ) ) {
$args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] );
}
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment