-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Closed
Labels
Needs Technical FeedbackNeeds testing from a developer perspective.Needs testing from a developer perspective.[Feature] Block APIAPI that allows to express the block paradigm.API that allows to express the block paradigm.[Priority] HighUsed to indicate top priority items that need quick attentionUsed to indicate top priority items that need quick attention[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Description
gutenberg_render_block()
no longer works since 3.8.0
Fatal error: Uncaught Error: Cannot use object of type WP_Block_Parser_Block as array
/**
* Renders a single block into a HTML string.
*
* @since 1.9.0
*
* @param array $block A single parsed block object.
* @return string String of rendered HTML.
*/
function gutenberg_render_block( $block ) {
$block_name = isset( $block['blockName'] ) ? $block['blockName'] : null;
$attributes = is_array( $block['attrs'] ) ? $block['attrs'] : array();
$raw_content = isset( $block['innerHTML'] ) ? $block['innerHTML'] : null;
if ( $block_name ) {
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block_name );
if ( null !== $block_type && $block_type->is_dynamic() ) {
return $block_type->render( $attributes );
}
}
if ( $raw_content ) {
return $raw_content;
}
return '';
}
I think it should be $block_name = isset( $block->blockName ) ? $block->blockName : null;
etc. now.
Also, it has no handling for innerBlocks
.
How to parse blocks (gutenberg_parse_blocks( $post->post_content )
) and then render them manually one by one?
saas786
Metadata
Metadata
Assignees
Labels
Needs Technical FeedbackNeeds testing from a developer perspective.Needs testing from a developer perspective.[Feature] Block APIAPI that allows to express the block paradigm.API that allows to express the block paradigm.[Priority] HighUsed to indicate top priority items that need quick attentionUsed to indicate top priority items that need quick attention[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended