From e842645b5c72904346e05a699f9c62c0bbd7436c Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Mon, 14 Nov 2022 11:52:04 -0300 Subject: [PATCH] fix: use `wp_check_filetype` to get a mime type if module FINFO not present --- src/classes/class-tainacan-media.php | 3 ++- src/classes/class-tainacan-private-files.php | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/classes/class-tainacan-media.php b/src/classes/class-tainacan-media.php index cd9020ffc..8a2e61730 100644 --- a/src/classes/class-tainacan-media.php +++ b/src/classes/class-tainacan-media.php @@ -188,7 +188,8 @@ class Media { finfo_close( $finfo ); return $mime_type; } - return ''; + $filetypes = \wp_check_filetype($filename); + return isset($filetypes['type']) && $filetypes['type'] != false ? $filetypes['type'] : ''; } /** diff --git a/src/classes/class-tainacan-private-files.php b/src/classes/class-tainacan-private-files.php index 160525220..2402e64b6 100644 --- a/src/classes/class-tainacan-private-files.php +++ b/src/classes/class-tainacan-private-files.php @@ -13,13 +13,13 @@ class Private_Files { public $dir_separator; - public static function get_instance() { - if(!isset(self::$instance)) { - self::$instance = new self(); - } + public static function get_instance() { + if(!isset(self::$instance)) { + self::$instance = new self(); + } - return self::$instance; - } + return self::$instance; + } protected function __construct() {