Searching as well in reusable blocks (core's has_block() doesn't), see more in the blog post.
Author: Karolína Vyskočilová (karolina@kybernaut.cz)
Updated: 2021-04-12
Better performance if used multiple times withing a function (parses the content just once).
Usage:
- Include the class (and namespace / rename it accroding to your needs).
- Instantiate it:
$helper = new BlockHelper();
- Use
$helper->has_block('block/name')
in your conditions ;)
Usage:
- Include both functions (and namespace / rename them accroding to your needs).
- Call
enhanced_has_block('block/name)
whenever you need to check.