Skip to content

Commit

Permalink
Font Library: remove "has_font_mime_type" function (#57364)
Browse files Browse the repository at this point in the history
* Remove usage of has_font_mime_type function

* Remove definition of has_font_mime_type function

* Remove test cases for has_font_mime_type
  • Loading branch information
HrithikDalal committed Dec 28, 2023
1 parent 1c79fd8 commit 36396cc
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 87 deletions.
15 changes: 0 additions & 15 deletions lib/experimental/fonts/font-library/class-wp-font-family-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,6 @@ public static function merge_fonts_data( $font1, $font2 ) {
return $merged_font;
}

/**
* Returns whether the given file has a font MIME type.
*
* @since 6.5.0
*
* @param string $filepath The file to check.
* @return bool True if the file has a font MIME type, false otherwise.
*/
public static function has_font_mime_type( $filepath ) {
$allowed_mime_types = WP_Font_Library::get_expected_font_mime_types_per_php_version();
$filetype = wp_check_filetype( $filepath, $allowed_mime_types );

return in_array( $filetype['type'], $allowed_mime_types, true );
}

/**
* Format font family to make it valid CSS.
*
Expand Down
11 changes: 0 additions & 11 deletions lib/experimental/fonts/font-library/class-wp-font-family.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,6 @@ private function get_upload_overrides( $filename ) {
* False if the download failed.
*/
private function download_asset( $url, $filename ) {
// Checks if the file to be downloaded has a font mime type.
if ( ! WP_Font_Family_Utils::has_font_mime_type( $filename ) ) {
return false;
}

// Include file with download_url() if function doesn't exist.
if ( ! function_exists( 'download_url' ) ) {
require_once ABSPATH . 'wp-admin/includes/file.php';
Expand Down Expand Up @@ -263,12 +258,6 @@ private function move_font_face_asset( $font_face, $file ) {
// because it is no longer needed.
unset( $new_font_face['uploadedFile'] );

// If the filename has no font mime type, don't move the file and
// return the font face definition without src to be ignored later.
if ( ! WP_Font_Family_Utils::has_font_mime_type( $filename ) ) {
return $new_font_face;
}

// Move the uploaded font asset from the temp folder to the fonts directory.
if ( ! function_exists( 'wp_handle_upload' ) ) {
require_once ABSPATH . 'wp-admin/includes/file.php';
Expand Down

This file was deleted.

0 comments on commit 36396cc

Please sign in to comment.