1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Option sanitize in wordpress theme panel ?

Discussion in 'PHP' started by wsandy, Apr 26, 2013.

  1. #1
    hi friends i have problem in my WordPress theme option admin panel but in textarea i try to post any html or script it automatic remove when i save it only text remain !

    I found it in option-sanitize.php

    function of_sanitize_textarea($input) {
    global $allowedposttags;
    $output = wp_kses($input, $allowedposttags);
    return $output;
    }
     
    add_filter('of_sanitize_textarea', 'of_sanitize_textarea');
    PHP:

    After Searching lot i found

    /*
    * This is an example of how to override a default filter
    * for 'textarea' sanitization and $allowedposttags + embed and script.
    */
    add_action('admin_init','optionscheck_change_santi ziation', 100);
    function optionscheck_change_santiziation() {
    remove_filter( 'of_sanitize_textarea', 'of_sanitize_textarea' );
    add_filter( 'of_sanitize_textarea', 'custom_sanitize_textarea' );
    }
    function custom_sanitize_textarea($input) {
    global $allowedposttags;
    $custom_allowedtags["script"] = array( "src" => array() );
    $custom_allowedtags = array_merge($custom_allowedtags, $allowedposttags);
    $output = wp_kses( $input, $custom_allowedtags);
    return $output;
    }
    PHP:


    it allow only script and src but still i want allow any kind in textarea can any body help ? Actually i want modify this script and allowed all kinds of code like html and script in my theme option textarea so any can modify script ?
     
    wsandy, Apr 26, 2013 IP