How to register block variations with PHP in WP 6.5 #228
Locked
justintadlock
started this conversation in
Topic Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
WordPress 6.5 is shipping with a new
get_block_type_variations
filter hook: https://github.com/WordPress/wordpress-develop/blob/4ba0963a1f61d062d7345e429c823f3eb5ab5f78/src/wp-includes/class-wp-block-type.php#L608-L616This essentially works as a PHP-based method of registering custom block variations. This would be a lightweight tutorial for anyone who wants to pick it up and showcase a new WP 6.5 feature. Of course, I'm always happy to take this one on myself too.
Some possible limitations I've seen in my early testing so far:
icon
property. I believe this may only be limited to dashicons.isActive
check seems to be limited to the array method of checking attributes.Example
Here's an example variation on the Spacer block that's specific to my theme, but it's just a PoC:
Beta Was this translation helpful? Give feedback.
All reactions