[wp-hackers] Enhancements to Settings API

Otto otto at ottodestruct.com
Fri Oct 21 15:10:27 UTC 2011

On Fri, Oct 21, 2011 at 9:42 AM, Ade Walker <photofantaisie at gmail.com> wrote:
> *Enhancements to Settings API*
> I am thinking of proposing some relatively minor changes to the Settings
> API, but thought I would bounce around some ideas here first before
> submitting a patch.
> One of the aspects I find limiting about the Settings API is the fixed
> nature of the XHTML markup generated by the do_settings_sections() function.
> By way of a reminder, this function iterates over a global variable (array)
> which holds the settings sections registered for that particular settings
> page, and then outputs the following markup and content for each registered
> section:

I get what you're saying, but the fixed nature of the markup is sorta
the whole point of the API in the first place. It's to provide a
consistent look and feel across all the settings pages. If you want to
do customized markup for a settings page, then using the Settings API
at all in pretty much unnecessary.

Also, something like markup for the tabs and such would likely be
better implemented outside the do_settings_sections call, in the
callback that you pass to the add_*_page. In there, you could do
something like output the Tab markup, then make a separate
do_settings_sections call for each tab, wrapping its output in the
appropriate markup for your jQuery tab interface.

Basically, instead of adding a $section parameter to
do_settings_sections(), just make more than one set of sections,
perhaps using a prefix for their names.


More information about the wp-hackers mailing list