WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 6 weeks 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:

Description

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 6 weeks ago.
Change the hard coded widget ID of recent comments widget

Download all attachments as: .zip

Change History (5)

#1 @audrasjb
6 weeks 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 :-)

Cheers,
Jb

#2 @justinahinon
6 weeks ago

  • Keywords has-patch added; needs-patch removed

Change the hard coded widget ID

@justinahinon
6 weeks ago

Change the hard coded widget ID of recent comments widget

#3 @audrasjb
6 weeks 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
6 weeks 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.