【发布时间】:2014-06-25 08:38:18
【问题描述】:
我正在开发一个 WordPress 镜头代码插件。
我在 TinyMCE 中添加了一个列表框,我需要从 wordpress 数据库将数据加载到 TinyMCE。我无法对列表框值进行硬编码,因为我所有的简码值都保存在 wordpress 数据库中。
有没有办法做到这一点?
(function() {
tinymce.PluginManager.add('AP_tc_button', function( editor, url ) {
editor.addButton( 'AP_tc_button', {
text: 'My test button',
icon: 'wp_code',
onclick: function() {
editor.windowManager.open( {
title: 'Select Your AD',
body: [
{
type: 'listbox',
name: 'level',
label: 'Header level',
values: getValues()
}],
onsubmit: function( e ) {
editor.insertContent('dd');
}
});
}
});
});
})();
function getValues() {
//Set new values to myKeyValueList (i need this values get from the db)
tinyMCE.activeEditor.settings.myKeyValueList = [{text: 'newtext', value: 'newvalue'}];
return tinyMCE.activeEditor.settings.myKeyValueList;
}
【问题讨论】:
-
你能把你开发的示例代码放上去吗?
-
好的,我已经添加了代码
标签: php wordpress listbox tinymce