WordPress.org

Make WordPress Core

Opened 2 months ago

Last modified 3 days ago

#52224 accepted enhancement

RSS Widget: allow removing the feed icon link

Reported by: sabernhardt Owned by: sabernhardt
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Widgets Keywords: has-patch
Focuses: accessibility Cc:

Description

Removing the icon link can help fix at least these two bugs:

  1. #47670: Icon links for multiple widgets have identical link text.
  2. Hiding the icon without hiding/disabling the link creates an invisible link in themes such as Twenty Twenty-One.

On #47670, one possible solution was to remove the first link for everyone, but that would break probably all themes that float or hide the icon link with either .rsswidget:first-of-type or .rsswidget:first-child.

With a new filter, setting it to return false (or null) could solve both issues without breaking:
add_filter( 'rss_widget_feed_link', '__return_false' );
(Although, if a theme adds the filter and updates the styles accordingly, a child theme that replaces the parent stylesheet would likewise need updating to avoid any breakage.)

Another, separate possibility I've considered is including a new widget checkbox option so individual site owners can remove that link and/or include a link to the feed at the bottom of the widget instead. Then they can quickly add the link back if the layout breaks in their theme. If adding an option for the link within the heading, I'd like that to be unchecked by default, at least for any newly-added widgets. Ideally the heading would not contain both links.

Attachments (1)

52224.filter.diff (1.6 KB) - added by sabernhardt 2 months ago.
adding: filter, unique classes, internationalization, lazy loading

Download all attachments as: .zip

Change History (3)

@sabernhardt
2 months ago

adding: filter, unique classes, internationalization, lazy loading

#1 @sabernhardt
2 months ago

  • Owner set to sabernhardt
  • Status changed from new to accepted

In addition to creating a filter for the icon link HTML, 52224.filter.diff:

  • Adds a unique class name to each of the links to help theme authors update styles with the :not() selector if necessary (example below is for Twenty Twenty)
    .widget_rss .widget-title a.rsswidget:first-of-type:not(.rss-widget-title) {
    	display: none;
    }
    
  • Adds internationalization function to translate "RSS" in alt text
  • Adds loading="lazy", as recommended on #50041
  • Moves the link-related variables inside the if($title) conditional

I expect this needs some polishing.

If desired, revisions to this filter could:

  1. Facilitate editing the heading text link as well (either adding an image inside or removing that link so the heading is only text).
  2. Encourage removing the icon link (within the docblock).
  3. Adjust the filter so we could consider a switch to opt-out later, if themes would not break by then.
Last edited 3 days ago by sabernhardt (previous) (diff)

#2 @sabernhardt
2 months ago

  • Keywords has-patch added
Note: See TracTickets for help on using tickets.