{"id":5919,"date":"2020-07-04T22:03:55","date_gmt":"2020-07-04T13:03:55","guid":{"rendered":"https:\/\/nsme.red\/wp\/?p=5919"},"modified":"2020-07-04T22:03:55","modified_gmt":"2020-07-04T13:03:55","slug":"%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%83%a6%e3%83%bc%e3%82%b6%e3%83%bc%e4%bb%a5%e5%a4%96%e3%81%af%e9%9d%9e%e5%85%ac%e9%96%8b%e3%81%ab%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/core.nsme.net\/notes\/wordpress\/function-php\/5919\/","title":{"rendered":"\u30ed\u30b0\u30a4\u30f3\u30e6\u30fc\u30b6\u30fc\u4ee5\u5916\u306f\u975e\u516c\u958b\u306b\u3059\u308b"},"content":{"rendered":"\n<p>function require_login() {<br>\u00a0 \u00a0 if ( ! is_user_logged_in() &amp;&amp; ! preg_match( &#8216;\/^(wp-login\\.php|async-upload\\.php)\/&#8217;, basename( $_SERVER[&#8216;REQUEST_URI&#8217;] ) ) &amp;&amp; ! ( defined( &#8216;DOING_AJAX&#8217; ) &amp;&amp; DOING_AJAX ) \u00a0&amp;&amp; ! ( defined( &#8216;DOING_CRON&#8217; ) &amp;&amp; DOING_CRON ) ) {<br>\u00a0 \u00a0 \u00a0 \u00a0 auth_redirect();<br>\u00a0\u00a0 \u00a0}<br>}<br>add_action( &#8216;init&#8217;, &#8216;require_login&#8217; );<\/p>\n\n\n\n<p>\/\/cron\u30da\u30fc\u30b8\u3078\u306e\u30a2\u30af\u30bb\u30b9\u306f\u51fa\u6765\u308b\u3088\u3046\u306b\u5909\u66f4(\u5206\u5c90\u30da\u30fc\u30b8\u3082)<br>&nbsp; &nbsp; add_action(&#8216;wp&#8217;, &#8216;access_restriction&#8217;);<br>&nbsp; &nbsp; function access_restriction() {<br>&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;if (is_user_logged_in() || is_page(&#8216;cron&#8217;) || is_page(&#8216;branch&#8217;)) {<br>&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return;<br>&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;}else{<br>&nbsp; &nbsp; &nbsp; &nbsp; auth_redirect();<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>&nbsp; }<\/p>\n","protected":false},"excerpt":{"rendered":"<p>function require_login() {\u00a0 \u00a0 if ( ! is_user_logged_in() &amp;&amp; ! preg_match( &#8216;\/^(wp-login\\.php|asyn [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[29],"tags":[],"class_list":["post-5919","post","type-post","status-publish","format-standard","hentry","category-function-php"],"acf":[],"_links":{"self":[{"href":"https:\/\/core.nsme.net\/notes\/wp-json\/wp\/v2\/posts\/5919","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/core.nsme.net\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/core.nsme.net\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/core.nsme.net\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/core.nsme.net\/notes\/wp-json\/wp\/v2\/comments?post=5919"}],"version-history":[{"count":1,"href":"https:\/\/core.nsme.net\/notes\/wp-json\/wp\/v2\/posts\/5919\/revisions"}],"predecessor-version":[{"id":5920,"href":"https:\/\/core.nsme.net\/notes\/wp-json\/wp\/v2\/posts\/5919\/revisions\/5920"}],"wp:attachment":[{"href":"https:\/\/core.nsme.net\/notes\/wp-json\/wp\/v2\/media?parent=5919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/core.nsme.net\/notes\/wp-json\/wp\/v2\/categories?post=5919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/core.nsme.net\/notes\/wp-json\/wp\/v2\/tags?post=5919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}