_acf_apply_get_local_internal_posts()ACF 6.1

Appends local ACF internal post types to the provided array.

Внутренняя функция — эта функция рассчитана на использование самим ядром. Не рекомендуется использовать эту функцию в своем коде.

Хуков нет.

Возвращает

Массив.

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

_acf_apply_get_local_internal_posts( $posts, $post_type );
$posts(массив)
An array of ACF posts.
По умолчанию: array()
$post_type(строка)
The ACF internal post type being loaded.
По умолчанию: 'acf-field-group'

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

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

Код _acf_apply_get_local_internal_posts() ACF 6.4.2

function _acf_apply_get_local_internal_posts( $posts = array(), $post_type = 'acf-field-group' ) {
	// Get local posts.
	$local_posts = acf_get_local_internal_posts( $post_type );

	if ( ! $local_posts ) {
		return $posts;
	}

	// Generate map of "index" => "key" data.
	$map = wp_list_pluck( $posts, 'key' );

	// Loop over local posts and update/append local.
	foreach ( $local_posts as $post ) {
		$i = array_search( $post['key'], $map, true );
		if ( $i !== false ) {
			unset( $post['ID'] );
			$posts[ $i ] = array_merge( $posts[ $i ], $post );
		} else {
			$posts[] = acf_get_internal_post_type( $post['key'], $post_type );
		}
	}

	// Sort list via menu_order and title.
	return wp_list_sort(
		$posts,
		array(
			'menu_order' => 'ASC',
			'title'      => 'ASC',
		)
	);
}