Add Text To TinyMCE Visual Pane In WordPress

I have successfully written a TinyMCE plugin for a WordPress site that inserts a script tag into the html of a new post or page. However, since the script tag contains no text, in the “visual” pane nothing shows up.

There must be a way to provide something to show in the visual pane while still only having a script tag in the “text” pane no?

Read More

My code:

jQuery(document).ready(function($) {

    tinymce.PluginManager.add('myplugin', function(editor, url) {

        editor.addButton('civicsciencejspoll', {
            text: 'CivicScience JSPoll',
            icon: false,
            onclick: function() {
                    var html = "<script src="mydomain.com/js/file.js"></script>";
                    editor.insertContent(html);
                }
            }
        });
    });
});

Related posts

1 comment

Comments are closed.