WordPress wp_editor 不会添加图像

标签 wordpress

我在循环中的插件中有以下代码,因此有多个所见即所得编辑器:

<?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 未设置或者随机数不唯一。我该怎么做才能使这项工作成功?媒体管理器在内容页面上运行得非常好。

源文件:http://pastebin.com/BhvqBLGB

最佳答案

来自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/

相关文章:

php - WordPress WooCommerce - 使用 WC_Cart 类将可变产品添加到购物车

php - 有没有办法在 WordPress 中使用渐进式 JPEG?

Wordpress 多站点 www 非 www 页面重定向失败

sql - 检测帖子评级系统的滥用

wordpress - 是什么导致我的博客页面等待时间如此之长?

css - Wordpress 后循环的边框,使用 Bootstrap 的网格

php - CSS 不适用于我的 PHP 代码(回显/无回显)

php - 访客客户检查 Woocommerce 订单账单电子邮件时可享受首单折扣

css - 本地主机上的 style.css 工作表未正确保存

php - WordPress 自定义帖子类型未显示在菜单页面中