4

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?

1

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.

0

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

  • 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
0

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.

  • the_editor() is in the deprecated functions list, so I wouldn't recommend using it. – mtekk Mar 3 '12 at 22:11

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.