ACF\AI\Abilities
AbstractAbilityGroup::get_acf_fields_for_object
Retrieves the AI-enabled ACF fields for the provided object.
Метод класса: AbstractAbilityGroup{}
Хуков нет.
Возвращает
array.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_acf_fields_for_object( $object_type, $object_id );
- $object_type(строка) (обязательный)
- The object type being queried.
- $object_id(int|строка) (обязательный)
- The object to get ACF fields for.
Список изменений
| С версии 6.8.0 | Введена. |
Код AbstractAbilityGroup::get_acf_fields_for_object() AbstractAbilityGroup::get acf fields for object ACF 6.8.8
protected function get_acf_fields_for_object( $object_type, $object_id ) {
// Get field groups that show on this object.
$field_groups = acf_get_field_groups(
array(
$object_type => $object_id,
)
);
$acf_fields = array();
foreach ( $field_groups as $field_group ) {
// Only include AI-accessible field groups that are exposed in REST.
if ( empty( $field_group['allow_ai_access'] ) || empty( $field_group['show_in_rest'] ) ) {
continue;
}
$fields = acf_get_fields( $field_group['key'] );
if ( $fields ) {
$acf_fields[ $field_group['key'] ] = array(
'title' => $field_group['title'],
'key' => $field_group['key'],
'fields' => $this->format_acf_fields_for_schema( $fields ),
);
}
}
return $acf_fields;
}