| 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 |
$epc_urls = $property->_epc_urls; |
| 27 |
if ( is_array($epc_urls) && !empty( $epc_urls ) ) |
| 28 |
{ |
| 29 |
echo '<div class="epcs">'; |
| 30 |
|
| 31 |
echo '<h4>' . esc_html(__( 'EPCs', 'propertyhive' )) . '</h4>'; |
| 32 |
|
| 33 |
foreach ($epc_urls as $epc) |
| 34 |
{ |
| 35 |
echo '<a href="' . esc_url($epc['url']) . '" data-fancybox="epcs" rel="nofollow"><img src="' . esc_url($epc['url']) . '" alt=""></a>'; |
| 36 |
} |
| 37 |
|
| 38 |
echo '</div>'; |
| 39 |
} |
| 40 |
} |
| 41 |
else |
| 42 |
{ |
| 43 |
$epc_attachment_ids = $property->get_epc_attachment_ids(); |
| 44 |
|
| 45 |
if ( !empty($epc_attachment_ids) ) |
| 46 |
{ |
| 47 |
echo '<div class="epcs">'; |
| 48 |
|
| 49 |
echo '<h4>' . esc_html(__( 'EPCs', 'propertyhive' )) . '</h4>'; |
| 50 |
|
| 51 |
foreach ( $epc_attachment_ids as $attachment_id ) |
| 52 |
{ |
| 53 |
if ( wp_attachment_is_image($attachment_id) ) |
| 54 |
{ |
| 55 |
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>'; |
| 56 |
} |
| 57 |
else |
| 58 |
{ |
| 59 |
echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" target="_blank" rel="nofollow">' . esc_html(__( 'View EPC', 'propertyhive' )) . '</a>'; |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
echo '</div>'; |
| 64 |
} |
| 65 |
} |