wc_get_theme_support()WC 3.3.0

Return "theme support" values from the current theme, if set.

No Hooks.

Return

Mixed. Value of prop(s).

Usage

wc_get_theme_support( $prop, $default );
$prop(string)
Name of prop (or key::subkey for arrays of props) if you want a specific value. Leave blank to get all props as an array.
Default: ''
$default(mixed)
Optional value to return if the theme does not declare support for a prop.
Default: null

Changelog

Since 3.3.0 Introduced.

wc_get_theme_support() code WC 8.6.1

function wc_get_theme_support( $prop = '', $default = null ) {
	$theme_support = get_theme_support( 'woocommerce' );
	$theme_support = is_array( $theme_support ) ? $theme_support[0] : false;

	if ( ! $theme_support ) {
		return $default;
	}

	if ( $prop ) {
		$prop_stack = explode( '::', $prop );
		$prop_key   = array_shift( $prop_stack );

		if ( isset( $theme_support[ $prop_key ] ) ) {
			$value = $theme_support[ $prop_key ];

			if ( count( $prop_stack ) ) {
				foreach ( $prop_stack as $prop_key ) {
					if ( is_array( $value ) && isset( $value[ $prop_key ] ) ) {
						$value = $value[ $prop_key ];
					} else {
						$value = $default;
						break;
					}
				}
			}
		} else {
			$value = $default;
		}

		return $value;
	}

	return $theme_support;
}