{"id":2266,"date":"2013-08-24T08:45:49","date_gmt":"2013-08-24T00:45:49","guid":{"rendered":"https:\/\/sdeno.com\/?p=2266"},"modified":"2013-08-16T17:47:25","modified_gmt":"2013-08-16T09:47:25","slug":"wordpress%e5%90%8e%e5%8f%b0%e7%bc%96%e8%be%91%e5%99%a8html%e6%a8%a1%e5%bc%8f%e7%95%8c%e9%9d%a2%e4%b8%ad%e6%b7%bb%e5%8a%a0%e4%bf%ae%e6%94%b9%e5%88%a0%e9%99%a4%e6%8c%89%e9%92%ae","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=2266","title":{"rendered":"WordPress\u540e\u53f0\u7f16\u8f91\u5668HTML\u6a21\u5f0f\u754c\u9762\u4e2d\u6dfb\u52a0\u4fee\u6539\u5220\u9664\u6309\u94ae"},"content":{"rendered":"<p>\u5728WordPress\u7f16\u8f91\u5668HTML\u6a21\u5f0f\u754c\u9762\u4e2d\u6dfb\u52a0&lt;code&gt;&lt;pre&gt;\u6309\u94ae\u4e00\u6587\u4e2d\uff0c\u6211\u5927\u81f4\u4ecb\u7ecd\u4e86\u600e\u4e48\u5728\u540e\u53f0\u6dfb\u52a0\u4e00\u4e9b\u81ea\u5b9a\u4e49\u7684\u6309\u94ae\uff0c\u672c\u6587\u5219\u66f4\u4e3a\u8be6\u7ec6\u5168\u9762\u7684\u5bf9wordpress\u540e\u53f0\u7f16\u8f91\u5668HTML\u6a21\u5f0f\u4e0b\u7684\u6309\u94ae\u81ea\u5b9a\u4e49\u8fdb\u884c\u8be6\u89e3\uff0c\u4ee5\u8ba9\u5f00\u53d1\u8005\u8086\u610f\u7684\u4fee\u6539\u6309\u94ae\u53ca\u5176\u5e03\u5c40\u3002<\/p>\n<p>\u81ea\u5b9a\u4e49\u6309\u94ae\u8d77\u6548\u7684\u4e24\u79cd\u9014\u5f84 \u2191<\/p>\n<p>\u9996\u5148\u6211\u4eec\u8981\u505a\u7684\u662f\u4e86\u89e3\u5982\u4f55\u624d\u80fd\u8ba9\u6211\u4eec\u81ea\u5b9a\u4e49\u7684\u6548\u679c\u53ef\u4ee5\u5728\u540e\u53f0\u8d77\u6548\uff0c\u5b9e\u73b0\u6309\u94ae\u4fee\u6539\u3002\u6211\u603b\u7ed3\u51fa\u4e86\u4e24\u79cd\u65b9\u6cd5\uff0c\u4e00\u79cd\u662f\u901a\u8fc7wordpress\u7684wp_enqueue_script\u6765\u5b9e\u73b0\uff0c\u4e00\u79cd\u662f\u901a\u8fc7\u5728\u540e\u53f0\u94a9\u4e0a\u7b2c\u4e00\u6bb5\u4ee3\u7801\u6765\u5b9e\u73b0\u3002<\/p>\n<p>\u7b2c\u4e00\u79cd\uff0c\u5229\u7528wp_enqueue_script\u6765\u5b9e\u73b0 \u2191<\/p>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u9700\u8981\u8fdb\u884c\u4e24\u4e2a\u6b65\u9aa4\uff0c\u4e00\u4e2a\u662f\u5728\u4e3b\u9898\u76ee\u5f55\u4e0b\u7684functions.php\u4e2d\u6dfb\u52a0\u4e0b\u9762\u7684\u4ee3\u7801\uff1a<\/p>\n<p>\u7b2c\u4e8c\u4e2a\u662f\u5728\u4e3b\u9898\u76ee\u5f55\u4e0b\u653e\u7f6e\u4e00\u4e2amy-custom-quicktags.js\uff0c\u91cc\u9762\u653e\u7f6e\u4e00\u6bb5\u5bf9\u811a\u672c\u7684\u9644\u52a0\u4ee3\u7801\u3002\u5f53\u7136\uff0c\u8fd9\u4e2a\u6587\u4ef6\u7684\u653e\u7f6e\u4f4d\u7f6e\u4e5f\u53ef\u4ee5\u4fee\u6539\uff0c\u8fd9\u65f6\u9700\u8981\u4fee\u6539\u4e0a\u9762\u4ee3\u7801\u4e2d\u7684plugins_url(basename(dirname(__FILE__)) . &#8220;\/my-custom-quicktags.js&#8221;)\u4e00\u53e5\u4ee5\u4fdd\u8bc1\u8def\u5f84\u6b63\u786e\u3002\u5728my-custom-quicktags.js\u4e2d\uff0c\u6211\u4eec\u653e\u7f6e\u5bf9\u5e94\u7684\u6dfb\u52a0\u4fee\u6539\u5220\u9664\u6309\u94ae\u529f\u80fd\u7684\u811a\u672c\u3002\u5982\u4e0b\uff1a<\/p>\n<p>[code]QTags.addButton( &#8216;printCode&#8217;, &#8216;printCode&#8217;, &#8216;[mycode]&#8217;+&#8221;\\n&#8221;, &#8220;\\n&#8221;+'[\/mycode]&#8217;);[\/code]<br \/>\n\/\/\u5c06\u5728\u73b0\u6709\u7684\u6309\u94ae\u6700\u540e\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684printCode\u6309\u94ae\u3002\u5177\u4f53\u7684\u65b9\u6cd5\u5c06\u5728\u4e0b\u6587\u8bb2\u5230\u3002<br \/>\n\u7b2c\u4e8c\u79cd\uff0c\u901a\u8fc7\u52fe\u4e0a\u4e00\u6bb5\u4ee3\u7801\uff0c\u5411\u540e\u53f0\u9875\u9762\u4e2d\u6dfb\u52a0\u4e00\u6bb5\u53ef\u4ee5\u5b9e\u73b0\u529f\u80fd\u7684\u4ee3\u7801 \u2191<\/p>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u6bd4\u8f83\u7b28\u62d9\uff0c\u4f46\u66f4\u5bb9\u6613\u88ab\u7406\u89e3\uff0c\u5373\u5728\u540e\u53f0\u9875\u9762\u7684\u5e95\u90e8\u589e\u52a0\u4e86\u4e00\u4e9b\u4ee3\u7801\uff0c\u8fd9\u4e9b\u4ee3\u7801\u6070\u597d\u80fd\u5b9e\u73b0\u8fd9\u4e00\u6548\u679c\u3002\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>[code]\/\/ \u4e0b\u9762\u7684\u4ee3\u7801\u53ef\u4ee5\u589e\u52a0HTML\u6a21\u5f0f\u4e0b\u7684\u6309\u94ae<br \/>\n$php_name = end(explode(&#8216;\/&#8217;,$_SERVER[&#8216;PHP_SELF&#8217;]));<br \/>\nif(is_admin() &amp;&amp; ($php_name == &#8216;post.php&#8217; || $php_name == &#8216;post-new.php&#8217;)):<br \/>\nfunction add_html_shortcode(){<br \/>\n?&gt;<br \/>\n&lt;script&gt;<br \/>\nedButtons[60]=new QTags.TagButton(&#8216;hr&#8217;,&#8217;hr&#8217;,&#8221;\\n\\n&lt;hr \/&gt;\\n\\n&#8221;,&#8221;,&#8217;hr&#8217;);<br \/>\nedButtons[122]=new QTags.TagButton(&#8216;h3&#8242;,&#8217;h3&#8242;,'&lt;h3&gt;&#8217;,'&lt;\/h3&gt;&#8217;,&#8217;h&#8217;);<br \/>\nedButtons[123]=new QTags.TagButton(&#8216;tab&#8217;,&#8217;TAB&#8217;,&#8221;\\t&#8221;,&#8221;,&#8217;tab&#8217;);<br \/>\nedButtons[130] = null;<br \/>\nedButtons[140] = null;<br \/>\n&lt;\/script&gt;<br \/>\n&lt;?php<br \/>\n}<br \/>\nadd_action(&#8216;admin_print_footer_scripts&#8217;,&#8217;add_html_shortcode&#8217;);<br \/>\nendif;[\/code]<br \/>\n\u5411\u540e\u53f0\u754c\u9762\u4e2d\u589e\u52a0\u65b0\u7684\u6309\u94ae \u2191<\/p>\n<p>\u7531\u4e8ewordpress\u540e\u53f0\u7f16\u8f91\u5668\u591a\u534a\u662f\u7528\u811a\u672c\u6765\u5b9e\u73b0\u7684\uff0c\u56e0\u6b64\u6211\u4eec\u8981\u505a\u7684\u662f\u901a\u8fc7\u811a\u672c\u4ee3\u7801\u6765\u63a7\u5236\u6309\u94ae\u7684\u6570\u91cf\u5e03\u5c40\u548c\u529f\u80fd\u3002<\/p>\n<p>\u5411\u540e\u53f0\u754c\u9762\u4e2d\u6dfb\u52a0\u6309\u94ae\u6709\u4e24\u4e2a\u9014\u5f84\uff0c\u4e0a\u6587\u4e2d\u5df2\u7ecf\u4ecb\u7ecd\u4e86\u4e00\u79cd\uff0c\u5373QTags.addButton(&#8216;printCode&#8217;,&#8217;printCode&#8217;, &#8216;[mycode]&#8217;, &#8216;[\/mycode]&#8217;);\uff0c\u53e6\u5916\u8fd8\u6709\u53e6\u5916\u4e00\u79cd\u589e\u52a0\u7684\u65b9\u6cd5\uff0c\u5373\u901a\u8fc7\u5728quicktags.js\u4e2d\u9884\u7559\u7684\u7a7a\u95f4\u91cc\u589e\u52a0\u6309\u94ae\u6570\u91cf\u3002<\/p>\n<p>\u8fd9\u4e24\u79cd\u589e\u52a0\u7684\u65b9\u6cd5\u6240\u6dfb\u52a0\u7684\u4ee3\u7801\uff0c\u901a\u8fc7\u4e0a\u6587\u6240\u8bf4\u7684\u4e24\u79cd\u8d77\u6548\u65b9\u6cd5\u90fd\u662f\u53ef\u4ee5\u5b9e\u73b0\u7684\uff0c\u53ea\u8981\u628aJS\u4ee3\u7801\u653e\u5728\u5bf9\u5e94\u7684\u5730\u65b9\u5373\u53ef\u3002<\/p>\n<p>\/wp-includes\/js\/quicktags.js\u4e2d\u5b9a\u4e49\u4e86\u540e\u53f0\u7f16\u8f91\u5668\u7684\u6309\u94ae\uff0c\u901a\u8fc7\u4ee3\u7801\u89e3\u538b\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\u8fd9\u4e9b\u6309\u94ae\u662f\u600e\u4e48\u8d77\u4f5c\u7528\u7684\u3002\u6211\u4eec\u53d1\u73b0\u5728\u6700\u540e\u7684\u6309\u94ae\u5b9a\u4e49\u7684\u5730\u65b9\uff1a<\/p>\n<p>[code]edButtons[10] = new c.TagButton(&#8220;strong&#8221;, &#8220;b&#8221;, &#8220;&lt;strong&gt;&#8221;, &#8220;&lt;\/strong&gt;&#8221;, &#8220;b&#8221;);<br \/>\nedButtons[20] = new c.TagButton(&#8220;em&#8221;, &#8220;i&#8221;, &#8220;&lt;em&gt;&#8221;, &#8220;&lt;\/em&gt;&#8221;, &#8220;i&#8221;),<br \/>\nedButtons[30] = new c.LinkButton(),<br \/>\nedButtons[40] = new c.TagButton(&#8220;block&#8221;, &#8220;b-quote&#8221;, &#8220;\\n\\n&lt;blockquote&gt;&#8221;, &#8220;&lt;\/blockquote&gt;\\n\\n&#8221;, &#8220;q&#8221;),<br \/>\nedButtons[50] = new c.TagButton(&#8220;del&#8221;, &#8220;del&#8221;, &#8216;&lt;del datetime=&#8221;&#8216; + a + &#8216;&#8221;&gt;&#8217;, &#8220;&lt;\/del&gt;&#8221;, &#8220;d&#8221;),<br \/>\nedButtons[60] = new c.TagButton(&#8220;ins&#8221;, &#8220;ins&#8221;, &#8216;&lt;ins datetime=&#8221;&#8216; + a + &#8216;&#8221;&gt;&#8217;, &#8220;&lt;\/ins&gt;&#8221;, &#8220;s&#8221;),<br \/>\nedButtons[70] = new c.ImgButton(),<br \/>\nedButtons[80] = new c.TagButton(&#8220;ul&#8221;, &#8220;ul&#8221;, &#8220;&lt;ul&gt;\\n&#8221;, &#8220;&lt;\/ul&gt;\\n\\n&#8221;, &#8220;u&#8221;),<br \/>\nedButtons[90] = new c.TagButton(&#8220;ol&#8221;, &#8220;ol&#8221;, &#8220;&lt;ol&gt;\\n&#8221;, &#8220;&lt;\/ol&gt;\\n\\n&#8221;, &#8220;o&#8221;),<br \/>\nedButtons[100] = new c.TagButton(&#8220;li&#8221;, &#8220;li&#8221;, &#8220;\\t&lt;li&gt;&#8221;, &#8220;&lt;\/li&gt;\\n&#8221;, &#8220;l&#8221;),<br \/>\nedButtons[110] = new c.TagButton(&#8220;code&#8221;, &#8220;code&#8221;, &#8220;&lt;code&gt;&#8221;, &#8220;&lt;\/code&gt;&#8221;, &#8220;c&#8221;),<br \/>\nedButtons[120] = new c.TagButton(&#8220;more&#8221;, &#8220;more&#8221;, &#8220;&lt;!&#8211;more&#8211;&gt;&#8221;, &#8220;&#8221;, &#8220;t&#8221;),<br \/>\nedButtons[130] = new c.SpellButton(),<br \/>\nedButtons[140] = new c.CloseButton();[\/code]<br \/>\n\u662f\u901a\u8fc7\u5bf9edButtons\u6570\u7ec4\u7684\u7d22\u5f15\u6765\u6392\u5e8f\u7684\uff0c\u6211\u4eec\u5728\u8fd9\u4e9b\u7d22\u5f15\u4e2d\u95f4\u589e\u52a0\u4e00\u4e9b\u5373\u53ef\u5b9e\u73b0\u6548\u679c\u3002\u5982\u6211\u4eec\u5728\u4e0a\u6587\u53ef\u4ee5\u8d77\u6548\u7684JS\u5185\u6dfb\u52a0\u8fd9\u6837\u4e00\u6bb5\u4ee3\u7801\uff1a<\/p>\n<p>[code]edButtons[122]=new QTags.TagButton(&#8216;h3&#8242;,&#8217;h3&#8242;,'&lt;h3&gt;&#8217;,'&lt;\/h3&gt;&#8217;,&#8217;h&#8217;);[\/code]<br \/>\n\u8fd9\u6837\u4e00\u6765\u5373\u53ef\u5b9e\u73b0\u4e86\u5728[120]more\u6309\u94ae\u4e4b\u540e\u589e\u52a0\u4e00\u4e2ah3\u6309\u94ae\u3002<\/p>\n<p>\u4fee\u6539\u6309\u94ae \u2191<\/p>\n<p>\u4fee\u6539\u6309\u94ae\u7684\u65b9\u6cd5\u6211\u53ea\u627e\u5230\u4e00\u79cd\uff0c\u5373\u5982\u4e0a\u6587\u6240\u8ff0\uff0c\u76f4\u63a5\u5b9a\u4e49\u4e00\u4e2a\u65b0\u7684edButtons\uff0c\u7528\u4e00\u4e2a\u76f8\u540c\u7684\u7d22\u5f15\u8986\u76d6\u6389\u539f\u6765\u7684\u6309\u94ae\u3002\u540c\u6837\u4ee5h3\u6309\u94ae\u4e3a\u4f8b\uff0c\u589e\u52a0\u4e00\u6bb5\u4ee3\u7801\uff1a<\/p>\n<p>[code]edButtons[120]=new QTags.TagButton(&#8216;h3&#8242;,&#8217;h3&#8242;,'&lt;h3&gt;&#8217;,'&lt;\/h3&gt;&#8217;,&#8217;h&#8217;);[\/code]<br \/>\n\u5373\u53ef\u8986\u76d6\u6389\u539f\u6765\u7684more\u6309\u94ae\uff0c\u88ab\u66ff\u6362\u4e3ah3\u6309\u94ae\u3002<\/p>\n<p>\u4f60\u53ef\u80fd\u8981\u95ee\u8fd9\u4e2a\u683c\u5f0f\u662f\u4ec0\u4e48\u3002\u5728\u4e0a\u9762\u7684JS\u4ee3\u7801\u4e2d\uff0cTagButton(&#8216;h3&#8242;,&#8217;h3&#8242;,'&lt;h3&gt;&#8217;,'&lt;\/h3&gt;&#8217;,&#8217;h&#8217;)\u6709\u4e94\u4e2a\u53c2\u6570\uff0c\u7b2c\u4e00\u4e2a\u662f\u4e00\u4e2a\u4ee3\u53f7\uff0c\u7b2c\u4e8c\u4e2a\u662f\u6309\u94ae\u5185\u8981\u663e\u793a\u7684\u6587\u5b57\uff0c\u7b2c\u4e09\u4e2a\u662f\u70b9\u51fb\u7b2c\u4e00\u4e0b\u6309\u94ae\u663e\u793a\u7684\u6807\u7b7e\uff0c\u7b2c\u56db\u4e2a\u4e0d\u7528\u8bf4\u5c31\u662f\u70b9\u51fb\u7b2c\u4e8c\u4e0b\u7684\u5173\u95ed\u6807\u7b7e\uff0c\u5982\u679c\u4f60\u8981\u589e\u52a0\u7684\u662f&lt;br&gt;\u6807\u7b7e\uff0c\u7b2c\u56db\u4e2a\u53c2\u6570\u5c31\u4e0d\u586b\u4e86\uff0c\u7b2c\u4e94\u4e2a\u53c2\u6570\u597d\u50cf\u6ca1\u4ec0\u4e48\u7528\uff0c\u53ef\u80fd\u662f\u4e00\u4e2a\u4ee3\u53f7\u3002<\/p>\n<p>\u5220\u9664\u6309\u94ae \u2191<\/p>\n<p>\u5220\u9664\u6309\u94ae\u7684\u65b9\u6cd5\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u662f\u4fee\u6539\u6309\u94ae\u7684\u4e00\u79cd\u7279\u6b8a\u60c5\u51b5\uff0c\u5373\u5c06\u4e00\u4e2a\u539f\u672c\u6709\u7684\u7d22\u5f15\u5bf9\u5e94\u7684\u503c\u8bbe\u7f6e\u4e3anull\u5373\u53ef\u5220\u9664\u8be5\u6309\u94ae\uff0c\u5982\uff1a<\/p>\n<p>[code]edButtons[120]=null;[\/code]<br \/>\n\u8fd9\u6837\u4e00\u6765\uff0cmore\u6309\u94ae\u5c31\u4e0d\u4f1a\u518d\u51fa\u73b0\u5728\u6309\u94ae\u4e00\u680f\u4e2d\u4e86\u3002<\/p>\n<p>\u901a\u8fc7\u4e0a\u6587\u7684\u8bb2\u89e3\uff0c\u76f8\u4fe1\u4f60\u5bf9\u5982\u4f55\u8fdb\u884c\u540e\u53f0\u7f16\u8f91\u5668\u7684\u6309\u94ae\u5b89\u6392\u5df2\u7ecf\u6709\u4e86\u4e00\u4e2a\u975e\u5e38\u5168\u9762\u7684\u638c\u63e1\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728WordPress\u7f16\u8f91\u5668HTML\u6a21\u5f0f\u754c\u9762\u4e2d\u6dfb\u52a0&lt;code&gt;&lt;pre&gt;\u6309\u94ae\u4e00\u6587\u4e2d\uff0c\u6211\u5927 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,11],"tags":[],"class_list":["post-2266","post","type-post","status-publish","format-standard","hentry","category-wordpress","category-11"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/2266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2266"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/2266\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}