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 / icon / plugin_shortcode.php

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

44 lines 1.2 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 * 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