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.

Adding this in the widget form method:

wp_editor($text, $this->get_field_id('text'));   

seems to work. But after you press the "Save" button the widget goes funky...

Adding _WP_Editors::editor_js(); makes it show after you press the save button, but then other things start to act weird. I think it has something to do with the javascript from the footer.

Has anyone successfully integrated wp_editor inside a widget?

share|improve this question
    
Not sure if this is what you're after, but I'm using this on a two of my clients' sites. It subs for the text widget: wordpress.org/extend/plugins/black-studio-tinymce-widget –  Intrepid Realist Apr 10 '12 at 8:20
add comment

3 Answers

As said I think it's quite hard to find a reliable solution because you have to take care of so many things. I go either for the way proposed by Danny van Kooten: http://dannyvankooten.com/450/tinymce-wysiwyg-editor-in-wordpress-plugin/

add and open the editor in a thickbox or another way I've used once, using the widget "accessibility mode" for "advanced" stuff as seen in this screenr: http://www.screenr.com/sY5s

this example is buggy but the overall concept works fine, even if it's quite funny that you have to use js to get and add the link to the corresponding (non-js fallback) widget-edit page :)

But on the other hand, on this seperate page you can actually do whatever you want.

share|improve this answer
add comment

I haven't dug into its code, but at first glance Spots may be using the built-in wp_editor().

share|improve this answer
1  
I can confirm that - we use the editor but it's a pretty complex method that actually generates the entire editor so using it within each widget of a certain type means loading the scripts again and confusing the cookies and settings. In spots we run wp_editor() once on the page and then create editor instances in each widget - there's a fair bit to do to create/save/destroy the editors each time a widget is saved as the html is replaced via ajax. Not for the faint of heart! –  sanchothefat Jan 9 '12 at 15:11
add comment

I'm new to WP so I'm not entirely sure of this solution but I did read recently that there are issues with using wp_editor() (I can't remember where I read this, though). However, I also remember reading that the_editor() is a better solution, especially with draggable elements.

I hope that helps.

share|improve this answer
    
the_editor() is in the deprecated functions list, so I wouldn't recommend using it. –  mtekk Mar 3 '12 at 22:11
add comment

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.