block_has_support

The timeline below displays how wordpress function block_has_support has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.4

/**
 * Checks whether the current block type supports the feature requested.
 *
 * @since 5.8.0
 * @since 6.4.0 The `$feature` parameter now supports a string.
 *
 * @param WP_Block_Type $block_type    Block type to check for support.
 * @param string|array  $feature       Feature slug, or path to a specific feature to check support for.
 * @param mixed         $default_value Optional. Fallback value for feature support. Default false.
 * @return bool Whether the feature is supported.
 */
function block_has_support($block_type, $feature, $default_value = false)
{
    $block_support = $default_value;
    if ($block_type instanceof WP_Block_Type) {
        if (is_array($feature) && count($feature) === 1) {
            $feature = $feature[0];
        }
        if (is_array($feature)) {
            $block_support = _wp_array_get($block_type->supports, $feature, $default_value);
        } elseif (isset($block_type->supports[$feature])) {
            $block_support = $block_type->supports[$feature];
        }
    }
    return true === $block_support || is_array($block_support);
}

WordPress Version: 6.2

/**
 * Checks whether the current block type supports the feature requested.
 *
 * @since 5.8.0
 *
 * @param WP_Block_Type $block_type    Block type to check for support.
 * @param array         $feature       Path to a specific feature to check support for.
 * @param mixed         $default_value Optional. Fallback value for feature support. Default false.
 * @return bool Whether the feature is supported.
 */
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);
}

WordPress Version: 6.1

/**
 * Checks whether the current block type supports the feature requested.
 *
 * @since 5.8.0
 *
 * @param WP_Block_Type $block_type Block type to check for support.
 * @param array         $feature    Path to a specific feature to check support for.
 * @param mixed         $default    Optional. Fallback value for feature support. Default false.
 * @return bool Whether the feature is supported.
 */
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);
}

WordPress Version: 5.9

/**
 * Checks whether the current block type supports the feature requested.
 *
 * @since 5.8.0
 *
 * @param WP_Block_Type $block_type Block type to check for support.
 * @param string        $feature    Name of the feature to check support for.
 * @param mixed         $default    Optional. Fallback value for feature support. Default false.
 * @return bool Whether the feature is supported.
 */
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);
}

WordPress Version: 5.8

/**
 * Checks whether the current block type supports the feature requested.
 *
 * @since 5.8.0
 *
 * @param WP_Block_Type $block_type Block type to check for support.
 * @param string        $feature    Name of the feature to check support for.
 * @param mixed         $default    Fallback value for feature support, defaults to false.
 *
 * @return boolean                  Whether or not the feature is supported.
 */
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);
}