Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alexkalh/a14594ab80c6ed6c798e to your computer and use it in GitHub Desktop.
Save alexkalh/a14594ab80c6ed6c798e to your computer and use it in GitHub Desktop.
/*
* Remove warning : Invalid argument supplied for foreach() on functions.php on line 451
* @version 1.2
*
* Open file: wp-content/themes/enliven/inc/functions.php
*
* Select codes from 444 to 458
* Replace it by new codes below:
*
*/
if ( ! function_exists( 'enliven_add_first_and_last_class_for_menuitem' ) ) {
function enliven_add_first_and_last_class_for_menuitem( $items ) {
$parent = array();
if( !empty( $items ) ){
foreach ( $items as $k => $v ) {
$parent[ $v->menu_item_parent ][] = $v;
}
}
if( !empty( $parent ) ){
foreach ( $parent as $k => $v ) {
$v[0]->classes[] = 'enliven-menu-item-first';
$v[ count( $v ) -1 ]->classes[] = 'enliven-menu-item-last';
}
}
return $items;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment