block_has_support( WP_Block_Type $block_type, array $feature, mixed $default_value = false ): bool

Checks whether the current block type supports the feature requested.


Parameters

$block_type WP_Block_Type Required
Block type to check for support.
$feature array Required
Path to a specific feature to check support for.
$default_value mixed Optional
Fallback value for feature support.

Default: false


Top ↑

Return

bool Whether the feature is supported.


Top ↑

Source

File: wp-includes/blocks.php. View all references

function block_has_support( $block_type, $feature, $default_value = false ) {
	$block_support = $default_value;
	if ( $block_type && property_exists( $block_type, 'supports' ) ) {
		$block_support = _wp_array_get( $block_type->supports, $feature, $default_value );
	}

	return true === $block_support || is_array( $block_support );
}


Top ↑

Changelog

Changelog
Version Description
5.8.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.