{"id":29864,"date":"2024-11-25T16:44:57","date_gmt":"2024-11-25T08:44:57","guid":{"rendered":"https:\/\/fwq.ai\/blog\/29864\/"},"modified":"2024-11-25T16:44:57","modified_gmt":"2024-11-25T08:44:57","slug":"wordpress%e4%b8%8a%e4%bc%a0%e6%96%87%e4%bb%b6%e8%87%aa%e5%8a%a8%e9%87%8d%e5%91%bd%e5%90%8d%e7%9a%84%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/29864\/","title":{"rendered":"WordPress\u4e0a\u4f20\u6587\u4ef6\u81ea\u52a8\u91cd\u547d\u540d\u7684\u65b9\u6cd5"},"content":{"rendered":"<p>\u4e0b\u9762\u7531\/&#8221; target=&#8221;_blank&#8221;&gt;<strong>wordpress\u5165\u95e8\u6559\u7a0b<\/strong>\u680f\u76ee\u7ed9\u5927\u5bb6\u63a8\u8350\u4e24\u6bb5\u5728\u4e0a\u4f20\u5a92\u4f53\u6587\u4ef6\u65f6\u81ea\u52a8\u91cd\u547d\u540d\u7684\u4ee3\u7801\u3002\u5e0c\u671b\u5bf9\u9700\u8981\u7684\u670b\u53cb\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/020\/5de08f08be360764.jpg\" class=\"aligncenter\" title=\"WordPress\u4e0a\u4f20\u6587\u4ef6\u81ea\u52a8\u91cd\u547d\u540d\u7684\u65b9\u6cd5\u63d2\u56fe\" alt=\"WordPress\u4e0a\u4f20\u6587\u4ef6\u81ea\u52a8\u91cd\u547d\u540d\u7684\u65b9\u6cd5\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4ee3\u7801\u4e00\uff0c\u6309\u65f6\u95f4\u91cd\u547d\u540d<\/strong><\/p>\n<p>\u4e0a\u4f20\u6587\u4ef6\u65f6\u4f1a\u4ee5\u201c\u5e74\u6708\u65e5\u65f6\u5206\u79d2+\u5343\u4f4d\u6beb\u79d2\u6574\u6570\u201d\u7684\u683c\u5f0f\u91cd\u547d\u540d\u6587\u4ef6\uff0c\u5982\u201c20161023122221765.jpg\u201d<\/p>\n<pre>\/\/\u4e0a\u4f20\u6587\u4ef6\u91cd\u547d\u540d\nfunction&nbsp;git_upload_filter($file)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;$time&nbsp;=&nbsp;date(\"YmdHis\");\n&nbsp;&nbsp;&nbsp;&nbsp;$file['name']&nbsp;=&nbsp;$time&nbsp;.&nbsp;\"\"&nbsp;.&nbsp;mt_rand(1,&nbsp;100)&nbsp;.&nbsp;\".\"&nbsp;.&nbsp;pathinfo($file['name'],&nbsp;PATHINFO_EXTENSION);\n&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;$file;\n}\nadd_filter('wp_handle_upload_prefilter',&nbsp;'git_upload_filter');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6e90\u4ee3\u7801\uff1a<\/p>\n<pre>http:\/\/www.lmlblog.com\/2147.html<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4ee3\u7801\u4e8c\uff0c\u7528MD5\u52a0\u5bc6\u751f\u6210\u6570\u5b57\u5e76\u91cd\u547d\u540d<\/strong><\/p>\n<p>\u540d\u79f0\u89c4\u5219\u662f\u7531\u7cfb\u7edf\u81ea\u52a8\u751f\u6210\u7684\u4e00\u4e2a32\u4f4d\u7684MD5\u52a0\u5bc6\u6587\u4ef6\u540d\uff0c\u7531\u4e8e\u9ed8\u8ba4\u751f\u6210\u768432\u4f4d\u6587\u4ef6\u540d\u6709\u70b9\u957f\uff0c\u6240\u4ee5\u4f7f\u7528substr(md5($name), 0, 20) \u622a\u65ad\u5c06\u5176\u8bbe\u7f6e\u4e3a20\u4f4d\u3002<\/p>\n<pre>function&nbsp;rename_filename($filename)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;$info&nbsp;=&nbsp;pathinfo($filename);\n&nbsp;&nbsp;&nbsp;&nbsp;$ext&nbsp;=&nbsp;emptyempty($info['extension'])&nbsp;?&nbsp;''&nbsp;:&nbsp;'.'&nbsp;.&nbsp;$info['extension'];\n&nbsp;&nbsp;&nbsp;&nbsp;$name&nbsp;=&nbsp;basename($filename,&nbsp;$ext);\n&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;substr(md5($name),&nbsp;0,&nbsp;20)&nbsp;.&nbsp;$ext;\n}\nadd_filter('sanitize_file_name',&nbsp;'rename_filename',&nbsp;10);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6e90\u4ee3\u7801\uff1a<\/p>\n<pre>http:\/\/www.boke8.net\/wordpress-auto-rename-file.html<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4f7f\u7528\u65b9\u6cd5<\/strong><\/p>\n<p>\u5c06\u4ee3\u7801\u6dfb\u52a0\u5230\u5f53\u524d\u4e3b\u9898functions.php\u6a21\u677f\u6587\u4ef6\u4e2d\u5373\u53ef\u3002<\/p>\n<p>\u4ee5\u4e0a\u4ee3\u7801\uff0c\u5f88\u65b9\u4fbf\uff0c\u8282\u7701\u65f6\u95f4\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fWordPress\u4e0a\u4f20\u6587\u4ef6\u81ea\u52a8\u91cd\u547d\u540d\u7684\u65b9\u6cd5\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u9762\u7531\/&#8221; target=&#8221;_blank&#8221;&gt;wordpress\u5165\u95e8\u6559\u7a0b\u680f\u76ee\u7ed9\u5927\u5bb6\u63a8\u8350\u4e24\u6bb5\u5728\u4e0a\u4f20\u5a92\u4f53\u6587\u4ef6\u65f6\u81ea\u52a8\u91cd\u547d\u540d\u7684\u4ee3\u7801\u3002\u5e0c\u671b\u5bf9\u9700\u8981\u7684\u670b\u53cb\u6709\u6240\u5e2e\u52a9\uff01 \u4ee3\u7801\u4e00\uff0c\u6309\u65f6\u95f4\u91cd\u547d\u540d \u4e0a\u4f20\u6587\u4ef6\u65f6\u4f1a\u4ee5\u201c\u5e74\u6708\u65e5\u65f6\u5206\u79d2+\u5343\u4f4d\u6beb\u79d2\u6574\u6570\u201d\u7684\u683c\u5f0f\u91cd\u547d\u540d\u6587\u4ef6\uff0c\u5982\u201c20161023122221765.jpg\u201d \/\/\u4e0a\u4f20\u6587\u4ef6\u91cd\u547d\u540d function&nbsp;git_upload_filter($file)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;$time&nbsp;=&nbsp;date(&#8220;YmdHis&#8221;); &nbsp;&nbsp;&nbsp;&nbsp;$file[&#8216;name&#8217;]&nbsp;=&nbsp;$time&nbsp;.&nbsp;&#8220;&#8221;&nbsp;.&nbsp;mt_rand(1,&nbsp;100)&nbsp;.&nbsp;&#8220;.&#8221;&nbsp;.&nbsp;pathinfo($file[&#8216;name&#8217;],&nbsp;PATHINFO_EXTENSION); &nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;$file; } add_filter(&#8216;wp_handle_upload_prefilter&#8217;,&nbsp;&#8216;git_upload_filter&#8217;); \u767b\u5f55\u540e\u590d\u5236 \u6e90\u4ee3\u7801\uff1a http:\/\/www.lmlblog.com\/2147.html \u767b\u5f55\u540e\u590d\u5236 \u4ee3\u7801\u4e8c\uff0c\u7528MD5\u52a0\u5bc6\u751f\u6210\u6570\u5b57\u5e76\u91cd\u547d\u540d \u540d\u79f0\u89c4\u5219\u662f\u7531\u7cfb\u7edf\u81ea\u52a8\u751f\u6210\u7684\u4e00\u4e2a32\u4f4d\u7684MD5\u52a0\u5bc6\u6587\u4ef6\u540d\uff0c\u7531\u4e8e\u9ed8\u8ba4\u751f\u6210\u768432\u4f4d\u6587\u4ef6\u540d\u6709\u70b9\u957f\uff0c\u6240\u4ee5\u4f7f\u7528substr(md5($name), 0, 20) \u622a\u65ad\u5c06\u5176\u8bbe\u7f6e\u4e3a20\u4f4d\u3002 function&nbsp;rename_filename($filename)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;$info&nbsp;=&nbsp;pathinfo($filename); &nbsp;&nbsp;&nbsp;&nbsp;$ext&nbsp;=&nbsp;emptyempty($info[&#8216;extension&#8217;])&nbsp;?&nbsp;&#8221;&nbsp;:&nbsp;&#8216;.&#8217;&nbsp;.&nbsp;$info[&#8216;extension&#8217;]; &nbsp;&nbsp;&nbsp;&nbsp;$name&nbsp;=&nbsp;basename($filename,&nbsp;$ext); &nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;substr(md5($name),&nbsp;0,&nbsp;20)&nbsp;.&nbsp;$ext; } add_filter(&#8216;sanitize_file_name&#8217;,&nbsp;&#8216;rename_filename&#8217;,&nbsp;10); \u767b\u5f55\u540e\u590d\u5236 \u6e90\u4ee3\u7801\uff1a http:\/\/www.boke8.net\/wordpress-auto-rename-file.html \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528\u65b9\u6cd5 \u5c06\u4ee3\u7801\u6dfb\u52a0\u5230\u5f53\u524d\u4e3b\u9898functions.php\u6a21\u677f\u6587\u4ef6\u4e2d\u5373\u53ef\u3002 \u4ee5\u4e0a\u4ee3\u7801\uff0c\u5f88\u65b9\u4fbf\uff0c\u8282\u7701\u65f6\u95f4\u3002 \u4ee5\u4e0a\u5c31\u662fWordPress\u4e0a\u4f20\u6587\u4ef6\u81ea\u52a8\u91cd\u547d\u540d\u7684\u65b9\u6cd5\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-29864","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29864","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=29864"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29864\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=29864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=29864"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=29864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}