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 / oscpopover / plugin_shortcode.php

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

114 lines 3.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 function osc_theme_popover($params, $content = 'Popover') {
8 $atts = shortcode_atts(array(
9 'trigger' => '',
10 'title' => '',
11 'pop_content' => '',
12 'style' => '',
13 'size' => '',
14 'type' => '',
15 'class' => ''
16 ), $params);
17
18 $trigger = Sanitizer::attr( $atts['trigger'] );
19 $title = Sanitizer::attr( $atts['title'] );
20 $pop_content = Sanitizer::attr( $atts['pop_content'] );
21 $style = Sanitizer::attr( $atts['style'] );
22 $size = Sanitizer::class_list( $atts['size'] );
23 $type = Sanitizer::class_list( $atts['type'] );
24 $class = Sanitizer::class_list( $atts['class'] );
25
26 $out = '';
27 $out = '<button class="osc_popover btn ' . $size . ' ' . $type . ' ' . $class . EBS_CONTAINER_CLASS . '" data-content="' . $pop_content . '" data-placement="' . $style . '" data-toggle="popover" data-trigger="' . $trigger . '" data-container="body" type="button" data-title="' . $title . '"> ' . do_shortcode( $content ) . ' </button>';
28
29 if ( EBS_POPOVER_TEMPLATE === '' ) {
30 $out .= "
31 <script>
32 jQuery(document).ready(function(){
33 jQuery('.osc_popover').popover();
34 });
35 </script>
36 ";
37
38 } else {
39 $out .= "
40 <script>
41 jQuery(document).ready(function(){
42 jQuery('.osc_popover').popover({template:'" . EBS_POPOVER_TEMPLATE . "'});
43 });
44 </script>
45 ";
46 }
47 return $out;
48 }
49
50 $_osc_popover_array = array( 'count' => 0 );
51
52 function osc_theme_popover_new($params, $content = '') {
53 global $_osc_popover_array;
54 $atts = shortcode_atts(array(
55 'id' => count( $_osc_popover_array ),
56 'trigger' => '',
57 'title' => '',
58 'button_text' => 'Popover',
59 'style' => '',
60 'size' => '',
61 'type' => '',
62 'class' => ''
63 ), $params);
64
65 $id = Sanitizer::int( $atts['id'] );
66 $trigger = Sanitizer::attr( $atts['trigger'] );
67 $title = Sanitizer::attr( $atts['title'] );
68 $button_text = Sanitizer::html( $atts['button_text'] );
69 $style = Sanitizer::attr( $atts['style'] );
70 $size = Sanitizer::class_list( $atts['size'] );
71 $type = Sanitizer::class_list( $atts['type'] );
72 $class = Sanitizer::class_list( $atts['class'] );
73
74 $_osc_popover_array[ $id ] = array();
75 $out = '';
76 $out = '<button class="osc_popover_new btn ' . $size . ' ' . $type . ' ' . $class . EBS_CONTAINER_CLASS . '" data-placement="' . $style . '" data-toggle="popover" data-trigger="' . $trigger . '" data-container="body" type="button" data-title="' . $title . '" data-contentwrapper="osc_popover_' . $id . '"> ' . $button_text . ' </button>';
77 $out .= '<div id="osc_popover_' . $id . '" style="display:none;">' . do_shortcode( $content ) . '</div>';
78
79 if ( EBS_POPOVER_TEMPLATE === '' ) {
80 $out .= "
81 <script>
82 jQuery(document).ready(function(){
83 jQuery('.osc_popover_new').popover({
84 html:true,
85 content:function(){
86 return jQuery('#'+jQuery(this).data('contentwrapper')).html();
87 }
88
89 });
90 });
91 </script>
92 ";
93
94 } else {
95 $out .= "
96 <script>
97 jQuery(document).ready(function(){
98 jQuery('.osc_popover_new').popover({
99 template:'" . EBS_POPOVER_TEMPLATE . "',
100 html:true,
101 content:function(){
102 return jQuery('#'+jQuery(this).data('contentwrapper')).html();
103 }
104 });
105 });
106 </script>
107 ";
108 }
109 return $out;
110 }
111
112 ebs_backward_compatibility_callback('popover', 'osc_theme_popover');
113 ebs_backward_compatibility_callback('popovernew', 'osc_theme_popover_new');
114