Hy, I created a WordPress Theme using a lot of custom options. While saving the options in the backend amongst other things I'm adding backslashes before characters that need to be escaped. Such as ' and ".
Now I need to remove them before displaying them on the frontend. The easiest way would be stripslashes(get_option($key)). But that would mean I'd have to go though the whole Theme and change all get_option() manually.
Is there a way to add a filter to the get_option()?
If not, is there a way to achieve this with find/replace (I'm using Sublime Text 3 which allows regex)?
Why not just create your own function in place of
get_option()(but which takes advantage of it)? For example, you could define the following in functions.php:And then use Sublime to replace all instances of
get_optionwithmy_stripslashes_function...no regex required, and it's more DRY.