From a3c8b3ddea424c50c8277e4008782e732c20e836 Mon Sep 17 00:00:00 2001 From: noisysocks Date: Tue, 17 Nov 2020 04:31:08 +0000 Subject: [PATCH] Customize: Ensure multiple CSS classes are passed to nav_menu_link_attributes as an array When multiple CSS classes are added to a menu item, the nav_menu_link_attributes filter should be called with $item->classes set to an array of CSS class names. When previewing in the Customizer, however, a single string was being passed to $item->classes because WP_Customize_Nav_Menu_Item_Setting::preview() bypasses wp_update_nav_menu_item() and instead uses filter_wp_get_nav_menu_items(). The fix is to make filter_wp_get_nav_menu_items() match what wp_update_nav_menu_item() does and split the string into an array. Fixes #43113. Props dlh. Built from https://develop.svn.wordpress.org/trunk@49624 git-svn-id: http://core.svn.wordpress.org/trunk@49362 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../customize/class-wp-customize-nav-menu-item-setting.php | 5 +++++ wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php b/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php index 5da6515f5f..18cf83dfda 100644 --- a/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php +++ b/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php @@ -605,6 +605,11 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting { $item->post_title = $item->title; } + // 'classes' should be an array, as in wp_setup_nav_menu_item(). + if ( isset( $item->classes ) && is_scalar( $item->classes ) ) { + $item->classes = explode( ' ', $item->classes ); + } + $item->ID = $this->post_id; $item->db_id = $this->post_id; $post = new WP_Post( (object) $item ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 5faeceec9b..92307a5a2a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-beta4-49623'; +$wp_version = '5.6-beta4-49624'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.