The issue is in the call to the media_buttons action hook (line 192 of tinymce-templates.php). Remove the “if” statement and it should work perfectly.
Further, the plugin is currently set up to only handle one WYSIWYG field per post. If you were using a custom fields plugin to have multiple instances of that (for example, tabbed content where you’d really want templates), you’d want this to work on all those. This can be accomplished by:
- Changing the
media_buttons function in tinymce-templates.php so that the button does not have an id, but has two classes: button button-tinymce-templates
- Modify line 11 in tinymce-templates.js to
$(document).on('click', '.button-tinymce-templates', function(e){
to make the the handler live. This way, if more WYSIWYG fields are created, the button will work on those as well.
The javascript also has a problem with plugins like ACF where the name of the TinyMCE content is acf_content rather than just content. You can alter the code around line 130 of tinymce-templates.js to:
var tm = tinyMCEPreInit.mceInit;
var content_css = '';
for ( var i in tm ) {
if ( tm[i].content_css ) {
content_css = tm[i].content_css;
break;
}
}
var styles = content_css.replace(/(\s+)/g, "").split(',');
This will find the appropriate content_css.