Opened 13 years ago
Closed 9 years ago
#20264 closed defect (bug) (invalid)
WP_Editor unexpected behavior/bug when used in widget
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | major | Version: | 3.3.1 |
Component: | TinyMCE | Keywords: | |
Focuses: | Cc: |
Description
Creating a bare bones widget using the wp_editor() function only returns a non-functioning editor (a few times no editor at all). Using the setting teeny => true results in a javascript error where wp_editor will try to load /wp-includes/js/tinymce/themes/simple/editor_template.js (which does not exist).
A demo video of this behavior can be found here: https://vimeo.com/38863361
This is the demo code:
add_action('widgets_init', 'my_widgets_add'); function my_widgets_add() { register_widget('my_wysiwyg_widget'); } class my_wysiwyg_widget extends \WP_Widget { function __construct() { $widget_ops = array('classname' => 'my_wysiwyg_widget', 'description' => __('My WYSIWYG Widget')); $control_ops = array('width' => 650, 'height' => 350); parent::__construct(false, __("My WYSIWYG Widget"), $widget_ops, $control_ops); } function form() { // Create a TinyMCE editor wp_editor('content', $editor_id = "unique_id_goes_here", $settings = array( 'textarea_name' => "unique_name_goes_here", 'textarea_rows' => 7, teeny => false)); } function update($new_instance, $old_instance) { // Save data later $instance = $old_instance; return $instance; } function widget($args, $instance) { // print later } }
Change History (7)
#1
@
13 years ago
- Summary changed from WP_Editor to WP_Editor unexpected behavior/bug when used in widget
#4
@
13 years ago
Unfortunately TinyMCE cannot be moved in the DOM once it's initialized. That makes it impossible to use wp_editor() directly in a widget.
Was thinking to add another method to wp_editor() that would make it work in two steps:
- first enqueue scripts and output the hidden html for the dialogs (all that goes at the bottom of the page),
- second output the html around the editor and some JS to initialize it, leaving out the actual init call so it can be initialized on bemand.
That would make it possible to add the editor with ajax too.
Note: See
TracTickets for help on using
tickets.
Related: #20181