/home/techb158/balacoffee.com/wp-content/plugins/wp-rocket/inc/Engine/Optimization
Edit: /home/techb158/balacoffee.com/wp-content/plugins/wp-rocket/inc/Engine/Optimization/UrlTrait.php (3050B)
normalize_fullurl( $url );
$path = rocket_url_to_path( $url );
if ( $path ) {
return $path;
}
$relative_url = ltrim( wp_make_link_relative( $url ), '/' );
$ds = rocket_get_constant( 'DIRECTORY_SEPARATOR' );
$base_path = isset( $_SERVER['DOCUMENT_ROOT'] ) ? ( sanitize_text_field( wp_unslash( $_SERVER['DOCUMENT_ROOT'] ) ) . $ds ) : '';
return $base_path . str_replace( '/', $ds, $relative_url );
}
/**
* Normalize relative url to full url.
*
* @param string $url Url to be normalized.
* @param bool $remove_query Remove Query string or not.
*
* @return string Normalized url.
*/
public function normalize_fullurl( string $url, bool $remove_query = true ) {
$url = htmlspecialchars_decode( $url );
$parsed_url = wp_parse_url( $url );
if ( $remove_query && ! empty( $parsed_url['query'] ) ) {
$url = str_replace( '?' . $parsed_url['query'], '', $url );
}
if ( empty( $parsed_url['host'] ) ) {
$relative_url = ltrim( wp_make_link_relative( $url ), '/' );
$site_url_components = wp_parse_url( site_url( '/' ) );
return $site_url_components['scheme'] . '://' . $site_url_components['host'] . '/' . $relative_url;
}
return rocket_add_url_protocol( $url );
}
/**
* Gets content of a file
*
* @param string $file File path.
* @return string
*/
protected function get_file_content( $file ) {
if ( empty( $file ) ) {
return false;
}
return rocket_direct_filesystem()->get_contents( $file );
}
}