Filter hook 'sanitize_option_{$option}'

in WP Core File wp-includes/formatting.php at line 5119

View Source

sanitize_option_{$option}

Filter Hook
Description
Filters an option value following sanitization.

Hook Information

File Location wp-includes/formatting.php View on GitHub
Hook Type Filter
Line Number 5119

Hook Parameters

Type Name Description
mixed $value The sanitized option value.
string $option The option name.
mixed $original_value The original value passed to the function.

Usage Examples

Basic Usage
<?php
// Hook into sanitize_option_{$option}
add_filter('sanitize_option_{$option}', 'my_custom_filter', 10, 3);

function my_custom_filter($value, $option, $original_value) {
    // Your custom filtering logic here
    return $value;
}

Source Code Context

wp-includes/formatting.php:5119 - How this hook is used in WordPress core
<?php
5114  	 *
5115  	 * @param mixed  $value          The sanitized option value.
5116  	 * @param string $option         The option name.
5117  	 * @param mixed  $original_value The original value passed to the function.
5118  	 */
5119  	return apply_filters( "sanitize_option_{$option}", $value, $option, $original_value );
5120  }
5121  
5122  /**
5123   * Maps a function to all non-iterable elements of an array or an object.
5124   *

PHP Documentation

<?php
/**
	 * Filters an option value following sanitization.
	 *
	 * @since 2.3.0
	 * @since 4.3.0 Added the `$original_value` parameter.
	 *
	 * @param mixed  $value          The sanitized option value.
	 * @param string $option         The option name.
	 * @param mixed  $original_value The original value passed to the function.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/formatting.php
Related Hooks

Related hooks will be displayed here in future updates.