Support » Requests and Feedback » Magic quotes escape for plugins

  • Writing an option page for a plugin, I have to deal with the tedious magic quotes escaping.
    I think in WP there is already such a function (surely magic quotes are managed in the “public” part of WP, there is some row of code in wp-settings.php).

    This function can be used and will be stable in the future? What’s its name? I rhink in WP there are lots of functions useful for plugin writers: what about organize a section in the documentation for those features?


Viewing 1 replies (of 1 total)
  • Whilst developing my latest WordPress Plugin, To Do List, I had a problem when writing a text file from input into a textarea element. When magic quotes were turned on, the text file had all the special characters escaped!

    Looking around for information I found the following code fragment very useful that checks to see if magic quotes are turned on, on your server. And if so, the text is formatted to remove escape characters.

    if( get_magic_quotes_gpc() )
     // if magic quotes on, get rid of escape slashes inserted into text
     $todo_list = stripslashes($todo_list);

    This worked perfectly and meant only text was saved to file, and no escape characters. Obviously, you need a check to see if magic quotes are enabled as you do not want to try to remove escape characters when magic quotes are OFF!

Viewing 1 replies (of 1 total)
  • The topic ‘Magic quotes escape for plugins’ is closed to new replies.