コード例 #1
0
 public function check_allowed_file($file_data)
 {
     $bc_allowed_types = BC_Utility::get_all_brightcove_mimetypes();
     $allowed_ext = array_search($file_data['type'], $bc_allowed_types);
     if (false === $allowed_ext) {
         return false;
     }
     // Check if type is allowed by WordPress.
     $ext = pathinfo($file_data['name'], PATHINFO_EXTENSION);
     // If the extension matches the type.
     if ($allowed_ext === $ext) {
         return true;
     }
     return false;
 }
コード例 #2
0
 public static function mime_types($mime_types)
 {
     $bc_mime_types = BC_Utility::get_all_brightcove_mimetypes();
     foreach ($bc_mime_types as $ext => $mime_type) {
         // If, for instance, video/mp4 pre-exists exists, we still need to check extensions as many mime types have multiple extensions.
         if (in_array($mime_type, $mime_types)) {
             // The mime type does exist, but does it exist with the given extension? If not, add it to the list.
             if (!array_key_exists($ext, $mime_types)) {
                 $mime_types[$ext] = $mime_type;
             }
         } else {
             // The mime type does not exist, so we can safely add it to the list.
             $mime_types[$ext] = $mime_type;
         }
     }
     return $mime_types;
 }