Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add block supports render hook #984

Closed

Conversation

ajlende
Copy link

@ajlende ajlende commented Feb 9, 2021

Trac ticket: https://core.trac.wordpress.org/ticket/52476#ticket

In conjunction with WordPress/gutenberg#26361 for adding block supports for duotone filters, this adds a render hook for block supports.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

}

$block_content = call_user_func(
$block_support_config['render_block'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far the block supports were only used to actually add classnames or inline styles to the wrapper, this PR is changing that by allowing them to register a generic hook for render_block.

The use-case for these is to potentially support static blocks (adding style and classes to static blocks that don't explicitly call the get_block_wrapper_attributes but also to allow adding style tags in addition to the block markup. These are needed by two Gutenberg PRs. WordPress/gutenberg#26752 and WordPress/gutenberg#29335

It's not entirely clear why this hook is better than just using render_block directly though.

Curious though about your thoughts here @mcsf @mtias

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit late... but I see that the parent PR (WordPress/gutenberg#26752) is progressing nicely without this. Yes, I'm more in favour of not adding a new indirect API, just recommend render_block. If later we find that we have more compelling use cases for custom server rendering in block-supports, we can reassess.

@ajlende ajlende closed this Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants