| @@ -1,35 +1,28 @@ | ||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | - exit; | |
| 2 | + | |
| 3 | +function osc_theme_notification($atts, $content = null) { | |
| 4 | + extract(shortcode_atts(array( | |
| 5 | + 'type' => '', | |
| 6 | + 'close' => 'false', | |
| 7 | + 'class' => '' | |
| 8 | + ), $atts)); | |
| 9 | + $type = ($close == 'true' ? $type . ' alert-dismissable' : $type); | |
| 10 | + | |
| 11 | + | |
| 12 | + $result = '<div class = "alert ' . $type . ' ' . $class . '">'; | |
| 13 | + if ($close == 'true') { | |
| 14 | + $result .= '<button type = "button" class = "close" data-dismiss = "alert" aria-hidden = "true">× | |
| 15 | + </button>'; | |
| 16 | + } | |
| 17 | + $result .= do_shortcode($content); | |
| 18 | + $result .= '</div>'; | |
| 19 | + | |
| 20 | + return $result; | |
| 4 | 21 | } |
| 5 | -use EBS\Security\Sanitizer; | |
| 6 | 22 | |
| 7 | -function osc_theme_notification( $atts, $content = null ) { | |
| 8 | - $atts = shortcode_atts( | |
| 9 | - array( | |
| 10 | - 'type' => '', | |
| 11 | - 'close' => 'false', | |
| 12 | - 'class' => '', | |
| 13 | - ), | |
| 14 | - $atts | |
| 15 | - ); | |
| 23 | +add_shortcode('notification', 'osc_theme_notification'); | |
| 16 | 24 | |
| 17 | - $type = Sanitizer::class_list( $atts['type'] ); | |
| 18 | - $class = Sanitizer::class_list( $atts['class'] ); | |
| 19 | 25 | |
| 20 | - if ( 'true' === $atts['close'] ) { | |
| 21 | - $type .= ' alert-dismissable'; | |
| 22 | - } | |
| 23 | 26 | |
| 24 | - $result = '<div class = "alert ' . $type . ' ' . $class . EBS_CONTAINER_CLASS . '">'; | |
| 25 | - if ( 'true' === $atts['close'] ) { | |
| 26 | - $result .= '<button type = "button" class = "close' . EBS_CONTAINER_CLASS . '" data-dismiss = "alert" aria-hidden = "true">× | |
| 27 | - </button>'; | |
| 28 | - } | |
| 29 | - $result .= do_shortcode( $content ); | |
| 30 | - $result .= '</div>'; | |
| 31 | 27 | |
| 32 | - return $result; | |
| 33 | -} | |
| 34 | 28 | |
| 35 | -ebs_backward_compatibility_callback( 'notification', 'osc_theme_notification' ); | |