wc_block_theme_has_styles_for_element()
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.
Returns
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() wc block theme has styles for element code WC 10.3.3
function wc_block_theme_has_styles_for_element( $element ) {
if (
! wp_is_block_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;
}