| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 4 |
|
| 5 |
extract(shortcode_atts(array( |
| 6 |
"show_title" => "yes", |
| 7 |
), $atts)); |
| 8 |
|
| 9 |
global $property; |
| 10 |
|
| 11 |
if ( !isset($property->id) ) { |
| 12 |
return; |
| 13 |
} |
| 14 |
|
| 15 |
if ( isset($atts['show_title']) && $atts['show_title'] != 'yes' ) |
| 16 |
{ |
| 17 |
?> |
| 18 |
<style type="text/css"> |
| 19 |
.epcs h4 { display:none; } |
| 20 |
</style> |
| 21 |
<?php |
| 22 |
} |
| 23 |
|
| 24 |
if ( get_option('propertyhive_epcs_stored_as', '') == 'urls' ) |
| 25 |
{ |
| 26 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WPBakery html_template local variable; this file is a framework-rendered view receiving $atts/$this, and PrefixAllGlobals sees it outside the framework render scope. |
| 27 |
$epc_urls = $property->_epc_urls; |
| 28 |
if ( is_array($epc_urls) && !empty( $epc_urls ) ) |
| 29 |
{ |
| 30 |
echo '<div class="epcs">'; |
| 31 |
|
| 32 |
echo '<h4>' . esc_html(__( 'EPCs', 'propertyhive' )) . '</h4>'; |
| 33 |
|
| 34 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WPBakery html_template local variable; this file is a framework-rendered view receiving $atts/$this, and PrefixAllGlobals sees it outside the framework render scope. |
| 35 |
foreach ($epc_urls as $epc) |
| 36 |
{ |
| 37 |
echo '<a href="' . esc_url($epc['url']) . '" data-fancybox="epcs" rel="nofollow"><img src="' . esc_url($epc['url']) . '" alt=""></a>'; |
| 38 |
} |
| 39 |
|
| 40 |
echo '</div>'; |
| 41 |
} |
| 42 |
} |
| 43 |
else |
| 44 |
{ |
| 45 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WPBakery html_template local variable; this file is a framework-rendered view receiving $atts/$this, and PrefixAllGlobals sees it outside the framework render scope. |
| 46 |
$epc_attachment_ids = $property->get_epc_attachment_ids(); |
| 47 |
|
| 48 |
if ( !empty($epc_attachment_ids) ) |
| 49 |
{ |
| 50 |
echo '<div class="epcs">'; |
| 51 |
|
| 52 |
echo '<h4>' . esc_html(__( 'EPCs', 'propertyhive' )) . '</h4>'; |
| 53 |
|
| 54 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WPBakery html_template local variable; this file is a framework-rendered view receiving $atts/$this, and PrefixAllGlobals sees it outside the framework render scope. |
| 55 |
foreach ( $epc_attachment_ids as $attachment_id ) |
| 56 |
{ |
| 57 |
if ( wp_attachment_is_image($attachment_id) ) |
| 58 |
{ |
| 59 |
echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" data-fancybox="epcs" rel="nofollow"><img src="' . esc_url(wp_get_attachment_url($attachment_id)) . '" alt=""></a>'; |
| 60 |
} |
| 61 |
else |
| 62 |
{ |
| 63 |
echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" target="_blank" rel="nofollow">' . esc_html(__( 'View EPC', 'propertyhive' )) . '</a>'; |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
echo '</div>'; |
| 68 |
} |
| 69 |
} |