• Hello,

    I’m having problems with the header when I upgrade the PHP from 5.6.39 to any version 7.

    The following warning occurs:

    “Warning: Declaration of my_Walker_CategoryDropdown::start_el(&$output, $category, $depth, $args) should be compatible with Walker_CategoryDropdown::start_el(&$output, $category, $depth = 0, $args = Array, $id = 0) in D:\appdata\IIS\vhosts\vdwerff.nl\httpdocs\wp-content\themes\werff\inc\nav-walker.php on line 229”

    I’m guessing it has something to do with a plugin, but since I haven’t build the website and i’m fairly new to wordpress, i’m not sure what to do.

    I’ve tried to hide it with: define( ‘WP_DEBUG’, false );
    to hide the error, but this doesn’t work either.

    Thanks in advance

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Hi @vdwerff,

    Array is a type. You’re looking for array() (or []), since you’re assigning a default value. I.e. $args = Array should be $args = array().

    See the reference: https://stackoverflow.com/questions/42013978/declaration-should-be-compatible-with-php-7

    Please let me know if this fixed your issue.

    Thanks.

    Thread Starter vdwerff

    (@vdwerff)

    Hi Adnan,

    Thank you for your quick response. I’ve checked the nav-walker.php file.
    It looks like there are no lines with $args = Array anymore.
    All I see is $args = array().

    I’m I looking at the wrong direction or is there a different cause for the error?

    Thanks in advance.

    Hi @vdwerff

    But I can clearly see the $args = Array in warning message in your topic, so that’s why I have shared this solution.

    Can you please share code with me for further tracking the issue?

    Thanks.

    Thread Starter vdwerff

    (@vdwerff)

    Hi Adnan,

    If i’m correct this is the piece of code which this occurs.

    }
    $mobilereparatie_walker= new mobilereparatie_walker();

    class my_Walker_CategoryDropdown extends Walker_CategoryDropdown {

    function start_el(&$output, $category, $depth, $args) {
    $pad = str_repeat(‘ ‘, $depth * 3);

    $cat_name = apply_filters(‘list_cats’, $category->name, $category);
    $output .= “\t<option class=\” ggg level-$depth\” value=\””.$category->slug.”\””;
    if ( $category->term_id == $args[‘selected’] )
    $output .= ‘ selected=”selected”‘;
    $output .= ‘>’;
    $output .= $pad.$cat_name;
    if ( $args[‘show_count’] )
    $output .= ‘  (‘. $category->count .’)’;
    if ( $args[‘show_last_update’] ) {
    $format = ‘Y-m-d’;
    $output .= ‘  ‘ . gmdate($format, $category->last_update_timestamp);
    }
    $output .= “</option>\n”;
    }
    }
    $mobilereparatie_walker_cat_d = new my_Walker_CategoryDropdown ;
    ?>

    Please try

    function start_el(&$output, $category, $depth, $args)

    to

    function start_el(&$output, $category, $depth, $args, $id)

    and let me know if it will fix your issue.

    Thanks

    Thread Starter vdwerff

    (@vdwerff)

    Thank you so much Adnan!

    This works perfectly. Thank you for your time and have a wonderful day.

    You are welcome.

    Thread Starter vdwerff

    (@vdwerff)

    Sorry! I concluded to early, it seems the error is still happening.

    edit;
    this is the code now:

    }
    $mobilereparatie_walker= new mobilereparatie_walker();

    class my_Walker_CategoryDropdown extends Walker_CategoryDropdown {

    function start_el(&$output, $category, $depth, $args, $id) {
    $pad = str_repeat(‘ ‘, $depth * 3);

    $cat_name = apply_filters(‘list_cats’, $category->name, $category);
    $output .= “\t<option class=\” ggg level-$depth\” value=\””.$category->slug.”\””;
    if ( $category->term_id == $args[‘selected’] )
    $output .= ‘ selected=”selected”‘;
    $output .= ‘>’;
    $output .= $pad.$cat_name;
    if ( $args[‘show_count’] )
    $output .= ‘  (‘. $category->count .’)’;
    if ( $args[‘show_last_update’] ) {
    $format = ‘Y-m-d’;
    $output .= ‘  ‘ . gmdate($format, $category->last_update_timestamp);
    }
    $output .= “</option>\n”;
    }
    }
    $mobilereparatie_walker_cat_d = new my_Walker_CategoryDropdown ;
    ?>

    • This reply was modified 5 years, 1 month ago by vdwerff.
    • This reply was modified 5 years, 1 month ago by vdwerff.

    Please try again

    function start_el(&$output, $category, $depth, $args)

    to

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

    and let me know if it will fix your issue.

    Thanks

    Thread Starter vdwerff

    (@vdwerff)

    Adnan, this works! And now for real ??
    Thank you very much

    Great don’t forget to resolve this topic.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Problems when upgrading PHP from 5.6 to 7(.3)’ is closed to new replies.