最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

customization - Multiple Tinymcewp_editor in WordPress >4.8

programmeradmin3浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 1

After 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

发布评论

评论列表(0)

  1. 暂无评论