/var/www/(Del)hsihk.com/wp-content/themes/flatsome/inc/shortcodes/tabs.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
// [tabgroup]
function ux_tabgroup$params$content null ) {
    
$GLOBALS['tabs'] = array();
    
$GLOBALS['tab_count'] = 0;
    
$i 1;
    
$randomid rand();

    
extract(shortcode_atts(array(
        
'title' => '',
        
'style' => 'normal',
    ), 
$params));

    
$content fixShortcode($content);

    if( 
is_array$GLOBALS['tabs'] ) ){
        
        foreach( 
$GLOBALS['tabs'] as $key => $tab ){
            
$active $key == ' active' ''// Set first tab active by default.
            
$tabs[] = '<li class="tab'.$active.'"><a href="#panel'.$randomid.$i.'">'.$tab['title'].'</a></li>';
            
$panes[] = '<div class="panel'.$active.'" id="panel'.$randomid.$i.'">'.fixShortcode($tab['content']).'</div>';
            
$i++;
        }
        if(
$title$title '<h3>'.$title.'</h3>';
        
$return '
        <div class="tabbed-content shortcode_tabgroup pos_'
.$style.'">
            '
.$title.'
            <ul class="tabs">'
.implode"\n"$tabs ).'</ul><div class="panels">'.implode"\n"$panes ).'</div></div>';
    }
    return 
$return;
}

// [tabgroup_vertical]
function ux_tabgroup_vertical$params$content null ) {
    
$GLOBALS['tabs'] = array();
    
$GLOBALS['tab_count'] = 0;
    
$i 1;
    
$randomid rand();

    
extract(shortcode_atts(array(
        
'title' => '',
        
'style' => 'normal',
    ), 
$params));

    
$content fixShortcode($content);

    if( 
is_array$GLOBALS['tabs'] ) ){
    
        foreach( 
$GLOBALS['tabs'] as $key => $tab ){
            
$current $key == ' current-menu-item' ''// Set first menu item active by default.
            
$active $key == ' active' ''// Set first tab active by default.
            
$tabs[] = '<li class="tab'.$current.'"><a href="#panel'.$randomid.$i.'">'.$tab['title'].'</a></li>';
            
$panes[] = '<div class="tabs-inner'.$active.'" id="panel'.$randomid.$i.'">'.fixShortcode($tab['content']).'</div>';
            
$i++;
        }
        if(
$title$title '<h3>'.$title.'</h3>';
        
$return '
            <div class="row collapse vertical-tabs shortcode_tabgroup_vertical pos_'
.$style.'">
            '
.$title.'
            <div class="large-3 columns"><ul class="tabs-nav">'
.implode"\n"$tabs ).'</ul></div><div class="large-9 columns">'.implode"\n"$panes ).'</div></div>';
    }
    return 
$return;
}


function 
ux_tab$params$content null) {
    
extract(shortcode_atts(array(
            
'title' => '',
            
'title_small' => ''
    
), $params));
    
    
$x $GLOBALS['tab_count'];
    
$GLOBALS['tabs'][$x] = array( 'title' => sprintf$title$GLOBALS['tab_count'] ), 'content' =>  $content );
    
$GLOBALS['tab_count']++;
}


add_shortcode('tabgroup''ux_tabgroup');
add_shortcode('tabgroup_vertical''ux_tabgroup_vertical');
add_shortcode('tab''ux_tab' );