-
-
Save fseonline/39b34dbe900b640a060ee9daf42649ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function url_exists($url) { | |
if (!$fp = curl_init($url)) return false; | |
return true; | |
} | |
$upload_dir = wp_upload_dir(); | |
$propertiesXML = 'https://services.jupix.co.uk/api/get_properties.php?clientID=ae5ea52e914b984e17a4992b977fd466&passphrase=4911a15731cc6fdb9773f0febc002d63'; | |
if( url_exists( $propertiesXML ) ): | |
// Let's get the XML file for the properties... | |
$properties = new SimpleXMLElement( file_get_contents( $propertiesXML ) ); | |
$property = $properties->property; | |
$properties_size = sizeof($properties); | |
$has_featured_property = false; | |
$propertyofweek_web_link = ''; | |
$propertyofweek_main_summary = ''; | |
// Let's get the first 'featuredProperty' we can find... | |
// Then break apart once we find it! | |
for ($i=0; $i < $properties_size; $i++) { | |
if( $property[$i]->featuredProperty == '1' ) { | |
$has_featured_property = true; | |
$propertyofweek_price_text = number_format((string)$property[$i]->price); | |
$propertyofweek_main_summary = $property[$i]->mainSummary; | |
if( $propertyofweek_main_summary !== '' ) { | |
$propertyofweek_main_summary = $property[$i]->fullDescription; | |
} | |
$propertyofweek_advert_heading = $property[$i]->addressStreet . ', ' . $property[$i]->address3; | |
$propertyofweek_web_link = $property[$i]->virtualTours->virtualTour; | |
// Expert Agent bug. | |
// So we'll remove the 'https//' (bug is the missing colon...) | |
// And add the 'https://' ourselves | |
$propertyofweek_web_link = ($pos=strpos($propertyofweek_web_link,"//"))?substr($propertyofweek_web_link,$pos+2):$propertyofweek_web_link; | |
$propertyofweek_web_link = 'https://' . $propertyofweek_web_link; | |
$propertyofweek_picture_filename = $property[$i]->images->image; | |
break; | |
} | |
} | |
if( $has_featured_property ): | |
?> | |
<section class="featured-property section-featured-property"> | |
<div class="row no-gutters"> | |
<div class="col-12 col-lg-6"> | |
<a href="<?php echo $propertyofweek_web_link; ?>" target="_blank"> | |
<div class="featured-property__video"> | |
<style media="screen"> | |
.featured-property__video { | |
background-image: url('<?php echo $propertyofweek_picture_filename; ?>'); | |
} | |
</style> | |
</div> | |
</a> | |
</div> | |
<div class="col-12 col-lg-6"> | |
<div class="featured-property__content ml-auto mr-auto ml-lg-0"> | |
<h2 class="featured-property__content__heading">Featured Property</h2> | |
<h3 class="featured-property__content__property-title"><?php echo $propertyofweek_advert_heading; ?></h3> | |
<div class="featured-property__content__price"> | |
<span>£<?php echo $propertyofweek_price_text; ?></span> | |
</div> | |
<?php if( $propertyofweek_main_summary !== '' ): ?> | |
<p class="featured-property__content__description"><?php echo limit_words( $propertyofweek_main_summary, 26 ) . '…'; ?></p> | |
<?php endif; ?> | |
<?php if( $propertyofweek_web_link !== '' ): ?> | |
<a class="btn btn--primary-1 mt-3" href="<?php echo $propertyofweek_web_link; ?>" target="_blank">View Property</a> | |
<?php endif; ?> | |
</div> | |
</div> | |
</div> | |
</section> | |
<?php endif; ?> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment