Description
Filter the sanitize callback function. This allows for custom sanitization of different data types. Please note, if the callback is empty or does not exist, the data sanitize callback will default to sanitize_text_field()
Usage
apply_filters(
'wp_data_sync_sanitize_callback'
,
$sanitize_callback
,
$key
);
Parameters
$sanitize_callback | string | The callback function to apply to the value | $key | string | The array key of the data to be sanitized |
Code Example
Sanitize the value of a geo location coordinate as a float.
add_filter(
'wp_data_sync_sanitize_callback',
function
(
$sanitize_callback
,
$key
) {
if (
'_latitude'
===
$key
||
'_longitude'
===
$key
) {
$sanitize_callback
=
'float'
;
}
return
$sanitize_callback
;
), 10, 2 );