wp_editor loses data, perhaps an html_entity_decode problem?

I have a custom meta box that I created with WP Alchemy. It has two wp_editor fields. These fields are behaving very strangely. If I just type simple text into them, they work just fine. But if I use text with formatting (bold, italics, lots of paragraph breaks, that sort of thing), it will initially save the text just fine. I save it, I see it there, I look at the site and I see it, and then I go to edit the post again, and the text is gone.

I have the same problem whether I use WP Alchemy to create the meta box or not.

Read More

Here is the code for the relevant field of the metabox:

<?php
    $content = html_entity_decode($metabox->get_the_value('reviews')); 
    $id = $metabox->get_the_name('reviews');
    $settings = array();

    wp_editor( $content, $id, $settings );
?>  

I think the problem is somehow related to html_entity_decode. If I leave that out, it seems to save the data just fine, but of course it then shows HTML, which I don’t want.

Is there some alternative to html_entity_decode? Is there something else I can do to prevent my data from being erased? I have created dozens of meta boxes with wp_editor, and I have never seen this behavior. (And I have deactivated all of the plugins on my site to make sure it isn’t a plugin conflict.)

Related posts