Skip to content

Instantly share code, notes, and snippets.

@propertyhive
propertyhive / gist:f3e31b81e9ebbb9206703368eae8691d
Created March 3, 2025 10:59
Get list of unsubscribed contacts
SELECT p.ID AS contact_id,
p.post_title AS contact_name,
pm.meta_value AS email_address,
c.comment_date
FROM wp_posts p
INNER JOIN wp_comments c ON p.ID = c.comment_post_ID
LEFT JOIN wp_postmeta pm ON p.ID = pm.post_id AND pm.meta_key = '_email_address'
WHERE p.post_type = 'contact'
AND c.comment_type = 'propertyhive_note'
AND c.comment_content LIKE '%unsubscribe%'
add_action( "propertyhive_property_imported_blm", "import_blm_custom_fields", 10, 2 );
function import_blm_custom_fields($post_id, $property)
{
// Assuming CUSTOM_FIELD_OTHER_LINK_00 is always a flipbook
if ( isset($property['CUSTOM_FIELD_OTHER_LINK_00']) && $property['CUSTOM_FIELD_OTHER_LINK_00'] != '' )
{
update_post_meta( $post_id, '_flipbook_url', $property['CUSTOM_FIELD_OTHER_LINK_00'] );
}
}
@propertyhive
propertyhive / gist:3679b558998c6b767fcd33ee3e53d866
Last active February 26, 2025 12:21
Add fees in lightbox as new action button
add_filter( 'propertyhive_single_property_actions', 'add_fees_action' );
function add_fees_action( $actions )
{
global $property;
if ( $property->department == 'residential-lettings' )
{
$fees = nl2br(get_option('propertyhive_lettings_fees', ''));
if (!empty($fees))
{
jQuery(document).ready(function() {
// Wait for the sliders to initialize
setTimeout(function() {
jQuery(".search-form-slider-bedrooms_slider").each(function() {
var slider = jQuery(this);
var label = slider.closest("form").find(".search-form-slider-value-bedrooms_slider");
// Hook into the slide event to modify the values
slider.slider("option", "slide", function(event, ui) {
var minVal = ui.values[0];
@propertyhive
propertyhive / gist:c50ff09bed1cf9b617aa5d5a359cf1b9
Created February 24, 2025 13:34
Remove address line 2 from being queried
add_filter( 'propertyhive_address_fields_to_query', 'custom_address_fields' );
function custom_address_fields( $address_fields_to_query)
{
if (($key = array_search('_address_two', $address_fields_to_query)) !== false)
{
unset($address_fields_to_query[$key]);
}
return $address_fields_to_query;
}
function ep_propertyhive_enquiry_form_shortcode()
{
global $post;
ob_start();
// Get Property Hive post ID so we can use that as post ID instead of the Residence post ID
$hive_post_id = get_post_meta( $post->ID, '_propertyhive_property_id', TRUE );
propertyhive_enquiry_form($hive_post_id);
add_action( "propertyhive_wpresidence_property_synced", 'hive_availability_in_action_category_in_wpr', 10, 3 );
function hive_availability_in_action_category_in_wpr( $hive_post_id, $wpr_post_id, $synced )
{
if ( $synced === true )
{
$property = new PH_Property((int)$hive_post_id);
$hive_availability = $property->availability;
wp_set_object_terms( $wpr_post_id, $hive_availability, "property_action_category" );
@propertyhive
propertyhive / gist:af8ac8475372f3695fab9c076fa02aaa
Last active February 17, 2025 14:43
Changed imported media filenames
add_filter( 'propertyhive_property_import_media_filename', 'custom_filename', 10, 2 );
function custom_filename($filename, $post_id)
{
$filename = str_replace(".", "-" . $post_id . "-" . time() . ".", $filename);
return $filename;
}
add_action( 'elementor/query/propertiesorderedbyprice', 'elementor_query_ordered_by_price' );
function elementor_query_ordered_by_price( $query )
{
$query->set('orderby', 'meta_value_num');
$query->set('order', 'DESC');
$query->set('meta_key', '_price_actual');
}
@propertyhive
propertyhive / gist:807823423db7dc481d40383adddeb150
Created February 12, 2025 10:28
Import different size image when importing from other Houzez site as to not get large/massive images
add_filter( 'houzez_property_feed_wp_rest_api_houzez_media_source_url', 'different_source_url', 10, 2);
function different_source_url($url, $attachment)
{
if ( isset($attachment['media_details']['sizes']['1536x1536']['source_url']) && !empty($attachment['media_details']['sizes']['1536x1536']['source_url']) )
{
return $attachment['media_details']['sizes']['1536x1536']['source_url'];
}
return $url;
}