This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Options Framework stripping characters

  • Creator
    Topic
  • #11158
    askwpgirl
    Participant

    Hi Jason,

    This may not be within your scope of support, but I have created a textarea options field for various footer scripts. The options framework is stripping characters from this textarea, so the scripts are broken.

    The scripts work fine when placed in a plain text widget just not in the text area of the theme options. Is there any field validation being done on the options framework fields that would remove certain HTML or any special filter I should use when retrieving the values to keep that textarea content from being stripped? This is script provided to me by a client, and I assume what goes in, should come out exactly in the source code.

    Thanks!

    Angela

Viewing 8 replies - 1 through 8 (of 8 total)
  • Author
    Replies
  • #11168
    Jason Bobich
    Keymaster

    Hi Angela,

    You could try removing sanitization like this, maybe?

    function my_sanitize_textarea ( $input ) {
    	// do nothing, but needed to save ...
    	return $input;
    }
    remove_filter( 'themeblvd_sanitize_textarea', 'themeblvd_sanitize_textarea' );
    add_filter( 'themeblvd_sanitize_textarea', 'my_sanitize_textarea' );
    #11174
    askwpgirl
    Participant

    Cool.

    #12114
    Bluenotes
    Participant

    Hi Jason… Continuing with this convo. I’ve run into it too and did try the above sanitization filter but didn’t work for me. I’m using a textarea as a way for custom css to be added and it’s replacing something such as “>” with it’s html code version.

    So for example:

    #primary > .menu { color: red }

    Becomes

    #primary > .menu { color: red }

    Any input would be awesome! changing the field to text works but not textarea.

    Thanks!

    #12118
    Jason Bobich
    Keymaster

    @Bluenotes

    This is a little more tricky because this is actually from how the textarea being outtputed and having WordPress’s esc_textarea() function sanitizing the output from the database into the textarea field.

    This might do the trick for you —

    function my_esc_textarea( $text ) {
    	$text = str_replace( '>', '>', $text );
    	$text = str_replace( '>', '>', $text );
    	return $text;
    }
    add_filter( 'esc_textarea', 'my_esc_textarea' );
    #12121
    Bluenotes
    Participant

    Thank you sir. Works great!

    #12123
    Bluenotes
    Participant

    @themeblvd
    Ok I lied…. It works on the admin side but not the output on the frontend. I just tried it in an arcadian install on my local and it’s doing the same thing even with your above esc_textarea function.

    Do you happen to have another idea? 🙂

    #12132
    Jason Bobich
    Keymaster

    How are you actually outputting on the frontend?

    You may try outputting like this with the same sanitization:

    echo esc_textarea( themeblvd_get_option( 'whatever' ) );
    #12139
    Bluenotes
    Participant

    Thanks Jason, this looks to be working in combination with the above esc_textarea method. Below is how I was doing it.

    $custom_options = themeblvd_get_option( 'custom_styles' );

    Then just echoing it later on within my style function.

    echo $custom_options;

    Now using:

    function bne_theme_options_esc_textarea( $text ) {
    	$text = str_replace( '>', '>', $text );
    	$text = str_replace( '>', '>', $text );
    	$text = str_replace( '&lt;', '<', $text );
    	$text = str_replace( '&amp;lt;', '<', $text );
    	return $text;
    }
    add_filter( 'esc_textarea', 'bne_theme_options_esc_textarea' );

    AND adding the esc to the get option in the style function got it to work.

    $custom_options = esc_textarea( themeblvd_get_option( 'custom_styles' ) );

    Thanks again!

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.