1
votes

Hi folks i’m hoping someone can assist me. I’m learning WordPress Theme Development and i’m just at the point of adding options in the customiser. I’m not sure how to correctly deal with html in a text area. I want to make sure that the texture is sanitised and safe, but also allow it to output HTML. This is the function and code that i’m using.

$wp_customize->add_setting( 'fs_theme_footer', array(
'default' => '',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'transport' => '',
'sanitize_callback' => 'esc_textarea',
) );
$wp_customize->add_control( 'fs_theme_footer', array(
'type' => 'textarea',
'section' => 'fs_theme_footer',
'label' => __( 'Textarea Field', 'fluidstudio' ),
'description' => '',
) );

In my theme

<?php echo esc_url( get_theme_mod( 'fs_theme_footer', '' ) ); ?>

I have tried different variations of escaping etc but i can’t seem to get the output to correctly display as html, instead the full html code shows on the front end.

Any help would be greatly appreciated.

Thanks

1

1 Answers

0
votes

You can use 'wp_filter_nohtml_kses' function of WP, to sanitize the text field. Give it a try and let me know whether it helps...