{"id":2915,"date":"2012-04-20T18:46:08","date_gmt":"2012-04-20T09:46:08","guid":{"rendered":"https:\/\/y2tech.net\/blog\/?p=2915"},"modified":"2012-04-20T17:22:02","modified_gmt":"2012-04-20T08:22:02","slug":"killing_wp_auto_paragraph","status":"publish","type":"post","link":"https:\/\/y2tech.net\/blog\/inet\/wp\/killing_wp_auto_paragraph-2915\/","title":{"rendered":"WordPress\u306e\u81ea\u52d5\u6574\u5f62\u6a5f\u80fd\u3092\u5916\u3059\u65b9\u6cd5"},"content":{"rendered":"<h3>WordPress\u306e\u81ea\u52d5\u6574\u5f62\u6a5f\u80fd(auto paragraph) \u3092\u7121\u52b9\u306b\u3059\u308b\u65b9\u6cd5<\/h3>\r\n<br>\r\n<p>WordPress\u306e\u30c6\u30ad\u30b9\u30c8\u30a8\u30c7\u30a3\u30bf\u306b\u306f\u3001Visual\u30e2\u30fc\u30c9\u3068HTML\u30e2\u30fc\u30c9\u306e\uff12\u7a2e\u985e\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u5927\u90e8\u5206\u306e\u4eba\u306fHTML\u30e2\u30fc\u30c9\u3067\u5165\u529b\u3057\u3066\u3044\u308b\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\uff0eWordpress\u3092\u4f7f\u3046\u3088\u3046\u306a\u4eba\u306fWEB\u6280\u8853\u306b\u9577\u3051\u305f\u4eba\u305f\u3061\u306a\u306e\u3067\u3001\u8a33\u306e\u308f\u304b\u3089\u306a\u3044HTML\u30b3\u30fc\u30c9\u3092\u52dd\u624b\u306b\u751f\u6210\u3055\u308c\u308b\u3088\u308a\u306f\u3001\u81ea\u5206\u3067HTML\u30b3\u30fc\u30c9\u3092\u81ea\u7531\u306b\u5165\u529b\u3067\u304d\u308bHTML\u30e2\u30fc\u30c9\u3092\u597d\u3093\u3067\u4f7f\u3046\u306e\u3060\u3068\u601d\u3044\u307e\u3059\uff0e\r<\/p>\r\n<br>\r\n<p>HTML\u30b3\u30fc\u30c9\u3092\u81ea\u7531\u306b\u5165\u529b\u3067\u304d\u308b\u306e\u306f\u826f\u3044\u306e\u3067\u3059\u304c\u3001\u6b8b\u5ff5\u306a\u3053\u3068\u306bWordpress\u306f\u4f59\u8a08\u306a\u304a\u7bc0\u4ecb\u3092\u50cd\u3044\u3066\u30e6\u30fc\u30b6\u304c\u5165\u529b\u3057\u305fHTML\u30b3\u30fc\u30c9\u3092\u52dd\u624b\u306b\u5909\u66f4\u3057\u3066\u3057\u307e\u3044\u307e\u3059\uff0eauto paragraph \u3068\u547c\u3070\u308c\u3066\u3044\u308b\u3053\u306e\u6a5f\u80fd\u306f\u3001\u4e3b\u306b\u30c6\u30ad\u30b9\u30c8\u306e\u6539\u884c\u30b3\u30fc\u30c9\u3084HTML\u306e\u6539\u884c\u30b3\u30fc\u30c9\u3092\u52dd\u624b\u306b\u5909\u63db\u3057\u3066\u3057\u307e\u3044\u307e\u3059\uff0e\u30e6\u30fc\u30b6\u304c\u610f\u56f3\u3057\u3066\u5165\u308c\u305f\u6539\u884c\u30bf\u30b0\u3092\u53d6\u308a\u9664\u3044\u3066\u3057\u307e\u3046\u3070\u304b\u308a\u3067\u306f\u306a\u304f\u3001\u52dd\u624b\u306b\u30d1\u30e9\u30b0\u30e9\u30d5 &lt;p&gt; &lt;\/p&gt; \u3092\u8ffd\u52a0\u3057\u3066\u3057\u307e\u3044\u307e\u3059\uff0e\u5e38\u306b\u6b63\u3057\u3044\u30d1\u30e9\u30b0\u30e9\u30d5\u30bf\u30b0\u3092\u5165\u308c\u3066\u304f\u308c\u308b\u306e\u3067\u3042\u308c\u3070\u3001\u307e\u3060\u6551\u3044\u3088\u3046\u304c\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u958b\u59cb\u30bf\u30b0\u3060\u3051\u3060\u3063\u305f\u308a\u3001\u9589\u3058\u30bf\u30b0\u3060\u3051\u3092\u5165\u308c\u3066\u304f\u308c\u305f\u308a\u3057\u3066\u5909\u306aHTML\u30b3\u30fc\u30c9\u3092\u5410\u304d\u51fa\u3057\u3066\u304f\u308c\u307e\u3059\uff0e\u3069\u3053\u304b\u306eOffice\u7cfb\u30a2\u30d7\u30ea\u306e\u3088\u3046\u306b\u3001\u672c\u5f53\u306b\u56f0\u3063\u305f\u304a\u7bc0\u4ecb\u3067\u3059\uff0e\r<\/p>\r\n<br>\r\n<p>\u3053\u306e\u4f59\u8a08\u306a\u304a\u7bc0\u4ecb\u6a5f\u80fd\u3092OFF\u306b\u3059\u308b\u65b9\u6cd5\u306f\u5e7e\u3064\u304b\u6709\u308b\u3088\u3046\u3067\u3059\u304c\u3001\u4e00\u756a\u7c21\u5358\u306a\u65b9\u6cd5\u306fWordpress\u306e\u81ea\u52d5\u6574\u5f62\u6a5f\u80fd\u3092\u7121\u52b9\u306b\u3059\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u5165\u308c\u308b\u3053\u3068\u3067\u3057\u3087\u3046\uff0e\u30d7\u30e9\u30b0\u30a4\u30f3\u306b\u3064\u3044\u3066\u306f\u5b9f\u969b\u306b\u3069\u3093\u306a\u7269\u304c\u3042\u308b\u306e\u304b\u307e\u3060\u8abf\u3079\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u4eca\u56de\u306f\u30c6\u30fc\u30de\u30d5\u30a1\u30a4\u30eb\u5074\u3067Wordpress\u306e\u81ea\u52d5\u6574\u5f62\u6a5f\u80fd\u3092\u7121\u52b9\u306b\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\uff0e\r<\/p>\r\n<br>\r\n<p>\u30c6\u30fc\u30de\u30d5\u30a1\u30a4\u30eb\u5074\u3067Wordpress\u306e\u81ea\u52d5\u6574\u5f62\u6a5f\u80fd\u3092\u7121\u52b9\u306b\u3059\u308b\u306e\u306f\u3068\u3066\u3082\u7c21\u5358\u3067\u3001\u30c6\u30fc\u30de\u30d5\u30a1\u30a4\u30eb\u306e &#8220;functions.php&#8221; \u306e\u4e2d\u306b\r\n[sourcecode language=&#8221;php&#8221;]\r\n&lt;?php \r\n\/\/ disable default wpautop filter\r\nremove_filter( &#8216;the_content&#8217;, &#8216;wpautop&#8217; );\r\nremove_filter( &#8216;the_excerpt&#8217;, &#8216;wpautop&#8217; );\r\n\r\n<br>\r\n<p>&#8230;\r\n\r\n?&gt;\r\n[\/sourcecode]\r\n\r\n\u306e\uff12\u884c\u3092\u66f8\u304d\u8fbc\u3080\u3060\u3051\u3067\u3059\uff0e\u6700\u521d\u306e\u884c\u304c\u672c\u6587\u7528\u3001\u6b21\u306e\u884c\u304c\u8981\u7d04(Excerpt\uff09\u7528\u306e\u3082\u306e\u3067\u3059\uff0e&#8217;wpautop&#8217; \u3068\u3044\u3046\u306e\u304c WordPress\u306e\u81ea\u52d5\u6574\u5f62\u6a5f\u80fd\u30d5\u30a3\u30eb\u30bf\u30fc\u30d7\u30ed\u30b0\u30e9\u30e0\u540d\u3067\u3001&#8221;wp-includes\/formatting.php&#8221; \u306e\u4e2d\u306b\u3001&#8221;wpautop()&#8221; \u3068\u3044\u3046\u540d\u524d\u306e\u95a2\u6570\u304c\u3042\u308a\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u767b\u9332\u3055\u308c\u3066\u3044\u307e\u3059\uff0e\r<\/p>\r\n<br>\r\n<p>WordPress\u306e\u81ea\u52d5\u6574\u5f62\u6a5f\u80fd\u3092\u7121\u52b9\u306b\u3059\u308b\u306b\u306f\u3001&#8221;remove_filter()&#8221; \u3092\u547c\u3073\u51fa\u3057\u3066 &#8220;wpautop&#8221; \u306e\u30d5\u30a3\u30eb\u30bf\u30fc\u767b\u9332\u3092\u5916\u305b\u3070OK\u3067\u3059\uff0eWordpress\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u81ea\u52d5\u6574\u5f62\u6a5f\u80fd\u3067\u306f\u306a\u304f\u81ea\u5206\u5c02\u7528\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u30d5\u30a3\u30eb\u30bf\u30fc\u3092\u767b\u9332\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u306e\u3067\u3001\u5fc5\u8981\u3067\u3042\u308c\u3070\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3057\u305f\u81ea\u52d5\u6574\u5f62\u6a5f\u80fd\u3092\u7d44\u307f\u8fbc\u3080\u306e\u3082\u4e00\u3064\u306e\u624b\u3067\u3057\u3087\u3046\uff0e&#8221;functions.php&#8221; \u306e\u4e2d\u306b\u81ea\u5206\u5c02\u7528\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u30d5\u30a3\u30eb\u30bf\u30fc\u3092\u66f8\u304d\u8fbc\u3093\u3067\u4e0b\u3055\u3044\uff0e\r<\/p>\r\n\r\n[sourcecode language=&#8221;php&#8221;]\r\n&lt;?php \r\n\/\/ disable default wpautop filter\r\nremove_filter( &#8216;the_content&#8217;, &#8216;wpautop&#8217; );\r\nremove_filter( &#8216;the_excerpt&#8217;, &#8216;wpautop&#8217; );\r\n\r\nadd_filter( &#8216;the_content&#8217;, &#8216;my_filter&#8217; );\r\nadd_filter( &#8216;the_excerpt&#8217;, &#8216;my_filter&#8217; );\r\n<br>\r\n<p>&#8230;\r\n\r\nfunction  my_filter( $content ) {\r\n  \/\/ \u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3000\u30d5\u30a3\u30eb\u30bf\u30fc\u3000\r\n<br>\r\n<p>    &#8230;\r\n   return( $content );\r\n}\r\n\r\n?&gt;\r\n[\/sourcecode]\r\n<br>\r\n<p>\u3061\u306a\u307f\u306b\u3001Wordpress\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u81ea\u52d5\u6574\u5f62\u6a5f\u80fd\u30d7\u30ed\u30b0\u30e9\u30e0 &#8220;wpautop()&#8221; \u306e\u5185\u5bb9\u306f\u6b21\u306e\u69d8\u306b\u306a\u3063\u3066\u3044\u307e\u3059\uff0e\u3068\u3066\u3082\u3053\u306e\u4e2d\u8eab\u3092\u5168\u90e8\u628a\u63e1\u3059\u308b\u6c17\u306b\u306f\u306a\u308c\u307e\u305b\u3093\u304c\u3001\u6b63\u898f\u8868\u73fe\u3067\u7279\u5b9a\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u63a2\u3057\u3060\u3057\u3001\u6587\u5b57\u5217\u3092\u7f6e\u63db\u3059\u308b\u3060\u3051\u306e\u5358\u7d14\u306a\u30d5\u30a3\u30eb\u30bf\u30fc\u3067\u3059\uff0e\r<\/p>\r\n<br>\r\n[sourcecode language=&#8221;php&#8221;]\r\n\/**\r\n * Replaces double line-breaks with paragraph elements.\r\n *\r\n * A group of regex replaces used to identify text formatted with newlines and\r\n * replace double line-breaks with HTML paragraph tags. The remaining\r\n * line-breaks after conversion become &lt;&lt;br \/&gt;&gt; tags, unless $br is set to &#8216;0&#8217;\r\n * or &#8216;false&#8217;.\r\n *\r\n * @since 0.71\r\n *\r\n * @param string $pee The text which has to be formatted.\r\n * @param int|bool $br Optional. If set, this will convert all remaining line-breaks after paragraphing. Default true.\r\n * @return string Text which has been converted into correct paragraph tags.\r\n *\/\r\nfunction wpautop($pee, $br = 1) {\r\n\r\n\tif ( trim($pee) === &#8221; )\r\n\t\treturn &#8221;;\r\n\t$pee = $pee . &quot;\\n&quot;; \/\/ just to make things a little easier, pad the end\r\n\t$pee = preg_replace(&#8216;|&lt;br \/&gt;\\s*&lt;br \/&gt;|&#8217;, &quot;\\n\\n&quot;, $pee);\r\n\t\/\/ Space things out a little\r\n\t$allblocks = &#8216;(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)&#8217;;\r\n\t$pee = preg_replace(&#8216;!(&lt;&#8216; . $allblocks . &#8216;[^&gt;]*&gt;)!&#8217;, &quot;\\n$1&quot;, $pee);\r\n\t$pee = preg_replace(&#8216;!(&lt;\/&#8217; . $allblocks . &#8216;&gt;)!&#8217;, &quot;$1\\n\\n&quot;, $pee);\r\n\t$pee = str_replace(array(&quot;\\r\\n&quot;, &quot;\\r&quot;), &quot;\\n&quot;, $pee); \/\/ cross-platform newlines\r\n\tif ( strpos($pee, &#8216;&lt;object&#8217;) !== false ) {\r\n\t\t$pee = preg_replace(&#8216;|\\s*&lt;param([^&gt;]*)&gt;\\s*|&#8217;, &quot;&lt;param$1&gt;&quot;, $pee); \/\/ no pee inside object\/embed\r\n\t\t$pee = preg_replace(&#8216;|\\s*&lt;\/embed&gt;\\s*|&#8217;, &#8216;&lt;\/embed&gt;&#8217;, $pee);\r\n\t}\r\n\t$pee = preg_replace(&quot;\/\\n\\n+\/&quot;, &quot;\\n\\n&quot;, $pee); \/\/ take care of duplicates\r\n\t\/\/ make paragraphs, including one at the end\r\n\t$pees = preg_split(&#8216;\/\\n\\s*\\n\/&#8217;, $pee, -1, PREG_SPLIT_NO_EMPTY);\r\n\t$pee = &#8221;;\r\n\tforeach ( $pees as $tinkle )\r\n\t\t$pee .= &#8216;&lt;p&gt;&#8217; . trim($tinkle, &quot;\\n&quot;) . &quot;&lt;\/p&gt;\\n&quot;;\r\n\t$pee = preg_replace(&#8216;|&lt;p&gt;\\s*&lt;\/p&gt;|&#8217;, &#8221;, $pee); \/\/ under certain strange conditions it could create a P of entirely whitespace\r\n\t$pee = preg_replace(&#8216;!&lt;p&gt;([^&lt;]+)&lt;\/(div|address|form)&gt;!&#8217;, &quot;&lt;p&gt;$1&lt;\/p&gt;&lt;\/$2&gt;&quot;, $pee);\r\n\t$pee = preg_replace(&#8216;!&lt;p&gt;\\s*(&lt;\/?&#8217; . $allblocks . &#8216;[^&gt;]*&gt;)\\s*&lt;\/p&gt;!&#8217;, &quot;$1&quot;, $pee); \/\/ don&#8217;t pee all over a tag\r\n\t$pee = preg_replace(&quot;|&lt;p&gt;(&lt;li.+?)&lt;\/p&gt;|&quot;, &quot;$1&quot;, $pee); \/\/ problem with nested lists\r\n\t$pee = preg_replace(&#8216;|&lt;p&gt;&lt;blockquote([^&gt;]*)&gt;|i&#8217;, &quot;&lt;blockquote$1&gt;&lt;p&gt;&quot;, $pee);\r\n\t$pee = str_replace(&#8216;&lt;\/blockquote&gt;&lt;\/p&gt;&#8217;, &#8216;&lt;\/p&gt;&lt;\/blockquote&gt;&#8217;, $pee);\r\n\t$pee = preg_replace(&#8216;!&lt;p&gt;\\s*(&lt;\/?&#8217; . $allblocks . &#8216;[^&gt;]*&gt;)!&#8217;, &quot;$1&quot;, $pee);\r\n\t$pee = preg_replace(&#8216;!(&lt;\/?&#8217; . $allblocks . &#8216;[^&gt;]*&gt;)\\s*&lt;\/p&gt;!&#8217;, &quot;$1&quot;, $pee);\r\n\tif ($br) {\r\n\t\t$pee = preg_replace_callback(&#8216;\/&lt;(script|style).*?&lt;\\\/\\\\1&gt;\/s&#8217;, &#8216;_autop_newline_preservation_helper&#8217;, $pee);\r\n\t\t$pee = preg_replace(&#8216;|(?&lt;!&lt;br \/&gt;)\\s*\\n|&#8217;, &quot;&lt;br \/&gt;\\n&quot;, $pee); \/\/ optionally make line breaks\r\n\t\t$pee = str_replace(&#8216;&lt;WPPreserveNewline \/&gt;&#8217;, &quot;\\n&quot;, $pee);\r\n\t}\r\n\t$pee = preg_replace(&#8216;!(&lt;\/?&#8217; . $allblocks . &#8216;[^&gt;]*&gt;)\\s*&lt;br \/&gt;!&#8217;, &quot;$1&quot;, $pee);\r\n\t$pee = preg_replace(&#8216;!&lt;br \/&gt;(\\s*&lt;\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^&gt;]*&gt;)!&#8217;, &#8216;$1&#8217;, $pee);\r\n\tif (strpos($pee, &#8216;&lt;pre&#8217;) !== false)\r\n\t\t$pee = preg_replace_callback(&#8216;!(&lt;pre[^&gt;]*&gt;)(.*?)&lt;\/pre&gt;!is&#8217;, &#8216;clean_pre&#8217;, $pee );\r\n\t$pee = preg_replace( &quot;|\\n&lt;\/p&gt;$|&quot;, &#8216;&lt;\/p&gt;&#8217;, $pee );\r\n\r\n\treturn $pee;\r\n}\r\n\r\n[\/sourcecode]\r\n","protected":false},"excerpt":{"rendered":"\u4f59\u8a08\u306a\u304a\u7bc0\u4ecb\u3067\u3042\u308bWordpress\u306e\u81ea\u52d5\u6574\u5f62\u6a5f\u80fd\u3092OFF\u306b\u3059\u308b\u65b9\u6cd5\u306f\u5e7e\u3064\u304b\u6709\u308b\u3088\u3046\u3067\u3059\u304c\u3001\u4e00\u756a\u7c21\u5358\u306a\u65b9\u6cd5\u306fWordpress\u306e\u81ea\u52d5\u6574\u5f62\u6a5f\u80fd\u3092\u7121\u52b9\u306b\u3059\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u5165\u308c\u308b\u3053\u3068\u3067\u3057\u3087\u3046\uff0e\u30d7\u30e9\u30b0\u30a4\u30f3\u306b\u3064\u3044\u3066\u306f\u5b9f\u969b\u306b\u3069\u3093\u306a\u7269\u304c\u3042\u308b\u306e\u304b\u307e\u3060\u8abf\u3079\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u4eca\u56de\u306f\u30c6\u30fc\u30de\u30d5\u30a1\u30a4\u30eb\u5074\u3067Wordpress\u306e\u81ea\u52d5\u6574\u5f62\u6a5f\u80fd\u3092\u7121\u52b9\u306b\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[12],"tags":[539,688,540],"class_list":["post-2915","post","type-post","status-publish","format-standard","hentry","category-wp","tag-autop","tag-wp","tag-540"],"_links":{"self":[{"href":"https:\/\/y2tech.net\/blog\/wp-json\/wp\/v2\/posts\/2915","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/y2tech.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/y2tech.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/y2tech.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/y2tech.net\/blog\/wp-json\/wp\/v2\/comments?post=2915"}],"version-history":[{"count":0,"href":"https:\/\/y2tech.net\/blog\/wp-json\/wp\/v2\/posts\/2915\/revisions"}],"wp:attachment":[{"href":"https:\/\/y2tech.net\/blog\/wp-json\/wp\/v2\/media?parent=2915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/y2tech.net\/blog\/wp-json\/wp\/v2\/categories?post=2915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/y2tech.net\/blog\/wp-json\/wp\/v2\/tags?post=2915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}