diff --git a/inc/Engine/Media/Fonts/Controller/Filesystem.php b/inc/Engine/Media/Fonts/Controller/Filesystem.php index ae280d14b1..90ec2ffa1b 100644 --- a/inc/Engine/Media/Fonts/Controller/Filesystem.php +++ b/inc/Engine/Media/Fonts/Controller/Filesystem.php @@ -23,13 +23,6 @@ class Filesystem extends AbstractFileSystem { */ private $path; - /** - * Version of the fonts. - * - * @var int - */ - private $version; - /** * Instantiate the class * @@ -155,7 +148,7 @@ private function download_font( string $url ) { * @return string Path for the font file. */ private function get_fonts_full_path( string $font_provider_path, string $hash ): string { - return $this->path . $font_provider_path . $this->get_version() . '/' . $this->hash_to_path( $hash ); + return $this->path . $font_provider_path . $this->hash_to_path( $hash ); } @@ -172,7 +165,7 @@ private function get_fonts_relative_path( string $font_provider_path, string $ha $wp_content_dir = rocket_get_constant( 'WP_CONTENT_DIR' ); $relative_path = str_replace( $wp_content_dir, '', $full_path ); - return $relative_path . $this->get_version() . '/' . $this->hash_to_path( $hash ); + return $relative_path . $this->hash_to_path( $hash ); } /** @@ -203,27 +196,6 @@ public function delete_font_css( string $url ): bool { return $this->delete_file( $dir ); } - - /** - * Set the version of the fonts - * - * @param int $version The version of the font. - * - * @return void - */ - public function set_version( int $version ): void { - $this->version = $version; - } - - /** - * Get the font version - * - * @return int - */ - public function get_version(): int { - return $this->version; - } - /** * Converts hash to path with filtered number of levels * diff --git a/inc/Engine/Media/Fonts/Controller/Fonts.php b/inc/Engine/Media/Fonts/Controller/Fonts.php index c601c89283..ae2cca3f64 100644 --- a/inc/Engine/Media/Fonts/Controller/Fonts.php +++ b/inc/Engine/Media/Fonts/Controller/Fonts.php @@ -41,19 +41,16 @@ public function __construct( /** * Start the process of downloading font locally * - * @param string $font_url URL of the font to be saved locally. - * @param string $provider Provider of the font. - * @param integer $version Version. + * @param string $font_url URL of the font to be saved locally. + * @param string $provider Provider of the font. * * @return void */ - public function process( string $font_url, string $provider, int $version ): void { + public function process( string $font_url, string $provider ): void { if ( ! $this->context->is_allowed() ) { return; } - $this->filesystem->set_version( $version ); - $this->filesystem->write_font_css( $font_url, $provider ); } } diff --git a/inc/Engine/Media/Fonts/Frontend/Controller.php b/inc/Engine/Media/Fonts/Frontend/Controller.php index 080071acdb..d99d9dac47 100644 --- a/inc/Engine/Media/Fonts/Frontend/Controller.php +++ b/inc/Engine/Media/Fonts/Frontend/Controller.php @@ -67,13 +67,13 @@ public function rewrite_fonts( string $html ): string { } foreach ( $v1_fonts as $font ) { - $this->download_font( $font['url'], 1 ); - $html = $this->replace_font( $font, $html, 1 ); + $this->download_font( $font['url'] ); + $html = $this->replace_font( $font, $html ); } foreach ( $v2_fonts as $font ) { - $this->download_font( $font['url'], 2 ); - $html = $this->replace_font( $font, $html, 2 ); + $this->download_font( $font['url'] ); + $html = $this->replace_font( $font, $html ); } return $html; @@ -84,14 +84,13 @@ public function rewrite_fonts( string $html ): string { * * @param array $font Font data. * @param string $html HTML content. - * @param int $version Provided font version. * @param string $font_provider Font provider. * * @return string */ - private function replace_font( array $font, string $html, int $version, string $font_provider = 'google-font' ): string { + private function replace_font( array $font, string $html, string $font_provider = 'google-font' ): string { $hash = md5( $font['url'] ); - $local = $this->get_optimized_markup( $hash, $font['url'], $version, $font_provider ); + $local = $this->get_optimized_markup( $hash, $font['url'], $font_provider ); return str_replace( $font[0], $local, $html ); } @@ -103,7 +102,6 @@ private function replace_font( array $font, string $html, int $version, string $ * * @param string $hash Font Url has. * @param string $original_url Fonts Url. - * @param int $version Fonts version. * @param string $font_provider Fonts provider. * * @return string @@ -111,7 +109,6 @@ private function replace_font( array $font, string $html, int $version, string $ protected function get_optimized_markup( string $hash, string $original_url, - int $version, string $font_provider ): string { $levels = 3; @@ -122,7 +119,7 @@ protected function get_optimized_markup( $path_array[] = $remain; $path = implode( '/', $path_array ); - $font_provider_path = sprintf( '%s/%d/', $font_provider, $version ); + $font_provider_path = sprintf( '%s/', $font_provider ); $url = $this->base_url . $font_provider_path . $path . '.css'; @@ -154,10 +151,9 @@ public function disable_google_fonts_preload( $disable ): bool { * Download font * * @param string $font_url Font url to be downloaded. - * @param int $font_version The version of the font. * @param string $provider The font provider. */ - private function download_font( string $font_url, int $font_version, string $provider = 'google-font' ): void { - $this->font->process( $font_url, $provider, $font_version ); + private function download_font( string $font_url, string $provider = 'google-font' ): void { + $this->font->process( $font_url, $provider ); } } diff --git a/tests/Fixtures/inc/Engine/Media/Fonts/Frontend/Controller/HTML/expected_v1.php b/tests/Fixtures/inc/Engine/Media/Fonts/Frontend/Controller/HTML/expected_v1.php index c433066bfa..8c1fbb7b89 100644 --- a/tests/Fixtures/inc/Engine/Media/Fonts/Frontend/Controller/HTML/expected_v1.php +++ b/tests/Fixtures/inc/Engine/Media/Fonts/Frontend/Controller/HTML/expected_v1.php @@ -9,8 +9,8 @@