我通过添加一个tinymce插件来解决这个问题,它几乎就在那里了,但当它试图从typekit检索字体css时,我得到了一个403禁止:
js公司:
(function() {
tinymce.create(\'tinymce.plugins.typekit\', {
init: function(ed, url) {
ed.onPreInit.add(function(ed) {
// Get the DOM document object for the IFRAME
var doc = ed.getDoc();
// Create the script we will add to the header asynchronously
var jscript = "var TypekitConfig = {\\n\\
kitId: \'*******\'\\n\\
};\\n\\
(function() {\\n\\
var tk = document.createElement(\'script\');\\n\\
tk.src = \'//use.typekit.com/\' + TypekitConfig.kitId + \'.js\';\\n\\
tk.type = \'text/javascript\';\\n\\
tk.async = \'true\';\\n\\
tk.onload = tk.onreadystatechange = function() {\\n\\
var rs = this.readyState;\\n\\
if (rs && rs != \'complete\' && rs != \'loaded\') return;\\n\\
try { Typekit.load(TypekitConfig); } catch (e) {}\\n\\
};\\n\\
var s = document.getElementsByTagName(\'script\')[0];\\n\\
s.parentNode.insertBefore(tk, s);\\n\\
})();";
// Create a script element and insert the TypeKit code into it
var script = doc.createElement("script");
script.type = "text/javascript";
script.appendChild(doc.createTextNode(jscript));
// Add the script to the header
doc.getElementsByTagName(\'head\')[0].appendChild(script);
});
},
getInfo: function() {
return {
longname: \'TypeKit For TinyMCE\',
author: \'Tom J Nowell\',
authorurl: \'http://tomjn.com/\',
infourl: \'http://twitter.com/tarendai\',
version: "1.0"
};
}
});
tinymce.PluginManager.add(\'typekit\', tinymce.plugins.typekit);
})();
PHP
add_filter("mce_external_plugins", "tomjn_mce_external_plugins");
function tomjn_mce_external_plugins($plugin_array){
$plugin_array[\'typekit\'] = get_template_directory_uri().\'/typekit.tinymce.js\';
return $plugin_array;
}