I'm struggling for two days and started here with success: Why Can't wp_editor Be Used in a Custom Widget?
I managed to have multiple TMCE on one page (displayed by a widget); all save data correctly. When i assign (as required) different IDs to each textfield, i get an upon clicking on the "visual" button (activating tmce):
'Uncaught TypeError: Cannot read property 'onpageload' of undefined'
When I assign a static ID to each textfield, the error is gone, but only the first textfield will get transformed to a tmce; the others remain regular textareas, no error.
I understand why the latter happens. I don't understand the error in first place, this is the resulting code, with a single tmce:
<textarea class="wp-editor-area" rows="30" autocomplete="off" cols="40" name="widgets[c29][wp_editor]" id="widget-bo_widget_rte-c29-wp_editor">this is text</textarea>
Im pretty sure this works in WP <4.8, since it uses TinyMCE <4 (??), but I can not find a solution for > 4.8
I'm struggling for two days and started here with success: Why Can't wp_editor Be Used in a Custom Widget?
I managed to have multiple TMCE on one page (displayed by a widget); all save data correctly. When i assign (as required) different IDs to each textfield, i get an upon clicking on the "visual" button (activating tmce):
'Uncaught TypeError: Cannot read property 'onpageload' of undefined'
When I assign a static ID to each textfield, the error is gone, but only the first textfield will get transformed to a tmce; the others remain regular textareas, no error.
I understand why the latter happens. I don't understand the error in first place, this is the resulting code, with a single tmce:
<textarea class="wp-editor-area" rows="30" autocomplete="off" cols="40" name="widgets[c29][wp_editor]" id="widget-bo_widget_rte-c29-wp_editor">this is text</textarea>
Im pretty sure this works in WP <4.8, since it uses TinyMCE <4 (??), but I can not find a solution for > 4.8
Share Improve this question edited Oct 23, 2018 at 8:15 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Oct 23, 2018 at 8:07 jansassjansass 213 bronze badges1 Answer
Reset to default 1After three days i found a solution, many others are seeking (dozends of unanswered threads here and there) wp_editor() does not work in WP >4.8
Instead, use wp.editor Javascript-API: https://codex.wordpress/Javascript_Reference/wp.editor