If “line 45” is the one that starts with $element->classes[]
in your display_element
method then try something like this:
public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
$element->has_children = ! empty( $children_elements[ $element->ID ] );
if ( ! isset( $element->classes ) ) {
$element->classes = array();
}
$element->classes[] = ( $element->current || $element->current_item_ancestor ) ? 'active' : '';
$element->classes[] = ( $element->has_children && 1 !== $max_depth ) ? 'has-dropdown' : '';
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
}
The problem may be that the display_element
function receives an element that doesn’t have that classes
property set in which case you are trying to push data to an array that isn’t referenced anywhere except that instance only.
EDIT: Also, why are you using the display_element
function when you can insert those classes in the start_el
function which itself gets called by display_element
with that element passed to it?