{"id":8724,"date":"2012-01-22T21:00:34","date_gmt":"2012-01-22T12:00:34","guid":{"rendered":"http:\/\/www.sssg.org\/blogs\/hiro345\/?p=8724"},"modified":"2012-01-23T09:07:06","modified_gmt":"2012-01-23T00:07:06","slug":"%e7%b0%a1%e5%8d%98%ef%bc%81wordpress%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%b8%e8%a8%ad%e5%ae%9a%e7%94%bb%e9%9d%a2%e3%82%92%e8%bf%bd%e5%8a%a0%e3%81%97%e3%82%88%e3%81%86","status":"publish","type":"post","link":"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/8724.html","title":{"rendered":"\u7c21\u5358\uff01WordPress\u30d7\u30e9\u30b0\u30a4\u30f3\u3078\u8a2d\u5b9a\u753b\u9762\u3092\u8ffd\u52a0\u3057\u3088\u3046"},"content":{"rendered":"<p>WordPress\u30d7\u30e9\u30b0\u30a4\u30f3\u3078\u8a2d\u5b9a\u753b\u9762\u3092\u8ffd\u52a0\u3057\u305f\u3044\u3068\u304d\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u3082\u7c21\u5358\u306b\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<br \/>\n<!--more--><\/p>\n<p>\u30b5\u30f3\u30d7\u30eb\u3067\u306f\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u6709\u52b9\u306b\u3057\u305f\u3068\u304d\u306b\u3001sample_config_plugin_init_options()\u95a2\u6570\u3067Option\u30c6\u30fc\u30d6\u30eb\u3078\u5404\u9805\u76ee\u306e\u521d\u671f\u5024\u3092\u8a2d\u5b9a\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u30d7\u30e9\u30b0\u30a4\u30f3\u6709\u52b9\u6642\u306b\u547c\u3073\u51fa\u3055\u308c\u308b\u3088\u3046\u306b\u3059\u308b\u306b\u306f\u3001register_activation_hook()\u95a2\u6570\u3092\u4f7f\u3044\u307e\u3059\u3002function sample-config-plugin-func()\u306f\u3068\u308a\u3042\u3048\u305a\u306e\u3068\u3053\u308d\u306f\u4e2d\u8eab\u304c\u7a7a\u3067\u767b\u9332\u3082\u3057\u3066\u3044\u307e\u305b\u3093\u3002\u8a2d\u5b9a\u753b\u9762\u3078\u306e\u767b\u9332\u306fadd_action(&#039;admin_menu&#039;, &#039;sample_config_plugin_add_admin_menu&#039;);\u306e\u884c\u3067\u3057\u3066\u3044\u307e\u3059\u3002sample_config_plugin_add_admin_menu()\u95a2\u6570\u3092\u547c\u3073\u51fa\u3057\u3001\u30b5\u30d6\u30e1\u30cb\u30e5\u30fc\u767b\u9332\u3092\u3057\u3066\u3044\u307e\u3059\u3002\u753b\u9762\u306fsample_config_plugin_admin_page()\u3067\u7528\u610f\u3057\u3001\u6295\u7a3f\u3001\u53c2\u7167\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; gutter: true\">\r\n&lt;?php\r\n\/*\r\n  Plugin Name: sample-config-plugin\r\n  Plugin URI: https:\/\/www.hiro345.net\/blogs\/hiro345\/sample-config-plugin\r\n  Description: sample-config-plugin\r\n  Version: 1.0\r\n  Author: hiro345\r\n  Author URI: https:\/\/www.hiro345.net\/blogs\/hiro345\/\r\n *\/\r\nfunction sample-config-plugin-func($args = &#039;&#039;) {\r\n}\r\n\r\nfunction sample_config_plugin_init_options() {\r\n  if (!get_option(&#039;sample-config-plugin_installed&#039;)) {\r\n    update_option(&#039;sample_config_int&#039;, -1);\r\n    update_option(&#039;sample_config_string&#039;, &#039;sample_config&#039;);\r\n    update_option(&#039;sample_config_plugin_installed&#039;, 1);\r\n  }\r\n}\r\nregister_activation_hook(__FILE__, &#039;sample_config_plugin_init_options&#039;);\r\n\r\nfunction sample_config_plugin_add_admin_menu() {\r\n  add_submenu_page(&#039;plugins.php&#039;, &#039;sample config plugin\u306e\u8a2d\u5b9a&#039;, &#039;sample_config_plugin\u306e\u8a2d\u5b9a&#039;, 8, __FILE__, &#039;sample_config_plugin_admin_page&#039;);\r\n}\r\nadd_action(&#039;admin_menu&#039;, &#039;sample_config_plugin_add_admin_menu&#039;);\r\n\r\nfunction sample_config_plugin_admin_page() {\r\n  \/\/ \u300c\u5909\u66f4\u3092\u4fdd\u5b58\u300d\u30dc\u30bf\u30f3\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3068\u304d\u306f\u3001\u8a2d\u5b9a\u3092\u4fdd\u5b58\u3059\u308b\r\n  if ($_POST[&#039;posted&#039;] == &#039;Y&#039;) {\r\n    update_option(&#039;sample_config_int&#039;, intval($_POST[&#039;config_int&#039;]));\r\n    update_option(&#039;sample_config_string&#039;, stripslashes($_POST[&#039;config_string&#039;]));\r\n  }\r\n?&gt;\r\n&lt;?php if($_POST[&#039;posted&#039;] == &#039;Y&#039;) : ?&gt;&lt;div class=&quot;updated&quot;&gt;&lt;p&gt;&lt;strong&gt;\u8a2d\u5b9a\u3092\u4fdd\u5b58\u3057\u307e\u3057\u305f&lt;\/strong&gt;&lt;\/p&gt;&lt;\/div&gt;&lt;?php endif; ?&gt;\r\n&lt;?php if($_POST[&#039;posted&#039;] == &#039;Y&#039;) : ?&gt;\r\n&lt;!-- config_string = &lt;?php echo $_POST[&#039;config_string&#039;]; ?&gt;, striped = &lt;?php echo stripslashes($_POST[&#039;config_string&#039;]); ?&gt;, saved = &lt;?php get_option(&#039;sample_config_string&#039;); ?&gt; --&gt;\r\n&lt;?php endif; ?&gt;\r\n&lt;div class=&quot;wrap&quot;&gt;\r\n  &lt;h2&gt;sample config plugin \u306e\u8a2d\u5b9a&lt;\/h2&gt;\r\n  &lt;form method=&quot;post&quot; action=&quot;&lt;?php echo str_replace( &#039;%7E&#039;, &#039;~&#039;, $_SERVER[&#039;REQUEST_URI&#039;]); ?&gt;&quot;&gt;\r\n    &lt;input type=&quot;hidden&quot; name=&quot;posted&quot; value=&quot;Y&quot;&gt;\r\n    &lt;table class=&quot;form-table&quot;&gt;\r\n      &lt;tr valign=&quot;top&quot;&gt;\r\n        &lt;th scope=&quot;row&quot;&gt;&lt;label for=&quot;config_int&quot;&gt;config_int&lt;label&gt;&lt;\/th&gt;\r\n        &lt;td&gt;\r\n          &lt;input name=&quot;config_int&quot; type=&quot;text&quot; id=&quot;config_int&quot; value=&quot;&lt;?php echo get_option(&#039;sample_config_int&#039;); ?&gt;&quot; class=&quot;regular-text code&quot; \/&gt;&lt;br \/&gt;\r\n          config_int\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\r\n        &lt;\/td&gt;\r\n      &lt;\/tr&gt;\r\n      &lt;tr valign=&quot;top&quot;&gt;\r\n        &lt;th scope=&quot;row&quot;&gt;&lt;label for=&quot;config_string&quot;&gt;config_string&lt;label&gt;&lt;\/th&gt;\r\n        &lt;td&gt;\r\n          &lt;input name=&quot;config_string&quot; type=&quot;text&quot; id=&quot;config_string&quot; value=&quot;&lt;?php echo esc_attr(get_option(&#039;sample_config_string&#039;)); ?&gt;&quot; class=&quot;regular-text code&quot; \/&gt;&lt;br \/&gt;config_string\u306e\u6587\u5b57\u5217\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\r\n        &lt;\/td&gt;\r\n      &lt;\/tr&gt;\r\n    &lt;\/table&gt;\r\n    &lt;p class=&quot;submit&quot;&gt;\r\n      &lt;input type=&quot;submit&quot; name=&quot;Submit&quot; class=&quot;button-primary&quot; value=&quot;\u5909\u66f4\u3092\u4fdd\u5b58&quot; \/&gt;\r\n    &lt;\/p&gt;\r\n  &lt;\/form&gt;\r\n&lt;\/div&gt;\r\n&lt;?php\r\n}\r\n?&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>WordPress\u30d7\u30e9\u30b0\u30a4\u30f3\u3078\u8a2d\u5b9a\u753b\u9762\u3092\u8ffd\u52a0\u3057\u305f\u3044\u3068\u304d\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u3082\u7c21\u5358\u306b\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[295,70],"class_list":["post-8724","post","type-post","status-publish","format-standard","hentry","category-program","tag-php","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/8724","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/comments?post=8724"}],"version-history":[{"count":2,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/8724\/revisions"}],"predecessor-version":[{"id":8726,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/8724\/revisions\/8726"}],"wp:attachment":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/media?parent=8724"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/categories?post=8724"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/tags?post=8724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}