PluginProbe
StreamCast – bring live radio to your site with a sleek player / trunk
StreamCast – bring live radio to your site with a sleek player vtrunk
2.4.5 2.4.4 trunk 1.0 1.1 2.0.0 2.1.10 2.1.2 2.1.4 2.1.5 2.1.8 2.2.1 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 All 29 releases
streamcast / inc / enable-mime-type.php

enable-mime-type.php in StreamCast – bring live radio to your site with a sleek player trunk, at inc/enable-mime-type.php

49 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly
4 }
5
6 // Allow some additional file types for upload.
7 function streamcast_mime_types( $mimes ) {
8 // New allowed mime types.
9 $mimes['pls'] = 'audio/x-scpls';
10 $mimes['m3u8'] = 'application/vnd.apple.mpegurl';
11
12 return $mimes;
13 }
14 add_filter( 'upload_mimes', 'streamcast_mime_types' );
15
16 function streamcast_add_allow_upload_extension_exception( $data, $file, $filename, $mimes, $real_mime = null ) {
17 // If file extension is 2 or more.
18 $f_sp = explode( '.', $filename );
19 $f_exp_count = count( $f_sp );
20
21 if ( $f_exp_count <= 1 ) {
22 return $data;
23 } else {
24 $f_name = $f_sp[0];
25 $ext = $f_sp[ $f_exp_count - 1 ];
26 }
27
28 if ( 'pls' === $ext ) {
29 $type = 'audio/x-scpls';
30 $proper_filename = '';
31 return compact( 'ext', 'type', 'proper_filename' );
32 } elseif ( 'm3u8' === $ext ) {
33 $type = 'application/vnd.apple.mpegurl';
34 $proper_filename = '';
35 return compact( 'ext', 'type', 'proper_filename' );
36 } else {
37 return $data;
38 }
39 }
40
41 // It's different arguments between WordPress 5.1 and previous versions.
42 global $wp_version;
43 if ( version_compare( $wp_version, '5.1' ) >= 0 ) {
44 add_filter( 'wp_check_filetype_and_ext', 'streamcast_add_allow_upload_extension_exception', 10, 5 );
45 } else {
46 add_filter( 'wp_check_filetype_and_ext', 'streamcast_add_allow_upload_extension_exception', 10, 4 );
47 }
48
49