我无法在wordpress编辑器中添加任何短代码。它显示 -
TypeError: window.tinyMCE.execInstanceCommand is not a function
window.tinyMCE.execInstanceCommand(id, 'mceInsertContent', false, shortcode)
。请帮我解决这个问题。
答案 0 :(得分:0)
TinyMCE API在版本4之后发生了变化。
(假设你有jQuery 1.7或更高版本)
jQuery(window).on("load", function(){
// First get the loaded TinyMCE version:
var mceVersion = parseInt(tinyMCE.majorVersion);
// ...
// Then later in your code where you want to insert your content:
if(mceVersion >= 4){
tinyMCE.execCommand("mceInsertContent", false, shortcode);
}else{
tinyMCE.execInstanceCommand("content", "mceInsertContent", false, shortcode);
}
});