PluginProbe
Property Hive / 2.3.0
Property Hive v2.3.0
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-epcs-shortcode.php

property-epcs-shortcode.php in Property Hive 2.3.0, at includes/avada-widgets/property-epcs-shortcode.php

78 lines 2.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_epcs', function( $atts ) {
9 $atts = shortcode_atts( array(
10 'show_title' => '',
11 ), $atts );
12
13 if ( get_post_type( get_the_ID() ) != 'property' )
14 {
15 return '';
16 }
17
18 fusion_element_rendering_elements( true );
19
20 global $property;
21
22 if ( empty($property) )
23 {
24 // 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.
25 $property = new PH_Property(get_the_ID());
26 }
27
28 ob_start();
29
30 if ( get_option('propertyhive_epcs_stored_as', '') == 'urls' )
31 {
32 $epc_urls = $property->_epc_urls;
33 if ( is_array($epc_urls) && !empty( $epc_urls ) )
34 {
35 echo '<div class="epcs">';
36
37 if ( $atts['show_title'] == 'yes' ) { echo '<h4>' . esc_html(__( 'EPCs', 'propertyhive' )) . '</h4>'; }
38
39 foreach ($epc_urls as $epc)
40 {
41 echo '<a href="' . esc_url($epc['url']) . '" data-fancybox="epcs" rel="nofollow"><img src="' . esc_url($epc['url']) . '" alt=""></a>';
42 }
43
44 echo '</div>';
45 }
46 }
47 else
48 {
49 $epc_attachment_ids = $property->get_epc_attachment_ids();
50
51 if ( !empty($epc_attachment_ids) )
52 {
53 echo '<div class="epcs">';
54
55 if ( $atts['show_title'] == 'yes' ) { echo '<h4>' . esc_html(__( 'EPCs', 'propertyhive' )) . '</h4>'; }
56
57 foreach ( $epc_attachment_ids as $attachment_id )
58 {
59 if ( wp_attachment_is_image($attachment_id) )
60 {
61 echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" data-fancybox="epc" rel="nofollow"><img src="' . esc_url(wp_get_attachment_url($attachment_id)) . '" alt=""></a>';
62 }
63 else
64 {
65 echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" target="_blank" rel="nofollow">' . esc_html(__( 'View EPC', 'propertyhive' )) . '</a>';
66 }
67 }
68
69 echo '</div>';
70 }
71 }
72
73 $html = ob_get_clean();
74
75 fusion_element_rendering_elements( false );
76
77 return $html;
78 });