Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

PHP warning if none menu has been assigned to a location #165

Closed
aldolat opened this Issue · 2 comments

2 participants

@aldolat

Hi @deshack
On a fresh WordPress installation a PHP warning appears next to the site name:

Warning: in_array() expects parameter 2 to be array, string given in /var/www/test/wp-content/themes/melany/inc/template-tags.php on line 179

This happens because none menu has been assigned to any theme location.

A fix could be:

function melany_active_item_class( $classes = array(), $menu_item = false ) {
    if ( is_array( $menu_item->classes ) ) {
        if ( in_array( 'current-menu-item', $menu_item->classes ) )
            $classes[] = 'active';
    }
    return $classes;
}
@deshack deshack was assigned
@deshack
Owner

Thanks @aldolat !

@deshack deshack closed this
@aldolat

You're welcome! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.