<?php

/**
 * Plugin Name:       Carhop Blocks
 * Description:       Un série de Blocks sur mesure pour l'écriture du contenu de Carhop
 * Author:            Deligraph
 * Text Domain:       carhop-blocks
 */

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

function carhop_add_block_categories($categories)
{
	return array_merge(

		[
			[
				'slug'  => 'carhop-blocks',
				'title' => __('Blocs Carhop ', 'carhop-blocks'),
				'icon'  => 'heart',
			],

		],
		$categories
	);
}
add_action('block_categories_all', 'carhop_add_block_categories', 25, 2);


/* ----------------------------------------------------------------
	##### ENQUEUE BLOCKS
 ------------------------------------------------------------------*/

function carhop_register_blocks()
{
	if (!function_exists('register_block_type')) {
		return;
	}

	register_block_type(__DIR__ . '/blocks/latest-news/build');
	register_block_type(__DIR__ . '/blocks/front-header/build');
	register_block_type(__DIR__ . '/blocks/chapter-section/build');
	register_block_type(__DIR__ . '/blocks/dbmob-grid/build');
	register_block_type(__DIR__ . '/blocks/content-box/build');
	register_block_type(__DIR__ . '/blocks/heading/build');
	register_block_type(__DIR__ . '/blocks/decorative-shapes/build');
	register_block_type(__DIR__ . '/blocks/narrative-card/build');
	register_block_type(__DIR__ . '/blocks/scroll-story-block/build');
	register_block_type(__DIR__ . '/blocks/cta-group/build');
	register_block_type(__DIR__ . '/blocks/content-card/build');
	register_block_type(__DIR__ . '/blocks/card-grid/build');
	// register_block_type(__DIR__ . '/blocks/localisation-map/build');


	register_block_type(__DIR__ . '/acf-blocks/gallery');
	register_block_type(__DIR__ . '/acf-blocks/social-networks');
	register_block_type(__DIR__ . '/acf-blocks/custom-video');

	// Enregistrer le script pour le bloc gallery
	wp_register_script(
		'carhop-gallery-view',
		plugins_url('acf-blocks/gallery/view.js', __FILE__),
		array(),
		filemtime(__DIR__ . '/acf-blocks/gallery/view.js'),
		true
	);
}
add_action('init', 'carhop_register_blocks');

/* ----------------------------------------------------------------
	##### ENQUEUE BLOCKS
 ------------------------------------------------------------------*/

require_once __DIR__ . '/blocks/subscribe-infolettre/subscribe-infolettre.php';
require_once __DIR__ . '/blocks/cta/cta.php';
require_once __DIR__ . '/blocks/localisation-map/localisation-map.php';
// require_once __DIR__ . '/blocks/cta-group/cta-group.php';
