wc_is_valid_url()
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() wc is valid url code WC 9.7.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; }