_acf_apply_get_local_internal_posts()
Appends local ACF internal post types 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_internal_posts( $posts, $post_type );
- $posts(array)
- An array of ACF posts.
Default:array() - $post_type(string)
- The ACF internal post type being loaded.
Default:'acf-field-group'
Changelog
| Since 6.1 | Introduced. |
_acf_apply_get_local_internal_posts() acf apply get local internal posts code ACF 6.8.8
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',
)
);
}