From 04dd99613e864bed703a33e43bef1605e41e41f1 Mon Sep 17 00:00:00 2001 From: Peter Fabian Date: Wed, 2 May 2018 22:07:49 +0200 Subject: [PATCH] Putting public functions back. In case some plugins are using them. --- includes/wc-core-functions.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php index 210445d54e1..865034c5578 100644 --- a/includes/wc-core-functions.php +++ b/includes/wc-core-functions.php @@ -1997,6 +1997,31 @@ function wc_delete_expired_transients() { } add_action( 'woocommerce_installed', 'wc_delete_expired_transients' ); +/** + * Make a URL relative, if possible. + * + * @since 3.2.0 + * @param string $url URL to make relative. + * @return string + */ +function wc_get_relative_url( $url ) { + return wc_is_external_resource( $url ) ? $url : str_replace( array( 'http://', 'https://' ), '//', $url ); +} + + +/** + * See if a resource is remote. + * + * @since 3.2.0 + * @param string $url URL to check. + * @return bool + */ +function wc_is_external_resource( $url ) { + $wp_base = str_replace( array( 'http://', 'https://' ), '//', get_home_url( null, '/', 'http' ) ); + + return strstr( $url, '://' ) && ! strstr( $url, $wp_base ); +} + /** * See if theme/s is activate or not. *