wc_get_theme_support( string $prop = '', mixed $default = null )

Return “theme support” values from the current theme, if set.


Description Description


Parameters Parameters

$prop

(Optional) 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 value: ''

$default

(Optional) value to return if the theme does not declare support for a prop.

Default value: null


Top ↑

Return Return

(mixed) Value of prop(s).


Top ↑

Source Source

File: includes/wc-core-functions.php

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

Top ↑

Changelog Changelog

Changelog
Version Description
3.3.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.