6

I'm building my theme options page and I want to use Wordpress TinyMCE editor here, so I'm calling wp_editor. But when I'm saving data some entities are added to the content for example, lets say I want to add image:

<img class="" title="" src="path_to_image" alt="" />

Thats what I've got after clicking save:

<img title="\&quot;\&quot;" src="\&quot;path_to_image\&quot;" alt="\&quot;\&quot;" />

Why is this changing quotes into entities (and leaves actual - correctly displayed quotes?)??

@edit: This is how I display my editor:

    $class = (isset($value['class'])) ? $value['class']:'';
    $content = (get_option($value['id']) ? get_option($value['id']) : '');

    $settings = array(
        'textarea_name' => $value['id'], 
        'editor_class' => $class
        );
    wp_editor($content, strtolower($value['id']), $settings );

And that's how I save data for this field:

update_option($value['id'],
$_POST[ $value['id'] ]);
0
13

WordPress is running addslashes on POST input. The value you get from the data base looks probably like:

<img title=\"\" …

… and the editor tries to enforce valid markup from that.

So … call the editor with …

wp_editor( stripslashes( $content ), strtolower($value['id']), $settings );
4

I too had same problem. Then I used :

<? wp_editor(html_entity_decode(stripcslashes(get_option('wid1_cont'))), "editor1",$settings = array('textarea_name'=>'wid1_cont','textarea_rows'=>'5') ); ?>

It worked..

2
  • Please explain your solution. Why is it better than the other approaches? – fuxia Dec 14 '12 at 20:54
  • @Pavan I know they say not to comment Thank you but - THANK YOU! – jerrygarciuh Nov 3 '16 at 22:52
1

sometimes, the problem not is in save: is just on view stage.

Try:

 wp_editor( html_entity_decode($content), strtolower($value['id']), $settings );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.