Thanks for the help folks. Here it is...
<?php
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
if ( !defined( 'CVH_COUNTRYFIELD_DONT_DELETE' ) or !CVH_COUNTRYFIELD_DONT_DELETE )
{
foreach ( \IPS\Db::i()->select( '*', 'core_pfields_data', array( 'pf_type=?', 'CountryFieldCvh' ) ) AS $countryField )
{
$field = \IPS\core\ProfileFields\Field::load( $countryField[ 'pf_id' ] );
$field->delete();
}
foreach ( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'field_type=?', 'CountryFieldCvh' ) ) AS $countryField )
{
$field = \IPS\cms\Fields::load( $countryField[ 'field_id' ], $countryField[ 'field_database_id' ] );
$field->delete();
}
}