/** * Generate slug => description array for Frontend Uploader settings * @return array */ function fu_get_exts_descs() { $mimes = fu_get_mime_types(); $a = array(); foreach ($mimes as $ext => $mime) { $a[$ext] = sprintf('%1$s (.%2$s)', $mime['label'], $ext); } return $a; }
/** * Slightly convoluted workaround to allow modifying of allowed MIME types for WP < 3.5, * Workaround for IE sometimes setting image/pjepg and image/x-png for JPEGs and PNGs respectively */ function _get_mime_types() { // Use wp_get_mime_types if available, fallback to get_allowed_mime_types() $mime_types = function_exists('wp_get_mime_types') ? wp_get_mime_types() : get_allowed_mime_types(); $fu_mime_types = fu_get_mime_types(); // Workaround for IE $mime_types['jpg|jpe|jpeg|pjpg'] = 'image/pjpeg'; $mime_types['png|xpng'] = 'image/x-png'; // Iterate through default extensions foreach ($fu_mime_types as $extension => $details) { // Skip if it's not in the settings if (!in_array($extension, $this->settings['enabled_files'])) { continue; } // Iterate through mime-types for this extension foreach ($details['mimes'] as $ext_mime) { $mime_types[$extension . '|' . $extension . sanitize_title_with_dashes($ext_mime)] = $ext_mime; } } // Configuration filter: fu_allowed_mime_types should return array of allowed mime types (see readme) $mime_types = apply_filters('fu_allowed_mime_types', $mime_types); foreach ($mime_types as $ext_key => $mime) { // Check for php just in case if (false !== strpos($mime, 'php')) { unset($mime_types[$ext_key]); } } return $mime_types; }