ACF\AI\GEO
FieldSettings::get_output_format_choices
Get output format choices for a field
Returns the valid output formats for the field's type and selected property. For example, an Image field mapped to the 'image' property can output either 'URL' or 'ImageObject'.
Method of the class: FieldSettings{}
Hooks from the method
Returns
array. Array of format => label pairs.
Usage
// private - for code of main (parent) class only $result = $this->get_output_format_choices( $field );
- $field(array) (required)
- The field being edited.
Changelog
| Since 6.8.0 | Introduced. |
FieldSettings::get_output_format_choices() FieldSettings::get output format choices code ACF 6.8.8
private function get_output_format_choices( $field ) {
$field_type = $field['type'] ?? '';
$qualified_property = $field['schema_property'] ?? '';
// If no property selected yet, return empty choices.
if ( empty( $qualified_property ) ) {
return array();
}
// Extract just the property name from qualified property (e.g., "Recipe.recipeYield" -> "recipeYield").
$property = Schema::get_property_name( $qualified_property );
$valid_formats = Schema::get_valid_output_formats( $field_type, $property );
if ( empty( $valid_formats ) ) {
return array();
}
// Build choices array with format as both key and label.
$choices = array();
foreach ( $valid_formats as $format ) {
$choices[ $format ] = $format;
}
/**
* Filter the available output format choices.
*
* @param array $choices The output format choices.
* @param string $field_type The ACF field type.
* @param string $property The selected Schema.org property.
*/
return apply_filters( 'acf/schema/output_format_choices', $choices, $field_type, $property );
}