<?php

use ACFComposer\ACFComposer;

add_action('acf/init', function () {
    ACFComposer::registerFieldGroup([
        'name'     => 'pageBlocks',
        'title'    => 'Page Blocks',
        'fields'   => [
            [
                'label'        => 'Blocks',
                'name'         => 'page-blocks',
                'type'         => 'flexible_content',
                'button_label' => 'Add Block',
                'acfe_flexible_modal' => [
                    'acfe_flexible_modal_enabled'    => 1,
                    'acfe_flexible_modal_size'       => 'large',
                    'acfe_flexible_modal_col'        => '3',
                    'acfe_flexible_modal_categories' => 0,
                ],
                'acfe_flexible_layouts_thumbnails' => 1,
                'layouts'      => [
                    [
                        'name'       => 'image-text',
                        'label'      => 'Image & Text',
                        'display'    => 'block',
                        'acfe_flexible_thumbnail' => get_image_src('image-text-block.png'),
                        'sub_fields' => codelibry_acf_fields_image_text(),
                    ],
                    [
                        'name'       => 'testimonials',
                        'label'      => 'Testimonials',
                        'display'    => 'block',
                        'acfe_flexible_thumbnail' => get_image_src('testimonials-block.png'),
                        'sub_fields' => codelibry_acf_fields_testimonials(),
                    ],
                    [
                        'name'       => 'reusable-block',
                        'label'      => 'Reusable Block',
                        'display'    => 'block',
                        'acfe_flexible_thumbnail' => get_image_src('reusable-block.png'),
                        'sub_fields' => [
                            [
                                'label'         => 'Reusable Block',
                                'name'          => 'reusable-block-post',
                                'type'          => 'post_object',
                                'post_type'     => ['reusable-blocks'],
                                'return_format' => 'id',
                                'multiple'      => 0,
                                'allow_null'    => 0,
                                'ui'            => 1,
                            ],
                        ],
                    ],
                ],
            ],
        ],
        'location' => [
            [
                ['param' => 'page_template', 'operator' => '==', 'value' => 'default'],
            ],
        ],
        'menu_order' => 0,
    ]);
});
