Settings API vs Options API

A quick tip for our readers today. I’ve received a question asking me to explain the difference between the Settings API and Options API when developing WordPress plugins.

The Options API precedes the Settings API in WordPress history. The Settings API was only introduced in WP 2.7 in order to facilitate the building of options pages for themes and plugins, thus building on the existing Options API.

Basically the Options API is the simplest form of saving options to your database, but does not provide any methods for building the settings interface, and neither does it do any validation checks, leaving both these cumbersome tasks to the developer. That is not even mentioning the security hassles whereby which developers (especially new contributors) could easily create security holes if not following best practices. This of course would be bad for the community in general who downloaded that plugin.

Creating settings interfaces, security checks and data validation are very repetitive tasks for developers. The can also lead to custom implementations (especially in terms of UI) which conflict with the overall interface of WordPress. So the good folks at WordPress decided to create the Settings API to help us out.

Nowadays, with the Settings API all the security checks are handled automatically by WordPress itself. Creating the settings form is also taken care of automatically. Basically, all you have to do is to register your options with the Settings API and specify the input fields you wish to add to the options page, and you’re ready to go.

Hope that explains the concept to you. If you have any other questions or which to contribute to WPMayor do get in touch!

If you enjoyed this post, make sure to subscribe to WPMayor’s RSS feed.

About Jean Galea

Jean Galea is a WordPress developer, entrepreneur and padel player. He is the founder of WP Mayor, the plugins WP RSS Aggregator and EDD Bookings, as well as the Mastermind.fm podcast. His personal blog can be found at jeangalea.com.

Related Articles

4 Responses

  1. Mario Peshev
    Mario Peshev November 10, 2012 at 17:58 | | Reply

    It is worth mentioning the Transients API as well, for caching and storing data with a clear expiration path ( still be careful with sensitive data using the Transients as it could get lost easily ).

  2. Matthew Ruddy
    Matthew Ruddy November 11, 2012 at 10:35 | | Reply

    Settings API I feel is great for very clear-cut situations where nothing too fancy is required. However, I don’t find it intuitive when things start getting complicated, situations where using the Options API gives more flexibility.

  3. Ryan Hellyer
    Ryan Hellyer November 11, 2012 at 10:52 | | Reply

    The settings API only handles basic security for you. You still need to manually sanitise/validate data inputs.

  4. VOX Diseño Web
    VOX Diseño Web December 8, 2015 at 20:42 | | Reply

    As a wordpress theme developer trying to enter the plugins creation world… I find the settings api code really bloated. I know that in large projects it makes sense… but a big % of the wordpress plugins are not that big. In fact the nature of a plugin could very well be to solve some simple problem or to add a very specific feature. I think there should be a simpler alternative between going with the settings api and coding your settings page by your own.

Leave a Reply