On this page
block_has_support( WP_Block_Type $block_type, array $feature, mixed $default = false ): bool
Checks whether the current block type supports the feature requested.
Parameters
$block_typeWP_Block_Type Required-
Block type to check for support.
$featurearray Required-
Path to a specific feature to check support for.
$defaultmixed Optional-
Fallback value for feature support.
Default:
false
Return
bool Whether the feature is supported.
Source
File: wp-includes/blocks.php. View all references
function block_has_support( $block_type, $feature, $default = false ) {
$block_support = $default;
if ( $block_type && property_exists( $block_type, 'supports' ) ) {
$block_support = _wp_array_get( $block_type->supports, $feature, $default );
}
return true === $block_support || is_array( $block_support );
}
Related
Uses
| Uses | Description |
|---|---|
| _wp_array_get() wp-includes/functions.php | Accesses an array in depth based on a path of keys. |
Used By
| Used By | Description |
|---|---|
| WP_Theme_JSON::get_layout_styles() wp-includes/class-wp-theme-json.php | Gets the CSS layout rules for a particular block from theme.json layout definitions. |
Changelog
| Version | Description |
|---|---|
| 5.8.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/block_has_support