<?php
 
 function button_block_render_callback($block, $content = '', $is_preview = false, $post_id = 0) {
    $context = Timber::context();
    $context['block'] = $block;
    $context['is_preview'] = $is_preview;
    $context['text'] = get_field('text');
    $context['button'] = get_field('button');
    $context['link'] = get_field('link');
    $context['color'] = get_field('color');
    Timber::render('modules/blog/editor-blocks/button_block/editor-block-template.twig', $context);
}


 add_action('acf/init', function(){
    if( function_exists('acf_register_block') ) {
        // register a testimonial block

        acf_register_block(array(
            'name'              => 'gp_button_block',
            'title'             => __('GP - button_block'),
            'description'       => __('button_block block'),
            'render_callback'   => 'button_block_render_callback',
            'category'          => 'formatting',
            'icon'              => 'admin-comments',
            'keywords'          => array( 'button_block', 'gp-block',),
            'mode' => 'preview',
            'enqueue_assets'    => function(){
                wp_enqueue_style('gp_util_style', get_template_directory_uri() . '/modules/layout/assets/css/gp-style-core.css', array(), '1.0', 'all');
                wp_enqueue_style('gp_normalize', get_template_directory_uri() . '/modules/layout/assets/css/gp-style-normalize.css', array(), '1.0', 'all');
                wp_enqueue_style('gp_button_block_style', get_template_directory_uri() . '/modules/blog/editor-blocks/button_block/assets/css/style.css', array(), '2.0', 'all');
            },
            'supports' => array(
                'align' => true,
                'multiple' => true,
                'jsx' => true,
                '__experimentalInnerBlocks' => true, // Включение поддержки вложенных блоков
            ),
        ));
    }
});




?>