{"id":1968,"date":"2014-04-26T11:01:20","date_gmt":"2014-04-26T02:01:20","guid":{"rendered":"http:\/\/www.a-legend.net\/wordpress\/?p=1968"},"modified":"2019-09-23T10:14:35","modified_gmt":"2019-09-23T01:14:35","slug":"tipswordpress-%e3%80%8c%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e5%90%8d%e5%91%bd%e5%90%8d%e8%a6%8f%e7%b4%84%e7%b5%b1%e4%b8%80%e5%8c%96%e3%80%8d","status":"publish","type":"post","link":"https:\/\/www.a-legend.net\/?p=1968","title":{"rendered":"[Tips] \u300eFile Renaming on upload\u300f\u30d7\u30e9\u30b0\u30a4\u30f3 \uff08WordPress\uff09"},"content":{"rendered":"<p>\u3044\u3061\u3044\u3061\u753b\u50cf\u3092\u30a2\u30c3\u30d7\u3059\u308b\u969b\u306b\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u5909\u3048\u3066\u304b\u3089\u30a2\u30c3\u30d7\u3059\u308b\u306e\u304c\u9762\u5012\u304f\u3055\u3044\u65b9\u306b\u306f\u30b3\u30ec<br \/>\n\u30d7\u30e9\u30b0\u30a4\u30f3\u300cFile Renaming on upload\u300d<\/p>\n<p>\u753b\u50cf\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u305f\u969b\u306b\u3001\u81ea\u52d5\u3067\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u5909\u63db\u3057\u3066\u304f\u308c\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u3059\u3002<br \/>\nWeb\u5f62\u5f0f\u3067\u3059\u3068\u65e5\u672c\u8a9e\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u30a2\u30c3\u30d7\u3059\u308b\u3068\u6587\u5b57\u5316\u3051\u3057\u3066\u3057\u307e\u3046\u3068\u3044\u3046\u4e0d\u4fbf\u3055\u3092\u89e3\u6d88\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<p>\u79c1\u306f\u30a2\u30c3\u30d7\u6642\u9593\u3092\u30d5\u30a1\u30a4\u30eb\u540d\u306b\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u30a2\u30c3\u30d7\u6642\u306e\u6642\u9593\u304cUTC\uff08\u4e16\u754c\u6a19\u6e96\u6642\u9593\uff09\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u3001\u65e5\u672c\u6642\u9593\u3088\u308a9\u6642\u9593\u524d\u306e\u6642\u9593\u3067\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<br \/>\n\u305d\u308c\u3092\u89e3\u6d88\u3059\u308b\u305f\u3081\u306b\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u4e00\u90e8\u5206\u3092\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p>\u5bfe\u8c61\u30d5\u30a1\u30a4\u30eb\uff1afile-renaming-on-upload\/classes\/Options\/Rules\/class-datetime-option.php\uff08\u30d0\u30fc\u30b8\u30e7\u30f3 2.3.4\uff09<\/p>\n<p>\u4ee5\u4e0b\u90e8\u5206\u306b\u30bf\u30a4\u30e0\u30be\u30fc\u30f3\u6307\u5b9a\u304c\u5fc5\u8981<br \/>\n\uff1c\u5909\u66f4\u524d\uff1e<\/p>\n<div class=\"codecolorer-container php default\" style=\"overflow:auto;white-space:nowrap;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/><\/div><\/td><td><div class=\"php codecolorer\"><span class=\"kw1\">if<\/span> <span class=\"br0\">&#40;<\/span> <a href=\"http:\/\/www.php.net\/strpos\"><span class=\"kw3\">strpos<\/span><\/a><span class=\"br0\">&#40;<\/span> <span class=\"re0\">$structure_rules<\/span><span class=\"sy0\">,<\/span> <span class=\"st_h\">'{'<\/span> <span class=\"sy0\">.<\/span> <span class=\"re0\">$this<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">option_id<\/span> <span class=\"sy0\">.<\/span> <span class=\"st_h\">'}'<\/span> <span class=\"br0\">&#41;<\/span> <span class=\"sy0\">!==<\/span> <span class=\"kw4\">false<\/span> <span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"re0\">$datetime<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"sy0\">=<\/span> \\DateTime<span class=\"sy0\">::<\/span><span class=\"me2\">createFromFormat<\/span><span class=\"br0\">&#40;<\/span> <span class=\"st_h\">'U.u'<\/span><span class=\"sy0\">,<\/span> <a href=\"http:\/\/www.php.net\/number_format\"><span class=\"kw3\">number_format<\/span><\/a><span class=\"br0\">&#40;<\/span><a href=\"http:\/\/www.php.net\/microtime\"><span class=\"kw3\">microtime<\/span><\/a><span class=\"br0\">&#40;<\/span><span class=\"kw4\">true<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">6<\/span><span class=\"sy0\">,<\/span> <span class=\"st_h\">'.'<\/span><span class=\"sy0\">,<\/span> <span class=\"st_h\">''<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"re0\">$format<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"sy0\">=<\/span> <span class=\"re0\">$datetime<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">format<\/span><span class=\"br0\">&#40;<\/span> <span class=\"re0\">$this<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">get_option<\/span><span class=\"br0\">&#40;<\/span> <span class=\"re0\">$this<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">option_datetime_format<\/span><span class=\"sy0\">,<\/span> <span class=\"st_h\">'Y-m-d_H-i-s_u'<\/span> <span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"re0\">$filename_infs<\/span><span class=\"br0\">&#91;<\/span><span class=\"st_h\">'structure'<\/span><span class=\"br0\">&#93;<\/span><span class=\"br0\">&#91;<\/span><span class=\"st_h\">'translation'<\/span><span class=\"br0\">&#93;<\/span><span class=\"br0\">&#91;<\/span> <span class=\"re0\">$this<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">option_id<\/span> <span class=\"br0\">&#93;<\/span> <span class=\"sy0\">=<\/span> <span class=\"re0\">$format<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\uff1c\u5909\u66f4\u5f8c\uff1e<\/p>\n<div class=\"codecolorer-container php default\" style=\"overflow:auto;white-space:nowrap;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/><\/div><\/td><td><div class=\"php codecolorer\"><span class=\"kw1\">if<\/span> <span class=\"br0\">&#40;<\/span> <a href=\"http:\/\/www.php.net\/strpos\"><span class=\"kw3\">strpos<\/span><\/a><span class=\"br0\">&#40;<\/span> <span class=\"re0\">$structure_rules<\/span><span class=\"sy0\">,<\/span> <span class=\"st_h\">'{'<\/span> <span class=\"sy0\">.<\/span> <span class=\"re0\">$this<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">option_id<\/span> <span class=\"sy0\">.<\/span> <span class=\"st_h\">'}'<\/span> <span class=\"br0\">&#41;<\/span> <span class=\"sy0\">!==<\/span> <span class=\"kw4\">false<\/span> <span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"re0\">$datetime<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"sy0\">=<\/span> \\DateTime<span class=\"sy0\">::<\/span><span class=\"me2\">createFromFormat<\/span><span class=\"br0\">&#40;<\/span> <span class=\"st_h\">'U.u'<\/span><span class=\"sy0\">,<\/span> <a href=\"http:\/\/www.php.net\/number_format\"><span class=\"kw3\">number_format<\/span><\/a><span class=\"br0\">&#40;<\/span><a href=\"http:\/\/www.php.net\/microtime\"><span class=\"kw3\">microtime<\/span><\/a><span class=\"br0\">&#40;<\/span><span class=\"kw4\">true<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">6<\/span><span class=\"sy0\">,<\/span> <span class=\"st_h\">'.'<\/span><span class=\"sy0\">,<\/span> <span class=\"st_h\">''<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">setTimezone<\/span><span class=\"br0\">&#40;<\/span><span class=\"kw2\">new<\/span> \\DateTimeZone<span class=\"br0\">&#40;<\/span><span class=\"st_h\">'Asia\/Tokyo'<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"re0\">$format<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"sy0\">=<\/span> <span class=\"re0\">$datetime<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">format<\/span><span class=\"br0\">&#40;<\/span> <span class=\"re0\">$this<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">get_option<\/span><span class=\"br0\">&#40;<\/span> <span class=\"re0\">$this<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">option_datetime_format<\/span><span class=\"sy0\">,<\/span> <span class=\"st_h\">'Y-m-d_H-i-s_u'<\/span> <span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"re0\">$filename_infs<\/span><span class=\"br0\">&#91;<\/span><span class=\"st_h\">'structure'<\/span><span class=\"br0\">&#93;<\/span><span class=\"br0\">&#91;<\/span><span class=\"st_h\">'translation'<\/span><span class=\"br0\">&#93;<\/span><span class=\"br0\">&#91;<\/span> <span class=\"re0\">$this<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">option_id<\/span> <span class=\"br0\">&#93;<\/span> <span class=\"sy0\">=<\/span> <span class=\"re0\">$format<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p><del datetime=\"2019-09-23T01:04:37+00:00\">\u53c2\u8003URL<br \/>\n<a href=\"http:\/\/wordpress-recipe.com\/recipe\/media-upload-filepath-naming-rule\/\" target=\"_blank\" rel=\"noopener noreferrer\">WordPress\u306e\u753b\u50cf\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u6642\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u306e\u547d\u540d\u898f\u5247\u3092\u7d71\u4e00\u3055\u305b\u308b\u305f\u3081\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u300cFile Renaming on upload\u300d\u65e5\u672c\u306e\u30bf\u30a4\u30e0\u30be\u30fc\u30f3\u306b\u5bfe\u5fdc\u3055\u305b\u308b\u65b9\u6cd5<\/a><\/del><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3044\u3061\u3044\u3061\u753b\u50cf\u3092\u30a2\u30c3\u30d7\u3059\u308b\u969b\u306b\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u5909\u3048\u3066\u304b\u3089\u30a2\u30c3\u30d7\u3059\u308b\u306e\u304c\u9762\u5012\u304f\u3055\u3044\u65b9\u306b\u306f\u30b3\u30ec<br \/>\n\u30d7\u30e9\u30b0\u30a4\u30f3\u300cFile Renaming on upload\u300d<\/p>\n","protected":false},"author":2,"featured_media":2741,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,11],"tags":[66,63],"class_list":["post-1968","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tips","category-wordpress","tag-tips","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.a-legend.net\/index.php?rest_route=\/wp\/v2\/posts\/1968","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.a-legend.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.a-legend.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.a-legend.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.a-legend.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1968"}],"version-history":[{"count":0,"href":"https:\/\/www.a-legend.net\/index.php?rest_route=\/wp\/v2\/posts\/1968\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.a-legend.net\/index.php?rest_route=\/wp\/v2\/media\/2741"}],"wp:attachment":[{"href":"https:\/\/www.a-legend.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.a-legend.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1968"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.a-legend.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}