0

So I'm having some issues with an AWS multisite hosting of wordpress. Every couple of weeks my entire instance of websites goes down. The first time it happened I was getting 500 errors so I just restarted the instance & everything was fine. But the second time there were no 500 errors, and while restarting worked, I'd ideally like to solve the issue entirely so I dug a bit deeper & looked at my php error logs & found this:

"PHP WARNING: Declaration of my_menu_walker::start_el(&$output, $item, $depth, $args) should be compatible with Walker_Nav_Menu::start_el(&$output, $item, $depth = 0, $args = Array, $id = 0) in {filepath} on line 61"

Essentially there is some kind of issue with a line of code in the theme on one of my hosted sites, but as it's not a theme I created or anything like that I have no idea how to fix it. Here's the full class that's having issues. Line 61 is the last line of this class before the closing }'s.

class my_menu_walker extends Walker_Nav_Menu {

    function start_el(&$output, $item, $depth, $args) {

        global $wp_query;
        $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
        $class_names = $value = '';
        $classes = empty( $item->classes ) ? array() : (array) $item->classes;
        $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
        $class_names = ' class="'. esc_attr( $class_names ) . '"';

          $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';

          $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
          $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
          $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
          $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
          $description  = ! empty( $item->description ) ? '<span>'.esc_attr( $item->description ).'</span>' : '';

           if($depth != 0) 
                  $description = $append = $prepend = "";

            $item_output = $args->before;
            $item_output .= '<a'. $attributes .'>';
            $item_output .= $description.$args->link_after;
            $item_output .= $args->link_before.apply_filters( 'the_title', $item->title, $item->ID );
            $item_output .= '</a>';
            $item_output .= $args->after;
            $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
    }
}

Normally I would just send issues like this to the theme maker's support, but this theme is so old that I no longer have access to support from the theme maker without paying a large sum so if I can resolve it without doing that, that would be ideal.

  • The warning you mentioned is not a cause of the failure of your instance. This is just a PHP warning that doesn't affect website loading or even performance. You need to look for Fatal errors in your logs. If you can't find any, try with Apache error logs you may find something there. – Nour Edin Al-Habal Feb 22 '19 at 16:20
  • Follow the steps in this answer to resolve your issue: wordpress.stackexchange.com/a/325869/97257 – Nour Edin Al-Habal Feb 22 '19 at 16:23
0

Replcace this

function start_el(&$output, $item, $depth, $args) { ....

with this

function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { ....

I hope this will work.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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