Files
wp-cycling-stats/includes/core/gpx-upload.php
T
2026-04-22 12:51:16 +02:00

33 lines
929 B
PHP

<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Add GPX support to WordPress Media Library.
*
* @param array $mimes Allowed mime types.
* @return array Modified mime types.
*/
function statpress_add_gpx_mime_type( $mimes ) {
$mimes['gpx'] = 'application/gpx+xml';
return $mimes;
}
/**
* Bypasses WordPress's strict file type check for GPX files.
* This is needed because WordPress can be overly cautious with XML-based files.
*
* @param array $data File data.
* @param string $file Full path to the file.
* @param string $filename The filename.
* @param array $mimes Mime types.
* @return array Modified file data.
*/
function statpress_fix_gpx_upload_permission( $data, $file, $filename, $mimes ) {
if ( strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) ) === 'gpx' ) {
$data['ext'] = 'gpx';
$data['type'] = 'application/gpx+xml';
}
return $data;
}