| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
use EBS\Security\Sanitizer; |
| 6 |
|
| 7 |
/* * ********************************************************* |
| 8 |
* BUTTONS |
| 9 |
* ********************************************************* */ |
| 10 |
|
| 11 |
function osc_theme_icon($params, $content = null) { |
| 12 |
$atts = shortcode_atts(array( |
| 13 |
'type' => '', |
| 14 |
'color' => '', |
| 15 |
'class' => '', |
| 16 |
'fontsize' => '' |
| 17 |
), $params); |
| 18 |
|
| 19 |
$type = Sanitizer::class_list( $atts['type'] ); |
| 20 |
$class = Sanitizer::class_list( $atts['class'] ); |
| 21 |
$color = Sanitizer::hex_color( $atts['color'] ); |
| 22 |
$fontsize = Sanitizer::int( $atts['fontsize'] ); |
| 23 |
|
| 24 |
$style_parts = array(); |
| 25 |
if ( $color !== '' ) { |
| 26 |
$style_parts[] = 'color:' . $color . ';'; |
| 27 |
} |
| 28 |
if ( $fontsize !== 0 ) { |
| 29 |
$style_parts[] = 'font-size:' . $fontsize . 'px;'; |
| 30 |
} |
| 31 |
$style = implode( '', $style_parts ); |
| 32 |
|
| 33 |
$iconcount = explode( ' ', $atts['type'] ); |
| 34 |
array_filter( $iconcount ); |
| 35 |
if ( count( $iconcount ) === 1 ) { |
| 36 |
$type = 'glyphicon ' . $type; |
| 37 |
} |
| 38 |
|
| 39 |
$out = '<i class=" ' . $type . ' ' . $class . '" style="' . $style . '"></i>'; |
| 40 |
return $out; |
| 41 |
} |
| 42 |
|
| 43 |
ebs_backward_compatibility_callback('icon', 'osc_theme_icon'); |
| 44 |
|