WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. notkristina
    Member
    Posted 1 year 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?

    http://wordpress.org/extend/plugins/simple-image-widget/

  2. Brady Vercher
    Member
    Plugin Author

    Posted 1 year 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
    Member
    Posted 8 months ago #

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

    Thanks!

  4. Brady Vercher
    Member
    Plugin Author

    Posted 8 months 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

About this Topic

Tags