Skip to content

Commit

Permalink
Fixed case in menu helper build_menu method when ->classes is not an …
Browse files Browse the repository at this point in the history
…array (e.g. certain cases in Customizer)
  • Loading branch information
Daniel Koskinen committed Mar 19, 2019
1 parent 3f6cb0b commit eee335c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed
- Fixed case in menu helper build_menu method when $item->classes is not an array (e.g. certain cases in Customizer)

## [1.21.3] - 2019-03-04

### Fixed
Expand Down
5 changes: 5 additions & 0 deletions helpers/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ private static function build_menu( $menu_items, $parent = 0, $type = 'page', $o
if ( $item->menu_item_parent == $parent ) {
$item->sub_menu = self::build_menu( $menu_items, $item->ID, $item->object, $override );

// Make sure $item->classes is an array. Needed to work with the Customizer.
if ( ! is_array( $item->classes ) ) {
$item->classes = [];
}

if ( is_array( $item->sub_menu ) && count( $item->sub_menu ) > 0 ) {
$item->classes[] = 'menu-item-has-children';
}
Expand Down

0 comments on commit eee335c

Please sign in to comment.