Читать книгу Professional WordPress Plugin Development - Brad Williams - Страница 87
Benefits of the Settings API
ОглавлениеDealing with user inputs introduces new constraints in the option process: you need to design a user interface, monitor form submissions, handle security checks, and validate user inputs. To easily manage these common tasks, WordPress wraps the option functions into a comprehensive Settings API.
The Settings API enables you to handle these simple tasks:
Tell WordPress that you are going to use some new options and how you want them displayed.
Specify a function that will sanitize user inputs.
while WordPress transparently manages for you these cumbersome and repetitive parts:
Draw most of the option page itself.
Monitor form submission and handle $_POST data.
Create and update options if needed.
Wield all the required security measures and hidden fields for nonces, covered in detail in Chapter 4, “Security and Performance.”
Now it's time to dissect the Settings API; you'll learn to use it through a step‐by‐step example.