wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



block_has_support › WordPress Function

Seit5.8.0
Veraltetn/v
block_has_support ( $block_type, $feature, $default_value = false )
Parameter: (3)
  • (WP_Block_Type) $block_type Block type to check for support.
    Erforderlich: Ja
  • (string|array) $feature Feature slug, or path to a specific feature to check support for.
    Erforderlich: Ja
  • (mixed) $default_value Optional. Fallback value for feature support. Default false.
    Erforderlich: Nein
    Standard: false
Gibt zurück:
  • (bool) Whether the feature is supported.
Definiert in:
Codex:
Changelog:
  • 6.4.0

Checks whether the current block type supports the feature requested.



Quellcode

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