block_has_support() WordPress Function

The block_has_support() function is used to check if a given block type supports a certain feature.

block_has_support( WP_Block_Type $block_type, string $feature, mixed $default = false ) #

Checks whether the current block type supports the feature requested.


Parameters

$block_type

(WP_Block_Type)(Required)Block type to check for support.

$feature

(string)(Required)Name of the feature to check support for.

$default

(mixed)(Optional) Fallback value for feature support.

Default value: false


Top ↑

Return

(bool) Whether the feature is supported.


Top ↑

Source

File: wp-includes/blocks.php

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 );
}


Top ↑

Changelog

Changelog
VersionDescription
5.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.