Reads in fields that match an array of conditions.
array $conditions: An array of conditions to match against. Keys are names of properties found in field configuration files, and values are conditions to match.
array $include_additional: The default behavior of this function is to not return fields that are inactive or have been deleted. Setting $include_additional['include_inactive'] or $include_additional['include_deleted'] to TRUE will override this behavior.
An array of fields matching $params. If $include_additional['include_deleted'] is TRUE, the array is keyed by field ID, otherwise it is keyed by field name.
function field_read_fields($conditions = array(), $include_additional = array()) {
// Include inactive fields if specified in the $include_additional parameter.
$include_inactive = isset($include_additional['include_inactive']) && $include_additional['include_inactive'];
// Include deleted fields if specified either in the $include_additional or
// the $conditions parameters.
$include_deleted = isset($include_additional['include_deleted']) && $include_additional['include_deleted'] || isset($conditions['deleted']) && $conditions['deleted'];
// Pass include_inactive and include_deleted to the $conditions array.
$conditions['include_inactive'] = $include_inactive;
$conditions['include_deleted'] = $include_deleted;
return entity_load_multiple_by_properties('field_entity', $conditions);
}