Skip to content

Instantly share code, notes, and snippets.

@g-maclean
g-maclean / snippet.php
Created April 24, 2025 20:23
PropertyHive - IAmProperty RTDF rewrite rules
//flush rewrite rules after adding: Dashboard->Settings->Permalinks->Save
add_action( 'init', 'iamproperty_rtdf_endpoints_rewrite_rules');
function iamproperty_rtdf_endpoints_rewrite_rules() {
add_rewrite_rule(
'^([0-9]+)/sendpropertydetails[/]?',
'index.php?rtdf=1&rtdf_action=sendpropertydetails&import_id=$matches[1]',
'top'
);
add_rewrite_rule(
'^([0-9]+)/removeproperty[/]?',
@g-maclean
g-maclean / snippet.php
Last active April 17, 2025 11:58
ProeprtyHive - Foundations - Use Ref ID as Title
add_action( "propertyhive_property_imported_reapit_foundations_json", 'use_ref_as_post_title', 10, 2 );
function use_ref_as_post_title($post_id, $property)
{
if ( isset($property['id']) && $property['id'] != '' )
{
$new_title = $property['id'];
$my_post = array(
'ID' => $post_id,
'post_title' => wp_strip_all_tags( $new_title ),
'post_name' => wp_strip_all_tags( $new_title )
@g-maclean
g-maclean / snippet.php
Created April 9, 2025 11:05
PropertyHive - Avantio - Use Original Image Size
add_filter('propertyhive_avantio_xml_image_size', 'use_original_image_url', 10, 2);
function use_original_image_url($image, $property)
{
return (string)$image->OriginalURI;
}
@g-maclean
g-maclean / snippet.php
Created April 8, 2025 21:30
PropertyHive - admin columns modification example - remove Size, add Location
// remove size column
function remove_size_column($columns) {
unset($columns['size']);
return $columns;
}
add_filter('manage_edit-property_columns', 'remove_size_column', 11);
// Step 1: Add the Location column to the Property post type
add_filter('manage_property_posts_columns', 'add_property_location_column');
function add_property_location_column($columns) {
@g-maclean
g-maclean / snippet.php
Created March 28, 2025 11:21
PropertyHive - Kyero Import Virtual Tour
add_action( "propertyhive_property_imported_kyero_xml", 'import_virtual_tour_kyero', 10, 2 );
function import_virtual_tour_kyero( $post_id, $property )
{
if ( isset($property->virtual_tour_url) && !empty($property->virtual_tour_url) )
{
update_post_meta( $post_id, '_virtual_tour_0', (string)$property->virtual_tour_url );
update_post_meta( $post_id, '_virtual_tour_label_0', __( 'Virtual Tour', 'propertyhive' ));
}
}
@g-maclean
g-maclean / snippet.php
Last active March 28, 2025 11:10
PropertyHive - Show login required popup for shortlist shortcode
add_shortcode('force_login_shortlist_button', 'force_login_shortlist_button');
function force_login_shortlist_button()
{
if ( is_user_logged_in() )
{
return do_shortcode('[shortlist_button class="action-shortlist"]');
}
$assets_path = str_replace( array( 'http:', 'https:' ), '', PH()->plugin_url() ) . '/assets/';
@g-maclean
g-maclean / snippet.php
Created March 27, 2025 17:02
PropertyHive - Foundations - Import BER
add_action( "propertyhive_property_imported_reapit_foundations_json", 'import_ber_foundations', 10, 2 );
function import_ber_foundations( $post_id, $property )
{
$rating = isset( $property['regional']['irl']['buildingEnergyRating']['rating'] ) ? $property['regional']['irl']['buildingEnergyRating']['rating'] : '';
$ber_id = isset( $property['regional']['irl']['buildingEnergyRating']['refNumber'] ) ? $property['regional']['irl']['buildingEnergyRating']['refNumber'] : '';
update_post_meta( $post_id, '_ber_rating', $rating );
update_post_meta( $post_id, '_ber_id', $ber_id );
}
@g-maclean
g-maclean / snippet.php
Created March 26, 2025 11:03
PropertyHive - Force login to use shortlist feature
add_filter( 'propertyhive_single_property_actions', 'force_user_login_for_shortlist', 999 );
function force_user_login_for_shortlist( $actions )
{
//if user is logged in skip
if ( is_user_logged_in() )
{
return $actions;
}
// get shortlist action
@g-maclean
g-maclean / snippet.php
Last active March 17, 2025 20:04
PropertyHive - Elementor order by availability change
//NOT for main search page, but for standalone loop grids
//use orderbyavailabilitychange in the queryID field
function custom_elementor_loop_order_availability_change($query) {
$query->set('meta_key', '_availability_change_date');
$query->set('orderby', 'meta_value');
$query->set('order', 'DESC');
}
add_action('elementor/query/orderbyavailabilitychange', 'custom_elementor_loop_order_availability_change');
@g-maclean
g-maclean / snippet.php
Created March 10, 2025 15:49
ProeprtyHive - Reapit Foundations filter properties by Reapit office ID on import
add_filter( "propertyhive_reapit_foundations_json_properties_due_import", 'remove_non_auction_properties' );
function remove_non_auction_properties( $properties )
{
$office_ids = array( 1, 2, 3 );
$new_properties = array();
foreach ( $properties as $property )
{
if ( isset( $property['officeIds'] ) && is_array( $property['officeIds'] ) && count( $property['officeIds'] ) > 0 )
{
if(in_array($property['officeIds'][0], $office_ids))