Rechercher

Authoriser les SVG dans les champs ACF

Placeholder image
/**
 * ACF SVG filter to allow raw SVG code.
 * 
 * https://www.advancedcustomfields.com/resources/html-escaping/
 * 
 */
add_filter( 'wp_kses_allowed_html', 'acf_add_allowed_svg_tag', 10, 2 );

function acf_add_allowed_svg_tag( $tags, $context ) {
    if ( $context === 'acf' ) {
      $tags['svg']  = array(
          'xmlns'				=> true,
          'width'				=> true,
          'height'				=> true,
          'preserveAspectRatio'	=> true,
          'fill'					=> true,
          'viewbox'			=> true,
          'role'				=> true,
          'aria-hidden'			=> true,
          'focusable'			=> true,
      );
      $tags['path'] = array(
          'd'    => true,
          'fill' => true,
      );
    }
    return $tags;
}