wp/wp-includes/widgets/class-wp-widget-rss.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
--- a/wp/wp-includes/widgets/class-wp-widget-rss.php	Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-includes/widgets/class-wp-widget-rss.php	Tue Sep 27 16:37:53 2022 +0200
@@ -86,10 +86,31 @@
 		/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
 		$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
 
-		$url  = strip_tags( $url );
-		$icon = includes_url( 'images/rss.png' );
 		if ( $title ) {
-			$title = '<a class="rsswidget" href="' . esc_url( $url ) . '"><img class="rss-widget-icon" style="border:0" width="14" height="14" src="' . esc_url( $icon ) . '" alt="RSS" /></a> <a class="rsswidget" href="' . esc_url( $link ) . '">' . esc_html( $title ) . '</a>';
+			$feed_link = '';
+			$feed_url  = strip_tags( $url );
+			$feed_icon = includes_url( 'images/rss.png' );
+			$feed_link = sprintf(
+				'<a class="rsswidget rss-widget-feed" href="%1$s"><img class="rss-widget-icon" style="border:0" width="14" height="14" src="%2$s" alt="%3$s"%4$s /></a> ',
+				esc_url( $feed_url ),
+				esc_url( $feed_icon ),
+				esc_attr__( 'RSS' ),
+				( wp_lazy_loading_enabled( 'img', 'rss_widget_feed_icon' ) ? ' loading="lazy"' : '' )
+			);
+
+			/**
+			 * Filters the classic RSS widget's feed icon link.
+			 *
+			 * Themes can remove the icon link by using `add_filter( 'rss_widget_feed_link', '__return_false' );`.
+			 *
+			 * @since 5.9.0
+			 *
+			 * @param string $feed_link HTML for link to RSS feed.
+			 * @param array  $instance  Array of settings for the current widget.
+			 */
+			$feed_link = apply_filters( 'rss_widget_feed_link', $feed_link, $instance );
+
+			$title = $feed_link . '<a class="rsswidget rss-widget-title" href="' . esc_url( $link ) . '">' . esc_html( $title ) . '</a>';
 		}
 
 		echo $args['before_widget'];
@@ -106,7 +127,7 @@
 			// The title may be filtered: Strip out HTML and make sure the aria-label is never empty.
 			$title      = trim( strip_tags( $title ) );
 			$aria_label = $title ? $title : __( 'RSS Feed' );
-			echo '<nav role="navigation" aria-label="' . esc_attr( $aria_label ) . '">';
+			echo '<nav aria-label="' . esc_attr( $aria_label ) . '">';
 		}
 
 		wp_widget_rss_output( $rss, $instance );