Skip to content

Instantly share code, notes, and snippets.

@g-maclean
g-maclean / snippet.php
Last active November 4, 2025 13:51
Property Hive - shortcode to output address without number
function ph_address_no_number_shortcode( $atts ) {
global $property;
// Do nothing if $property object isn't available
if ( ! isset( $property ) || ! is_object( $property ) ) {
return '';
}
// Shortcode attributes: separator, optional HTML tag, optional class
$atts = shortcode_atts( array(
@g-maclean
g-maclean / snippet.php
Created October 1, 2025 06:07
PropertyHive - Agent Insight - abbreviated floors / floorunit
add_filter( 'propertyhive_import_agentsinsight_units_description_table_data_columns', 'custom_data_columns' );
function custom_data_columns( $columns )
{
if ( isset($columns['name']) )
{
// Map of codes to labels
$floor_map = array(
'lg' => 'Lower Ground',
'g' => 'Ground',
'm' => 'Mezzanine',
@g-maclean
g-maclean / snippet.php
Created September 16, 2025 15:28
Property Hive - Shortcode to output council tax band
// [council_tax_band]
add_shortcode('council_tax_band', 'council_tax_band_shortcode');
function council_tax_band_shortcode($atts) {
global $property;
$council_tax_band = $property->council_tax_band;
if ( !empty($council_tax_band) ) {
return '<div class="council-tax-band">Council Tax Band: ' . esc_html($council_tax_band) . '</div>';
} else {
@g-maclean
g-maclean / snippet.php
Created September 3, 2025 14:16
Property Hive - Kyero - import plot size
add_action( "propertyhive_property_imported_kyero_xml", 'import_plot_size', 10, 2 );
function import_plot_size($post_id, $property)
{
if ( isset($property->surface_area) && isset($property->surface_area->plot) && !empty($property->surface_area->plot) ) {
update_post_meta( $post_id, '_plot_size', $property->surface_area->plot );
}
}
@g-maclean
g-maclean / snippet.php
Last active September 8, 2025 06:56
Property Hive - add view shortlist button to results page
add_action('propertyhive_before_search_results_loop', 'add_view_shortlist_button', 50);
function add_view_shortlist_button() {
if ( isset($_GET['shortlisted']) && $_GET['shortlisted'] == '1' ) {
echo '<div class="view-shortlist-container" style="clear: both;">
<a href="/search/" class="button view-shortlist-button">Back to Search</a>
</div>';
}
echo '<div class="view-shortlist-container" style="clear: both;">
<a href="/search/?shortlisted=1" class="button view-shortlist-button">View Shortlist</a>
</div>';
@g-maclean
g-maclean / snippet.php
Last active September 29, 2025 05:49
Property Hive - Alto - Assign additional field let type for student properties
add_action( "propertyhive_property_imported_vebra_api_xml", 'assign_student_let_type', 10, 2 );
function assign_student_let_type($post_id, $property)
{
$is_student = false;
// Check conditions
if ( isset($property->rm_let_type_id) && strtolower((string)$property->rm_let_type_id) == '3' ) {
$is_student = true;
}
@g-maclean
g-maclean / snippet.php
Created August 28, 2025 14:38
PropertyHive - custom shortcode for outputting a custom bulleted list
add_shortcode('property_details_list', 'custom_property_details_list_shortcode');
function custom_property_details_list_shortcode($atts) {
global $post;
$property = new PH_Property($post->ID);
$details = array(
'Price' => $property->price,
'Property Type' => $property->get_property_type(),
'Bedrooms' => $property->bedrooms,
@g-maclean
g-maclean / snippet.php
Created August 26, 2025 09:24
Property Hive - MRI Thesauraus - Import interactive floorplan
add_action( "propertyhive_property_imported_thesaurus_xml", 'import_interactive_floorplan', 10, 2 );
function import_interactive_floorplan($post_id, $property)
{
$virtual_tours = array();
for ($i = 245; $i <= 247; ++$i)
{
if (
$property[$i] != '' &&
(
strpos(strtolower($property[$i]), 'metropix') !== FALSE
@g-maclean
g-maclean / snippet.php
Created August 7, 2025 10:46
PropertyHive - Jupix - Import parking types
add_action( "propertyhive_property_imported_jupix_xml", 'assign_parking_taxonomy', 10, 2 );
function assign_parking_taxonomy($post_id, $property)
{
if ( isset($property->parking) && isset($property->parking->type) )
{
$parking_types = array();
if (isset($property->parking) && isset($property->parking->type)) {
foreach ($property->parking->type as $type) {
if (trim((string)$type) != '') {
$parking_types[] = sanitize_text_field((string)$type);
@g-maclean
g-maclean / snippet.php
Created August 5, 2025 13:00
PropertyHive - Remove office and location from reg form
add_filter( 'propertyhive_applicant_registration_form_fields', 'remove_location_and_hide_office_id', 10, 1 );
function remove_location_and_hide_office_id( $form_controls ) {
// Remove 'location' from the form controls
if ( isset($form_controls['location']) ) {
unset($form_controls['location']);
}
// Hide 'office_id' from the form controls
if ( isset($form_controls['office_id']) ) {
$form_controls['office_id']['type'] = 'hidden';