WordPress.org

Ready to get started?Download WordPress

Forums

Allowing script tags in textarea with wp_kses function (2 posts)

  1. John Peden
    Member
    Posted 1 year ago #

    I'm building a plugin that features an options page. I'm trying to paste some javascript into a textarea but as the content runs through wp_kses before it reaches the database, the <script> and <noscript> tags are beign stripped.

    I'm able to pass the contents of the textarea straight to the DB but is there a way of modifying wp_kses to allow specific tags?

  2. Brandon Kraft
    Happiness Engineer
    Posted 1 year ago #

    Yeah, Otto has a nice write-up on it:
    http://ottopress.com/2010/wp-quickie-kses/

    You can do something like

    global $allowedtags;
    $allowedtags['img'] = array( 'src' => array () );
    $filtered = wp_kses_data($unfiltered);

    (obviously with script and noscript instead).

    Just be mindful that any <script> would be allowed through that, so could be a big security issue, etc etc.

Topic Closed

This topic has been closed to new replies.

About this Topic