Learn how to validate your plugin settings. By ensuring that each setting is sanitized according to the expected type of data, you help to ensure a safe and secure plugin environment, and a more stable and consistent user experience.
- [Instructor] With our plugin settings in place…and working properly, we're ready to complete…the final callback function, which will be used…to validate, or sanitize our plugin settings.…Here in the settings callback file, we have…added this placeholder function, which…doesn't do anything at this point.…At the end of this video, this function…will contain all of the code necessary…to validate each of our plugin settings.…From the exercise files, we can grab the…complete validation code and use it…to replace the placeholder function.…Now we can explore the code and see how it works.…
First, we have the validation code for…the custom_url option.…Because this option is designed to contain…a url, we can use the esc_url function…to sanitize it.…Basically this code says, if the option is set,…then sanitize it as a url.…Next we have the custom-title option.…The custom-title option should contain a string…of text with no markup.…
So we can use sanitize_text_field to sanitize it.…Basically this code says, if the custom_title option…
- WordPress APIs
- Action and filter hooks
- Activating and deactivating plugins
- Plugin security
- Creating the directory and files
- Adding menus and the settings page
- Inserting custom functionality
- Testing and debugging WordPress plugins
- Creating widgets
- Managing users and roles
- Adding custom post types and taxonomies
- Working with custom fields and database queries
- Using APIs: Transients, HTTP, and REST
Skill Level Intermediate
WordPress: Developing Secure Siteswith Jeff Starr2h 38m Intermediate
1. First Steps
2. Plugin Basics
3. Building a WordPress Plugin
4. Essential Plugin Techniques
5. Extending Plugin Functionality
6. Advanced Plugin Techniques
Next steps1m 16s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.