blocks-mode.php
Coordinates WordPress block-editor pages with Kindly editing. It preserves the chosen page mode rather than assuming every page is native HTML.
Responsibility#
Coordinates WordPress block-editor pages with Kindly editing. It preserves the chosen page mode rather than assuming every page is native HTML.
This is an implementation reference for the released 0.9.13 module. Internal PHP helpers are not a compatibility promise for third-party callers. Prefer the documented REST, Abilities, theme, and filter contracts.
Related modules#
Module constants#
const CANTATA_EDIT_BLOCKS_EDITABLE = [ 'core/paragraph', 'core/heading', 'core/list-item', 'core/pullquote', 'core/button', 'core/image' ];
const CANTATA_EDIT_BLOCKS_HOLDERS = [ 'core/list', 'core/quote', 'core/buttons', 'core/cover', 'core/columns', 'core/column', 'core/group', 'core/media-text' ];
const CANTATA_EDIT_BLOCKS_INERT = [ 'core/separator', 'core/spacer' ];
These values describe this release. Defined configuration constants and generated identifiers can have different ownership; do not edit stored values directly without following the corresponding workflow.
WordPress hooks#
| Operation | Hook |
|---|---|
add_filter |
render_block_data |
add_filter |
render_block |
add_filter |
the_content |
add_filter |
the_content |
add_action and add_filter subscribe to a hook; do_action and apply_filters expose a hook. A subscription is not itself a new extension API. Dynamic hook names are not included in this literal inventory.
Function and method reference#
cantata_edit_blocks_mode#
function cantata_edit_blocks_mode( $post = null ): bool
A page made in the block editor and not built here: it's edited in blocks mode.
Implementation connections: cantata_edit_is_built.
Source location: includes/blocks-mode.php:20.
cantata_edit_block_role#
function cantata_edit_block_role( array $block ): string
What the editor may do with a block: 'edit', 'hold', 'inert' or 'lock'. Dynamic and unknown blocks are locked.
Implementation connections: cantata_edit_blocks_mode, cantata_edit_is_editing.
Source location: includes/blocks-mode.php:26.
cantata_edit_block_inline#
function cantata_edit_block_inline( string $html ): string
Words typed into a block: the tags the block editor's own text writes, nothing else (no script, handlers or javascript:).
Source location: includes/blocks-mode.php:134.
cantata_edit_block_replace_inner#
function cantata_edit_block_replace_inner( string $chunk, string $tag, string $inner ): ?string
Replace what's inside the first <$tag> of a markup piece (to its closing tag, or to the piece's end when it has none).
Source location: includes/blocks-mode.php:141.
cantata_edit_block_piece#
function cantata_edit_block_piece( array $block, string $tag, bool $last = false ): ?int
The index of the innerContent string that holds $tag, first or last.
Source location: includes/blocks-mode.php:151.
cantata_edit_save_blocks#
function cantata_edit_save_blocks( string $source, array $ops )
Apply the editor's changes to block markup. Each change names a block by path and type; a path whose type doesn't match is a conflict (the page changed meanwhile), a locked block is refused, and a list is only ever added to. Returns the new markup, or a WP_Error.
Implementation connections: cantata_edit_block_inline, cantata_edit_block_piece, cantata_edit_block_replace_inner, cantata_edit_block_role.
Source location: includes/blocks-mode.php:169.