acf_field_repeater::prepare_field_for_import()publicACF 5.0.0

prepare_field_for_import

Returns a flat array of fields containing all sub fields ready for import.

{} Это метод класса: acf_field_repeater{}

Хуков нет.

Возвращает

Массив.

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

$acf_field_repeater = new acf_field_repeater();
$acf_field_repeater->prepare_field_for_import( $field );
$field(массив) (обязательный)
The field settings.

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

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

Код acf_field_repeater::prepare_field_for_import() ACF 5.10.2

function prepare_field_for_import( $field ) {

	// Check for sub fields.
	if ( ! empty( $field['sub_fields'] ) ) {
		$sub_fields = acf_extract_var( $field, 'sub_fields' );

		// Modify sub fields.
		foreach ( $sub_fields as $i => $sub_field ) {
			$sub_fields[ $i ]['parent']     = $field['key'];
			$sub_fields[ $i ]['menu_order'] = $i;
		}

		// Return array of [field, sub_1, sub_2, ...].
		return array_merge( array( $field ), $sub_fields );

	}
	return $field;
}