PluginProbe
Easy Bootstrap Shortcode / trunk
Easy Bootstrap Shortcode vtrunk
trunk 2.4.0 2.5 3.4 3.5 3.6 3.7 4.0.0 4.4 4.5 4.5.4 5.0.0 5.0.1 5.0.2
easy-bootstrap-shortcodes / shortcode / tooltip / plugin_shortcode.php

plugin_shortcode.php in Easy Bootstrap Shortcode trunk, at shortcode/tooltip/plugin_shortcode.php

59 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5 use EBS\Security\Sanitizer;
6
7 /* * *********************************************************
8 * Tooltip
9 * ********************************************************* */
10
11 function osc_theme_tooltip($params, $content = 'Tooltip') {
12 $atts = shortcode_atts(array(
13 'type' => '',
14 'link' => '',
15 'tooltip' => '',
16 'style' => '',
17 'class' => '',
18 'target' => '',
19 ), $params);
20
21 $type = $atts['type'];
22 $link = Sanitizer::url( $atts['link'] );
23 $tooltip = Sanitizer::attr( $atts['tooltip'] );
24 $style = Sanitizer::attr( $atts['style'] );
25 $class = Sanitizer::class_list( $atts['class'] );
26 $target = Sanitizer::attr( $atts['target'] );
27
28 $out = '';
29 if ( $type === 'link' ) {
30 $out = '<a href="' . $link . '" data-placement="' . $style . '" title="' . $tooltip . '" class="osc_tooltip ' . $class . '" target="' . $target . '">' . do_shortcode( $content ) . '</a>
31 ';
32 } elseif ( $type === 'button' ) {
33 $out = '<button type="button" data-toggle="tooltip" data-placement="' . $style . '" title="' . $tooltip . '" class="btn osc_tooltip ' . $class . '">' . do_shortcode( $content ) . '</button>';
34 }
35
36 if ( EBS_TOOLTIP_TEMPLATE === '' ) {
37 $out .= "
38 <script>
39 jQuery(document).ready(function() {
40 jQuery('.osc_tooltip').tooltip();
41 });
42 </script>
43 ";
44
45 } else {
46 $out .= "
47 <script>
48 jQuery(document).ready(function(){
49 jQuery('.osc_tooltip').tooltip({template:'" . EBS_TOOLTIP_TEMPLATE . "'});
50 });
51 </script>
52 ";
53 }
54
55 return $out;
56 }
57
58 ebs_backward_compatibility_callback('tooltip', 'osc_theme_tooltip');
59