Make WordPress Core

Opened 6 weeks ago

Last modified 5 weeks ago

#65027 new enhancement

Add ID do Section titles generated by Settings API

Reported by: wetah's profile wetah Owned by:
Milestone: 7.1 Priority: normal
Severity: minor Version:
Component: Administration Keywords: has-patch
Focuses: ui, accessibility, administration Cc:

Description

I see that there's a lot of debate around improvements to the Forms generated by do_settings_sections.

I know more radical changes won't move up easily so I would like to suggest a simple one: having the section ID in the section title. For instance this:

<?php
     if ( $section['title'] ) {
        echo "<h2>{$section['title']}</h2>\n";
     }

To become something like this:

<?php
     if ( $section['title'] ) {
        echo '<h2 id="' . $section['id'] . '">' . $section['title'] . '</h2>\n';
     }

For consistency, I would add the IDs also to the Core forms that have sections not generated by do_settings_sections, such as options-media.php, options-reading.php, etc. They already do something different which is to add a 'title' class to all their section titles. This makes me think that maybe we should have a filter to change that title markup in the end... but that can be for another topic.

The main motivation for doing that is to allow hash navigation via URL. We could easily in the documentation have links such as wp-admin/options-discussion.php#avatars, which I think it is a huge benefit if we're talking long forms. I know it wouldn't solve more complex issues but can be beneficial even for Accessibility and for those who want to customize their forms via CSS, as discussed in the other linked tickets.

Change History (3)

This ticket was mentioned in PR #11472 on WordPress/wordpress-develop by @rakeshfalke.


5 weeks ago
#1

  • Keywords has-patch added

Trac ticket:

## Use of AI Tools

---
Ticket Details: https://core.trac.wordpress.org/ticket/65027

This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


5 weeks ago

#3 @joedolson
5 weeks ago

  • Milestone changed from Awaiting Review to 7.1
  • Severity changed from trivial to minor
Note: See TracTickets for help on using tickets.