Simple Image Widget
[resolved] HTML in the text area (4 posts)

  1. notkristina
    Posted 3 years ago #

    I'd like to allow HTML in the text area, but the plugin seems to be filtering it out. Is there a quick way for me to remove the filter from the code?


  2. Brady Vercher
    Plugin Author

    Posted 3 years ago #

    The content of the textarea is passed through wp_kses_data(), which strips out any HTML that isn't whitelisted in the $allowedtags global variable for security purposes. I believe you can filter which tags are allowed using the wp_kses_allowed_html filter if you want to add more tags.

  3. justinmyoung
    Posted 2 years ago #

    Could you offer an example how to do that within the widget? Or is that something that needs to be edited elsewhere?


  4. Brady Vercher
    Plugin Author

    Posted 2 years ago #

    You wouldn't want to edit the widget code directly since changes will get wiped out when the plugin is updated in the future, but you can add a snippet to your child theme or create a custom plugin of your own. The snippet to whitelist various HTML elements and attributes would look something like this:

    function prefix_allowed_html( $allowedtags, $context ) {
    	$allowedtags['br']   = array();
    	$allowedtags['li']   = array();
    	$allowedtags['ol']   = array( 'start' => true, 'type' => true );
    	$allowedtags['span'] = array( 'align' => true );
    	$allowedtags['ul']   = array( 'type' => true );
    	return $allowedtags;
    add_filter( 'wp_kses_allowed_html', 'prefix_allowed_html', 10, 2);

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Simple Image Widget
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic