-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.php
39 lines (35 loc) · 1.06 KB
/
utils.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace inseri_core;
function extend_upload_mimes($mimes) {
$mimes['md|markdown'] = 'text/markdown';
$mimes['htm|html'] = 'text/html';
$mimes['py'] = 'text/x-python';
$mimes['r'] = 'text/x-r';
$mimes['js'] = 'text/javascript';
$mimes['json'] = 'application/json';
$mimes['jsonld'] = 'application/ld+json';
$mimes['yml|yaml'] = 'application/x-yaml';
$mimes['toml'] = 'application/toml';
$mimes['sql'] = 'application/sql';
$mimes['svg|svgz'] = 'image/svg+xml';
return $mimes;
}
function wp_check_filetype_and_ext($data, $file, $filename, $mimes) {
$filetype = wp_check_filetype($filename, $mimes);
return [
'ext' => $filetype['ext'],
'type' => $filetype['type'],
'proper_filename' => $data['proper_filename'],
];
}
function get_blocks() {
$path = plugin_dir_path(__FILE__) . '../build/blocks';
$dir_items = scandir($path);
$folders = array_filter($dir_items, function ($f) use ($path) {
return $f !== '.' && $f !== '..' && is_dir("$path/$f");
});
$folders = array_map(function ($f) use ($path) {
return "$path/$f";
}, $folders);
return $folders;
}