Closed
Description
openedon Dec 3, 2017
Issue Overview
The idea is to add an has_block() function or similar to check if a post uses a specific block. This would be similar to the has_shortcode() function.
Possible Solution
Implementation could be similar to the gutenberg_content_has_blocks() function:
Line 370 in 9864a60
This function is optimized for speed and simply uses strpos to check for <!-- wp:
. has_block() could similarly check for <!-- wp:blockname
.
Alternatively, we could load all of the blocks for the post and loop through them until we found a block with that name. Maybe both implementations should be available (different functions or use a flag parameter) for different use cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment