<?php

/**
 * Plugin Name:       Dynamiques Blocks
 * Description:       Un série de Blocks sur mesure pour l'écriture du contenu de Dynamiques
 * Author:            Deligraph
 * Text Domain:       dynamiques-blocks
 * Version:           0.1.0
 * Requires at least: 6.7
 * Requires PHP:      7.4
 * License:           GPL-2.0-or-later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html

 *
 * @package CreateBlock
 */

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

require_once __DIR__ . '/_utilities/utilities.php';


function create_block_dynamiques_blocks_block_init()
{

	##### REGISTER ACF BLOCKS #####
	register_block_type(__DIR__ . '/acf-blocks/team-authors');
	register_block_type(__DIR__ . '/acf-blocks/team-dynamiques');
	register_block_type(__DIR__ . '/acf-blocks/statistics-datas');
	register_block_type(__DIR__ . '/acf-blocks/random-collection-image');

	if (function_exists('wp_register_block_metadata_collection')) {
		wp_register_block_metadata_collection(__DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php');
	}
	$manifest_data = require __DIR__ . '/build/blocks-manifest.php';
	foreach (array_keys($manifest_data) as $block_type) {
		register_block_type(__DIR__ . "/build/{$block_type}");
	}
}
add_action('init', 'create_block_dynamiques_blocks_block_init');



function dynamiques_add_block_categories($categories)
{
	return array_merge(

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

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