ACF\AI\Abilities
AbstractAbilityGroup::add_acf_fields_to_schema
Adds ACF fields to a schema.
Method of the class: AbstractAbilityGroup{}
No Hooks.
Returns
array.
Usage
// protected - for code of main (parent) or child class $result = $this->add_acf_fields_to_schema( $schema, $acf_fields ): array;
- $schema(array) (required)
- The schema to add fields to.
- $acf_fields(array) (required)
- The ACF fields to add.
Changelog
| Since 6.8.0 | Introduced. |
AbstractAbilityGroup::add_acf_fields_to_schema() AbstractAbilityGroup::add acf fields to schema code ACF 6.8.8
protected function add_acf_fields_to_schema( array $schema, array $acf_fields ): array {
if ( empty( $acf_fields ) ) {
return $schema;
}
$schema['properties']['acf'] = array(
'type' => 'object',
'description' => 'ACF field values',
'required' => false,
'properties' => array(),
);
foreach ( $acf_fields as $field_group ) {
foreach ( $field_group['fields'] as $field ) {
$schema['properties']['acf']['properties'][ $field['name'] ] = $field;
}
}
return $schema;
}