WooCommerce Code Reference

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:

  1. Add the block name to this array
  2. Optionally create a specific renderer in the Renderer/Blocks directory
  3. Add the renderer case in the get_block_renderer method

Properties

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>

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:

  1. Editor-available blocks: Set supports.email = true and render_email_callback
  2. 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.