A short overview of your code reveals some issues that seems to cause the problem:
Your function save($post_id)
saves all fields added to $fields
array.
This array if filled using function add($id, $label, $type="text", $default="")
But the problematic fields (checkbox, date and time) are not added to fields, so not saved by your function save($post_id)
.
Suggested Solution:
Either add these problematic fields using add()
function if possible.
Or within your function save()
capture each of the problematic fields submitted data and save to db by something like this
$meta="name_of_html_input"; //Replace name_of_html_input with actual name given in html
if( isset( $_POST[$meta] ) ){
$value = $_POST[$meta];
if(get_post_meta($post_id, $meta)){
update_post_meta($post_id, $meta, $value);
} else {
if ($value === '') {
delete_post_meta($post_id, $meta);
} else {
add_post_meta($post_id, $meta , $value );
}
}
}
I hope this may help!