_acf_apply_get_local_field_groups()ACF 5.7.10

_acf_apply_get_local_field_groups

Appends local field groups to the provided array.

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

No Hooks.

Returns

Array.

Usage

_acf_apply_get_local_field_groups( $groups );
$groups
.
Default: array()

Changelog

Since 5.7.10 Introduced.

_acf_apply_get_local_field_groups() code ACF 6.0.4

function _acf_apply_get_local_field_groups( $groups = array() ) {

	// Get local groups
	$local = acf_get_local_field_groups();
	if ( $local ) {

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

		// Loop over groups and update/append local.
		foreach ( $local as $group ) {

			// Get group allowing cache and filters to run.
			// $group = acf_get_field_group( $group['key'] );

			// Update.
			$i = array_search( $group['key'], $map );
			if ( $i !== false ) {
				unset( $group['ID'] );
				$groups[ $i ] = array_merge( $groups[ $i ], $group );

				// Append
			} else {
				$groups[] = acf_get_field_group( $group['key'] );
			}
		}

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

	// Return groups.
	return $groups;
}