将脚本排队以在 Wordpress 的tinyMCE 插件中使用
我有一个tinyMCE插件(用于帖子/页面编辑器),我从我的Wordpress插件加载它,需要加载几个外部javascript文件才能让我的tinyMCE插件工作。
在 Wordpress 3.3.1 中,我只需注册 mce_external_plugins 过滤器中的脚本并将其排入队列,但任何低于该版本的 WordPress 版本都不会加载脚本。
有人有这方面的经验吗?
I have a tinyMCE plugin (for the post/page editor) that I am loading from my Wordpress plugin that needs to have several external javascript files loaded in order for my tinyMCE plugin to work.
In Wordpress 3.3.1 I can just register and enqueue the scripts from the mce_external_plugins
filter but any Wordpress version below that doesn't load the scripts.
Anybody have experience in this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现解决我的问题的方法是挂钩
after_wp_tiny_mce
,然后在回调中直接调用wp_print_scripts
。它仍然处理脚本的所有依赖项。另外,由于脚本未排队,
wp_localize_script
无法使用此方法,因此我在对wp_print_scripts
的调用正上方回显我的对象,如下所示:编辑:
此修复仅适用于 Wordpress >= 3.2
The method that I found to work with my problem is by hooking to
after_wp_tiny_mce
and then in the callback, callingwp_print_scripts
directly. It still handles all the dependencies of the scripts.Also, because
wp_localize_script
won't work with this method due to the scripts not being enqueued, I am echoing my objects directly above my calls towp_print_scripts
like this:EDIT :
This fix will only work in Wordpress >= 3.2