Make WordPress Core

Opened 4 months ago

Last modified 2 months ago

#46747 assigned defect (bug)

Recent Comments widget can add duplicate ID to page

Reported by: mbrailer Owned by: audrasjb
Milestone: 5.3 Priority: normal
Severity: minor Version: 5.1
Component: Widgets Keywords: has-patch needs-dev-note
Focuses: Cc:


The Recent Comments widget includes the markup <ul id="recentcomments">

When more than one instance of the widget is used in a page, the ID appears multiple times, which is invalid according to W3.

Attachments (1)

46747.diff (737 bytes) - added by justinahinon 2 months ago.
Change the hard coded widget ID of recent comments widget

Download all attachments as: .zip

Change History (5)

#1 @audrasjb
3 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 5.3
  • Owner set to audrasjb
  • Status changed from new to accepted

Hi @mbrailer welcome to WordPress Core Trac and many thanks for opening that ticket!

I'm able to reproduce the issue. Moving it to 5.3 milestone :-)


#2 @justinahinon
2 months ago

  • Keywords has-patch added; needs-patch removed

Change the hard coded widget ID

2 months ago

Change the hard coded widget ID of recent comments widget

#3 @audrasjb
2 months ago

  • Keywords needs-dev-note added
  • Status changed from accepted to assigned

Thanks for the patch @justinahinon

The patch looks fine on my side. Adding a needs-dev-note tag to handle backward compatibility for theme authors.

#4 @birgire
2 months ago

ps: I was just wondering if the widget_id argument can be changed via some filter?

I didn't find a way, by quickly skimming through the widget code for WP_Widget_Recent_Comments and WP_Widget, but just wanted to be sure :-)

If we find a way then I think we should escape it with esc_attr().

Note: See TracTickets for help on using tickets.