# propertyhive/2.3.1/includes/avada-widgets/property-epcs-shortcode.php

Property Hive, version 2.3.1. 78 lines.

- Page: https://pluginprobe.com/plugins/propertyhive/2.3.1/code/includes/avada-widgets/property-epcs-shortcode.php
- Raw: https://pluginprobe.com/plugins/propertyhive/2.3.1/raw/includes/avada-widgets/property-epcs-shortcode.php
- Modified: 2026-09-16T09:29:48+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/propertyhive/2.3.1/code/includes/avada-widgets/property-epcs-shortcode.php#L10-L20`.

```php
<?php

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}


add_shortcode( 'avada_property_epcs', function( $atts ) {
    $atts = shortcode_atts( array(
        'show_title'    => '',
    ), $atts );

    if ( get_post_type( get_the_ID() ) != 'property' )
    {
    	return '';
    }

    fusion_element_rendering_elements( true );

    global $property;
    
    if ( empty($property) )
    {
        // 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.
        $property = new PH_Property(get_the_ID());
    }

    ob_start();

    if ( get_option('propertyhive_epcs_stored_as', '') == 'urls' )
    {
        $epc_urls = $property->_epc_urls;
        if ( is_array($epc_urls) && !empty( $epc_urls ) )
        {
            echo '<div class="epcs">';

            if ( $atts['show_title'] == 'yes' ) { echo '<h4>' . esc_html(__( 'EPCs', 'propertyhive' )) . '</h4>'; }

            foreach ($epc_urls as $epc)
            {
                echo '<a href="' . esc_url($epc['url']) . '" data-fancybox="epcs" rel="nofollow"><img src="' . esc_url($epc['url']) . '" alt=""></a>';
            }

            echo '</div>';
        }
    }
    else
    {
        $epc_attachment_ids = $property->get_epc_attachment_ids();

        if ( !empty($epc_attachment_ids) )
        {
            echo '<div class="epcs">';

            if ( $atts['show_title'] == 'yes' ) { echo '<h4>' . esc_html(__( 'EPCs', 'propertyhive' )) . '</h4>'; }

            foreach ( $epc_attachment_ids as $attachment_id )
            {
                if ( wp_attachment_is_image($attachment_id) )
                {
                    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>';
                }
                else
                {
                    echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" target="_blank" rel="nofollow">' . esc_html(__( 'View EPC', 'propertyhive' )) . '</a>';
                }
            }

            echo '</div>';
        }
    }

    $html = ob_get_clean();

    fusion_element_rendering_elements( false );

    return $html;
});
```
