Callback function quicktags that uses variable in start tag
I am trying to make a callback function that returns on click of a quick tag wordpress button dinamical generated variables inside the tags.
Something like
QTags.addButton( 'eg_wrap', 'WRAP ARROWND', 'div class="moudle-area"', 'p[Tweet "I just completed Module '+module_nr+' of the '+course+' Course"]/p/div', 'WRAP ARROWND', 'WRAP ARROWND', 1 );
Current Example
function callback_wrap() {
var course = getSelectedText("_lesson_course");
var module_info = jQuery("#title").val();
var module_nr = module_info.match( /\d+/g );
});
QTags.addButton('eg_wrap', 'WRAP ARROWND', callback_wrap);
Problem when I select text how can I pass the variables and read the selected text in order to insert the start tag end tag and the variables.
So when clicked should return:
div class="moudle-area"
SELECTED STRING HERE
p[Tweet "I just completed Module NUMBER (2) of the
NAME OF COURSE Course"]
/p
/div
Topic quicktag html-editor plugin-development Wordpress
Category Web