{"id":523,"date":"2006-02-04T21:58:40","date_gmt":"2006-02-04T12:58:40","guid":{"rendered":"http:\/\/zone.maple4ever.net\/blog\/archives\/523\/"},"modified":"2006-02-04T22:12:10","modified_gmt":"2006-02-04T13:12:10","slug":"seaedhuie-wordpress-fvffofcfidheoe","status":"publish","type":"post","link":"http:\/\/zone.maple4ever.net\/blog\/archives\/523\/","title":{"rendered":"\u6295\u7a3f\u5185\u5bb9\u3092\u6539\u5909\u3059\u308b WordPress \u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u3072\u306a\u5f62"},"content":{"rendered":"<p>\n    \u6295\u7a3f\u5185\u5bb9\u3092\u6539\u5909\u3059\u308b WordPress \u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u3072\u306a\u5f62\u3067\u3059\u3002\n<\/p>\n<div class=\"hl-surround\" style=\"height:280px;\"><ol class=\"hl-main\" start=1><li>&nbsp;<span class=\"hl-inlinetags\">&lt;?php\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-inlinetags\"><\/span><span class=\"hl-comment\">\/*\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-comment\">Plugin Name: \r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-comment\">Plugin URI: <\/span><span class=\"hl-url\">http:\/\/zone.maple4ever.net\/blog\/<\/span><span class=\"hl-comment\">\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-comment\">Description: \r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-comment\">Author: hiromasa\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-comment\">Version: 1.0\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-comment\">Author URI: <\/span><span class=\"hl-url\">http:\/\/zone.maple4ever.net\/blog\/\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-url\"><\/span><span class=\"hl-comment\">*\/\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-comment\">\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-comment\"><\/span><span class=\"hl-var\">$wppostfix<\/span><span class=\"hl-code\"> = <\/span><span class=\"hl-reserved\">new <\/span><span class=\"hl-identifier\">WpPostFix<\/span><span class=\"hl-brackets\">()<\/span><span class=\"hl-code\">;\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\">\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\"><\/span><span class=\"hl-identifier\">add_action<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-string\">save_post<\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-code\">, <\/span><span class=\"hl-reserved\">array<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-var\">$wppostfix<\/span><span class=\"hl-code\">, <\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-string\">postfix<\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-brackets\">)<\/span><span class=\"hl-code\">, <\/span><span class=\"hl-number\">99<\/span><span class=\"hl-brackets\">)<\/span><span class=\"hl-code\">;\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\"><\/span><span class=\"hl-identifier\">add_action<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-string\">edit_post<\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-code\">, <\/span><span class=\"hl-reserved\">array<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-var\">$wppostfix<\/span><span class=\"hl-code\">, <\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-string\">postfix<\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-brackets\">)<\/span><span class=\"hl-code\">, <\/span><span class=\"hl-number\">99<\/span><span class=\"hl-brackets\">)<\/span><span class=\"hl-code\">; \r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\"><\/span><span class=\"hl-identifier\">add_action<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-string\">publish_post<\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-code\">, <\/span><span class=\"hl-reserved\">array<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-var\">$wppostfix<\/span><span class=\"hl-code\">, <\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-string\">postfix<\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-brackets\">)<\/span><span class=\"hl-code\">, <\/span><span class=\"hl-number\">99<\/span><span class=\"hl-brackets\">)<\/span><span class=\"hl-code\">; \r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\">\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\"><\/span><span class=\"hl-reserved\">class <\/span><span class=\"hl-identifier\">WpPostFix <\/span><span class=\"hl-brackets\">{\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-brackets\">&nbsp; &nbsp; \r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-brackets\">&nbsp; &nbsp; <\/span><span class=\"hl-reserved\">function <\/span><span class=\"hl-identifier\">postfix<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-var\">$postID<\/span><span class=\"hl-brackets\">) {\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-brackets\">&nbsp; &nbsp; &nbsp; &nbsp; \r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-brackets\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"hl-reserved\">global <\/span><span class=\"hl-var\">$wpdb<\/span><span class=\"hl-code\">;\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\">&nbsp; &nbsp; &nbsp; &nbsp; \r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"hl-comment\">\/\/ DB \u304b\u3089 content \u3092 post_id \u304b\u3089\u691c\u7d22\u3057\u3066\u6301\u3063\u3066\u304d\u3066\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-comment\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"hl-var\">$content<\/span><span class=\"hl-code\"> = <\/span><span class=\"hl-var\">$wpdb<\/span><span class=\"hl-code\">-&gt;<\/span><span class=\"hl-identifier\">get_var<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-string\">SELECT post_content FROM <\/span><span class=\"hl-var\">{$wpdb-&gt;posts} WHERE ID = '{$postID}<\/span><span class=\"hl-string\">' LIMIT 1<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-brackets\">)<\/span><span class=\"hl-code\">;\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"hl-comment\">\/\/ \u9069\u5f53\u306b\u4fee\u6b63\u3057\u3066\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-comment\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"hl-var\">$content<\/span><span class=\"hl-code\"> = <\/span><span class=\"hl-var\">$this<\/span><span class=\"hl-code\">-&gt;<\/span><span class=\"hl-identifier\">fixcontent<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-var\">$content<\/span><span class=\"hl-brackets\">)<\/span><span class=\"hl-code\">;\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"hl-comment\">\/\/ DB \u3092\u306a\u304a\u3057\u305f\u5185\u5bb9\u3067\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3059\u308b\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-comment\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"hl-var\">$wpdb<\/span><span class=\"hl-code\">-&gt;<\/span><span class=\"hl-identifier\">query<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-string\">UPDATE <\/span><span class=\"hl-var\">{$wpdb-&gt;posts} SET post_content = '{$content}' WHERE ID = '{$postID}<\/span><span class=\"hl-string\">'<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-brackets\">)<\/span><span class=\"hl-code\">;\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\">&nbsp; &nbsp; &nbsp; &nbsp; \r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"hl-comment\">\/\/ \u6b21\u306e\u4eba\u306e\u305f\u3081\u306b post_id \u623b\u3057\u3066\u304a\u304f\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-comment\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"hl-reserved\">return <\/span><span class=\"hl-var\">$postID<\/span><span class=\"hl-code\">;\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\">&nbsp; &nbsp; &nbsp; &nbsp; \r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\">&nbsp; &nbsp; <\/span><span class=\"hl-brackets\">}\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-brackets\">&nbsp; &nbsp; \r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-brackets\">&nbsp; &nbsp; <\/span><span class=\"hl-reserved\">function <\/span><span class=\"hl-identifier\">fixcontent<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-var\">$content<\/span><span class=\"hl-brackets\">) {\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-brackets\">&nbsp; &nbsp; &nbsp; &nbsp; \r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-brackets\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"hl-comment\">\/\/ \u6b63\u898f\u8868\u73fe\u3068\u304b\u3067\u7f6e\u63db\u3059\u308b\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-comment\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"hl-var\">$before<\/span><span class=\"hl-code\"> = <\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-string\">hogehoge<\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-code\">;\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"hl-var\">$after<\/span><span class=\"hl-code\">&nbsp; = <\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-string\">mogemoge<\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-code\">;\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"hl-var\">$content<\/span><span class=\"hl-code\"> = <\/span><span class=\"hl-identifier\">preg_replace<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-string\">\/<\/span><span class=\"hl-var\">$before<\/span><span class=\"hl-string\">\/i<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-code\">, <\/span><span class=\"hl-var\">$after<\/span><span class=\"hl-code\">, <\/span><span class=\"hl-var\">$content<\/span><span class=\"hl-brackets\">)<\/span><span class=\"hl-code\">;\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"hl-comment\">\/\/ \u623b\u3059\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-comment\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"hl-reserved\">return <\/span><span class=\"hl-var\">$content<\/span><span class=\"hl-code\">;\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\">&nbsp; &nbsp; &nbsp; &nbsp; \r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-code\">&nbsp; &nbsp; <\/span><span class=\"hl-brackets\">}\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-brackets\">&nbsp; &nbsp; \r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-brackets\">}\r<\/span><\/li>\n<li>&nbsp;<span class=\"hl-brackets\"><\/span><span class=\"hl-inlinetags\">?&gt;<\/span><\/li><\/ol><\/div>\n<p>\n    \u6295\u7a3f\u6642\u306b\u3001add_action \u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u5185\u5bb9\u3092\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3057\u3066\u3057\u307e\u3046\u30b3\u30fc\u30c9\u3067\u3059\u3002\u3000\u4e0a\u306e\u4f8b\u306f\u30a8\u30f3\u30c8\u30ea\u4e2d\u306b\u3001hogehoge \u304c\u3042\u3063\u305f\u3089 mogemoge \u306b\u7f6e\u63db\u3057\u307e\u3059\u3002\n<\/p>\n<p>\n    \u30d5\u30a3\u30eb\u30bf\u30fc\u3067\u306f\u306a\u3044\u306e\u3067\u3001\u5b9f\u30c7\u30fc\u30bf\u304b\u304d\u304b\u3048\u3061\u3083\u3044\u307e\u3059\u3002\u4f7f\u3046\u3068\u304d\u306f\u304a\u6c17\u3092\u3064\u3051\u304f\u3060\u3055\u3044\u3002 \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6295\u7a3f\u5185\u5bb9\u3092\u6539\u5909\u3059\u308b WordPress \u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u3072\u306a\u5f62\u3067\u3059\u3002 &nbsp;&lt;?php &nbsp;\/* &nbsp;Plugin Name: &nbsp;Plugin URI: http:\/\/zone.maple4ever.net\/blog\/ &nbsp;Description: &nbsp;Author: hiromasa &nbsp;Version: 1.0 &nbsp;Author URI: http:\/\/zone.maple4ever.net\/blog\/ &nbsp;*\/ &nbsp; &nbsp;$wppostfix = new WpPostFix(); &nbsp; &nbsp;add_action(&#8216;save_post&#8217;, array($wppostfix, &#8216;postfix&#8217;), 99); &nbsp;add_action(&#8216;edit_post&#8217;, array($wppostfix, &#8216;postfix&#8217;), 99); &nbsp;add_action(&#8216;publish_post&#8217;, array($wppostfix, &#8216;postfix&#8217;), 99); &nbsp; &nbsp;class WpPostFix { &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; function postfix($postID) { &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/zone.maple4ever.net\/blog\/wp-json\/wp\/v2\/posts\/523"}],"collection":[{"href":"http:\/\/zone.maple4ever.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zone.maple4ever.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zone.maple4ever.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/zone.maple4ever.net\/blog\/wp-json\/wp\/v2\/comments?post=523"}],"version-history":[{"count":0,"href":"http:\/\/zone.maple4ever.net\/blog\/wp-json\/wp\/v2\/posts\/523\/revisions"}],"wp:attachment":[{"href":"http:\/\/zone.maple4ever.net\/blog\/wp-json\/wp\/v2\/media?parent=523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zone.maple4ever.net\/blog\/wp-json\/wp\/v2\/categories?post=523"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zone.maple4ever.net\/blog\/wp-json\/wp\/v2\/tags?post=523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}