Instantly share code, notes, and snippets.

Embed
What would you like to do?
Nettoyer la valeur des WYSIWYG de champs ACF avant leur enregistrement dans la base de données
<?php
// Article/tutoriel complet sur https://mosaika.fr/astuces-developpement-acf/
// Documentation officielle https://www.advancedcustomfields.com/resources/acf-validate_value/
/**
* Nettoyer/sécuriser la valeur d'un champ WYSIWYG
* Filtre : acf/update_value
*/
function msk_acf_sanitize_wysiwyg_fields($value, $post_id, $field) {
if (is_array($value)) {
return array_map('wp_kses_post', $value);
}
return wp_kses_post($value);
}
add_filter('acf/update_value/type=wysiwyg', 'msk_acf_sanitize_wysiwyg_fields', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment