acf_field_flexible_content::load_field
This filter is appied to the $field after it is loaded from the database
Method of the class: acf_field_flexible_content{}
No Hooks.
Returns
$field. - the field array holding all the field options
Usage
$acf_field_flexible_content = new acf_field_flexible_content(); $acf_field_flexible_content->load_field( $field );
- $field(required)
- .
Changelog
| Since 3.6 | Introduced. |
acf_field_flexible_content::load_field() acf field flexible content::load field code ACF 6.0.4
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;
}