我在循环中的插件中有以下代码,因此有多个所见即所得编辑器:
<?php wp_editor( stripslashes($arr['item-content']), $key.'-item-content', array(
'editor_class' => 'tsort-contarea',
'media_buttons' => true,
'editor_height' => 360,
) ); ?>
添加图像时,wp-includes/js/media-editor.js
内标记为 send-attachment-to-editor
的 XHR 请求有一个 wp.media.view.settings.post.id
为 0。此外,wp.media.view.settings.nonce.sendToEditor
始终为以下值:e8b2eea867
return wp.media.post( 'send-attachment-to-editor', {
nonce: wp.media.view.settings.nonce.sendToEditor,
attachment: options,
html: html,
post_id: wp.media.view.settings.post.id
});
xhr 请求正常触发,但不会添加任何所见即所得。我确信这是因为 post_id 未设置或者随机数不唯一。我该怎么做才能使这项工作成功?媒体管理器在内容页面上运行得非常好。
最佳答案
来自Codex :
Note that the ID that is passed to the wp_editor() function can only be composed of lower-case letters. No underscores, no hyphens. Anything else will cause the WYSIWYG editor to malfunction. (As of 3.6.1 you can use underscores in the ID.)
据我所知,您当前正在使用破折号。尝试改变它,看看它是如何工作的。
关于WordPress wp_editor 不会添加图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28484058/