Documentation

BlockPattern
in package

BlockPattern Module class.

Table of Contents

Properties

$action_hook  : ActionHook
ActionHook instance.
$pattern_name  : string
Block pattern name.
$pattern_properties  : array<string|int, mixed>
Block pattern properties.

Methods

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

Properties

$action_hook

ActionHook instance.

private ActionHook $action_hook

ActionHook object for the register_block_pattern method.

Tags
since
1.0.0

Methods

__construct()

Constructor.

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

Constructs the BlockPattern object by setting the pattern name, pattern properties, and action hook.

Parameters
$pattern_name : string

Block pattern name including namespace.

$pattern_properties : array<string|int, mixed>

List of properties for the block pattern.

$action_hook : ActionHook = null

Optional. ActionHook instance. Default 'init'.

Tags
since
1.0.0

__toString()

Custom toString magic method.

public __toString() : string

Returns the block pattern as a JSON string.

Tags
since
1.0.0
Return values
string

JSON string.

initialize()

Initializes the block pattern.

private initialize() : void

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

Tags
since
1.0.0

        
On this page

Search results