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

Calling render_callback() without register_block_type? #4723

Closed
phpbits opened this issue Jan 29, 2018 · 6 comments
Closed

Calling render_callback() without register_block_type? #4723

phpbits opened this issue Jan 29, 2018 · 6 comments
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Type] Enhancement A suggestion for improvement.

Comments

@phpbits
Copy link
Contributor

phpbits commented Jan 29, 2018

Checking https://github.com/WordPress/gutenberg/blob/a41173b0be06c5c8c8e397bfb7b30604099e3182/lib/blocks.php and there seems to be no block render_callback option without register_block_type. Will there be any filters available? It will be easier rather that removing the the_content filter and override it with a new one. Thanks!

@danielbachhuber danielbachhuber added the [Type] Help Request Help with setup, implementation, or "How do I?" questions. label Jan 30, 2018
@danielbachhuber
Copy link
Member

Hi @phpbits,

Could you share more detail on what you're trying to do?

@phpbits
Copy link
Contributor Author

phpbits commented Jan 30, 2018

@danielbachhuber I'm trying to hide several specific blocks and there's no filter/callback option. I did it by using remove_filter( 'the_content', 'do_blocks', 9 ); then copy the do_blocks() and adding it again. Then add my conditions on the foreach loop per block.

Would be really helpful and better if you have filters and actions available there. Thanks!

@phpbits
Copy link
Contributor Author

phpbits commented Feb 1, 2018

@danielbachhuber Thedo_blocks() seems been changed : https://github.com/WordPress/gutenberg/blob/master/lib/blocks.php. Can you please add a filter foreach block before adding them to the content? Something like this on the previous code :

$content_after_blocks .= apply_filters( 'do_content_block', gutenberg_render_block( $block ), $block );

Thanks!

@aduth
Copy link
Member

aduth commented Feb 1, 2018

Relevant exchange at #4591 (comment)

@danielbachhuber danielbachhuber added [Type] Enhancement A suggestion for improvement. [Feature] Extensibility The ability to extend blocks or the editing experience and removed [Type] Help Request Help with setup, implementation, or "How do I?" questions. labels Apr 11, 2018
@mtias mtias mentioned this issue Aug 1, 2018
16 tasks
@chrisvanpatten
Copy link
Contributor

Seconding this — additional filters on block render would be super valuable. For instance right now I'm trying to change the structure of image tags to modify the sizes and srcset attributes and have to resort to an ugly domdoc solution because there's no easy way to filter the markup at runtime.

@mcsf
Copy link
Contributor

mcsf commented Oct 3, 2018

@chrisvanpatten, I think it's best to follow #2751, as its resolution should provide an overarching solution for this.

@mcsf mcsf closed this as completed Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

5 participants