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

opposite of allowed_block_types filter #10951

Closed
ihdk opened this issue Oct 23, 2018 · 4 comments
Closed

opposite of allowed_block_types filter #10951

ihdk opened this issue Oct 23, 2018 · 4 comments
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.

Comments

@ihdk
Copy link

ihdk commented Oct 23, 2018

Hello,
I'd like to define blocks which are hidden from inserter. We can do that using allowed_block_types filter, where are defined blocks which are visible in inserter.

Is there a filter opposite to allowed_block_types? Filter where I can define exactly which blocks are not visible in inserter.

Alternative may be use of allowed_block_types filter if I loop through all blocks and remove unwanted blocks - I am not sure now, if there is a function to get all available blocks and loop through them in php, something like javascript wp.blocks.getBlockTypes().
Anyway this loop through all blocks may be useless if there could be opposite of allowed_block_types filter where could be defined blocks hidden in inserter.

Thanks, Ivan.

@ihdk
Copy link
Author

ihdk commented Oct 23, 2018

Thanks for response and sorry if I was not so clear with my questions.
I am aware of the ability to deregister block, but I would not like to definitely deregister block (block is as template for page). I just want to make this block hidden from inserter so user cannot add this block manually - as I said, block is available in editor as template right when editor loads.
So I'd not deregister the block, just hide it from inserter using some opposite filter to allowed_block_types.

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

This sounds to me like what is done for the Column block which is used by the Columns block (plural) but the Column block (singular) is not offered via the block inserter. That was done in #9523. Can you check there to see if that use case helps you learn how to do what you are asking?

@ihdk
Copy link
Author

ihdk commented Oct 24, 2018

great, thank you to point me to right direction! it was exactly what I was looking for and I found solution in the commit related to issue with column 5bae40e
It's a pity that something like that isn't mentioned in docs for supports parameter of registerBlockType function.
Anyway, thanks again for your help!
Ivan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests

3 participants