WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Авторские Темы для WordPress
функция не описана

acf_duplicate_field_group() ACF 5.0.0

Duplicates a field group.

Хуки из функции
Возвращает

Массив. The new field group.

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

acf_duplicate_field_group( $id, $new_post_id );
$id((int|строка))
The field_group ID, key or name.
$new_post_id(int)
Optional post ID to override.

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

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

Код acf_duplicate_field_group() ACF 5.9.1

<?php
function acf_duplicate_field_group( $id = 0, $new_post_id = 0 ){
	
	// Disable filters to ensure ACF loads data from DB.
	acf_disable_filters();
	
	// Get the field_group.
	$field_group = acf_get_field_group( $id );
	
	// Bail early if field_group was not found.
	if( !$field_group || !$field_group['ID'] ) {
		return false;
	}
	
	// Get fields.
	$fields = acf_get_fields( $field_group );
	
	// Update attributes.
	$field_group['ID'] = $new_post_id;
	$field_group['key'] = uniqid('group_');
	
	// Add (copy) to title when apropriate.
	if( !$new_post_id ) {
		$field_group['title'] .= ' (' . __("copy", 'acf') . ')';
	}
	
	// When importing a new field group, insert a temporary post and set the field group's ID.
	// This allows fields to be updated before the field group (field group ID is needed for field parent setting).
	if( !$field_group['ID'] ) {
		$field_group['ID'] = wp_insert_post( array( 'post_title' => $field_group['key'] ) );
	}
	
	// Duplicate fields.
	$duplicates = acf_duplicate_fields( $fields, $field_group['ID'] );
	
	// Save field group.
	$field_group = acf_update_field_group( $field_group );
	
	/**
	 * Fires immediately after a field_group has been duplicated.
	 *
	 * @date	12/02/2014
	 * @since	5.0.0
	 *
	 * @param	array $field_group The field_group array.
	 */
	do_action( 'acf/duplicate_field_group', $field_group );
	
	// return
	return $field_group;
}