Guide

Block Bits architecture

Registry, editor format, and frontend walker for inline bits.

Pipeline

PHP register_block_bit()
  → Assets project window.prcBlockBits.bits
  → Editor hydrateFromWindow + JS overlays
  → Format type prc-block-bits/bit + toolbar insertObject
  → Saved <span class="prc-block-bit" data-prc-block-bit="…">
  → Walker render_block priority 100 (iapi or callback)

There is no @wordpress/data store — the editor registry is a module-level Map.

Strategies

StrategyBehavior
iapiEmit Interactivity API directives on the span; default_text remains if the store is absent
callbackPHP render_callback replaces the span; output passes a central wp_kses allowlist

Public PHP API

\PRC\Platform\Block_Bits\register_block_bit( 'my-plugin/my-bit', $args );
\PRC\Platform\Block_Bits\get_block_bit( $name );
\PRC\Platform\Block_Bits\get_block_bits_applicable_to( $block_name );

default_text must be request-deterministic (no per-user or clock variance) so VIP edge cache stays safe. Callable default_text is rejected.

Attribute types include string, int, hex_color, icon_name, enum.

Public JS API

Import from @prc/block-bits (externalized to prc-block-bits-editor / window.prcBlockBitsEditor when built with the root webpack config):

  • registerBlockBit, getBlockBit, getAllBlockBits, getBitsApplicableTo

JS overlays add icon, title, and optional edit picker. If a bit is disabled in settings, it is omitted from window.prcBlockBits.bits and JS register is a no-op.

Walker

includes/class-walker.php — late render_block filter (priority 100) with early exit unless content contains prc-block-bit. Tag processor for iAPI bits; HTML processor for callbacks.

Built-in registration

Classes under includes/bits/ register on init priority 11: icon-span, copyright, shareable-text.

Was this helpful?