ACF\Site_Health

AI_Usage::get_ai_ready_countspublicACF 6.8.0

Get AI-ready object counts for Site Health display.

Method of the class: AI_Usage{}

No Hooks.

Returns

Array. Counts of AI-ready objects by type.

Usage

$AI_Usage = new AI_Usage();
$AI_Usage->get_ai_ready_counts( $field_groups, $post_types, $taxonomies ): array;
$field_groups(array) (required)
An array of ACF field groups.
$post_types(array) (required)
An array of ACF post types.
$taxonomies(array) (required)
An array of ACF taxonomies.

Changelog

Since 6.8.0 Introduced.

AI_Usage::get_ai_ready_counts() code ACF 6.8.8

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;
}