[wp-trac] [WordPress Trac] #47094: Widgets: current-page links are not programmatically labelled as such
WordPress Trac
noreply at wordpress.org
Sun Sep 1 18:46:55 UTC 2019
#47094: Widgets: current-page links are not programmatically labelled as such
-------------------------------------------------+-------------------------
Reporter: audrasjb | Owner: audrasjb
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 5.3
Component: Widgets | Version:
Severity: normal | Resolution:
Keywords: has-screenshots has-patch needs- | Focuses:
dev-note wpcampus-report aria-current | accessibility
-------------------------------------------------+-------------------------
Changes (by afercia):
* keywords:
has-screenshots has-patch needs-dev-note commit wpcampus-report aria-
current
=> has-screenshots has-patch needs-dev-note wpcampus-report aria-
current
Comment:
Tested a bit the patch and noticed something to address for the Recent
Posts widget. To reproduce:
- add the Recent Posts and the Archives widget to your site
- make sure to have 2-3 published post in August 2019
- in any case, set the Recent Posts widget to display a number of posts
that includes all the ones from August
- go to the monthly Archive `yoursite.test/2019/08`
- at this point, "August 2019" in the Archive widget will have the `aria-
current="page"` attribute
- however, also the oldest post from August in the Recent Posts widget
will have the `aria-current="page"` attribute, which is incorrect because
this is an archive page
- seems related to the use of `get_the_ID()`
- in [attachment:"47094.diff"] I'm trying to avoid this checking also for
`is_single()`, not sure if there are better ways to avoid the attribute
gets printed out also in pages that aren't posts /Cc @audrasjb
@SergeyBiryukov
Some additional minor adjustments:
- Categories: in order to avoid to use an additional `foreach` I thought
to use the existing one and then manipulate the link string. Something
like: `$link = str_replace( '<a', '<a aria-current="page"', $link );`
- Archives: use only one ternary
- applied some coding standards
Some review and testing would be nice :)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47094#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list