function microdata_is_item in Microdata 7
Function to see if a field is an item or not.
@todo Try to remove the necessity for this logic.
1 call to microdata_is_item()
- microdata_preprocess_field in ./
microdata.module - Implements MODULE_preprocess_HOOK().
File
- ./
microdata.module, line 1150
Code
function microdata_is_item($entity_type, $entity, $field_name, $delta) {
$wrapper = entity_metadata_wrapper($entity_type, $entity);
$value = $wrapper->{$field_name}
->value();
if (!is_object($value)) {
// If the value is an array, we should test the correct entity, but
// compound fields would also have an array value, so test that the element
// in the delta position is an object.
if (is_array($value)) {
if (isset($value[$delta]) && is_object($value[$delta])) {
$value = $value[$delta];
}
}
else {
return FALSE;
}
}
return isset($value->microdata['#attributes']['itemscope']);
}