acf_field_flexible_content::get_layout_meta
Retrieves layout meta for the Flexible Content field saved to the provided post.
Метод класса: acf_field_flexible_content{}
Хуков нет.
Возвращает
array.
Использование
$acf_field_flexible_content = new acf_field_flexible_content(); $acf_field_flexible_content->get_layout_meta( $post_id, $field );
- $post_id(int|строка) (обязательный)
- The ID of the post being edited.
- $field(массив) (обязательный)
- The Flexible Content field array.
Список изменений
| С версии 6.5 | Введена. |
Код acf_field_flexible_content::get_layout_meta() acf field flexible content::get layout meta ACF 6.8.8
public function get_layout_meta( $post_id, $field ) {
$field_name = $field['name'];
// Enables compatibility with nested Flexible Content fields during render.
if ( ! empty( $field['_prepare'] ) ) {
$field_name = acf_get_field_type( 'repeater' )->get_field_name_from_input_name( $field_name );
}
// Bail early if we don't have a field name to check.
if ( empty( $field_name ) ) {
return array();
}
// Return the cached meta if we have it.
$cache_key = "$post_id:$field_name";
if ( ! empty( $this->layout_meta[ $cache_key ] ) ) {
return $this->layout_meta[ $cache_key ];
}
$layout_meta = acf_get_metadata_by_field(
$post_id,
array(
'name' => '_' . $field_name . '_layout_meta',
)
);
if ( empty( $layout_meta ) || ! is_array( $layout_meta ) ) {
return array();
}
$this->layout_meta[ $cache_key ] = $layout_meta;
return $this->layout_meta[ $cache_key ];
}