Skip to content

Instantly share code, notes, and snippets.

@propertyhive
Created September 8, 2021 09:47
Show Gist options
  • Save propertyhive/978efd25892d160ad37af7b562a9a431 to your computer and use it in GitHub Desktop.
Save propertyhive/978efd25892d160ad37af7b562a9a431 to your computer and use it in GitHub Desktop.
AgentsInsight Snippets
// Import AI field into custom field added using our free Template Assistant add on
add_action( "propertyhive_property_imported_agentsinsight_xml", 'import_custom_field', 10, 2 );
function import_custom_field($post_id, $property)
{
update_post_meta( $post_id, '_url', (string)$property->url );
}
// Customise the fields used in the AI import
add_action( "propertyhive_property_imported_agentsinsight_xml", 'customise_description_fields', 10, 2 );
function customise_description_fields( $post_id, $property )
{
$description_i = 0;
if ( isset($property->specification_description) && (string)$property->specification_description != '' )
{
update_post_meta( $post_id, '_description_name_' . $description_i, '' );
update_post_meta( $post_id, '_description_' . $description_i, (string)$property->specification_description );
++$description_i;
}
if ( isset($property->location) && (string)$property->location != '' )
{
update_post_meta( $post_id, '_description_name_' . $description_i, 'Location' );
update_post_meta( $post_id, '_description_' . $description_i, (string)$property->location );
++$description_i;
}
if ( isset($property->marketing_text_1) && (string)$property->marketing_text_1 != '' )
{
update_post_meta( $post_id, '_description_name_' . $description_i, (string)$property->marketing_title_1 );
update_post_meta( $post_id, '_description_' . $description_i, (string)$property->marketing_text_1 );
++$description_i;
}
if ( isset($property->marketing_text_2) && (string)$property->marketing_text_2 != '' )
{
update_post_meta( $post_id, '_description_name_' . $description_i, (string)$property->marketing_title_2 );
update_post_meta( $post_id, '_description_' . $description_i, (string)$property->marketing_text_2 );
++$description_i;
}
if ( isset($property->marketing_text_3) && (string)$property->marketing_text_3 != '' )
{
update_post_meta( $post_id, '_description_name_' . $description_i, (string)$property->marketing_title_3 );
update_post_meta( $post_id, '_description_' . $description_i, (string)$property->marketing_text_3 );
++$description_i;
}
if ( isset($property->marketing_text_4) && (string)$property->marketing_text_4 != '' )
{
update_post_meta( $post_id, '_description_name_' . $description_i, (string)$property->marketing_title_4 );
update_post_meta( $post_id, '_description_' . $description_i, (string)$property->marketing_text_4 );
++$description_i;
}
if ( isset($property->marketing_text_5) && (string)$property->marketing_text_5 != '' )
{
update_post_meta( $post_id, '_description_name_' . $description_i, (string)$property->marketing_title_5 );
update_post_meta( $post_id, '_description_' . $description_i, (string)$property->marketing_text_5 );
++$description_i;
}
if ( isset($property->marketing_text_transport) && (string)$property->marketing_text_transport != '' )
{
update_post_meta( $post_id, '_description_name_' . $description_i, (string)$property->marketing_title_transport );
update_post_meta( $post_id, '_description_' . $description_i, (string)$property->marketing_text_transport );
++$description_i;
}
update_post_meta( $post_id, '_descriptions', $description_i );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment