<?php
 
 function slider_render_callback($block, $content = '', $is_preview = false, $post_id = 0) {
    $context = Timber::context();
    $context['block'] = $block;
    $context['is_preview'] = $is_preview;
    $context['gallery'] = get_field('gallery');
    Timber::render('modules/blog/editor-blocks/swiper/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_slider',
            'title'             => __('GP - slider'),
            'description'       => __('Slider block'),
            'render_callback'   => 'slider_render_callback',
            'category'          => 'formatting',
            'icon'              => 'admin-comments',
            'keywords'          => array( 'slider', '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_script('layout-swiper-bundle.min-js',get_template_directory_uri() . '/modules/layout/assets/js/swiper-bundle.min.js', ['jquery'], '1.0', 'all');
                wp_enqueue_script('gp_arcticle_slider_js',get_template_directory_uri() . '/modules/blog/editor-blocks/swiper/assets/js/script.js', ['jquery'], '1.0', 'all');
                wp_enqueue_style('gp_slider_style', get_template_directory_uri() . '/modules/blog/editor-blocks/swiper/assets/css/style.css', array(), '2.0', 'all');
                wp_enqueue_style('layout-swiper-bundle-css', get_template_directory_uri() . '/modules/layout/assets/css/swiper-bundle.css', array(), '1.0', 'all');
            }
        ));
    }
});




?>