PluginProbe
Property Hive / 2.2.3
Property Hive v2.2.3
2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 All 261 releases
propertyhive / includes / avada-widgets / property-brochures-link-shortcode.php

property-brochures-link-shortcode.php in Property Hive 2.2.3, at includes/avada-widgets/property-brochures-link-shortcode.php

85 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 add_shortcode( 'avada_property_brochures_link', function( $atts ) {
4 $atts = shortcode_atts( array(
5 'content_align' => 'left',
6 'fusion_font_family_brochures_link_font' => '',
7 'fusion_font_variant_brochures_link_font' => '',
8 'font_size' => '',
9 'letter_spacing' => '',
10 'text_transform' => '',
11 'line_height' => '',
12 'text_color' => '',
13 'label' => '',
14 ), $atts );
15
16 if ( get_post_type( get_the_ID() ) != 'property' )
17 {
18 return '';
19 }
20
21 fusion_element_rendering_elements( true );
22
23 global $property;
24
25 if ( empty($property) )
26 {
27 $property = new PH_Property(get_the_ID());
28 }
29
30 $style = Fusion_Builder_Element_Helper::get_font_styling( $atts, 'bedrooms_font' );
31
32 if ( $atts['font_size'] ) {
33 $style .= 'font-size:' . fusion_library()->sanitize->get_value_with_unit( $atts['font_size'] ) . ';';
34 }
35
36 if ( $atts['letter_spacing'] ) {
37 $style .= 'letter-spacing:' . fusion_library()->sanitize->get_value_with_unit( $atts['letter_spacing'] ) . ';';
38 }
39
40 if ( ! empty( $atts['text_transform'] ) ) {
41 $style .= 'text-transform:' . $atts['text_transform'] . ';';
42 }
43
44 if ( ! empty( $atts['content_align'] ) ) {
45 $style .= 'text-align:' . $atts['content_align'] . ';';
46 }
47
48 ob_start();
49
50 if ( get_option('propertyhive_brochures_stored_as', '') == 'urls' )
51 {
52 $brochure_urls = $property->brochure_urls;
53 if ( !is_array($brochure_urls) ) { $brochure_urls = array(); }
54
55 if ( !empty($brochure_urls) )
56 {
57 echo '<div ' . FusionBuilder::attributes( 'property-brochures-link-shortcode' ) . '>';
58 foreach ( $brochure_urls as $brochure )
59 {
60 echo '<a href="' . esc_url($brochure['url']) . '" target="_blank" rel="nofollow" style="' . $style . '">' . esc_html($label) . '</a>';
61 }
62 echo '</div>';
63 }
64 }
65 else
66 {
67 $brochure_attachment_ids = $property->get_brochure_attachment_ids();
68
69 if ( !empty($brochure_attachment_ids) )
70 {
71 echo '<div ' . FusionBuilder::attributes( 'property-brochures-link-shortcode' ) . '>';
72 foreach ( $brochure_attachment_ids as $attachment_id )
73 {
74 echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" target="_blank" rel="nofollow" style="' . $style . '">' . esc_html($label) . '</a>';
75 }
76 echo '</div>';
77 }
78 }
79
80 $html = ob_get_clean();
81
82 fusion_element_rendering_elements( false );
83
84 return $html;
85 });