| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
|
| 8 |
add_shortcode( 'avada_property_availability', function( $atts ) { |
| 9 |
$atts = shortcode_atts( array( |
| 10 |
'content_align' => 'left', |
| 11 |
'fusion_font_family_availability_font' => '', |
| 12 |
'fusion_font_variant_availability_font' => '', |
| 13 |
'font_size' => '', |
| 14 |
'letter_spacing' => '', |
| 15 |
'text_transform' => '', |
| 16 |
'line_height' => '', |
| 17 |
'text_color' => '', |
| 18 |
), $atts ); |
| 19 |
|
| 20 |
if ( get_post_type( get_the_ID() ) != 'property' ) |
| 21 |
{ |
| 22 |
return ''; |
| 23 |
} |
| 24 |
|
| 25 |
fusion_element_rendering_elements( true ); |
| 26 |
|
| 27 |
global $property; |
| 28 |
|
| 29 |
if ( empty($property) ) |
| 30 |
{ |
| 31 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared frontend property global used by the Avada shortcode contract; changing $property would break the existing property context passed to these widgets. |
| 32 |
$property = new PH_Property(get_the_ID()); |
| 33 |
} |
| 34 |
|
| 35 |
if ( $property->availability == '' ) |
| 36 |
{ |
| 37 |
return ''; |
| 38 |
} |
| 39 |
|
| 40 |
$style = Fusion_Builder_Element_Helper::get_font_styling( $atts, 'availability_font' ); |
| 41 |
|
| 42 |
if ( $atts['font_size'] ) { |
| 43 |
$style .= 'font-size:' . fusion_library()->sanitize->get_value_with_unit( $atts['font_size'] ) . ';'; |
| 44 |
} |
| 45 |
|
| 46 |
if ( $atts['letter_spacing'] ) { |
| 47 |
$style .= 'letter-spacing:' . fusion_library()->sanitize->get_value_with_unit( $atts['letter_spacing'] ) . ';'; |
| 48 |
} |
| 49 |
|
| 50 |
if ( ! empty( $atts['text_transform'] ) ) { |
| 51 |
$style .= 'text-transform:' . $atts['text_transform'] . ';'; |
| 52 |
} |
| 53 |
|
| 54 |
if ( ! empty( $atts['content_align'] ) ) { |
| 55 |
$style .= 'text-align:' . $atts['content_align'] . ';'; |
| 56 |
} |
| 57 |
|
| 58 |
ob_start(); |
| 59 |
|
| 60 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- FusionBuilder::attributes() returns the complete HTML attribute fragment and escapes each attribute name and value. |
| 61 |
echo '<div ' . FusionBuilder::attributes( 'property-availability-shortcode' ) . '> |
| 62 |
<div style="' . esc_attr( safecss_filter_attr( $style ) ) . '">'; |
| 63 |
echo esc_html($property->availability); |
| 64 |
echo ' |
| 65 |
</div> |
| 66 |
</div>'; |
| 67 |
|
| 68 |
$html = ob_get_clean(); |
| 69 |
|
| 70 |
fusion_element_rendering_elements( false ); |
| 71 |
|
| 72 |
return $html; |
| 73 |
}); |