| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
use EBS\Security\Sanitizer; |
| 6 |
use EBS\Styles\Dynamic_Css; |
| 7 |
|
| 8 |
/* * ********************************************************* |
| 9 |
* Servicebox |
| 10 |
* ********************************************************* */ |
| 11 |
$_ebsp_servicebox = array(); |
| 12 |
|
| 13 |
function osc_theme_servicebox($params, $content = null) { |
| 14 |
global $_ebsp_servicebox; |
| 15 |
$atts = shortcode_atts(array( |
| 16 |
'id' => count( $_ebsp_servicebox ), |
| 17 |
'icon' => '', |
| 18 |
'type' => 'icon', |
| 19 |
'icontype' => 'glyphicon', |
| 20 |
'icon_size' => 40, |
| 21 |
'iconbg_size' => 100, |
| 22 |
'iconbg_radius' => 50, |
| 23 |
'margin_bottom' => 30, |
| 24 |
'margin_top' => 30, |
| 25 |
'iconbgcolor' => '#FFFFFF', |
| 26 |
'iconcolor' => '#777777', |
| 27 |
'headingtype' => 'h3', |
| 28 |
'heading' => '', |
| 29 |
'class' => '', |
| 30 |
'readmore' => '', |
| 31 |
'readmore_link' => '', |
| 32 |
'readmore_text' => '', |
| 33 |
'readmore_type' => '', |
| 34 |
'readmorestyle' => 'default', |
| 35 |
'readmore_bgcolor' => '', |
| 36 |
'readmore_fgcolor' => '' |
| 37 |
), $params); |
| 38 |
|
| 39 |
$id = Sanitizer::int( $atts['id'] ); |
| 40 |
$icon = Sanitizer::class_list( $atts['icon'] ); |
| 41 |
$icontype = Sanitizer::class_list( $atts['icontype'] ); |
| 42 |
$icon_size = Sanitizer::int( $atts['icon_size'] ); |
| 43 |
$iconbg_size = Sanitizer::int( $atts['iconbg_size'] ); |
| 44 |
$iconbg_radius = Sanitizer::int( $atts['iconbg_radius'] ); |
| 45 |
$margin_bottom = Sanitizer::int( $atts['margin_bottom'] ); |
| 46 |
$margin_top = Sanitizer::int( $atts['margin_top'] ); |
| 47 |
$iconbgcolor = Sanitizer::hex_color( $atts['iconbgcolor'] ); |
| 48 |
$iconcolor = Sanitizer::hex_color( $atts['iconcolor'] ); |
| 49 |
$headingtype = Sanitizer::heading_tag( $atts['headingtype'] ); |
| 50 |
$heading = Sanitizer::html( $atts['heading'] ); |
| 51 |
$class = Sanitizer::class_list( $atts['class'] ); |
| 52 |
$readmore = $atts['readmore']; |
| 53 |
$readmore_link = Sanitizer::url( $atts['readmore_link'] ); |
| 54 |
$readmore_text = Sanitizer::html( $atts['readmore_text'] ); |
| 55 |
$readmore_type = Sanitizer::class_list( $atts['readmore_type'] ); |
| 56 |
$readmorestyle = $atts['readmorestyle']; |
| 57 |
$readmore_bgcolor = Sanitizer::hex_color( $atts['readmore_bgcolor'] ); |
| 58 |
$readmore_fgcolor = Sanitizer::hex_color( $atts['readmore_fgcolor'] ); |
| 59 |
|
| 60 |
$out = ''; |
| 61 |
$style = ''; |
| 62 |
$_ebsp_servicebox[ $id ] = array(); |
| 63 |
|
| 64 |
$out .= '<div id="osc_servicebox_' . $id . '" class="osc_servicebox ' . $class . '">'; |
| 65 |
|
| 66 |
if ( $icon !== '' ) { |
| 67 |
$out .= '<span class="' . $icontype . ' ' . $icon . ' icon_bg iconcircle"></span>'; |
| 68 |
} |
| 69 |
|
| 70 |
if ( $heading !== '' ) { |
| 71 |
$out .= '<' . $headingtype . '>' . $heading . '</' . $headingtype . '>'; |
| 72 |
} |
| 73 |
$out .= '<div class="osc_servicebox_content">'; |
| 74 |
$out .= do_shortcode( $content ); |
| 75 |
$out .= '</div>'; |
| 76 |
if ( $readmore === 'true' ) { |
| 77 |
if ( $readmore_type !== '' ) { |
| 78 |
$btnclass = ' btn ' . $readmore_type; |
| 79 |
} else { |
| 80 |
$btnclass = ' osc_servicebox_readmore'; |
| 81 |
} |
| 82 |
$out .= '<a href="' . $readmore_link . '" class="osc_servicebox_readmore_css' . $btnclass . '">' . $readmore_text . '</a>'; |
| 83 |
} |
| 84 |
$out .= '</div>'; |
| 85 |
|
| 86 |
if ( $readmore === 'true' && $readmorestyle === 'custom' ) { |
| 87 |
$style .= ' |
| 88 |
#osc_servicebox_' . $id . ' .osc_servicebox_readmore_css{ |
| 89 |
color:' . $readmore_fgcolor . '; |
| 90 |
background-color:' . $readmore_bgcolor . '; |
| 91 |
}'; |
| 92 |
} |
| 93 |
$lineheight = $iconbg_size - 10; |
| 94 |
$style .= ' |
| 95 |
#osc_servicebox_' . $id . ' .iconcircle{ |
| 96 |
|
| 97 |
} |
| 98 |
#osc_servicebox_' . $id . ' span.iconcircle { |
| 99 |
color:' . $iconcolor . '; |
| 100 |
font-size:' . $icon_size . 'px; |
| 101 |
line-height:' . $lineheight . 'px; |
| 102 |
background-color:' . $iconbgcolor . '; |
| 103 |
height:' . $iconbg_size . 'px; |
| 104 |
width:' . $iconbg_size . 'px; |
| 105 |
margin-top:' . $margin_top . 'px; |
| 106 |
margin-bottom:' . $margin_bottom . 'px; |
| 107 |
border-radius:' . $iconbg_radius . '%; |
| 108 |
-moz-border-radius: ' . $iconbg_radius . '%; |
| 109 |
-webkit-border-radius: ' . $iconbg_radius . '%; |
| 110 |
-ms-border-radius: ' . $iconbg_radius . '%; |
| 111 |
-o-border-radius: ' . $iconbg_radius . '%; |
| 112 |
; |
| 113 |
}'; |
| 114 |
|
| 115 |
Dynamic_Css::add( $style ); |
| 116 |
|
| 117 |
return $out; |
| 118 |
} |
| 119 |
|
| 120 |
ebs_backward_compatibility_callback('servicebox', 'osc_theme_servicebox'); |
| 121 |
|