carhop__plugins__PROD-DEV/plugins/carhop-blocks/carhop-blocks.php
Antoine M 5dc6ea260d
All checks were successful
continuous-integration/drone/push Build is passing
CHORE REFACTOR upgrading plugin to handle a unique monopackage bundler
2025-11-20 11:06:56 +01:00

100 lines
2.6 KiB
PHP

<?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
* 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
* Text Domain: carhop-blocks
*
*
* @package CreateBlock
*/
if (! defined('ABSPATH')) {
exit; // Exit if accessed directly.
}
##### REGISTER BLOCKS #####
function create_block_carhop_blocks_block_init()
{
if (function_exists('wp_register_block_types_from_metadata_collection')) {
wp_register_block_types_from_metadata_collection(__DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php');
return;
}
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}");
}
##### REGISTER ACF BLOCKS #####
register_block_type(__DIR__ . '/acf-blocks/gallery');
register_block_type(__DIR__ . '/acf-blocks/social-networks');
register_block_type(__DIR__ . '/acf-blocks/custom-video');
register_block_type(__DIR__ . '/acf-blocks/team-carhop');
}
add_action('init', 'create_block_carhop_blocks_block_init');
##### REGISTER BLOCK CATEGORIES #####
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);
##### CUSTOM BLOCKS SETTINGS #####
require_once __DIR__ . '/src/audio-player/audio-player.php';
/* ----------------------------------------------------------------
##### ENQUEUE BLOCKS
------------------------------------------------------------------*/
function carhop_register_blocks()
{
if (!function_exists('register_block_type')) {
return;
}
register_block_type(__DIR__ . '/acf-blocks/gallery');
register_block_type(__DIR__ . '/acf-blocks/social-networks');
register_block_type(__DIR__ . '/acf-blocks/custom-video');
register_block_type(__DIR__ . '/acf-blocks/team-carhop');
// 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');