Last active
November 8, 2024 11:28
-
-
Save thierrypigot/5ce9c3ebb8d10de88d3b to your computer and use it in GitHub Desktop.
Permet d'interpréter les caractères html dans le label des fields.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// [update : sécurité des sorties] | |
add_filter( 'gform_field_content', 'tp_subsection_field', 10, 5 ); | |
function tp_subsection_field( $content, $field, $value, $lead_id, $form_id ) | |
{ | |
// Limiter les balises HTML autorisées dans les labels (gras, images, etc.) | |
$allowed_html = array( | |
'strong' => array(), | |
'em' => array(), | |
'b' => array(), | |
'i' => array(), | |
'img' => array( | |
'src' => array(), | |
'alt' => array(), | |
'width' => array(), | |
'height' => array(), | |
'class' => array(), | |
), | |
'a' => array( | |
'href' => array(), | |
'title' => array(), | |
'target' => array(), | |
), | |
// Ajouter d'autres balises si besoin | |
); | |
// Appliquer wp_kses pour filtrer le contenu | |
return wp_kses($content, $allowed_html); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Merci! Pratique pour ajouter des images dans les titres des labels ;)