WP_Block
- Since
- 5.5.0
- Source
wp-includes/class-wp-block.php:15
Class representing a parsed instance of a block.
Compatibility
- WordPress
- since 5.5.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Hooks and filters fired · 7
Every hook that fires from inside WP_Block, in the order it appears in the class, grouped by the method that fires it.
WP_Block::render()
- apply_filters( interactivity_process_directives )filter line 514
- apply_filters( pre_render_block )filter line 552
- apply_filters( render_block_data )filter line 561
- apply_filters( render_block_context )filter line 564
- apply_filters( render_block )filter line 648
- apply_filters( render_block_{$this->name} )filter line 663
- apply_filters( enqueue_empty_block_content_assets )filter line 701
Properties · 9
$parsed_blockarraypublic- Original parsed array representation of block.
$namestring|nullpublic- Name of block.
$block_typeWP_Block_Typepublic- Block type associated with the instance.
$contextarraypublic- Block context values.
$available_contextarrayprotected- All available context of the current hierarchy.
$registryWP_Block_Type_Registryprotected- Block type registry.
$inner_blocksWP_Block_Listpublic- List of inner blocks (of this same class)
$inner_htmlstringpublic- Resultant HTML from inside block comment delimiters after removing inner blocks.
$inner_contentarraypublic- List of string fragments and null markers where inner blocks were found
Methods · 8
- __construct()Constructor.
- refresh_context_dependents()Updates the context for the current block and its inner blocks.
- refresh_parsed_block_dependents()Updates the parsed block content for the current block and its inner blocks.
- __get()Returns a value from an inaccessible property.
- process_block_bindings()Processes the block bindings and updates the block attributes with the values from the sources.
- replace_html()Depending on the block attribute name, replace its value in the HTML based on the value provided.
- get_block_bindings_processor()
- render()Generates the render output for the block.
Source code
#[AllowDynamicProperties]class WP_Block { /** * Original parsed array representation of block. * * @since 5.5.0 * @var array */ public $parsed_block; /** * Name of block. * * @example "core/paragraph" * * @since 5.5.0 * @var string|null */ public $name; /** * Block type associated with the instance. * * @since 5.5.0 * @var WP_Block_Type */ public $block_type; /** * Block context values. * * @since 5.5.0 * @var array */ public $context = array(); /** * All available context of the current hierarchy. * * @since 5.5.0 * @var array */ protected $available_context = array(); /** * Block type registry. * * @since 5.9.0 * @var WP_Block_Type_Registry */ protected $registry; /** * List of inner blocks (of this same class) * * @since 5.5.0 * @var WP_Block_List */ public $inner_blocks = array(); /** * Resultant HTML from inside block comment delimiters after removing inner * blocks. * * @example "...Just <!-- wp:test /--> testing..." -> "Just testing..." * * @since 5.5.0 * @var string */ public $inner_html = ''; /** * List of string fragments and null markers where inner blocks were found * * @example array( * 'inner_html' => 'BeforeInnerAfter', * 'inner_blocks' => array( block, block ), * 'inner_content' => array( 'Before', null, 'Inner', null, 'After' ), * )Changelog
Introduced in 5.5.0. 3 changes between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
6.9.7
Method
get_block_bindings_processor() added.verified against source6.8.8
Method
refresh_context_dependents() added.verified against source6.8.8
Method
refresh_parsed_block_dependents() added.verified against source5.5.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-includes/class-wp-block.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.