Description
Sanitizes various option values based on the nature of the option.
This is basically a switch statement which will pass $value
through a number of functions depending on the $option
. After the value has been handled by these functions, it will be passed through a sanitize_option_$option filter.
Usage
<?php sanitize_option( $option, $value ); ?>
Parameters
- $option
- (string) (required) The name of the option.
- Default: None
- $value
- (string) (required) The unsanitized value.
- Default: None
Return Values
- (string)
- Sanitized Value.
Examples
Notes
Existing options handled by sanitize_option()
:
- admin_email
- new_admin_email
- thumbnail_size_w
- thumbnail_size_h
- medium_size_w
- medium_size_h
- large_size_w
- large_size_h
- mailserver_port
- comment_max_links
- page_on_front
- page_for_posts
- rss_excerpt_length
- default_category
- default_email_category
- default_link_category
- close_comments_days_old
- comments_per_page
- thread_comments_depth
- users_can_register
- start_of_week
- posts_per_page
- posts_per_rss
- default_ping_status
- default_comment_status
- blogdescription
- blogname
- blog_charset
- blog_public
- date_format
- time_format
- mailserver_url
- mailserver_login
- mailserver_pass
- upload_path
- ping_sites
- gmt_offset
- siteurl
- home
- WPLANG
- illegal_names
- limited_email_domains
- banned_email_domains
- timezone_string
- permalink_structure
- category_base
- tag_base
New options can be defined by adding an appropriate sanitize_option_$option filter (e.g. 'sanitize_option_avatar' for a filter for an 'avatar' option)
Filters
- 'sanitize_option_$option':
apply_filters( 'sanitize_option_$option', $value, $option )
Change Log
Source File
sanitize_option() is located in wp-includes/formatting.php
.
Related
Functions
sanitize_option()
is in a class of functions that help you sanitize potentially unsafe data which allow you to pass an arbitrary variable and receive the clean version based on data type. Others include:
sanitize_option()
is called by functions that add and update options:
Filters