PluginProbe
Easy Bootstrap Shortcode / 3.7
Easy Bootstrap Shortcode v3.7
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 / dropdown / plugin_shortcode.php

plugin_shortcode.php in Easy Bootstrap Shortcode 3.7, at shortcode/dropdown/plugin_shortcode.php

77 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function osc_theme_dropdown($params, $content = null) {
4 extract(shortcode_atts(array(
5 'dropup' => '',
6 'class' => ''
7 ), $params));
8 $content = str_replace("]<br />", ']', $content);
9 $content = str_replace("]<br />\n", ']', $content);
10 $content = str_replace("<br />\n[", '[', $content);
11 if ($dropup != 'dropup') {
12 $dropup = '';
13 }
14 $out = '<div class="btn-group ' . $dropup . ' ' . $class . '">' . do_shortcode($content) . '</div>';
15 $out .= "
16 <script>
17 jQuery(document).ready(function(){
18 jQuery('.dropdown-toggle').dropdown();
19 });
20 </script>
21 ";
22 return $out;
23 }
24
25 add_shortcode('dropdown', 'osc_theme_dropdown');
26
27 function osc_theme_dropdown_head($params, $content = null) {
28 extract(shortcode_atts(array(
29 'size' => '',
30 'style' => '',
31 'split' => ''), $params));
32 $out = '';
33 if ($split == "split") {
34 $out = '<button type="button" class="btn ' . $size . ' ' . $style . '">' . $content . '</button>';
35
36 $out .= '<button type="button" class="btn ' . $size . ' ' . $style . ' dropdown-toggle" data-toggle="dropdown">';
37 $out .= '<span class="caret"></span></button>';
38 } else {
39 $out = ' <button type="button" class="btn ' . $size . ' ' . $style . ' dropdown-toggle" data-toggle="dropdown">';
40 $out .= $content . ' <span class="caret"></span> </button>';
41 }
42
43 return $out;
44 }
45
46 add_shortcode('dropdownhead', 'osc_theme_dropdown_head');
47
48 function osc_theme_dropdown_body($params, $content = null) {
49 $content = str_replace("]<br />", ']', $content);
50 $content = str_replace("]<br />\n", ']', $content);
51 $content = str_replace("<br />\n[", '[', $content);
52 $out = '<ul class="dropdown-menu" role="menu">' . do_shortcode($content) . '</ul>';
53 return $out;
54 }
55
56 add_shortcode('dropdownbody', 'osc_theme_dropdown_body');
57
58 function osc_theme_dropdown_items($params, $content = null) {
59 extract(shortcode_atts(array(
60 'type' => '',
61 'link' => '',
62 'disabled' => ''), $params));
63 $out = '';
64 if ($type == "divider") {
65 $out = '<li class="divider"></li>';
66 } elseif ($type == "menuitem") {
67 if ($disabled == 'disabled') {
68 $out = '<li class="disabled"><a href="' . $link . '">' . do_shortcode($content) . '</a></li>';
69 } else {
70 $out = '<li><a href="' . $link . '">' . do_shortcode($content) . '</a></li>';
71 }
72 }
73 return $out;
74 }
75
76 add_shortcode('dropdownitem', 'osc_theme_dropdown_items');
77 ?>