[wp-trac] [WordPress Trac] #46747: Recent Comments widget can add duplicate ID to page
WordPress Trac
noreply at wordpress.org
Fri Sep 27 17:20:06 UTC 2019
#46747: Recent Comments widget can add duplicate ID to page
--------------------------------------------------+-----------------------
Reporter: mbrailer | Owner: audrasjb
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 5.3
Component: Widgets | Version: 5.1
Severity: normal | Resolution:
Keywords: needs-dev-note has-patch 2nd-opinion | Focuses:
--------------------------------------------------+-----------------------
Changes (by desrosj):
* keywords: needs-dev-note has-patch => needs-dev-note has-patch 2nd-
opinion
Comment:
I dug into this a bit, and here's what I found: Of the top 200 popular
themes + 15 featured themes + 10 default themes, there are a total of 18
occurrences of the `#recentcomments` selector.
These numbers, of course, cannot account for any Custom CSS that has been
written in the Customizer.
While that is not a large number, I think there may be a safer way to fix
this. It seems to me that having more than one active Recent Comments
widget on a site at once is probably an edge case. I could see different
sidebars for different areas of a site that both have Recent Comments
widgets, but I think that may not be that common.
What if this ID was only changed if more than one widget of this type was
active (not in the `wp_inactive_widgets` sidebar) at once?
This would prevent sites using just one Recent Comments widget from
breaking. Only sites with two Recent Comments widgets would have the
potential for problems.
Also, what was the reason for changing the `recentcomments` part? Themes
seem to use `recent-comments-` with a hyphen as mentioned above. Leaving
that part alone allows `-num` to be added.
In summary, what if the fix happened like this:
- One active recent comments widget: ID remains `#recentcomments`. No
breakage.
- More than one active recent comments widget: IDs become
`#recentcomments-#ID`. Potential for breakage.
- Dev note describes the proper way to target recent comments widgets is
the `.recentcomments` selector.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46747#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list