Pages, Post Types: Escape CSS classes in Walker_Page::start_el() after the page_css_class filter runs.

Don't add an empty `class` attribute if there are no classes, for consistency with `Walker_Nav_Menu::start_el()`.

Props abhijitrakas, mukesh27.
Fixes #44880.
Built from https://develop.svn.wordpress.org/trunk@44415


git-svn-id: http://core.svn.wordpress.org/trunk@44245 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2019-01-07 12:55:38 +00:00
parent d3e0f97705
commit 49452cd73d
2 changed files with 3 additions and 2 deletions

View File

@ -148,6 +148,7 @@ class Walker_Page extends Walker {
* @param int $current_page ID of the current page. * @param int $current_page ID of the current page.
*/ */
$css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) ); $css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );
$css_classes = $css_classes ? ' class="' . esc_attr( $css_classes ) . '"' : '';
if ( '' === $page->post_title ) { if ( '' === $page->post_title ) {
/* translators: %d: ID of a post */ /* translators: %d: ID of a post */
@ -186,7 +187,7 @@ class Walker_Page extends Walker {
} }
$output .= $indent . sprintf( $output .= $indent . sprintf(
'<li class="%s"><a%s>%s%s%s</a>', '<li%s><a%s>%s%s%s</a>',
$css_classes, $css_classes,
$attributes, $attributes,
$args['link_before'], $args['link_before'],

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.1-alpha-44414'; $wp_version = '5.1-alpha-44415';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.