wc_block_theme_has_styles_for_element()WC 7.4.0

Given an element name, returns true or false depending on whether the current theme has styles for that element defined in theme.json.

If the theme is not a block theme or the WP-related function is not defined, return false.

No Hooks.

Return

true|false.

Usage

wc_block_theme_has_styles_for_element( $element );
$element(string) (required)
The name of the element.

Changelog

Since 7.4.0 Introduced.

wc_block_theme_has_styles_for_element() code WC 9.4.2

function wc_block_theme_has_styles_for_element( $element ) {
	if (
		! wc_current_theme_is_fse_theme() ||
		wc_wp_theme_get_element_class_name( $element ) === ''
	) {
		return false;
	}

	if ( function_exists( 'wp_get_global_styles' ) ) {
		$global_styles = wp_get_global_styles();
		if (
			array_key_exists( 'elements', $global_styles ) &&
			array_key_exists( $element, $global_styles['elements'] )
		) {
			return is_array( $global_styles['elements'][ $element ] );
		}
	}

	return false;
}