<?php
namespace ThimPress\ThimBlocks\Gutenberg\Blocks\SlideItem;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

use ThimPress\ThimBlocks\Gutenberg\Blocks\AbstractBlockType;

/**
 * Class SlideItemBlockType
 *
 * Handle register, render block template
 */
class SlideItemBlockType extends AbstractBlockType {
	public $block_name = 'slide-item';

	public function get_supports(): array {
		return array(
			'align'           => false,
			'anchor'          => false,
			'customClassName' => true,
		);
	}

	public function render_content_block_template( array $attributes, $content, $block ): string {
		$html = '';

		try {

			$wrapper_attributes = get_block_wrapper_attributes(
				array(
					'class' => 'swiper-slide slider-custom',
				)
			);

			ob_start();
			echo '<div ' . wp_kses_post( $wrapper_attributes ) . '>';
			echo $content;
			echo '</div>';

			$html = ob_get_clean();

		} catch ( Throwable $e ) {
			return $html;
		}

		return $html;
	}

}
