You sanitization callback function get passed all the values that correspond with the setting name. When a POST request is made to the options.php
file from the page on which your settings resides, WordPress calls your sanitization callback in a way that would resemble this:
<?php
boj_myplugin_validate_options( $_POST['boj_myplugin_options'] );
Notice that the name attribute looks mysteriously like indexing an associative array: boj_myplugin_options[text_string]
.
This sets up $_POST['boj_myplugin_options']
as an array. But, as you can see above, WordPress doesn’t pass the entire $_POST
array into your sanitization callback: it just passes the values related to your plugin. Doing it this way allows you to store multiple values in the same option. You don’t always do that, but it’s fairly common.
Related Posts:
- Settings API – sanitizing urls, email addresses and text
- Storing HTML in wp_options
- WordPress Settings API – Sanitize Integer
- Preserve old values on error in setting API
- Seeking clarity on data sanitization fields for settings textarea
- How to handle complex data with Settings API
- Settings api sanatize callback not being triggered
- How to sanitize settings API value
- Settings API vs Theme Customizer
- Run function AFTER theme options are saved?
- Add your own settings page for plugin
- Adding an html editor to plugin settings page
- add static page to reading settings for custom post type
- How to display an admin notice after updating plugin settings?
- Add settings fields on options discussion admin page
- Validate an option array
- Default WordPress settings API data sanitization
- Dynamic settings fields with Settings API
- Settings API repeater fields
- do_settings_sections() doesn’t escape quotes
- Import / Export Settings API fields values?
- Saving multiple checkboxes with WordPress settings api
- Letting user dynamically create fields using Settings API
- wordpress settings api add fields
- Adding labels to Setting titles with API
- register_setting sanitize callback $input is null
- Can I dynamically create duplicate fields with the Settings API?
- What exactly is the purpose of settings_fields()?
- Persist fields with Setting API
- wordpress settings API and option array structure
- Echo all API Settings sections?
- Settings Page won’t save
- How do I save custom options on the options page ‘Reading’?
- Settings API – generating field value based on a different field?
- Submit options page input values with decimals
- Using multiple settings_fields() on 1 settings page
- Settings API store serialized data in the database (The Right Way)
- Output ‘do_settings_sections()’ as tabs, not one under the other
- Saving plugin’s settings in 1 field in json format
- PHP Notice: Undefined offset: 0 in /wordpress/wp-includes/plugin.php and Register Settings API change
- Hide output of add_settings_field()
- How to make new plugin setting checkbox default as checked
- How to wrap html around Settings API add_settings_section()
- Settings API – sanitize_callback is not called and it leads to an incorrect behavior
- What is the best way to save and retrieve Multiple rows of data with the Settings API?
- Multiple fields with add_settings_field callback
- Settings API: Two update notices after saving settings?
- Settings API in Section
- Storage of array in settings
- Settings API and dynamically generated submenu pages
- Error: options page not found when I try to save the changes made in my settings page
- Display Each Setting Section In Each Specific Tab within Same Page || Settings API
- WordPress API Setting : the title of the section rendered not showing
- add_settings_section() order
- Splitting do_settings_sections within HTML?
- Why are these settings unregistered?
- Settings field is not showing up in the general options page
- How to use/retrieve an options array, with defaults, using get_option()
- How to prevent options.php deleting valid existing data from the database
- Displaying errors with settings api
- Displaying validation message in options-general.php
- How I can Make two input field at add_settings_section
- Settings Page – Option won’t save in database
- Customize format of settings
- Prevent invalid or empty values from being saved to the database and retain the form field values upon error
- Getting error to display radio button value in General Settings page
- How to create a WordPress options page
- When should I use register_setting() and add_settings_field()
- Why aren’t these WordPress options being saved to the database correctly?
- input on custom settings page adds http://
- Is it possible to get a list of options for a specific options group?
- update_option_$option action not working as expected
- Saving array of data to database using wordpress settings API
- settings api sub menu and data not populating
- how to get wp_editor to save data in plugin admin page
- Getting all the settings for a plugin
- Can someone tell me where I’ve gone wrong with this plugin’s Settings page?
- Use the Settings API to whitelist a setting, but don’t output it
- Can’t save settings to database using Setting API
- How to use checked() function with multiple check box group? How to properly sanitize that checkbox group?
- Verify Submitted Form Values and Show Warning Messages with Setting API
- WordPress settings API VS Table In Database?
- Writing Mysql and Php code in wordpress Posts
- Should I escape the html for the settings field created with add_settings_field?
- How to Save value from two inputs as array?
- How to save Checkbox-Options in Plugin Options Page
- Assign value to custom checkbox using get_option()
- Multiple plugins linked to same settings page
- Settings page – can’t change checkbox to unchecked
- Add Logo Upload per Setting API
- Add two input fields in add_settings_field
- Custom setting field value not working inside add_action init hook
- settings api callback functions won’t display?
- Restrict access to options-*.php pages
- How to move setting field up a row on general page?
- Option doesn’t save
- Save button in theme customization page stays disabled
- Settings API Multiple Checkbox in General Settings
- Can I use add_option for a plugin categories and how?
- Adding Form Fields with Settings API