PluginProbe
Property Hive / 2.3.1
Property Hive v2.3.1
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.3.1, at includes/avada-widgets/property-brochures-link-shortcode.php

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