_inject_theme_attribute_in_template_part_block()WP 6.4.0

Injects the active theme's stylesheet as a theme attribute into a given template part block.

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

No Hooks.

Return

null. Nothing (null).

Usage

_inject_theme_attribute_in_template_part_block( $block );
$block(array) (required) (passed by reference — &)
a parsed block.

Changelog

Since 6.4.0 Introduced.

_inject_theme_attribute_in_template_part_block() code WP 6.7.1

function _inject_theme_attribute_in_template_part_block( &$block ) {
	if (
		'core/template-part' === $block['blockName'] &&
		! isset( $block['attrs']['theme'] )
	) {
		$block['attrs']['theme'] = get_stylesheet();
	}
}