Template Functions epl_has_matterport, epl_mp_has_video, epl_get_matterport_urls

Use these functions in your listing templates to check for a 3D tour before you output anything for it, for example a "3D Tour" heading. They use the same detection as the extension: the Matterport Domains setting, all six link fields, and each tour counted once even if it's pasted in several fields.

epl_has_matterport()

Returns true when the listing has at least one tour. Pass a listing ID, or leave it out to use the current listing.

<?php
if ( function_exists( 'epl_has_matterport' ) && epl_has_matterport() ) {
	?>
	<div id="tour" class="epl-section-inner__panel epl-section-inner__panel--tour">
		<h3 class="epl-section-inner__title">3D Tour</h3>
		<?php echo do_shortcode( '[epl_matterport]' ); ?>
	</div>
	<?php
}
?>

The function_exists() check keeps the template working if the extension is ever deactivated.

epl_mp_has_video()

Returns true when the listing has a real video in the Video URL field. A 3D tour link in the video field doesn't count, so a "Video" section isn't shown for a tour. Use it in place of a plain check of the video field:

<?php
$has_video = function_exists( 'epl_mp_has_video' ) ? epl_mp_has_video() : '' !== get_property_meta( 'property_video_url' );
if ( $has_video ) {
	do_action( 'epl_property_video' );
}
?>

epl_get_matterport_urls()

Returns the listing's tour links as an array keyed by field, for example array( 'property_external_link' => 'https://my.matterport.com/show/?m=…' ). Each tour appears once. Takes an optional listing ID.

<?php
$tours = function_exists( 'epl_get_matterport_urls' ) ? epl_get_matterport_urls() : array();
echo count( $tours ) . ' 3D tours';
?>

See also: [epl_matterport] Shortcode and Matterport Developer Filters.