WordPress在TinyMCE编辑器中注入自己的外部脚本文件iframe
, 请参见示例wp-includes/js/tinymce/plugins/wpembed/plugin.js
文件:
(function ( tinymce ) {
\'use strict\';
tinymce.PluginManager.add( \'wpembed\', function ( editor, url ) {
editor.on( \'init\', function () {
var scriptId = editor.dom.uniqueId();
var scriptElm = editor.dom.create( \'script\', {
id: scriptId,
type: \'text/javascript\',
src: url + \'/../../../wp-embed.js\'
} );
editor.getDoc().getElementsByTagName( \'head\' )[ 0 ].appendChild( scriptElm );
} );
} );
})( window.tinymce );
The
plugin.js
使用
tiny_mce_plugins
滤器