ACF\Site_Health
AI_Usage::get_ai_ready_counts
Get AI-ready object counts for Site Health display.
Метод класса: AI_Usage{}
Хуков нет.
Возвращает
array. Counts of AI-ready objects by type.
Использование
$AI_Usage = new AI_Usage(); $AI_Usage->get_ai_ready_counts( $field_groups, $post_types, $taxonomies ): array;
- $field_groups(массив) (обязательный)
- An array of ACF field groups.
- $post_types(массив) (обязательный)
- An array of ACF post types.
- $taxonomies(массив) (обязательный)
- An array of ACF taxonomies.
Список изменений
| С версии 6.8.0 | Введена. |
Код AI_Usage::get_ai_ready_counts() AI Usage::get ai ready counts ACF 6.8.11
public function get_ai_ready_counts( $field_groups, $post_types, $taxonomies ): array {
$counts = array(
'field_groups' => 0,
'post_types' => 0,
'taxonomies' => 0,
);
// Count AI-ready field groups.
foreach ( $field_groups as $field_group ) {
if ( ! empty( $field_group['allow_ai_access'] ) && ! empty( $field_group['active'] ) ) {
++$counts['field_groups'];
}
}
// Count AI-ready post types.
foreach ( $post_types as $post_type ) {
if ( ! empty( $post_type['allow_ai_access'] ) && ! empty( $post_type['active'] ) ) {
++$counts['post_types'];
}
}
// Count AI-ready taxonomies.
foreach ( $taxonomies as $taxonomy ) {
if ( ! empty( $taxonomy['allow_ai_access'] ) && ! empty( $taxonomy['active'] ) ) {
++$counts['taxonomies'];
}
}
return $counts;
}