| 1 |
<?php |
| 2 |
|
| 3 |
add_shortcode( 'avada_property_bathrooms', function( $atts ) { |
| 4 |
$atts = shortcode_atts( array( |
| 5 |
'content_align' => 'left', |
| 6 |
'fusion_font_family_bathrooms_font' => '', |
| 7 |
'fusion_font_variant_bathrooms_font' => '', |
| 8 |
'font_size' => '', |
| 9 |
'letter_spacing' => '', |
| 10 |
'text_transform' => '', |
| 11 |
'line_height' => '', |
| 12 |
'text_color' => '', |
| 13 |
'icon' => '', |
| 14 |
'before' => '', |
| 15 |
'after' => '', |
| 16 |
), $atts ); |
| 17 |
|
| 18 |
if ( get_post_type( get_the_ID() ) != 'property' ) |
| 19 |
{ |
| 20 |
return ''; |
| 21 |
} |
| 22 |
|
| 23 |
fusion_element_rendering_elements( true ); |
| 24 |
|
| 25 |
global $property; |
| 26 |
|
| 27 |
if ( empty($property) ) |
| 28 |
{ |
| 29 |
$property = new PH_Property(get_the_ID()); |
| 30 |
} |
| 31 |
|
| 32 |
if ( $property->bathrooms == '' || $property->bathrooms == 0 ) |
| 33 |
{ |
| 34 |
return ''; |
| 35 |
} |
| 36 |
|
| 37 |
$style = Fusion_Builder_Element_Helper::get_font_styling( $atts, 'bathrooms_font' ); |
| 38 |
|
| 39 |
if ( $atts['font_size'] ) { |
| 40 |
$style .= 'font-size:' . fusion_library()->sanitize->get_value_with_unit( $atts['font_size'] ) . ';'; |
| 41 |
} |
| 42 |
|
| 43 |
if ( $atts['letter_spacing'] ) { |
| 44 |
$style .= 'letter-spacing:' . fusion_library()->sanitize->get_value_with_unit( $atts['letter_spacing'] ) . ';'; |
| 45 |
} |
| 46 |
|
| 47 |
if ( ! empty( $atts['text_transform'] ) ) { |
| 48 |
$style .= 'text-transform:' . $atts['text_transform'] . ';'; |
| 49 |
} |
| 50 |
|
| 51 |
if ( ! empty( $atts['content_align'] ) ) { |
| 52 |
$style .= 'text-align:' . $atts['content_align'] . ';'; |
| 53 |
} |
| 54 |
|
| 55 |
ob_start(); |
| 56 |
|
| 57 |
echo '<div ' . FusionBuilder::attributes( 'property-bathrooms-shortcode' ) . '> |
| 58 |
<div style="' . $style . '">'; |
| 59 |
|
| 60 |
if ( ! empty($atts['icon']) ) |
| 61 |
{ |
| 62 |
echo '<span class="' . esc_attr($atts['icon']) . '"></span> '; |
| 63 |
} |
| 64 |
|
| 65 |
if ( isset($atts['before']) && !empty($atts['before']) ) |
| 66 |
{ |
| 67 |
echo $atts['before'] . ' '; |
| 68 |
} |
| 69 |
echo esc_html($property->bathrooms); |
| 70 |
if ( isset($atts['after']) && !empty($atts['after']) ) |
| 71 |
{ |
| 72 |
echo ' ' . $atts['after']; |
| 73 |
} |
| 74 |
echo ' |
| 75 |
</div> |
| 76 |
</div>'; |
| 77 |
|
| 78 |
$html = ob_get_clean(); |
| 79 |
|
| 80 |
fusion_element_rendering_elements( false ); |
| 81 |
|
| 82 |
return $html; |
| 83 |
}); |