<?php
add_action( 'acf/init', function () {
	if(function_exists('acf_register_block_type')){
		acf_register_block_type(array(
			'name'            => 'bw-gallery',
			'title'           => __( 'Custom Gallery' ),
			'description'     => '',
			'render_callback' => 'bw_render_acf_block',
			'category'        => 'layout',
			'icon'            => 'images-alt',
			'mode'            => 'edit',
			'enqueue_assets'  => 'bw_gallery_assets',
			'supports' => array(
				'jsx' => true
			)
		) );
	}
} );

function bw_gallery_assets () {
	wp_enqueue_style('bw_gallery_style', get_stylesheet_directory_uri() . '/acf-blocks/bw-gallery/gallery.css', array(), '0.0.1');
	wp_enqueue_script('bw_gallery_script', get_stylesheet_directory_uri() . '/acf-blocks/bw-gallery/gallery.js', array( 'jquery' ), '0.0.1');
}

add_action( 'acf/include_fields', function() {
	if ( ! function_exists( 'acf_add_local_field_group' ) ) {
		return;
	}

	acf_add_local_field_group( array(
		'key' => 'group_63c035e85b59b',
		'title' => 'Block: Custom Gallery',
		'fields' => array(
			array(
				'key' => 'field_660d84fa840c5',
				'label' => 'Hide Inner Content',
				'name' => 'hide_inner',
				'aria-label' => '',
				'type' => 'true_false',
				'instructions' => '',
				'required' => 0,
				'conditional_logic' => 0,
				'wrapper' => array(
					'width' => '',
					'class' => '',
					'id' => '',
				),
				'wpml_cf_preferences' => 1,
				'message' => '',
				'default_value' => 0,
				'ui_on_text' => '',
				'ui_off_text' => '',
				'ui' => 1,
			),
			array(
				'key' => 'field_662a7193f5a19',
				'label' => 'Inner Content Position',
				'name' => 'inner_content_position',
				'aria-label' => '',
				'type' => 'select',
				'instructions' => '',
				'required' => 0,
				'conditional_logic' => 0,
				'wrapper' => array(
					'width' => '',
					'class' => '',
					'id' => '',
				),
				'choices' => array(
					'left' => 'Left',
					'center' => 'Center',
					'right' => 'Right',
				),
				'default_value' => 'left',
				'return_format' => 'value',
				'multiple' => 0,
				'allow_null' => 0,
				'ui' => 0,
				'ajax' => 0,
				'placeholder' => '',
			),
			array(
				'key' => 'field_63c03638b70a5',
				'label' => 'Images',
				'name' => 'images',
				'aria-label' => '',
				'type' => 'repeater',
				'instructions' => '',
				'required' => 0,
				'conditional_logic' => 0,
				'wrapper' => array(
					'width' => '',
					'class' => '',
					'id' => '',
				),
				'layout' => 'row',
				'pagination' => 0,
				'min' => 0,
				'max' => 0,
				'collapsed' => '',
				'button_label' => 'Add Row',
				'rows_per_page' => 20,
				'wpml_cf_preferences' => 1,
				'sub_fields' => array(
					array(
						'key' => 'field_63c03655b70a6',
						'label' => 'Image',
						'name' => 'image',
						'aria-label' => '',
						'type' => 'image',
						'instructions' => '',
						'required' => 0,
						'conditional_logic' => 0,
						'wrapper' => array(
							'width' => '',
							'class' => '',
							'id' => '',
						),
						'return_format' => 'id',
						'library' => 'all',
						'min_width' => '',
						'min_height' => '',
						'min_size' => '',
						'max_width' => '',
						'max_height' => '',
						'max_size' => '',
						'mime_types' => '',
						'preview_size' => 'medium',
						'parent_repeater' => 'field_63c03638b70a5',
						'wpml_cf_preferences' => 1,
					),
				),
			),
		),
		'location' => array(
			array(
				array(
					'param' => 'block',
					'operator' => '==',
					'value' => 'acf/bw-gallery',
				),
			),
		),
		'menu_order' => 0,
		'position' => 'normal',
		'style' => 'default',
		'label_placement' => 'top',
		'instruction_placement' => 'label',
		'hide_on_screen' => '',
		'active' => true,
		'description' => '',
		'show_in_rest' => 0,
		'acfml_field_group_mode' => 'translation',
	) );
} );
