/wp-content/themes/zibll/inc/options/admin-options.php
//新增自定义文案文件名前缀开关
'custom' => __('自定义文案', 'zib_language'),
//新增自定义文案文件名前缀开关end
),
//新增自定义文案文件名前缀
'desc' => __('选择上传文件重命名的格式', 'zib_language'),
),
array(
'dependency' => array('newfilename_type', '==', 'custom'),
'title' => __('自定义文案', 'zib_language'),
'subtitle' => __('输入自定义的文案作为文件名前缀', 'zib_language'),
'id' => 'newfilename_custom_text',
'type' => 'text',
'default' => '',
),
//新增自定义文案文件名前缀end
- /wp-content/themes/zibll/inc/functions/zib-attachment.php
function zib_new_filename($file) { $newfilename_type = _pz('newfilename_type'); if ($newfilename_type === 'random') { $info = pathinfo($file['name']); $ext = empty($info['extension']) ? '' : '.' . $info['extension']; $md5 = md5($file['name']); $file['name'] = substr($md5, 0, 10) . current_time('YmdHis') . $ext; } elseif ($newfilename_type === 'time') { $file['name'] = current_time('YmdHis') . mt_rand(10, 99) . mt_rand(0, 9) . '-' . $file['name']; } elseif ($newfilename_type === 'custom') { $custom_text = _pz('newfilename_custom_text'); $file['name'] = $custom_text . '-' . $file['name']; } return $file; } if (_pz('newfilename')) { add_filter('wp_handle_upload_prefilter', 'zib_new_filename', 99); add_filter('wp_handle_sideload_prefilter', 'zib_new_filename', 99); }
文章源自小武站https://1z345.cn/小武站-https://bbs.50-0.cn/1022.html
继续阅读
拓宽眼界的最好途径之一,每一本都值得收藏
拓宽眼界的最好途径之一,每一本都值得收藏
[hidecontent type="vip1" desc="隐藏内容:会员可查看"]链接:https://caiyun.139.com/m/i?125Ce7vJ09B1D[/hidecontent]...
用php代码检测友链是否存在
用php代码检测友链是否存在
前言随着友链的增多,有些网站可能会不经意间就把你网站的友链去除掉了,所以就写了个php代码来检测友链是否存在教程1.首先在网站目录中新建一个urls.txt的文本。2.根据友链网站的友链地址,比如有些...