This file contains hidden or 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
| add_filter( 'propertyhive_single_property_actions', 'remove_floorplans_action' ); | |
| function remove_floorplans_action( $actions ) | |
| { | |
| foreach ( $actions as $i => $action ) | |
| { | |
| if ( isset( $action['class'] ) && $action['class'] === 'action-floorplans' ) | |
| { | |
| unset( $actions[ $i ] ); | |
| } | |
| } |
This file contains hidden or 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
| // Shortcode: [ph_active_properties_count department="residential-sales"] | |
| add_shortcode( 'ph_active_properties_count', function ( $atts ) { | |
| $atts = shortcode_atts([ | |
| 'department' => '', | |
| ], $atts); | |
| $meta_query = [ | |
| [ | |
| 'key' => '_on_market', |
This file contains hidden or 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
| add_action( "propertyhive_property_imported_street_json", function( $post_id, $property ) { | |
| if ( isset( $property['attributes']['tenure'] ) && $property['attributes']['tenure'] == 'Leasehold' && isset( $property['attributes']['lease_expiry_date'] ) && is_numeric( $property['attributes']['lease_expiry_date'] ) ) { | |
| $date1 = new DateTime(); | |
| $date2 = new DateTime( $property['attributes']['lease_expiry_date'] ); | |
| $days = $date1->diff($date2)->days; | |
| $years = ceil($days / 365.2425); // round up |
This file contains hidden or 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
| add_action( "propertyhive_property_imported_xml", function( $post_id, $property, $import_id ) { | |
| update_post_meta( $post_id, '_realtime_portal_0', 'yes' ); | |
| }, 10, 3 ); |
This file contains hidden or 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
| // currently, when meta_key is used in the properties shortcode it effectively remvoes the price sorting, this restores it | |
| add_filter( 'propertyhive_shortcode_properties_query', function( $args, $atts ) { | |
| // Only apply when shortcode is filtering investment properties | |
| if ( | |
| empty( $atts['meta_key'] ) || | |
| $atts['meta_key'] !== '_investment_property' | |
| ) { | |
| return $args; | |
| } |
This file contains hidden or 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
| add_action( 'propertyhive_property_imported_street_json', function( $post_id, $property ) { | |
| wp_suspend_cache_invalidation( true ); | |
| wp_defer_term_counting( true ); | |
| wp_defer_comment_counting( true ); | |
| $is_on_market = false; | |
| if ( isset( $property['lettingsListing'], $property['lettingsListing']['status'] ) ) { | |
| $status = trim( (string) $property['lettingsListing']['status'] ); |
This file contains hidden or 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
| add_action( 'propertyhive_property_imported_street_json', function( $post_id, $property ) { | |
| if ( empty( $property['address']['line_2'] ) ) { | |
| return; // nothing to do | |
| } | |
| $line_2 = trim( $property['address']['line_2'] ); | |
| $parts = explode( ' ', $line_2 ); | |
| // Match: 100, 100b, 12A etc |
This file contains hidden or 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
| add_action( "propertyhive_wpresidence_property_synced", 'set_property_user', 10, 3 ); | |
| function set_property_user($property_id, $post_id, $synced) | |
| { | |
| // Import ID => WordPress User ID | |
| $import_to_user_map = array( | |
| '1000000' => 10, | |
| '1000001' => 11, | |
| '1000002' => 12, | |
| ); |
This file contains hidden or 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
| add_filter( 'propertyhive_form_taxonomy_terms_args', 'custom_form_taxonomy_terms_args', 10, 2 ); | |
| function custom_form_taxonomy_terms_args( $args, $field ) { | |
| if ( $field['type'] == 'property_type' ) { | |
| $args['include'] = array( 1, 2, 3 ); // Replace with your desired term IDs from Property Hive -> Settings -> Custom Fields -> Residential Property Types | |
| } | |
| return $args; | |
| } |
This file contains hidden or 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
| // for use when the embedded area isn't populated or doesn't work for some reason | |
| add_action( "propertyhive_property_imported_reapit_foundations_json", "assign_location_from_multiple_fields", 10, 2 ); | |
| function assign_location_from_multiple_fields( $post_id, $property ) { | |
| $location_set = false; | |
| $fields_to_check = array( 'line2', 'line3' ); | |
| foreach ( $fields_to_check as $field ) { |
NewerOlder