| 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 |
|