Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Wordpress converts my theme options text with smart quotes.

I know that to remove problem from posts etc:

remove_filter('the_content', 'wptexturize');

remove_filter('the_excerpt', 'wptexturize');

remove_filter('comment_text', 'wptexturize');

But how to remove this effects when saving into Wordpress options api?

share|improve this question

2 Answers 2

Use a function to replace the smart quotes (following is based on code from this plugin), in functions.php:

function wpse89095_untexturize( $text ) {
    $char_codes   = array( '‘', '’', '“', '”', '′', '″' );
    $replacements = array( "'", "'", '"', '"', "'", '"' );
    return str_replace( $char_codes, $replacements, $text );
}

Then filter your option before it's saved to the database, in functions.php:

function wpse89095_untexturize_option( $newvalue, $oldvalue ){
    $newvalue = wpse89095_untexturize( $newvalue );
    return $newvalue;
}
add_filter( 'pre_update_option_{OPTION}', 'wpse89095_untexturize_option', 10, 2 );

NB: replace {OPTION} with the name of the option you'd like to filter.

share|improve this answer

WordPress does not automatically texturize options. If you are using add_option(), update_option(), and/or get_option() then it should "just work".

Example:

//Add an option to the database
update_option('my_test_option','This is an option. Isn\'t it "special"?');

//Returns string: This is an option. Isn't it "special"?
echo get_option('my_test_option');
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.