Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#29706 closed enhancement (invalid)

Settings API - term consitency

Reported by: Cleanshooter Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0
Component: Options, Meta APIs Keywords:
Focuses: Cc:


Hey I've been working with the settings API quite a bit lately and I'm wondering if you can shed some light on why things are labeled the way they are.

So why is it that in order to call up a "setting" I've registered with register_setting() I use a function called get_option() shouldn't this be get_setting()?

And why does my registered "setting" get get updated by using a function called update_option()? Should this too not be update_setting()?

Basically it would be nice if you could stick to one term either call them settings or options. Having 2 terms for the same thing is just confusing.

Also do_settings_sections() sounds like it should allow you to display the fields from a section but no that's do_settings_fields(). The functions name just kind of implies that the parameter will be a section not a settings group/page. do_settings_fields() is kind of goofy too because I always want to display fields when using either of these functions isn't that their implied task? Wouldn't it make more sense if it was just do_settings() or do_settings_page() to display all of them. Then do_settings_section() to be the one that displays just one?

I'm probably just being picky with the last part but It would be helpful to at least have the consistency mention in the first half of this rant.

Thanks for all your hard work on WordPress. It's a great system and it keeps getting better all the time.

Change History (1)

#1 @nacin
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

I'm not going to spend too much time defending the Settings API as it is fairly convoluted. But the points you mention are fairly easy to explain. The easiest way to look at it is the Options API is a low-level CRUD API for storing key/value pairs for a site, called options, while the Settings API is a higher-level API designed to handle user interactions for a subset of those options — not all options are UI settings. These interactions include the interface and also saving, including sanitization/validation.

You can use the Options API for anything you want to store, but a user can't actually modify it without a UI and without it being registered for this use with register_setting().

do_settings_sections() clearly is designed to "do"multiple sections, and it's best to consider the entire function prototype when figuring out what it does, not just the name. do_settings_sections( $page ) does the setting sections for a page, while do_settings_fields( $page, $section ) does the fields for a page's section.

Note: See TracTickets for help on using tickets.