REFACTOR Cleaning init comments in file
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Antoine M 2025-06-05 10:24:07 +02:00
parent 0efd5c2df7
commit 9f7cdb7fe2

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Plugin Name: Dernieres Dynamiques * Plugin Name: Dernieres Dynamiques
* Description: Example block scaffolded with Create Block tool. * Description: Example block scaffolded with Create Block tool.
@ -13,47 +14,25 @@
* @package CreateBlock * @package CreateBlock
*/ */
if ( ! defined( 'ABSPATH' ) ) { if (! defined('ABSPATH')) {
exit; // Exit if accessed directly. exit; // Exit if accessed directly.
} }
/**
* Registers the block using a `blocks-manifest.php` file, which improves the performance of block type registration. function create_block_dernieres_dynamiques_block_init()
* Behind the scenes, it also registers all assets so they can be enqueued {
* through the block editor in the corresponding context.
* if (function_exists('wp_register_block_types_from_metadata_collection')) {
* @see https://make.wordpress.org/core/2025/03/13/more-efficient-block-type-registration-in-6-8/ wp_register_block_types_from_metadata_collection(__DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php');
* @see https://make.wordpress.org/core/2024/10/17/new-block-type-registration-apis-to-improve-performance-in-wordpress-6-7/
*/
function create_block_dernieres_dynamiques_block_init() {
/**
* Registers the block(s) metadata from the `blocks-manifest.php` and registers the block type(s)
* based on the registered block metadata.
* Added in WordPress 6.8 to simplify the block metadata registration process added in WordPress 6.7.
*
* @see https://make.wordpress.org/core/2025/03/13/more-efficient-block-type-registration-in-6-8/
*/
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; return;
} }
/** if (function_exists('wp_register_block_metadata_collection')) {
* Registers the block(s) metadata from the `blocks-manifest.php` file. wp_register_block_metadata_collection(__DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php');
* Added to WordPress 6.7 to improve the performance of block type registration.
*
* @see https://make.wordpress.org/core/2024/10/17/new-block-type-registration-apis-to-improve-performance-in-wordpress-6-7/
*/
if ( function_exists( 'wp_register_block_metadata_collection' ) ) {
wp_register_block_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' );
} }
/**
* Registers the block type(s) in the `blocks-manifest.php` file.
*
* @see https://developer.wordpress.org/reference/functions/register_block_type/
*/
$manifest_data = require __DIR__ . '/build/blocks-manifest.php'; $manifest_data = require __DIR__ . '/build/blocks-manifest.php';
foreach ( array_keys( $manifest_data ) as $block_type ) { foreach (array_keys($manifest_data) as $block_type) {
register_block_type( __DIR__ . "/build/{$block_type}" ); register_block_type(__DIR__ . "/build/{$block_type}");
} }
} }
add_action( 'init', 'create_block_dernieres_dynamiques_block_init' ); add_action('init', 'create_block_dernieres_dynamiques_block_init');