Skip to content

Instantly share code, notes, and snippets.

@thierrypigot
Last active November 8, 2024 11:28
Show Gist options
  • Save thierrypigot/5ce9c3ebb8d10de88d3b to your computer and use it in GitHub Desktop.
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.
<?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);
}
@AlTI5
Copy link

AlTI5 commented Jul 9, 2015

Merci! Pratique pour ajouter des images dans les titres des labels ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment