Gruby refaktor
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add GPX support to WordPress Media Library.
|
||||
*
|
||||
* @param array $mimes Allowed mime types.
|
||||
* @return array Modified mime types.
|
||||
*/
|
||||
function mystat_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 mystat_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;
|
||||
}
|
||||
Reference in New Issue
Block a user