PluginProbe
Easy Bootstrap Shortcode / trunk
Easy Bootstrap Shortcode vtrunk
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 / badge / plugin_shortcode.php

plugin_shortcode.php in Easy Bootstrap Shortcode trunk, at shortcode/badge/plugin_shortcode.php

45 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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