_inject_theme_attribute_in_template_part_block()
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.
Returns
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() inject theme attribute in template part block code WP 6.9
function _inject_theme_attribute_in_template_part_block( &$block ) {
if (
'core/template-part' === $block['blockName'] &&
! isset( $block['attrs']['theme'] )
) {
$block['attrs']['theme'] = get_stylesheet();
}
}