Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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'] ]);
share|improve this question
1  
That's not the normal behavior. Show us how you sanitize and save the data. –  toscho Apr 30 '12 at 17:54
    
@toscho Added some parts of my code into question. There is no validation or something like that. Simple form with some CSS and what You see above. –  smogg Apr 30 '12 at 18:10
1  
That's is probably WordPress' nasty addslashes … the editor tries to fix that. Try to set wp_editor( stripslashes($content) … ). –  toscho Apr 30 '12 at 18:29
    
@toscho Yeah, that was it. Thank You. Bad You didn't posted it as an answer, cause I can't accept it. –  smogg Apr 30 '12 at 18:34
    
I'll do it now. :) –  toscho Apr 30 '12 at 18:58

3 Answers 3

up vote 6 down vote accepted

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 );
share|improve this answer

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

Try:

 wp_editor( html_entity_decode($content), strtolower($value['id']), $settings );
share|improve this answer

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..

share|improve this answer
    
Please explain your solution. Why is it better than the other approaches? –  toscho Dec 14 '12 at 20:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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