Skip to content
Docs
Get RestroPress

Filter

rpress_settings_sanitize_{$type}

Updated
On this page

Filters a setting value during sanitization, per field type.

Runs for each submitted setting while the settings form is saved, with the registered field type in the hook name, such as text or checkbox. It runs before the generic rpress_settings_sanitize filter. Return the cleaned value.

Parameters#

ParameterTypeDescription
$valuemixedThe submitted value for the setting.
$keystringThe setting key.

Return value#

mixed. The sanitized value.

Example#

function my_sanitize_text_setting( $value, $key ) {
	return is_string( $value ) ? trim( $value ) : $value;
}
add_filter( 'rpress_settings_sanitize_text', 'my_sanitize_text_setting', 10, 2 );

Notes#

The built-in sanitizer for text fields (rpress_sanitize_text_field) is attached to rpress_settings_sanitize_text.

Source#

Applied in:

  • includes/admin/settings/register-settings.php (line 1910), in rpress_settings_sanitize()

See also#

Was this page helpful?