Function: sanitize_option

sanitize_option( string $option, string $value )

Sanitises various option values based on the nature of the option.

Shortcut: so

You can use above key combination to trigger the associated snippet for this function in the WordPress Snippets for Visual Studio Code extension. You can also use this shortcut to search for this function on this website.

This is basically a switch statement which will pass $value through a number of functions depending on the $option.


Name Type(s) Default Value Description
$option string

The name of the option.

$value string

The unsanitised value.



Sanitized value.

WordPress Developer Newsletter

Stay informed of new chapter releases, important WordPress API updates and more.