Menus: In Walker_Nav_Menu, Walker_Category, and Walker_Page, properly output link attributes having a legitimate "empty" value, for example an HTML data attribute with a value of zero (0).

Props nevma, AkSDvP, greenshady, SergeyBiryukov.
Fixes #47720.
Built from https://develop.svn.wordpress.org/trunk@46413


git-svn-id: http://core.svn.wordpress.org/trunk@46211 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov
2019-10-06 15:06:03 +00:00
parent ea5d76fbb2
commit 8252125175
4 changed files with 4 additions and 4 deletions

View File

@@ -139,7 +139,7 @@ class Walker_Category extends Walker {
$attributes = '';
foreach ( $atts as $attr => $value ) {
if ( ! empty( $value ) ) {
if ( is_scalar( $value ) && '' !== $value && false !== $value ) {
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
$attributes .= ' ' . $attr . '="' . $value . '"';
}