ACF_Local_JSON::get_filespublicACF 5.9.0

Returns an array of found JSON files.

Метод класса: ACF_Local_JSON{}

Хуков нет.

Возвращает

Массив.

Использование

$ACF_Local_JSON = new ACF_Local_JSON();
$ACF_Local_JSON->get_files( $post_type );
$post_type(строка)
The ACF post type to get files for.
По умолчанию: 'acf-field-group'

Список изменений

С версии 5.9.0 Введена.

Код ACF_Local_JSON::get_files() ACF 6.4.2

public function get_files( $post_type = 'acf-field-group' ) {
	$files = array();

	foreach ( $this->files as $key => $path ) {
		$internal_post_type = acf_determine_internal_post_type( $key );

		if ( $internal_post_type === $post_type ) {
			$files[ $key ] = $path;
		} elseif ( 'acf-field-group' === $post_type ) {
			// If we can't figure out the ACF post type, make an educated guess that it's a field group.
			$json = json_decode( file_get_contents( $path ), true );
			if ( ! is_array( $json ) ) {
				continue;
			}

			if ( isset( $json['fields'] ) ) {
				$files[ $key ] = $path;
			}
		}
	}

	return $files;
}