• Hi, thank you for this great plugin.
    I’m using the Types and Views plugin to create custom posttypes and fields. Your Template button appears on the regular content editor in the custom post type, but not with the custom field editor. Is there a way to show your Template button here also?
    Thanks in advance,
    Erik

    https://www.ads-software.com/plugins/tinymce-templates/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Ashworth Creative

    (@ashworthcreative)

    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.

    Ashworth Creative

    (@ashworthcreative)

    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:

    1. 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
    2. 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.
    Ashworth Creative

    (@ashworthcreative)

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Template button for Custom Field Editor’ is closed to new replies.