Opened 6 months ago
Closed 4 months ago
#62879 closed defect (bug) (fixed)
get_custom_logo does not apply the aria-current attribute in all cases
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | has-patch commit |
Focuses: | accessibility | Cc: |
Description
When reading settings have a posts page set but not a page set for the homepage - get_custom_logo does not apply the aria-current attribute to the logo link on the homepage.
Attachments (2)
Change History (22)
This ticket was mentioned in βPR #8206 on βWordPress/wordpress-develop by β@bschneidewind.
6 months ago
#1
- Keywords has-patch added
#2
@
5 months ago
- Milestone changed from Awaiting Review to 6.8
- Owner set to audrasjb
- Status changed from new to reviewing
Hello, thanks for the ticket and the patch!
Self assigning for review.
β@audrasjb commented on βPR #8206:
5 months ago
#3
#4
in reply to:
βΒ description
;
follow-up:
βΒ 9
@
5 months ago
Replying to bschneidewind:
When reading settings have a posts page set but not a page set for the homepage
Some questions:
- Is that actually considered a valid, supported configuration (to have a posts page set but not a page set for the homepage)? That doesn't really seem like it would be useful combination of settings to me. I see that the WordPress admin section does in fact allow you to configure things that way, which is a bit odd and might be a bug?
- Assuming that this is a configuration that should be supported by WordPress, doesn't that imply that
is_front_page()
andWP_Query::is_front_page()
are broken in that configuration? It appears that they will never returntrue
in that configuration, which doesn't really make sense (obviously the site still has a front page).
- The current proposed changes to support this configuration involve adding some rather complex conditional logic.
It is currently proposed that this logic be copied into multiple different places in the code?
- βhttps://github.com/WordPress/wordpress-develop/pull/8206 - this fixes
get_custom_logo()
- βhttps://github.com/WordPress/wordpress-develop/pull/8237 - this fixes the
twentytwenty
theme (#62895)
- βhttps://github.com/WordPress/wordpress-develop/pull/8206 - this fixes
- Copying this complex code into multiple places doesn't seem very βDRY. Is this going to need to get copied into other places too? What about all the other themes besides
twentytwenty
? Fixingis_front_page()
could perhaps eliminate the need for this.
#5
follow-up:
βΒ 7
@
5 months ago
@siliconforks - my thoughts on things:
1 - The UX already supports this in the admin area, I don't think it's the most logical approach overall but how could you force users to add a 'homepage' that may have already set it up this way? The render_block_core_home_link function already has support for this edge case as well.
2 - Agreed, it would be better if is_front_page always rang true when it's the root page but there are edge cases that need to be accounted for and there is some debate on whether is_front_page should remain true. Ex: if it's a paginated page... from an accessibility point it shouldn't, but the argument may differ in other aspects.
3 - This PR fixes get_custom_logo(). The TwentyTwenty update is to address the specific template function where the text version is missing the aria-current attribute. Yes, I am proposing this in multiple places to fix older themes and in core to address block based themes.
4 - I am proposing a similar approach be added in some of the older themes here where site logo support does not currently exist: #61766
Additional theme updates will be needed for bundled themes prior to TwentyTwentyTwo because of how things were built on each theme. Even if the is_front_page() was updated to account for the edge case, a theme update would be needed on those bundled themes that do not have support for aria-current on the site title links.
With TwentyTwentyTwo and up using block based approach, the aria-current attribute is applied correctly there on the text links for the site-title.
It does create some repeated code between TwentyTwentyOne and earlier bundled themes and the update to get_custom_logo, however I think it makes sense in these cases as the theme updates are only needed because of a different approach to building in TwentyTwentyOne and prior.
#6
@
5 months ago
Related, βhttps://github.com/WordPress/wordpress-develop/pull/8237 - has been updated to account for all bundled themes (#62895)
#7
in reply to:
βΒ 5
@
5 months ago
Replying to bschneidewind:
Ex: if it's a paginated page... from an accessibility point it shouldn't, but the argument may differ in other aspects.
Yes, the pagination is another edge case, but the behavior of is_front_page()
has always been to ignore pagination, so I'm not suggesting changing that here. I'm just proposing that is_front_page()
handle the case where WordPress is configured without a page set for the homepage (assuming it is decided that this is actually a supported configuration).
Additional theme updates will be needed for bundled themes prior to TwentyTwentyTwo because of how things were built on each theme. Even if the is_front_page() was updated to account for the edge case, a theme update would be needed on those bundled themes that do not have support for aria-current on the site title links.
My point is that if is_front_page()
is fixed, the theme update will be much simpler and require less duplicated code.
#8
@
5 months ago
@siliconforks - Good points - it's been discussed before it looks like #59252
I did throw a patch up to see if it gets anywhere and will adjust any other PR's if it makes progress.
#9
in reply to:
βΒ 4
;
follow-ups:
βΒ 10
βΒ 11
@
5 months ago
Is that actually considered a valid, supported configuration (to have a posts page set but not a page set for the homepage)? That doesn't really seem like it would be useful combination of settings to me.
The edge case might be fine to allow, but I do not think the special posts page should have aria-current
(or current-menu-item
classes) on home links.
When I assigned the page of posts without a static home page, the two URLs gave me duplicate content. With the Site Title block, I had the same link attributes at both URLs, too:
<p class="wp-block-site-title"><a href="http://localhost/wp671" target="_self" rel="home" aria-current="page">WP 6.7.1</a></p>
The home links' conditions for current-page ARIA and class names might need to check the URL (or $wp->request
) instead of is_front_page()
and/or is_home()
. The logo link already adds aria-current
incorrectly on the network signup and activation pages. Comments on #43536 note that wp-signup.php
and wp-activate.php
return true
for both is_front_page()
and is_home()
, and is_home()
potentially can return true
as a fallback in other edge cases.
History for aria-current
on home links:
- [48749]
get_custom_logo()
- GB35880 Site Title block
- GB51478 Home Link block
#10
in reply to:
βΒ 9
@
5 months ago
I do not think the special posts page should have
aria-current
(orcurrent-menu-item
classes) on home links.
My first sentence was not highly appropriate on this ticket. The conditions in PR 8206 would add aria-current
on the home page without adding the attribute on the extra page. However, the conditions might need changes for other cases.
#11
in reply to:
βΒ 9
@
5 months ago
Replying to sabernhardt:
Is that actually considered a valid, supported configuration (to have a posts page set but not a page set for the homepage)? That doesn't really seem like it would be useful combination of settings to me.
The edge case might be fine to allow, but I do not think the special posts page should have
aria-current
(orcurrent-menu-item
classes) on home links.
When I assigned the page of posts without a static home page, the two URLs gave me duplicate content. With the Site Title block, I had the same link attributes at both URLs, too:
<p class="wp-block-site-title"><a href="http://localhost/wp671" target="_self" rel="home" aria-current="page">WP 6.7.1</a></p>
Does this have anything to do with the edge case configuration, though? What happens if you do assign a static home page (in addition to a page of posts)? Won't you have the same issue on the posts page? (i.e., the link says aria-current="page"
when it shouldn't)
This looks like it's a separate issue, with the Site Title block.
#12
@
5 months ago
Sorry, I have managed to make this quite confusing. Parts of comment:9 relate better to the Site Title and Home Link blocks.
Regarding get_custom_logo()
:
- The front-page conditions used in [48749] already created false positives for home logo links (and the unlink option) on the two network pages.
- Introducing an
is_home()
condition theoretically can addaria-current
in βunknown edge cases, thoughparse_query()
corrects some situations in the lines following$this->is_home = true
(so it might not be a major concern).
What happens if you do assign a static home page (in addition to a page of posts)?
The static home page would match is_front_page()
, and aria-current
is appropriate there (before or after PR 8206).
This ticket was mentioned in βSlack in #accessibility by joedolson. βView the logs.
4 months ago
#14
@
4 months ago
Hello, my opinion here is that the proposed changeset is not so complex (a one-line change) and that it's worth adding this fix even for such a edge case.
#15
@
4 months ago
The PR effectively fixes the issue, but considering that this is an edge case, it might be worth evaluating the performance implications before merging.
#16
@
4 months ago
Test Report
Patch Tested: βhttps://github.com/WordPress/wordpress-develop/pull/8206
Environment:
WordPress - 6.8-alpha-20250202.040014
OS - Windows
Browser - Firefox
Theme: Twenty Twenty
PHP - 7.4.31
Active Plugin: None
Actual Results:
- Issue Resolved With Patch.β
Screenshots:
- Added Attachment
This ticket was mentioned in βSlack in #core by audrasjb. βView the logs.
4 months ago
β@audrasjb commented on βPR #8206:
4 months ago
#19
Thanks for pushing the test cases @peterwilsoncc !
When reading settings have a posts page set but not a page set for the homepage - get_custom_logo does not apply the aria-current attribute to the logo link on the homepage.
Trac ticket: https://core.trac.wordpress.org/ticket/62879