mirror of https://github.com/vtrois/kratos
fix: renameother option
parent
0e47ac65f8
commit
4b4c9a5ead
|
@ -232,11 +232,11 @@ function custom_upload_filter($file)
|
||||||
|
|
||||||
$ext = '.' . $info['extension'];
|
$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');
|
$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 = explode("|", $str);
|
||||||
$arr = array_filter($arr);
|
$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) {
|
foreach ($compressed_mimes as $compressed_mime) {
|
||||||
if ($info['extension'] == $compressed_mime) {
|
if ($info['extension'] == $compressed_mime) {
|
||||||
$file['name'] = $prdfix . $file['name'];
|
$file['name'] = $prdfix . $file['name'];
|
||||||
|
|
|
@ -12,10 +12,17 @@ defined('ABSPATH') || exit;
|
||||||
$prefix = 'kratos_options';
|
$prefix = 'kratos_options';
|
||||||
|
|
||||||
if (!function_exists('kratos_option')) {
|
if (!function_exists('kratos_option')) {
|
||||||
function kratos_option($option = '', $default = null)
|
function kratos_option($option = '', $default = null, $fieldset = '')
|
||||||
{
|
{
|
||||||
$options = get_option('kratos_options');
|
$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(
|
'default' => array(
|
||||||
'g_renameother' => false,
|
'g_renameother' => false,
|
||||||
'g_renameother_prdfix' => '[' . getdomain(home_url()) . ']',
|
'g_renameother_prdfix' => getdomain(home_url()),
|
||||||
'g_renameother_mime' => 'tar|zip|gz|gzip|rar|7z',
|
'g_renameother_mime' => 'tar|zip|gz|gzip|rar|7z',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue