Determine whether a field has any data.
$field: A field structure.
TRUE if the field has data for any entity; FALSE otherwise.
function field_has_data($field) {
$query = new EntityFieldQuery();
$query = $query
->fieldCondition($field)
->range(0, 1)
->count()
->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
return (bool) $query
->execute() || (bool) $query
->age(FIELD_LOAD_REVISION)
->execute();
}