I am making a Vimeo Upload plugin for Wordpress, so that you can upload directly from wordpress onto Vimeo and embed it directly. Anyways i think i have the hardest part done and that was the authentication (bad examples where there).
Now I have another problem. In Wordpress you can embed images in the rich text editor through pressing on a button in the popup. ( ) ('Invoegen in bericht' button in dutch).
Now I want to do the same thing, insert 'some tekst' (a url is enough) into the rich text area when someone clicks on my 'invoegen' button ( ) how can I achieve this?
I can't find any javascript documentation on the Wordpress site. Hoping someone can help. I thought, lets look how the other button does it, but the inspector does not show any 'onclicks' and such on that button. Those are hooked on the fly and I don't know where in the code to look for that.
Hoping someone can help me out.
Kind regards.
I am making a Vimeo Upload plugin for Wordpress, so that you can upload directly from wordpress onto Vimeo and embed it directly. Anyways i think i have the hardest part done and that was the authentication (bad examples where there).
Now I have another problem. In Wordpress you can embed images in the rich text editor through pressing on a button in the popup. ( http://cl.ly/6Xns ) ('Invoegen in bericht' button in dutch).
Now I want to do the same thing, insert 'some tekst' (a url is enough) into the rich text area when someone clicks on my 'invoegen' button ( http://cl.ly/6Wmn ) how can I achieve this?
I can't find any javascript documentation on the Wordpress site. Hoping someone can help. I thought, lets look how the other button does it, but the inspector does not show any 'onclicks' and such on that button. Those are hooked on the fly and I don't know where in the code to look for that.
Hoping someone can help me out.
Kind regards.
Share Improve this question edited Sep 25, 2011 at 12:37 Matthijn asked May 5, 2011 at 22:12 MatthijnMatthijn 3,23410 gold badges48 silver badges74 bronze badges 2- 1 Answer your own question in the answer box below and hit accept. Otherwise, your question will remain open forever! – bpeterson76 Commented May 16, 2011 at 19:45
- 1 Also to note, do you know Wordpress supports Oembed, so the user just pastes a Vimeo URL into the content area, and it will be converted to an embed code. – addedlovely Commented May 23, 2011 at 6:07
2 Answers
Reset to default 7Fixed it myself.
function appendText(text) {
//Insert content
parent.tinyMCE.activeEditor.setContent(parent.tinyMCE.activeEditor.getContent() + text);
//Close window
parent.jQuery("#TB_closeWindowButton").click();
}
For those of you who want to add the text at the current cursor location, you can make use of the mceInsertContent
function (built-in TinyMCE function).
A quick example would be:
function addTextIntoEditor(myText){
tinymce.activeEditor.execCommand('mceInsertContent', false, myText);
}
This is based on Magus's answer located here