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

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

68 lines 2.0 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 * jQuery UI Tabs
9 * ********************************************************* */
10 $_oscitas_tabs = array();
11
12 function osc_theme_tabs( $params, $content = null ) {
13 global $_oscitas_tabs;
14
15 $atts = shortcode_atts(
16 array(
17 'id' => count( $_oscitas_tabs ),
18 'class' => '',
19 ),
20 $params
21 );
22
23 $id = Sanitizer::int( $atts['id'] );
24 $class = Sanitizer::class_list( $atts['class'] );
25
26 $_oscitas_tabs[ $id ] = array();
27 do_shortcode( $content );
28 $scontent = '<ul class="nav nav-tabs' . EBS_CONTAINER_CLASS . '" id="oscitas-tabs-' . $id . '">' . implode( '', $_oscitas_tabs[ $id ]['tabs'] ) . '</ul><div class="tab-content' . EBS_CONTAINER_CLASS . '">' . implode( '', $_oscitas_tabs[ $id ]['panes'] ) . '</div>';
29
30 if ( '' !== trim( $scontent ) ) {
31 $output = '<div class="' . $class . '">' . $scontent;
32 $output .= '</div>';
33
34 return $output;
35 }
36
37 return '';
38 }
39
40 ebs_backward_compatibility_callback( 'tabs', 'osc_theme_tabs' );
41
42 function osc_theme_tab( $params, $content = null ) {
43 global $_oscitas_tabs;
44
45 $atts = shortcode_atts(
46 array(
47 'title' => 'title',
48 'active' => '',
49 ),
50 $params
51 );
52
53 $title = Sanitizer::html( $atts['title'] );
54 $active = Sanitizer::class_list( $atts['active'] );
55
56 $index = count( $_oscitas_tabs ) - 1;
57 if ( ! isset( $_oscitas_tabs[ $index ]['tabs'] ) ) {
58 $_oscitas_tabs[ $index ]['tabs'] = array();
59 }
60
61 $pane_id = 'pane-' . $index . '-' . count( $_oscitas_tabs[ $index ]['tabs'] );
62
63 $_oscitas_tabs[ $index ]['tabs'][] = '<li class="' . $active . EBS_CONTAINER_CLASS . '"><a class="' . EBS_CONTAINER_CLASS . '" href="#' . Sanitizer::attr( $pane_id ) . '" data-toggle="tab">' . $title . '</a></li>';
64 $_oscitas_tabs[ $index ]['panes'][] = '<div class="tab-pane ' . $active . EBS_CONTAINER_CLASS . '" id="' . Sanitizer::attr( $pane_id ) . '">' . do_shortcode( trim( $content ) ) . '</div>';
65 }
66
67 ebs_backward_compatibility_callback( 'tab', 'osc_theme_tab' );
68