wc_string_to_bool( string|bool $string )

Converts a string (e.g. ‘yes’ or ‘no’) to a bool.


Description Description


Parameters Parameters

$string

(Required) String to convert. If a bool is passed it will be returned as-is.


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: includes/wc-formatting-functions.php

function wc_string_to_bool( $string ) {
	return is_bool( $string ) ? $string : ( 'yes' === strtolower( $string ) || 1 === $string || 'true' === strtolower( $string ) || '1' === $string );
}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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