| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
use EBS\Security\Sanitizer; |
| 6 |
|
| 7 |
/* * ********************************************************* |
| 8 |
* Badges |
| 9 |
* ********************************************************* */ |
| 10 |
|
| 11 |
function osc_theme_badge( $params, $content = '' ) { |
| 12 |
$atts = shortcode_atts( |
| 13 |
array( |
| 14 |
'bgcolor' => '', |
| 15 |
'color' => '', |
| 16 |
'value' => '', |
| 17 |
'float_right' => '', |
| 18 |
'class' => '', |
| 19 |
), |
| 20 |
$params |
| 21 |
); |
| 22 |
|
| 23 |
$out = ''; |
| 24 |
$content = str_replace( '<br class="osc" />', '', $content ); |
| 25 |
$content = str_replace( '<br class="osc" />\n', '', $content ); |
| 26 |
|
| 27 |
$style = ''; |
| 28 |
if ( '' !== $atts['bgcolor'] ) { |
| 29 |
$style .= 'background:' . Sanitizer::hex_color( $atts['bgcolor'] ) . ';'; |
| 30 |
} |
| 31 |
if ( '' !== $atts['color'] ) { |
| 32 |
$style .= 'color:' . Sanitizer::hex_color( $atts['color'] ) . ';'; |
| 33 |
} |
| 34 |
$style_attr = '' !== $style ? ' style="' . Sanitizer::attr( $style ) . '"' : ''; |
| 35 |
$float_right = 'true' === $atts['float_right'] ? ' pull-right' : ''; |
| 36 |
$class = Sanitizer::class_list( $atts['class'] ); |
| 37 |
$value = Sanitizer::html( $atts['value'] ); |
| 38 |
|
| 39 |
$out = '<span class="badge ' . $class . $float_right . EBS_CONTAINER_CLASS . '"' . $style_attr . '>' . $value . '</span>'; |
| 40 |
|
| 41 |
return $out; |
| 42 |
} |
| 43 |
|
| 44 |
ebs_backward_compatibility_callback( 'badge', 'osc_theme_badge' ); |
| 45 |
|