Documentation

BlockTypes
in package

AbstractYes

BlockTypes Registration class.

Enables the batch registration of custom block types, making it simpler for developers to extend the WordPress block editor with custom content blocks. Utilizes the BlockType module for each block type's registration, ensuring that each block type is registered in accordance with WordPress standards.

Tags
see
BlockType

for the BlockType class.

since
1.0.0

Table of Contents

Methods

set()  : void
Registers multiple block types in bulk.

Methods

set()

Registers multiple block types in bulk.

public static set([array<string|int, mixed> $block_types = [] ]) : void

This method simplifies the process of registering custom block types by accepting an array of block type definitions. Each definition specifies the block type's properties, settings, and the block type's render callback function, allowing for comprehensive and flexible block type creation.

Example usage:

BlockTypes::set([
    [
        'name' => 'custom-block',
        'args' => [
            'editor_script' => 'script-handle',
            'editor_style'  => 'style-handle',
            'render_callback' => 'render_callback_function_name',
            // Additional block type arguments.
        ],
    ],
    ...
]);
Parameters
$block_types : array<string|int, mixed> = []

An array of block type definitions. Each definition is an associative array that includes 'name' and 'args', where 'args' is an array of arguments for registering the block type (such as 'editor_script', 'editor_style', 'render_callback', etc.).

Tags
since
1.0.0

        
On this page

Search results