Documentation

BlockType
in package

BlockType Module class.

Table of Contents

Properties

$action_hook  : ActionHook
ActionHook instance.
$args  : array<string|int, mixed>|null
An array of arguments for registering a block type.
$block_type  : string
Block type key.

Methods

__construct()  : mixed
Constructor.
__toString()  : string
Custom toString magic method.
register_block_type()  : void
Registers the block type with WordPress.
initialize()  : void
Initializes the block type.

Properties

$action_hook

ActionHook instance.

private ActionHook $action_hook

ActionHook object for the register_block_type method.

Tags
since
1.0.0

Methods

__construct()

Constructor.

public __construct(string $block_type, array<string|int, mixed>|string $args[, ActionHook $action_hook = null ]) : mixed

Constructs the BlockType object by setting the block type key, arguments, and action hook.

Parameters
$block_type : string

Block type key. Must not exceed 20 characters and may only contain lowercase alphanumeric characters, dashes, and underscores. See sanitize_key() .

$args : array<string|int, mixed>|string

Optional. Array or query string of arguments for registering a block type. See register_block_type() for information on accepted arguments.

$action_hook : ActionHook = null

Optional. ActionHook object for the register_block_type method. Default 'init'.

Tags
since
1.0.0

__toString()

Custom toString magic method.

public __toString() : string

Returns the block type as a JSON string.

Tags
since
1.0.0
Return values
string

JSON string.

initialize()

Initializes the block type.

private initialize() : void

Hooks the action to register the block type and adds the block type to the registry.

Tags
since
1.0.0

        
On this page

Search results