| @@ -1,28 +1,19 @@ | ||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | - exit; | |
| 4 | -} | |
| 5 | -use EBS\Security\Sanitizer; | |
| 6 | 2 | |
| 7 | -function osc_theme_dropdown( $params, $content = null ) { | |
| 8 | - $atts = shortcode_atts( | |
| 9 | - array( | |
| 10 | - 'dropup' => '', | |
| 11 | - 'class' => '', | |
| 12 | - ), | |
| 13 | - $params | |
| 14 | - ); | |
| 15 | - | |
| 16 | - $content = str_replace( ']<br />', ']', $content ); | |
| 17 | - $content = str_replace( "]<br />\n", ']', $content ); | |
| 18 | - $content = str_replace( "<br />\n[", '[', $content ); | |
| 19 | - | |
| 20 | - $dropup = 'dropup' === $atts['dropup'] ? 'dropup' : ''; | |
| 21 | - $class = Sanitizer::class_list( $atts['class'] ); | |
| 22 | - | |
| 23 | - $out = '<div class="btn-group ' . $dropup . ' ' . $class . EBS_CONTAINER_CLASS . '">' . do_shortcode( $content ) . '</div>'; | |
| 24 | - $out .= " | |
| 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 .= " | |
| 25 | 16 | <script> |
| 26 | 17 | jQuery(document).ready(function(){ |
| 27 | 18 | jQuery('.dropdown-toggle').dropdown(); |
| 28 | 19 | }); |
| @@ -27,78 +18,60 @@ | ||
| 27 | 18 | jQuery('.dropdown-toggle').dropdown(); |
| 28 | 19 | }); |
| 29 | 20 | </script> |
| 30 | 21 | "; |
| 31 | - | |
| 32 | - return $out; | |
| 22 | + return $out; | |
| 33 | 23 | } |
| 34 | 24 | |
| 35 | -ebs_backward_compatibility_callback( 'dropdown', 'osc_theme_dropdown' ); | |
| 25 | +add_shortcode('dropdown', 'osc_theme_dropdown'); | |
| 36 | 26 | |
| 37 | -function osc_theme_dropdown_head( $params, $content = null ) { | |
| 38 | - $atts = shortcode_atts( | |
| 39 | - array( | |
| 40 | - 'size' => '', | |
| 41 | - 'style' => '', | |
| 42 | - 'split' => '', | |
| 43 | - ), | |
| 44 | - $params | |
| 45 | - ); | |
| 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>'; | |
| 46 | 35 | |
| 47 | - $size = Sanitizer::class_list( $atts['size'] ); | |
| 48 | - $style = Sanitizer::class_list( $atts['style'] ); | |
| 49 | - $content = do_shortcode( $content ); | |
| 50 | - $out = ''; | |
| 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 | + } | |
| 51 | 42 | |
| 52 | - if ( 'split' === $atts['split'] ) { | |
| 53 | - $out = '<button type="button" class="btn ' . $size . ' ' . $style . EBS_CONTAINER_CLASS . '">' . $content . '</button>'; | |
| 54 | - $out .= '<button type="button" class="btn ' . $size . ' ' . $style . EBS_CONTAINER_CLASS . ' dropdown-toggle" data-toggle="dropdown">'; | |
| 55 | - $out .= '<span class="caret' . EBS_CONTAINER_CLASS . '"></span></button>'; | |
| 56 | - } else { | |
| 57 | - $out = ' <button type="button" class="btn ' . $size . ' ' . $style . EBS_CONTAINER_CLASS . ' dropdown-toggle" data-toggle="dropdown">'; | |
| 58 | - $out .= $content . ' <span class="caret' . EBS_CONTAINER_CLASS . '"></span> </button>'; | |
| 59 | - } | |
| 60 | - | |
| 61 | - return $out; | |
| 43 | + return $out; | |
| 62 | 44 | } |
| 63 | 45 | |
| 64 | -ebs_backward_compatibility_callback( 'dropdownhead', 'osc_theme_dropdown_head' ); | |
| 46 | +add_shortcode('dropdownhead', 'osc_theme_dropdown_head'); | |
| 65 | 47 | |
| 66 | -function osc_theme_dropdown_body( $params, $content = null ) { | |
| 67 | - $content = str_replace( ']<br />', ']', $content ); | |
| 68 | - $content = str_replace( "]<br />\n", ']', $content ); | |
| 69 | - $content = str_replace( "<br />\n[", '[', $content ); | |
| 70 | - | |
| 71 | - $out = '<ul class="dropdown-menu' . EBS_CONTAINER_CLASS . '" role="menu">' . do_shortcode( $content ) . '</ul>'; | |
| 72 | - | |
| 73 | - return $out; | |
| 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; | |
| 74 | 54 | } |
| 75 | 55 | |
| 76 | -ebs_backward_compatibility_callback( 'dropdownbody', 'osc_theme_dropdown_body' ); | |
| 56 | +add_shortcode('dropdownbody', 'osc_theme_dropdown_body'); | |
| 77 | 57 | |
| 78 | -function osc_theme_dropdown_items( $params, $content = null ) { | |
| 79 | - $atts = shortcode_atts( | |
| 80 | - array( | |
| 81 | - 'type' => '', | |
| 82 | - 'link' => '', | |
| 83 | - 'disabled' => '', | |
| 84 | - ), | |
| 85 | - $params | |
| 86 | - ); | |
| 87 | - | |
| 88 | - $out = ''; | |
| 89 | - $link = Sanitizer::url( $atts['link'] ); | |
| 90 | - | |
| 91 | - if ( 'divider' === $atts['type'] ) { | |
| 92 | - $out = '<li class="divider' . EBS_CONTAINER_CLASS . '"></li>'; | |
| 93 | - } elseif ( 'menuitem' === $atts['type'] ) { | |
| 94 | - if ( 'disabled' === $atts['disabled'] ) { | |
| 95 | - $out = '<li class="disabled' . EBS_CONTAINER_CLASS . '"><a class="' . EBS_CONTAINER_CLASS . '" href="' . $link . '">' . do_shortcode( $content ) . '</a></li>'; | |
| 96 | - } else { | |
| 97 | - $out = '<li><a class="' . EBS_CONTAINER_CLASS . '" href="' . $link . '">' . do_shortcode( $content ) . '</a></li>'; | |
| 98 | - } | |
| 99 | - } | |
| 100 | - | |
| 101 | - return $out; | |
| 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; | |
| 102 | 74 | } |
| 103 | 75 | |
| 104 | -ebs_backward_compatibility_callback( 'dropdownitem', 'osc_theme_dropdown_items' ); | |
| 76 | +add_shortcode('dropdownitem', 'osc_theme_dropdown_items'); | |
| 77 | +?> | |