Widgets: Add filter to disable RSS widget icon.

Add a filter that disables output of the icon on RSS feed widgets. Improves accessibility by providing a path to prevent duplicate or invisible links.

Props sabernhardt, Boniu91.
Fixes #52224.
Built from https://develop.svn.wordpress.org/trunk@52031


git-svn-id: http://core.svn.wordpress.org/trunk@51623 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
joedolson 2021-11-07 23:04:56 +00:00
parent 201f4ddfbe
commit fffde30995
6 changed files with 32 additions and 7 deletions

View File

@ -229,6 +229,10 @@ input[type="checkbox"] {
margin: 0;
}
.widget_rss .widget-title .rsswidget:first-child:not(.rss-widget-title) {
float: left;
}
.search-form .search-submit {
left: 3px;
right: auto;

View File

@ -2662,7 +2662,7 @@ h2.widget-title {
/* RSS Widget */
.widget_rss .widget-title .rsswidget:first-child {
.widget_rss .widget-title .rsswidget:first-child:not(.rss-widget-title) {
float: right;
}

View File

@ -4286,7 +4286,7 @@ div.comment:first-of-type {
/* Widget: RSS ------------------------------- */
.widget_rss .widget-title a.rsswidget:first-of-type {
.widget_rss .widget-title a.rsswidget:first-of-type:not(.rss-widget-title) {
display: none;
}

View File

@ -4320,7 +4320,7 @@ div.comment:first-of-type {
/* Widget: RSS ------------------------------- */
.widget_rss .widget-title a.rsswidget:first-of-type {
.widget_rss .widget-title a.rsswidget:first-of-type:not(.rss-widget-title) {
display: none;
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.9-alpha-52030';
$wp_version = '5.9-alpha-52031';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -86,10 +86,31 @@ class WP_Widget_RSS extends WP_Widget {
/** 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'];