Strict Standards Walker Error After Upgrading WordPress

Nowadays, many developers uses framework to reduce development time and focuses on the features or interface. But after upgrading to the WordPress latest version, front or back end shows strict standards or E_STRICT level error message. The message comes from some custom classes provided by the framework or even the WordPress core. This also occurs when updating theme framework and the child theme generate the same errors. In plugins, this also could happened for addons.

Strict Standards: Declaration of My_Walker_Menu::start_el() should be compatible with Walker::start_el(&$output, $object, $depth = 0, $args = Array, $current_object_id = 0) in /usr/home/mysite/lib/menu-walker.php on line 63

Strict Standards: Declaration of My_Nav_Desc_Menu::start_lvl() should be compatible with Walker::start_lvl(&$output, $depth = 0, $args = Array) in /usr/home/mysite/lib/menu-walker.php on line 116

Strict Standards: Declaration of My_Nav_Desc_Menu::end_lvl() should be compatible with Walker::end_lvl(&$output, $depth = 0, $args = Array) in /usr/home/mysite/lib/menu-walker.php on line 116

Strict Standards: Declaration of My_Nav_Desc_Menu::start_el() should be compatible with Walker::start_el(&$output, $object, $depth = 0, $args = Array, $current_object_id = 0) in /usr/home/mysite/lib/menu-walker.php on line 116

This happens when child class has different arguments, or a different access level. As an example, a function inside a parent class have five arguments while the child class only provides four arguments. To solve this problem, we can disable the error_reporting. Another way to solve this problem is by updating WordPress plugins or themes child class coding by providing the standard arguments, or contact the WordPress plugin/theme developer to update their code.

If you want to do it manually by yourself, open the child class error file, in example above menu-walker.php and copy paste the complete function from the error message, in example above start_lvl(&$output, $depth = 0, $args = Array)

// The child class before updated
class My_Walker_Menu extends Walker_Nav_Menu {
    function start_lvl(&$output, $depth) {
        // some code
    }
}
// The child class updated
class My_Walker_Menu extends Walker_Nav_Menu {
    function start_lvl(&$output, $depth = 0, $args = array())
        // some code
    }
}

From the above example, please try change the $args = Array to $args = array() to avoid errors. If you have any idea or problem regarding to this issue please use the comment form below.

5 comments on “Strict Standards Walker Error After Upgrading WordPress

  1. Changed everything as said. still a single error ” Declaration of Walker_Nav_Menu_Dropdown::start_el() should be compatible with Walker_Nav_Menu::start_el(&$output, $item, $depth = 0, $args = Array, $id = 0)” persists.

    1. Just replace it as the message:
      function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
      // code
      }

  2. please resolve this error : Strict Standards: Declaration of DropDown_Nav_Menu::end_el() should be compatible with Walker_Nav_Menu::end_el(&$output, $item, $depth = 0, $args = Array)

  3. Thank you for posting this! It saved me big time!.. Do you think that in the future that we may be required to update that part of the code again as WordPress progresses?

    Also, Just something that I noticed, should there not be an opening curly bracket ‘{‘ on line three for the ‘updated code’

    Kind Regards,
    Jared

Create Comment

Your email address will not be published. Required fields are marked *