Character \ appearing before ' after saving a settings page

It's a strange issue and I've seen it happen with plugins, however I don't know how to fix it. Maybe just a PHP issue?

Anyhow, I have a settings/options page with several text areas. Upon saving, a "\" appears before each apostrophe. Each time it's saved, an additional back-slash appears.

I'm not sure what code would be helpful to look at for this.

Topic esc-textarea text options Wordpress

Category Web


It's a PHP issue. The character ' is being escaped so that it can be safely in various places, not least of which is the database. That's why your ' look like \'.

You can use PHP's stripslashes() function to clean it up, or (if it's an array you need to clean up) WordPress's stripslashes_deep() function.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.