Blocks

Helpers
in package

Global helper functions

Table of Contents

Methods

get_block_by_name()  : Block|null
Gets the single block instance by block name.
render_blocks()  : mixed
Renders and sanitizes a content string of blocks.
render_blocks_in_post_context()  : mixed
Renders a content string (of blocks) in the context of a post.
render_inner_blocks_in_post_context()  : mixed
Renders inner blocks within the context of a post.
set_acf_block_mode()  : mixed
Sets the ACF block mode.
set_default_block_category()  : mixed
Sets the default category for new blocks. Must be called before blocks are initialized.

Methods

get_block_by_name()

Gets the single block instance by block name.

public static get_block_by_name(string $name) : Block|null
Parameters
$name : string

The block name.

Return values
Block|null

Block instance or null if it cannot be found.

render_blocks()

Renders and sanitizes a content string of blocks.

public static render_blocks(string|array<string|int, mixed> $content) : mixed
Parameters
$content : string|array<string|int, mixed>

$content The content string, or array of block structures.

render_blocks_in_post_context()

Renders a content string (of blocks) in the context of a post.

public static render_blocks_in_post_context(string|array<string|int, mixed> $content, int $post_id) : mixed
Parameters
$content : string|array<string|int, mixed>

The content string, or array of block structures.

$post_id : int

The ID of the context post.

render_inner_blocks_in_post_context()

Renders inner blocks within the context of a post.

public static render_inner_blocks_in_post_context(WP_Block $wp_block, int $post_id) : mixed
Parameters
$wp_block : WP_Block

The block whose inner blocks should be rendered. Available within render templates.

$post_id : int

The ID of the context post.

set_acf_block_mode()

Sets the ACF block mode.

public static set_acf_block_mode(string $block_name[, string $mode = 'preview' ]) : mixed
Parameters
$block_name : string

The full block name including vendor prefix.

$mode : string = 'preview'

The ACF block mode.

set_default_block_category()

Sets the default category for new blocks. Must be called before blocks are initialized.

public static set_default_block_category(string $category) : mixed
Parameters
$category : string

The default category for new blocks.


        
On this page

Search results