Tooltip Button not showing within WYSIWYG Toolbar

by wgallop   Last Updated September 12, 2018 15:08 PM

I've been using this code to insert a tooltip button within the WYSIWYG Toolbar in my Wordpress sites but for some reason it has stopped working. I'm wondering if an update to core may have been the culprit.

It should also be noted that this code is approximately 2-3 years old and I'm using the most recent version of Wordpress.

Update: I found out the issue lies within the JS file, not functions.php.

(function($){
if (typeof(tinyMCE) != "undefined") {
  if (tinyMCE.activeEditor == null || tinyMCE.activeEditor.isHidden() != false) {
    tinymce.create('tinymce.plugins.tooltips', {
          init : function(ed, url) {
             ed.addButton('tooltips', {
                title : 'Tooltips',
                icon: 'info-circle',
                onclick : function() {
                    if ( ed.selection.getContent() != "" ) {
                        var content = ed.selection.getContent() + ' ';
                    } else {
                        var content = '';
                    }
                    var tip = prompt("Enter your tip below:", "");
                    if (tip != null && tip != ''){
                        ed.execCommand('mceInsertContent', false, content + ' [tooltip tip="' + tip + '"]<i class="fa fa-info-circle"></i>[/tooltip]');
                    }
                }
             });
          },
          createControl : function(n, cm) {
             return null;
          },
          getInfo : function() {
             return {
                longname : "Tooltip",
                author : 'Konstantinos Kouratoras',
                authorurl : 'http://www.kouratoras.gr',
                infourl : 'http://www.smashingmagazine.com',
                version : "1.0"
             };
          }
    });
    tinymce.PluginManager.add('tooltips', tinymce.plugins.tooltips);
  }
}})(jQuery);


Related Questions





Apply custom style to single word in Wordpress

Updated September 27, 2017 16:08 PM