I am developing a WordPress shot-code plugin.
i have added a listbox in TinyMCE and i need to load data to TinyMCE from wordpress database. i can not hard code the listbox values since all my shortcodes values are saved in wordpress database.
is there any possible way to do this ?
(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;
}
if it helps someone who visit this post.
My solution was retrieving the data through a ajax request. The trick is doing a synchronous request (async: false).