Initializer
in package
Initializes the core blocks renderers.
Table of Contents
- ALLOWED_BLOCK_TYPES = array('core/button', 'core/buttons', 'core/column', 'core/columns', 'core/group', 'core/heading', 'core/image', 'core/list', 'core/list-item', 'core/paragraph', 'core/quote', 'core/spacer', 'core/social-link', 'core/social-links', 'core/site-logo', 'core/site-title', 'core/table')
- List of supported WordPress core blocks in the email editor.
- RENDER_ONLY_BLOCK_TYPES = array('core/gallery', 'core/media-text', 'core/audio', 'core/embed', 'core/cover', 'core/video', 'core/post-title')
- List of blocks that only need rendering capabilities (not available in email editor).
- $renderers : array<string|int, mixed>
- Cache renderers by block name.
- adjust_theme_json() : WP_Theme_JSON
- Adjusts the editor's theme to add blocks specific settings for core blocks.
- allow_styles() : array<string|int, mixed>
- Allow styles for the email editor.
- initialize() : void
- Initializes the core blocks renderers.
- render_block() : string
- Returns the block content rendered by the block renderer.
- update_block_settings() : array<string|int, mixed>
- Configure block settings for email editor support and rendering.
- get_block_renderer() : Abstract_Block_Renderer
- Return an instance of Abstract_Block_Renderer by the block name.
Constants
ALLOWED_BLOCK_TYPES
List of supported WordPress core blocks in the email editor.
public
mixed
ALLOWED_BLOCK_TYPES
= array('core/button', 'core/buttons', 'core/column', 'core/columns', 'core/group', 'core/heading', 'core/image', 'core/list', 'core/list-item', 'core/paragraph', 'core/quote', 'core/spacer', 'core/social-link', 'core/social-links', 'core/site-logo', 'core/site-title', 'core/table')
RENDER_ONLY_BLOCK_TYPES
List of blocks that only need rendering capabilities (not available in email editor).
public
mixed
RENDER_ONLY_BLOCK_TYPES
= array('core/gallery', 'core/media-text', 'core/audio', 'core/embed', 'core/cover', 'core/video', 'core/post-title')
To add a new render-only block:
- Add the block name to this array
- Optionally create a specific renderer in the Renderer/Blocks directory
- Add the renderer case in the get_block_renderer method
Properties
$renderers
Cache renderers by block name.
private
array<string|int, mixed>
$renderers
= array()
Methods
adjust_theme_json()
Adjusts the editor's theme to add blocks specific settings for core blocks.
public
adjust_theme_json(WP_Theme_JSON $editor_theme_json) : WP_Theme_JSON
Parameters
- $editor_theme_json : WP_Theme_JSON
-
Editor theme JSON.
Return values
WP_Theme_JSON —allow_styles()
Allow styles for the email editor.
public
allow_styles(array<string|int, mixed>|null $allowed_styles) : array<string|int, mixed>
Parameters
- $allowed_styles : array<string|int, mixed>|null
-
Allowed styles.
Return values
array<string|int, mixed> —initialize()
Initializes the core blocks renderers.
public
initialize() : void
Return values
void —render_block()
Returns the block content rendered by the block renderer.
public
render_block(string $block_content, array<string|int, mixed> $parsed_block, Rendering_Context $rendering_context) : string
Parameters
- $block_content : string
-
Block content.
- $parsed_block : array<string|int, mixed>
-
Parsed block settings.
- $rendering_context : Rendering_Context
-
Rendering context.
Return values
string —update_block_settings()
Configure block settings for email editor support and rendering.
public
update_block_settings(array<string|int, mixed> $settings) : array<string|int, mixed>
This method handles two types of blocks:
- Editor-available blocks: Set supports.email = true and render_email_callback
- Render-only blocks: Only set render_email_callback (not available in editor)
Parameters
- $settings : array<string|int, mixed>
-
Block settings.
Return values
array<string|int, mixed> — Modified block settings.get_block_renderer()
Return an instance of Abstract_Block_Renderer by the block name.
private
get_block_renderer(string $block_name) : Abstract_Block_Renderer
Parameters
- $block_name : string
-
Block name.
