Blocks

Trait_Restrict_To_Post_Types uses trait:short

Trait for restricting a block to the editor of particular post types.

Table of Contents

Methods

get_post_types()  : array<string|int, string>
Get all post types that this block is allowed to be used on.
init_trait_restrict_to_post_types()  : mixed
Trait initialization function.
post_types()  : array<string|int, string>
Function to provide an array of post types that this block is allowed to be used on.
restrict_to_editor_context()  : mixed
Will ensure that the block is only available within a specified editor context.
restrict_to_post_editor()  : mixed
Restrict block availability to the post editor only.
restrict_to_post_types()  : mixed
Restict the availibility of the block using this trait to posts of types proivided by the post_types function.
restrict_to_site_editor()  : mixed
Restrict block availability to the site editor only.

Methods

get_post_types()

Get all post types that this block is allowed to be used on.

public get_post_types() : array<string|int, string>
Return values
array<string|int, string>

An array of post types.

init_trait_restrict_to_post_types()

Trait initialization function.

protected init_trait_restrict_to_post_types() : mixed

post_types()

Function to provide an array of post types that this block is allowed to be used on.

protected abstract post_types() : array<string|int, string>
Return values
array<string|int, string>

An array of post types.

restrict_to_editor_context()

Will ensure that the block is only available within a specified editor context.

protected restrict_to_editor_context(string $editor_context_name) : mixed
Parameters
$editor_context_name : string

The name of the editor context.

Tags
link

Block context documentation.

restrict_to_post_types()

Restict the availibility of the block using this trait to posts of types proivided by the post_types function.

protected restrict_to_post_types() : mixed

        
On this page

Search results