Sanitize WordPress custom Post Type metabox not working or saving when using the funcitn wp_kses

if ( isset( $_POST[‘cloudlyup_maulti_location_gmap_fields’] )){
$old = get_post_meta( $post_id, ‘cloudlyup_maulti_location_gmap_fields’, true );

$new = sanitize_meta( ‘cloudlyup_maulti_location_gmap_fields’, $_POST[‘cloudlyup_maulti_location_gmap_fields’], ‘post’ );

function sanitize_cloudlyup_maulti_location_gmap_fields($gmapfs) {

$value = wp_kses( $_POST[‘cloudlyup_maulti_location_gmap_fields’], array() );

return $value;
}
add_filter( ‘sanitize_post_meta_cloudlyup_maulti_location_gmap_fields’, ‘sanitize_cloudlyup_maulti_location_gmap_fields’ );

if ( $new && $new !== $old ) {
update_post_meta( $post_id, ‘cloudlyup_maulti_location_gmap_fields’, $new );
} elseif ( ” === $new && $old ) {
delete_post_meta( $post_id, ‘cloudlyup_maulti_location_gmap_fields’, $old );
}
}

}

I have created a pot type clupmap and meta box and some fields the data is not saving if we remove the WP_Kses function it working ok

Read more here:: Sanitize WordPress custom Post Type metabox not working or saving when using the funcitn wp_kses

Leave a Reply

Your email address will not be published. Required fields are marked *