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

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

72 lines 2.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_button($params, $content = null) {
12 $atts = shortcode_atts(array(
13 'title' => 'osCitas',
14 'link' => '',
15 'linkrel' => '',
16 'type' => 'link',
17 'style' => '',
18 'align' => '',
19 'target' => '',
20 'icon' => '',
21 'class' => '',
22 'iconcolor' => ''
23 ), $params);
24
25 $title = Sanitizer::html( $atts['title'] );
26 $link = Sanitizer::url( $atts['link'] );
27 $linkrel = Sanitizer::attr( $atts['linkrel'] );
28 $style = Sanitizer::class_list( $atts['style'] );
29 $class = Sanitizer::class_list( $atts['class'] );
30 $align = $atts['align'];
31 $type = $atts['type'];
32 $target = $atts['target'];
33 $icon = Sanitizer::class_list( $atts['icon'] );
34 $iconcolor = Sanitizer::hex_color( $atts['iconcolor'] );
35
36 $out = '';
37 $iconcount = array();
38 if ( $icon ) {
39 $iconcount = explode( ' ', $atts['icon'] );
40 }
41 array_filter( $iconcount );
42 if ( count( $iconcount ) === 1 ) {
43 $icon = 'glyphicon ' . $icon;
44 }
45
46 $iconcolor_attr = '';
47 if ( $iconcolor !== '' ) {
48 $iconcolor_attr = 'style="color:' . $iconcolor . ';"';
49 }
50
51 if ( $icon !== '' ) {
52 if ( $align === 'right' ) {
53 $value = $title . ' <i class="' . $icon . '" ' . $iconcolor_attr . '></i>';
54 } else {
55 $value = '<i class="' . $icon . '" ' . $iconcolor_attr . '></i> ' . $title;
56 }
57 } else {
58 $value = $title;
59 }
60
61 $target_attr = ' target="' . ( $target !== 'false' ? '_blank' : '_self' ) . '"';
62
63 if ( $type === 'link' ) {
64 $out = '<a class="btn ' . $style . ' ' . $class . ' ' . EBS_CONTAINER_CLASS . '" href="' . $link . '" rel="' . $linkrel . '" ' . $target_attr . '>' . $value . '</a>';
65 } elseif ( $type === 'button' ) {
66 $out = '<button class="btn ' . $style . ' ' . $class . ' ' . EBS_CONTAINER_CLASS . '">' . $value . '</button>';
67 }
68 return $out;
69 }
70
71 ebs_backward_compatibility_callback('button', 'osc_theme_button');
72