1

I am getting this warning after updating to PHP 7.2 can anyone help me resolve it?

Warning: Declaration of foundation_navigation::start_lvl(&$output, $depth) should be compatible with Walker_Nav_Menu::start_lvl(&$output, $depth = 0, $args = Array) in /nas/content/staging/arnoldhill/wp-content/themes/arnoldhill/functions.php on line 121

The function is currently written like this

// Add class to navigation sub-menu
class foundation_navigation extends Walker_Nav_Menu {

function start_lvl(&$output, $depth) {
    $indent = str_repeat("\t", $depth);
    $output .= "\n$indent<ul class=\"flyout\">\n";
}

function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {
    $id_field = $this->db_fields['id'];
    if ( !empty( $children_elements[ $element->$id_field ] ) ) {
        $element->classes[] = 'has-flyout';
    }
        Walker_Nav_Menu::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
    }
}

Thanks

Henry

1

As you can see here, the declaration of this function looks like this:

public function start_lvl( &$output, $depth = 0, $args = array() ) {

So in your class it should look the same - it should have 3 params. But in your code it has only 2:

function start_lvl(&$output, $depth) {

Also... You shouldn't change visibility of that function, so it also should be public.

So you should change your code so it looks like this:

...
public function start_lvl( &$output, $depth = 0, $args = array() ) {
    $indent = str_repeat("\t", $depth);
    $output .= "\n$indent<ul class=\"flyout\">\n";
}
...
  • That's worked a treat - many many thanks for your help – Henry Bagilhole Jan 24 '19 at 11:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.