WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've tried to import an option value via update_options($name, $value) where $value has special characters (like apostrophe's for example) and I've noticed that the apostrophe gets stripped out of the text before it reaches the database.

What is the suggested sanitization of strings prior to sending them to update_options()?

share|improve this question
It should work with apostrophes just fine. This seems like a configuration issue or bug introduced by something, rather than native behavior. Note that inline documentation states that update_option() explicitly expects input to not be SQL-escaped. – Rarst Jul 13 '11 at 18:49
could you please include specific example? It's waste of time to guess. :) – Rarst Jul 13 '11 at 20:50
up vote 2 down vote accepted

Try esc_html( $string ) (Codex ref), which among other things encodes single- and double-quotes.

For further reference, see the Data Validation entry in the Codex.

share|improve this answer

Your Answer


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.