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

Closed
aldolat opened this Issue Oct 20, 2013 · 2 comments

Projects

None yet

2 participants

@aldolat
aldolat commented Oct 20, 2013

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 Oct 21, 2013
@deshack deshack added a commit that referenced this issue Oct 21, 2013
@deshack Fix PHP warning when missing custom menu
Fix #165
df01d0b
@deshack
Owner
deshack commented Oct 21, 2013

Thanks @aldolat !

@deshack deshack closed this Oct 21, 2013
@aldolat
aldolat commented Oct 21, 2013

You're welcome! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment