book
鼠子Blog
「Zibll子比主题附件自定义前缀名」
search
brightness_6
Zibll子比主题附件自定义前缀名
鼠子
apps
WordPress
local_offer
暂无标签
timer
2024-08-24
分享本文
· Zibll子比主题附件自定义前缀名
QQ好友
QQ空间
新浪微博
Twitter(X)
Facebook
highlight_off
关闭
/wp-content/themes/zibll/inc/options/admin-options.php ```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 ``` ![1724499318-image.webp](https://blog.miomoe.cn/uploads/2024/08/255363391.webp) /wp-content/themes/zibll/inc/functions/zib-attachment.php 这段整体替换 ![1724499560-image.webp](https://blog.miomoe.cn/uploads/2024/08/3874829497.webp) ```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://www.zibll.com/forum-post/28269.html](https://www.zibll.com/forum-post/28269.html?ref=26762 "https://www.zibll.com/forum-post/28269.html")
本文链接:
https://blog.miomoe.cn/WordPress/Zibll-attachment-custom-prefix-name.html
版权声明:
本站文章大部分始于原创,用于个人学习记录,可能对您有所帮助,仅供参考!
comment
暂无评论
所有评论
发表评论
万水千山总是情,评论一句行不行~
取消回复
account_circle
名称·Name
email
邮箱·E-Mail
link
主页链接·Link
提交评论
鼠子
ShuShuicu
鼠子的互联网笔记,记录一些有用的知识和
废话
。
search
分类归档
随机文章
home
首页
rss_feed
Reed
apps
文章分类
keyboard_arrow_up
随写
35
开发笔记
6
Web前端
5
WordPress
12
Typecho
11
服务器
0
网站导航
1
教程文档
2
软件工具
1
Games
1
GTA
3
MuseDash
0
年度总结
0
library_books
独立页面
keyboard_arrow_up
友情链接
关于博主
access_time
每月归档
keyboard_arrow_up
2024年9月
5
2024年8月
14
2024年7月
38
2024年6月
18
2024年5月
2
Typecho实现自定义静态资源加载功能
罪恶都市MyGO人物
ViewImage.js 小巧卓越的原生JavaScript灯箱插件
MioMoe 主题 Beta 1.0.2 更新日志
搞了个PHP随机图片Api
add
cancel
code
keyboard_arrow_up
keyboard_arrow_down
search
brightness_medium