Tooltip Button not showing within WYSIWYG Toolbar

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.

function tooltip_shortcode_function($atts, $content = null) {
extract(shortcode_atts(array(
‘tip’ => null,
‘hover’ => null,
‘invert’ => false,
), $atts));

if ($invert) {
list ($tip, $hover) = array ($hover, $tip);
}

if ($content && ($tip || $hover)) {
$content = do_shortcode( $content );
$add_classes = “”;

if ($hover) { // swap tip/content
list ($tip, $content) = array ($content, $hover);
}

if ( strip_tags($content) == “” ) {
$add_classes .= “icon-tooltip”;
} else {
$add_classes .= “text-tooltip”;
}

$return = “<abbr class='” . $add_classes . “‘ title='”.esc_attr( $tip ).”‘ rel=’tooltip’ role=’tooltip’>”.$content.”</abbr>”;
return $return;
}
}
function register_button( $buttons ) {
array_push( $buttons, “|”, “tooltips” );
return $buttons;
}
function add_plugin( $plugin_array ) {
$plugin_array[‘tooltips’] = get_stylesheet_directory_uri() . ‘/js/tooltips.js’;
return $plugin_array;
}
function tooltips_button() {

add_shortcode(‘tooltip’, ‘tooltip_shortcode_function’);
add_filter( ‘mce_external_plugins’, ‘add_plugin’ );
add_filter( ‘mce_buttons’, ‘register_button’ );

}
add_action(‘init’, ‘tooltips_button’);

Read more here:: Tooltip Button not showing within WYSIWYG Toolbar

Leave a Reply

Your email address will not be published. Required fields are marked *