su_shortcode_tooltip

The shortcodes-ultimate su shortcode tooltip function.

Published Date - February 15, 2021

Description

su_shortcode_tooltip( $atts, $content );

Parameters

  1. $atts

  2. $content


Usage

The following example is for adding a hook callback.

if ( !function_exists( 'su_shortcode_tooltip' ) ) {
    require_once ABSPATH . PLUGINDIR . 'shortcodes-ultimateshortcodes-ultimate/includes/shortcodes/tooltip.php';
}

// The input(s). 
$atts = null;
$content = null;

// NOTICE! Understand what this does before running.
$result = su_shortcode_tooltip( $atts, $content );
            

Defined

The function is defined in the following location(s).

shortcodes-ultimate/includes/shortcodes/tooltip.php

function su_shortcode_tooltip( $atts = null, $content = null ) {

	$atts = shortcode_atts( array(
			'style'        => 'yellow',
			'position'     => 'north',
			'shadow'       => 'no',
			'rounded'      => 'no',
			'size'         => 'default',
			'title'        => '',
			'content'      => __( 'Tooltip text', 'shortcodes-ultimate' ),
			'behavior'     => 'hover',
			'close'        => 'no',
			'class'        => ''
		), $atts, 'tooltip' );

	// Prepare style
	$atts['style'] = in_array( $atts['style'], array( 'light', 'dark', 'green', 'red', 'blue', 'youtube', 'tipsy', 'bootstrap', 'jtools', 'tipped', 'cluetip' ) )
		? $atts['style']
		: 'plain';

	// Position
	$atts['position'] = str_replace( array( 'top', 'right', 'bottom', 'left' ), array( 'north', 'east', 'south', 'west' ), $atts['position'] );
	$position = array(
		'my' => str_replace( array( 'north', 'east', 'south', 'west' ), array( 'bottom center', 'center left', 'top center', 'center right' ), $atts['position'] ),
		'at' => str_replace( array( 'north', 'east', 'south', 'west' ), array( 'top center', 'center right', 'bottom center', 'center left' ), $atts['position'] )
	);

	// Prepare classes
	$classes = array( 'su-qtip qtip-' . $atts['style'] );
	$classes[] = 'su-qtip-size-' . $atts['size'];

	if ( $atts['shadow'] === 'yes' ) {
		$classes[] = 'qtip-shadow';
	}

	if ( $atts['rounded'] === 'yes' ) {
		$classes[] = 'qtip-rounded';
	}

	// Query assets
	su_query_asset( 'css', 'qtip' );
	su_query_asset( 'css', 'su-shortcodes' );
	su_query_asset( 'js', 'jquery' );
	su_query_asset( 'js', 'qtip' );
	su_query_asset( 'js', 'su-shortcodes' );

	return '<span class="su-tooltip' . su_get_css_class( $atts ) . '" data-close="' . $atts['close'] . '" data-behavior="' . $atts['behavior'] . '" data-my="' . $position['my'] . '" data-at="' . $position['at'] . '" data-classes="' . implode( ' ', $classes ) . '" data-title="' . $atts['title'] . '" title="' . esc_attr( $atts['content'] ) . '">' . do_shortcode( $content ) . '</span>';

}