Skip to content

Instantly share code, notes, and snippets.

@propertyhive
Created October 29, 2025 09:02
Show Gist options
  • Save propertyhive/82480a3dca23fa34e6f8b1fddf868630 to your computer and use it in GitHub Desktop.
Save propertyhive/82480a3dca23fa34e6f8b1fddf868630 to your computer and use it in GitHub Desktop.
add_filter( "propertyhive_arthur_json_properties_due_import", 'property_tags_on_unit', 10, 2 );
function property_tags_on_unit( $properties, $import_id )
{
foreach ( $properties as $i => $property )
{
$tags = isset($property['tags']) && !empty($property['tags']) ? $property['tags'] : array();
if ( !empty($tags) )
{
if (
isset($property['units']) && is_array($property['units']) && !empty($property['units'])
)
{
foreach ( $property['units'] as $unit_i => $unit )
{
$unit_tags = isset($unit['tags']) && !empty($unit['tags']) ? $unit['tags'] : array();
$unit_tags = array_merge($unit_tags, $tags);
$unit_tags = array_unique($unit_tags);
$properties[$i]['units'][$unit_i]['tags'] = $unit_tags;
}
}
}
}
return $properties;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment