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
$args
An array of arguments for registering a block type.
private
array<string|int, mixed>|null
$args
Array or query string of arguments for registering a block type.
Tags
$block_type
Block type key.
private
string
$block_type
Block type key. Must not exceed 20 characters and may only contain lowercase alphanumeric characters, dashes, and underscores. See sanitize_key() .
Tags
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
__toString()
Custom toString magic method.
public
__toString() : string
Returns the block type as a JSON string.
Tags
Return values
string —JSON string.
register_block_type()
Registers the block type with WordPress.
public
register_block_type() : void
Uses the register_block_type()
function to register the block type.
Tags
initialize()
Initializes the block type.
private
initialize() : void
Hooks the action to register the block type and adds the block type to the registry.