Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for menu helper build_menu method when ->classes is not an array #110

Merged
merged 1 commit into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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