WP_Editor – Saving Value into Plugin Option – Stripping HTML

The Problem

This turned out to be a common case of needing to use stripslashes();.

How did I figure this out?

I logged into phpMyAdmin, navigated to the options table, found my option name, and edited it.

Here’s what I discovered…

s:11:"description";s:90:"<span style=\"text-decoration: underline;\">This is supposed to be underlined text.</span>";

So obviously my plugin is working. It’s saving stuff properly. The text I entered into the wp_editor(); is there, and the appropriate HTML is wrapping my text as well.

Notice the slashes that have been added automatically. This is what was causing the problem when outputting the contents from the wp_editor(); which were saved in my plugin option.

Simple Solution

  1. Use stripslashes(); after retrieving your option data before you
    output it.
  2. This should be done on output and not on input.