Opened 4 years ago
Last modified 3 years ago
#51086 accepted enhancement
Add native support for tabbed settings pages in WP Admin
Reported by: | stevegrunwell | Owned by: | joedolson |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | |
Component: | Administration | Keywords: | |
Focuses: | accessibility | Cc: |
Description
There are a lot of plugins out there handling tabbed setting screens in different ways, so it may be time to introduce a standard API for this pattern.
This patch adds a new do_tabbed_settings_sections()
function which works just like the Settings API's do_settings_sections()
function, but prints each section heading as a tab/panel combination. In situations where there's only one section to render, the new function will fall back to its un-tabbed sibling.
The patch also includes a standard script for tabbing between different setting sections, with support for linking directly to a particular tab via the URL hash (e.g. https://example.com/wp-admin/options-general.php?page=some-settings-page#some-tab-ID).
Attachments (7)
Change History (17)
@
4 years ago
A demo plugin that registers both a tabbed and non-tabbed settings page for testing/comparision
@
4 years ago
Remove reliance on JavaScript globals, use printf() for previously-concatenated string (props @szepeviktor)
#2
@
4 years ago
With some assistance from @szepeviktor, I've open-sourced a polyfill for plugin authors looking to start using do_tabbed_settings_sections()
: https://github.com/stevegrunwell/wp-admin-tabbed-settings-pages
@
4 years ago
Prevent <section> elements from being broken if no fields are registered for a setting (see https://github.com/stevegrunwell/wp-admin-tabbed-settings-pages/pull/11)
@
4 years ago
Refreshed diff, corresponding to v0.2.0 of the polyfill: https://github.com/stevegrunwell/wp-admin-tabbed-settings-pages/releases/tag/v0.2.0
Introduces do_tabbed_settings_sections()