diff --git a/wp-includes/class-walker-category.php b/wp-includes/class-walker-category.php
index 7b13264b95..c881e68045 100644
--- a/wp-includes/class-walker-category.php
+++ b/wp-includes/class-walker-category.php
@@ -108,7 +108,9 @@ class Walker_Category extends Walker {
return;
}
- $link = 'description ) ) {
/**
* Filters the category description for display.
@@ -118,11 +120,40 @@ class Walker_Category extends Walker {
* @param string $description Category description.
* @param object $category Category object.
*/
- $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"';
+ $atts['title'] = strip_tags( apply_filters( 'category_description', $category->description, $category ) );
}
- $link .= '>';
- $link .= $cat_name . '';
+ /**
+ * Filters the HTML attributes applied to a category list item's anchor element.
+ *
+ * @since 5.2.0
+ *
+ * @param array $atts {
+ * The HTML attributes applied to the list item's `` element, empty strings are ignored.
+ *
+ * @type string $href The href attribute.
+ * @type string $title The title attribute.
+ * }
+ * @param WP_Term $category Term data object.
+ * @param int $depth Depth of category, used for padding.
+ * @param array $args An array of arguments.
+ * @param int $id ID of the current category.
+ */
+ $atts = apply_filters( 'category_list_link_attributes', $atts, $category, $depth, $args, $id );
+
+ $attributes = '';
+ foreach ( $atts as $attr => $value ) {
+ if ( ! empty( $value ) ) {
+ $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
+ $attributes .= ' ' . $attr . '="' . $value . '"';
+ }
+ }
+
+ $link = sprintf(
+ '%s',
+ $attributes,
+ $cat_name
+ );
if ( ! empty( $args['feed_image'] ) || ! empty( $args['feed'] ) ) {
$link .= ' ';
@@ -134,6 +165,7 @@ class Walker_Category extends Walker {
$link .= '