Important parts of code:
javascript tinymceplugin:
init : function(ed, url) {
ed.addCommand('addVocabularyLinkCallout', function() {
ed.windowManager.open({
file : ajaxurl + '?action=addvocabularylinkbutton_function',
width : 350 + parseInt(ed.getLang('mytest.delta_width', 0)),
height : 250 + parseInt(ed.getLang('mytest.delta_height', 0)),
inline : 1
}, {
plugin_url : url
});
});
ed.addButton('addvocabularylink', {
title : 'Dodaj link do sÅowniczka',
cmd : 'addVocabularyLinkCallout',
image : url+'/../img/tinymce/insertpopup.png'
});
},
wordpress ajax support, only for logged in users:
add_action('wp_ajax_addvocabularylinkbutton_function', 'addvocabularylinkbutton_function_callback');
function addvocabularylinkbutton_function_callback() {?>
<!DOCTYPE html>
<head>
<title>Create a Single Link - Button</title>
</head>
<body>
<h2>Test</h2>
</html>
<?php }; ?>
It is not important, that the window doesnt do anything itself, what bothers me is “0” at end of the code of the popup window:
<!DOCTYPE html>
<head>
<title>Create a Single Link - Button</title>
</head>
<body>
<h2>Test</h2>
</html>
0
How to get rid of it?
After digging here and there, I have found, that it is not a problem of TinyMCE, but wp_ajax callout. It needs:
at the end.
So the correct code would be: