Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions custom_metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -1063,14 +1063,24 @@ function _sanitize_field_value( $field_slug, $field, $object_type, $object_id, $

$sanitize_callback = $this->get_sanitize_callback( $field, $object_type );

if ( $sanitize_callback )
return call_user_func( $sanitize_callback, $field_slug, $field, $object_type, $object_id, $value );

// convert date to unix timestamp
if ( in_array( $field->field_type, array( 'datepicker', 'datetimepicker', 'timepicker' ) ) ) {
$value = strtotime( $value );

// if $value is an array, we need to sanitize every value in the array
if( is_array( $value ) ) {
$result = array();
foreach ( $value as $val ) {
$result[] = strtotime( $val );
}
$value = $result;
} else {
$value = strtotime( $value );
}
}

if ( $sanitize_callback )
return call_user_func( $sanitize_callback, $field_slug, $field, $object_type, $object_id, $value );

return $value;
}

Expand Down