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_agentsinsight_xml', 'import_kato_dates', 10, 2 ); | |
| function import_kato_dates( $post_id, $property ) | |
| { | |
| // Created At | |
| if ( isset( $property->created_at ) && (string) $property->created_at != '' ) { | |
| update_post_meta( $post_id, '_kato_created_at', (string) $property->created_at ); | |
| } | |
| // Last Updated |
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
| /** | |
| * Custom Property details shortcode | |
| * Usage: [property_details] | |
| */ | |
| function my_property_details_shortcode() { | |
| // Make sure Property Hive is active. | |
| if ( ! class_exists( 'PH_Property' ) ) { | |
| return ''; | |
| } |
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_reapit_foundations_json', 'reapit_alt_url', 10, 2 ); | |
| function reapit_alt_url( $post_id, $property ) { | |
| // Used for the post title | |
| $full_address_parts = array_filter( array( | |
| $property['address']['line1'] ?? '', | |
| $property['address']['line2'] ?? '', | |
| $property['address']['line3'] ?? '', | |
| $property['address']['line4'] ?? '', |
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( 'pre_get_posts', function( $query ) { | |
| if ( is_admin() ) { | |
| return; | |
| } | |
| // Adjust this condition if the plugin uses a shortcode/custom query. | |
| if ( $query->get( 'post_type' ) !== 'office') { | |
| return; | |
| } |
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_valpal_email_to', 'my_valpal_email_recipient', 10, 4); | |
| function my_valpal_email_recipient($to, $post_data, $result, $return) { | |
| // Make sure required values exist | |
| if (empty($return['postcode']) || empty($post_data['valuation_type'])) { | |
| return $to; | |
| } | |
| $postcode = strtoupper(trim($return['postcode'])); |
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_reapit_foundations_json_properties_due_import", 'strip_second_part_of_postcode' ); | |
| function strip_second_part_of_postcode( $properties ) | |
| { | |
| foreach ( $properties as &$property ) | |
| { | |
| if ( !empty($property['address']['postcode']) ) | |
| { | |
| // Trim whitespace first | |
| $postcode = trim($property['address']['postcode']); |
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
| function order_shortcode_by_available_change_date( $args, $atts ) | |
| { | |
| global $post; | |
| if ( $post->ID == 11500 ) // track record page only | |
| { | |
| // Only include properties where _site_area_to > 100000 | |
| $args['meta_query'] = array( | |
| array( | |
| 'key' => '_site_area_to', |
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', 'use_public_address_as_title', 10, 2); | |
| function use_public_address_as_title($post_id, $property) | |
| { | |
| if (isset($property['public_address']) && $property['public_address'] != '') | |
| { | |
| $new_title = wp_strip_all_tags($property['public_address']); | |
| $new_slug = sanitize_title($new_title); | |
| // Default excerpt |
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( 'ph_rtdf_send_request_data', 'set_price_qualifier_for_commercial_rent', 10, 2 ); | |
| function set_price_qualifier_for_commercial_rent( $request_data, $post_id ) { | |
| $property = new PH_Property( $post_id ); | |
| if ( ! $property ) { | |
| return $request_data; | |
| } |
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( 'ph_rtdf_send_request_data', 'amend_property_request_data', 10, 2 ); | |
| function amend_property_request_data( $request_data, $post_id ) | |
| { | |
| $floor_area_raw = get_post_meta($post_id, '_floor_area', true); | |
| if ( !empty($floor_area_raw) ) | |
| { | |
| // Remove anything that isn't a number or decimal point | |
| $floor_area = preg_replace('/[^0-9.]/', '', $floor_area_raw); |