| @@ -27,19 +27,14 @@ | ||
| 27 | 27 | const TYPE_EARLYACCESS = 'earlyaccess'; |
| 28 | 28 | |
| 29 | 29 | private static array $folders = []; |
| 30 | 30 | |
| 31 | - public static function enqueue( string $font_name, string $font_type = self::TYPE_DEFAULT, $force_enqueue_from_cdn = false ): bool { | |
| 31 | + public static function enqueue( string $font_name, string $font_type = self::TYPE_DEFAULT ): bool { | |
| 32 | 32 | if ( static::enqueue_style( $font_name ) ) { |
| 33 | 33 | return true; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - $is_local_gf_enabled = (bool) get_option( 'elementor_local_google_fonts', '0' ); | |
| 37 | - if ( ! $is_local_gf_enabled ) { | |
| 38 | - $force_enqueue_from_cdn = true; | |
| 39 | - } | |
| 40 | - | |
| 41 | - if ( $force_enqueue_from_cdn || ! static::fetch_font_data( $font_name, $font_type ) ) { | |
| 36 | + if ( ! static::fetch_font_data( $font_name, $font_type ) ) { | |
| 42 | 37 | static::enqueue_from_cdn( $font_name, $font_type ); |
| 43 | 38 | return false; |
| 44 | 39 | } |
| 45 | 40 | |
| @@ -213,24 +208,15 @@ | ||
| 213 | 208 | |
| 214 | 209 | $cleaned_url = set_url_scheme( $original_font_url, 'https' ); |
| 215 | 210 | $cleaned_url = strtok( $cleaned_url, '?#' ); |
| 216 | 211 | |
| 217 | - $font_ext = pathinfo( $cleaned_url, PATHINFO_EXTENSION ); | |
| 218 | - | |
| 219 | 212 | $tmp_font_file = download_url( $cleaned_url ); |
| 220 | 213 | if ( is_wp_error( $tmp_font_file ) ) { |
| 221 | 214 | return ''; |
| 222 | 215 | } |
| 223 | 216 | |
| 224 | - $unique_font_id = static::get_unique_font_id( $cleaned_url ); | |
| 217 | + $current_font_basename = $sanitize_font_name . '-' . strtolower( sanitize_file_name( basename( $cleaned_url ) ) ); | |
| 225 | 218 | |
| 226 | - $current_font_basename = sprintf( | |
| 227 | - '%s-%s.%s', | |
| 228 | - $sanitize_font_name, | |
| 229 | - strtolower( sanitize_file_name( $unique_font_id ) ), | |
| 230 | - $font_ext | |
| 231 | - ); | |
| 232 | - | |
| 233 | 219 | $dest_file = $fonts_folder['path'] . $current_font_basename; |
| 234 | 220 | $dest_file_url = $fonts_folder['url'] . $current_font_basename; |
| 235 | 221 | |
| 236 | 222 | // Use copy and unlink because rename breaks streams. |
| @@ -248,17 +234,14 @@ | ||
| 248 | 234 | |
| 249 | 235 | return $css_content; |
| 250 | 236 | } |
| 251 | 237 | |
| 252 | - private static function get_unique_font_id( $font_url ): string { | |
| 253 | - return substr( sha1( $font_url ), 0, 8 ); | |
| 254 | - } | |
| 255 | - | |
| 256 | 238 | private static function enqueue_from_cdn( string $font_name, string $font_type ): void { |
| 257 | 239 | $font_url = static::get_google_fonts_remote_url( $font_name, $font_type ); |
| 258 | 240 | |
| 259 | 241 | $sanitize_font_name = static::sanitize_font_name( $font_name ); |
| 260 | 242 | |
| 243 | + // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 261 | 244 | wp_enqueue_style( |
| 262 | 245 | 'elementor-gf-' . $sanitize_font_name, |
| 263 | 246 | $font_url, |
| 264 | 247 | [], |