PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.2.3
StreamCast – bring live radio to your site with a sleek player v2.2.3
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 / mimes / enable-mime-type.php

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

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