acf_field_flexible_content::load_field()publicACF 3.6

This filter is appied to the $field after it is loaded from the database

@type filter

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

Хуков нет.

Возвращает

$field. - the field array holding all the field options

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

$acf_field_flexible_content = new acf_field_flexible_content();
$acf_field_flexible_content->load_field( $field );
$field (обязательный)
-

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

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

Код acf_field_flexible_content::load_field() ACF 5.10.2

function load_field( $field ) {

	// bail early if no field layouts
	if ( empty( $field['layouts'] ) ) {

		return $field;

	}

	// vars
	$sub_fields = acf_get_fields( $field );

	// loop through layouts, sub fields and swap out the field key with the real field
	foreach ( array_keys( $field['layouts'] ) as $i ) {

		// extract layout
		$layout = acf_extract_var( $field['layouts'], $i );

		// validate layout
		$layout = $this->get_valid_layout( $layout );

		// append sub fields
		if ( ! empty( $sub_fields ) ) {

			foreach ( array_keys( $sub_fields ) as $k ) {

				// check if 'parent_layout' is empty
				if ( empty( $sub_fields[ $k ]['parent_layout'] ) ) {

					// parent_layout did not save for this field, default it to first layout
					$sub_fields[ $k ]['parent_layout'] = $layout['key'];

				}

				// append sub field to layout,
				if ( $sub_fields[ $k ]['parent_layout'] == $layout['key'] ) {

					$layout['sub_fields'][] = acf_extract_var( $sub_fields, $k );

				}
			}
		}

		// append back to layouts
		$field['layouts'][ $i ] = $layout;

	}

	// return
	return $field;
}