wc_is_valid_url()WC 1.0

Simple check for validating a URL, it must start with http:// or https://. and pass FILTER_VALIDATE_URL validation.

No Hooks.

Return

true|false.

Usage

wc_is_valid_url( $url );
$url(string) (required)
to check.

wc_is_valid_url() code WC 8.6.1

function wc_is_valid_url( $url ) {

	// Must start with http:// or https://.
	if ( 0 !== strpos( $url, 'http://' ) && 0 !== strpos( $url, 'https://' ) ) {
		return false;
	}

	// Must pass validation.
	if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
		return false;
	}

	return true;
}