fix: renameother option

pull/409/head^2
Seaton Jiang 2021-08-20 08:28:24 +08:00
parent 0e47ac65f8
commit 4b4c9a5ead
No known key found for this signature in database
GPG Key ID: 0E05070D261ACFEA
2 changed files with 13 additions and 6 deletions

View File

@ -232,11 +232,11 @@ function custom_upload_filter($file)
$ext = '.' . $info['extension'];
$prdfix = kratos_option('g_renameother_prdfix', '') . '-';
$prdfix = kratos_option('g_renameother_prdfix', getdomain(home_url()), 'g_renameother') . '-';
$img_mimes = array('jpg', 'JPG', 'jpeg', 'JPEG', 'gif', 'GIF', 'png', 'PNG', 'bmp', 'BMP', 'webp', 'WEBP', 'svg', 'SVG');
$str = kratos_option('g_renameother_mime', '');
$str = kratos_option('g_renameother_mime', 'tar|zip|gz|gzip|rar|7z', 'g_renameother');
$arr = explode("|", $str);
$arr = array_filter($arr);
@ -255,7 +255,7 @@ function custom_upload_filter($file)
}
}
if (kratos_option('g_renameother', false)) {
if (kratos_option('g_renameother', false, 'g_renameother')) {
foreach ($compressed_mimes as $compressed_mime) {
if ($info['extension'] == $compressed_mime) {
$file['name'] = $prdfix . $file['name'];

View File

@ -12,10 +12,17 @@ defined('ABSPATH') || exit;
$prefix = 'kratos_options';
if (!function_exists('kratos_option')) {
function kratos_option($option = '', $default = null)
function kratos_option($option = '', $default = null, $fieldset = '')
{
$options = get_option('kratos_options');
return (isset($options[$option])) ? $options[$option] : $default;
if (!empty($fieldset)) {
$results = $options[$fieldset . "_fieldset"][$option];
} else {
$results = $options[$option];
}
return (isset($results)) ? $results : $default;
}
}
@ -200,7 +207,7 @@ CSF::createSection($prefix, array(
),
'default' => array(
'g_renameother' => false,
'g_renameother_prdfix' => '[' . getdomain(home_url()) . ']',
'g_renameother_prdfix' => getdomain(home_url()),
'g_renameother_mime' => 'tar|zip|gz|gzip|rar|7z',
),
),