Skip to content

How to: Access InnerBlocks.Content in PHP #7247

@manake

Description

@manake

An example request regarding this documentation page: https://github.com/WordPress/gutenberg/tree/master/editor/components/inner-blocks

wp.blocks.registerBlockType( 'example/hello-world', {
	title: 'Hello World',
	icon: 'universal-access-alt',
	category: 'layout',
	attributes: {},
	edit: function(){
		return wp.element.createElement( wp.editor.InnerBlocks );
	},
	save: function(){
		return null;
	},
});

// This function is wrong and needs documentation.
function php_render_block( $attributes, $content = '' ) {
	// #1 How do I access InnerBlocks.Content here?
	// #2 When accessed how do I typically parse all InnerBlocks.Content?
	return '<p>' . $attributes['foo'] . '</p>' . '<pre><code>' . htmlspecialchars( $content ) . '</code></pre>';
}

Similar example:
https://gist.github.com/mattheu/7cf235b4f932de891bc21cb5f3ff3de6

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Block APIAPI that allows to express the block paradigm.[Feature] ExtensibilityThe ability to extend blocks or the editing experience[Type] EnhancementA suggestion for improvement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions