From 1d161f743d63cdca3788d8b8df99d7f8e8ecb7c9 Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 20 Nov 2019 08:59:04 -0300 Subject: [PATCH] navigation: fix adding CSS custom class issue. It's a regression done by mistake. The original issue was taken over by @obenland (props!) --- .../block-library/src/navigation/index.php | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index c89483d310b6c..2c909b3c44eb5 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -49,21 +49,17 @@ function build_css_colors( $attributes ) { * @return string Returns the post content with the legacy widget added. */ function render_block_navigation( $attributes, $content, $block ) { - $colors = build_css_colors( $attributes ); - $class_attribute = sprintf( ' class="%s"', esc_attr( $colors['css_classes'] ? 'wp-block-navigation ' . $colors['css_classes'] : 'wp-block-navigation' ) ); - $style_attribute = $colors['inline_styles'] ? sprintf( ' style="%s"', esc_attr( $colors['inline_styles'] ) ) : ''; + $colors = build_css_colors( $attributes ); + $classes = array( 'wp-block-navigation', $colors['css_classes'] ); + if ( ! empty( $attributes['className'] ) ) { + $classes[] = $attributes['className']; + } + $classes = join( ' ', array_filter( $classes ) ); return sprintf( - implode( - "\n", - array( - '', - ' %s', - '', - ) - ), - $class_attribute, - $style_attribute, + '', + esc_attr( $classes ), + $colors['inline_styles'] ? sprintf( 'style="%s"', esc_attr( $colors['inline_styles'] ) ) : '', build_navigation_html( $block, $colors ) ); }