﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-网络转载笔记-文章分类-wordpress</title><link>http://www.blogjava.net/masy/category/52427.html</link><description /><language>zh-cn</language><lastBuildDate>Mon, 20 Aug 2012 21:44:21 GMT</lastBuildDate><pubDate>Mon, 20 Aug 2012 21:44:21 GMT</pubDate><ttl>60</ttl><item><title>WordPress禁止蜘蛛抓取某日志</title><link>http://www.blogjava.net/masy/articles/385864.html</link><dc:creator>韩麦斯</dc:creator><author>韩麦斯</author><pubDate>Mon, 20 Aug 2012 07:43:00 GMT</pubDate><guid>http://www.blogjava.net/masy/articles/385864.html</guid><wfw:comment>http://www.blogjava.net/masy/comments/385864.html</wfw:comment><comments>http://www.blogjava.net/masy/articles/385864.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/masy/comments/commentRss/385864.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/masy/services/trackbacks/385864.html</trackback:ping><description><![CDATA[<h2><p style="margin: 0px 0px 15px; padding: 0px; list-style: none; font-size: 14px; line-height: 22px; color: #333333; font-family: verdana, Arial, sans-serif; font-weight: normal; background-color: #f1f6fa; ">Wordpress 的日志公开度分为公开、密码保护、私人这三类还不是很完善，应该还可以分出一类：半公开。也就是说某篇日志允许朋友通过友情链接、RSS 订阅或者其他搜索以外的方式访问，但是这篇日志将不被搜索引擎收录。我想到的第一个解决方案就是用 robots.txt，但是每次写半公开日志都要更新 robots.txt 有些麻烦，而且我不希望 robots.txt 文件特别冗长。于是第二个解决方案诞生了，那就是用强大的自定义域，方法和之前提到的首页缩略图有相似之处。</p><p style="margin: 0px 0px 15px; padding: 0px; list-style: none; font-size: 14px; line-height: 22px; color: #333333; font-family: verdana, Arial, sans-serif; font-weight: normal; background-color: #f1f6fa; "><strong>首先在 header.php 中的 之间加入以下代码：</strong></p><blockquote style="border: 1px dashed #c2def3; background-color: #ffffff; font-size: 13px; line-height: 20px; color: #444444; padding-top: 10px; padding-bottom: 10px; margin-left: 20px; font-family: verdana, Arial, sans-serif; font-weight: normal; "><p style="margin: 0px; padding: 0px; list-style: none; ">&lt; ?php $private = get_post_meta($post-&gt;ID, 'noindex', true);<br style="height: 0px; overflow: hidden; " />if (!empty($private)) {<br style="height: 0px; overflow: hidden; " />echo '';<br style="height: 0px; overflow: hidden; " />}<br style="height: 0px; overflow: hidden; " />?&gt;</p></blockquote><p style="margin: 0px 0px 15px; padding: 0px; list-style: none; font-size: 14px; line-height: 22px; color: #333333; font-family: verdana, Arial, sans-serif; font-weight: normal; background-color: #f1f6fa; ">然后在日志编辑器中添加新自定义域，名称为 private，值可以是任意非空字符串，建议用 post id。禁止搜索引擎收录半公开的单篇日志就这么实现啦。</p><p style="margin: 0px 0px 15px; padding: 0px; list-style: none; font-size: 14px; line-height: 22px; color: #333333; font-family: verdana, Arial, sans-serif; font-weight: normal; background-color: #f1f6fa; ">　　最后补充说明一下，noindex 标签是互联网 meta robots 协议的其中之一，Google 和 Yahoo 这类搜索引擎都会中规中矩地按这个协议执行，唯独百度不鸟 noindex 这个标签，接下来 BS 百度的话我就不多说了</p></h2><img src ="http://www.blogjava.net/masy/aggbug/385864.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/masy/" target="_blank">韩麦斯</a> 2012-08-20 15:43 <a href="http://www.blogjava.net/masy/articles/385864.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>不用插件实现WordPress代码高亮显示</title><link>http://www.blogjava.net/masy/articles/385792.html</link><dc:creator>韩麦斯</dc:creator><author>韩麦斯</author><pubDate>Sun, 19 Aug 2012 16:30:00 GMT</pubDate><guid>http://www.blogjava.net/masy/articles/385792.html</guid><wfw:comment>http://www.blogjava.net/masy/comments/385792.html</wfw:comment><comments>http://www.blogjava.net/masy/articles/385792.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/masy/comments/commentRss/385792.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/masy/services/trackbacks/385792.html</trackback:ping><description><![CDATA[<p style="margin: 1em 0px; padding: 0px; text-indent: 2em; font-family: 'Segoe UI', Tahoma, Arial; line-height: 26px; -webkit-text-size-adjust: none; background-color: #f5faff; text-align: center; "><br /></p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">偶尔在日志中加入一些代码，感觉完全没必要安装代码高亮插件，万一某天不用插件了，页面可能会很乱。其实大部分插件都是在代码中强行加入一些标签，然后用CSS定义样式，通过查看页面源文件可以清楚地看到。</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">有一个叫&#8220;发芽网&#8221;的在线代码高亮转换网站。通过在线程序同样是向代码中加入不同的标签，然后定义样式，如果感兴趣可以到发芽网试试，但每次转换都需打开网址操作略显麻烦，不是本篇介绍的重点。</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">今天推荐的是一款本地转换代码高亮显示的小工具：<a target="_blank" href="http://www.blogjava.net/Files/Unmi/CodeRender(Unmi).rar" style="color: #1c3d72; text-decoration: none; ">CodeRender</a>，本程序是基于 dp.SyntaxHighlighter 写的代码语法着色的工具。支持的语言有：</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">java/xml/sql/jscript/css/cpp/c#/python/vb/perl/php/ruby/delphi。</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">可方便用于你的博客中粘贴代码，只要自定相应的样式 （highlight.css 的内容，.Text 支持自定义样式或在模板里加上语法样式），然后复制用这个工具生成的 HTML 代码就能让你的代码着高亮显示。 可以加入更多语种的支持，本程序就是在 dp.SyntaxHighlighter 的基础上扩展了对 Perl 语言的支持，网上可以找到相应语法的 JS 代码和 CSS。语言扩展支持通过在 shCore.js 和 highlight.css 加入相应代码即可。</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; ">程序界面</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; "><img alt="" width="600" height="382" jquery1284885623984="65" oldblock="inline" original="http://upload.chinaz.com/upimg/allimg/100919/1647080.jpg" loaded="true" src="http://upload.chinaz.com/upimg/allimg/100919/1647080.jpg" style="border: 1px solid #999999; display: inline; zoom: 1; " /></p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">操作很容易，Source Code 中贴上你要着色的代码，然后选择语种，点击 Render 按钮就会在 HTML Code 中生成相应的 HTML 代码，同时在 HTML Preview 中可以预览到效果。</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">简 要说明：Lang 下拉框可以选择所支持的语法，Options 右边的 Gutter、Controls、CollapseAll、FirstLine、Columns 是控制生成的额外的元素，逐一点试试就知道了。每个内容显示(输入)区都提供了 Copy/Paste/Clear 快捷操作链接，还有一个总的 Clear 按钮。</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">Copy生成 的HTML 代码，在日志编辑窗口切换到HTML源代码编辑模式，粘贴就可以了。</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">不过要想正确显示代码高亮还需在WordPress主题中加载样式文件&#8220;highlight.css&#8221;（在下载的压缩包中）</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">方法：</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">首先，把highlight.css上传到所使用主题目录中；</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">其次：打开header.php，查找：</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; "></p><table border="0" cellspacing="0" cellpadding="6" width="95%" align="center" style="border-collapse: collapse; border-spacing: 0px; width: 641px; background-color: #ffffff; color: #000000; font-size: 14px; line-height: 26px; text-align: start; text-indent: 0px; border-style: solid; border-color: #0099cc; table-layout: fixed; "><tbody><tr><td bgcolor="#ddedfb" style="margin: 0px; padding: 5px; border-style: solid; border-color: #dddddd; word-wrap: break-word; ">&lt;link&nbsp;rel="stylesheet"&nbsp;type="text/css"&nbsp;href="&lt;?php&nbsp;bloginfo('template_directory');&nbsp;?&gt;/style.css"&nbsp;/&gt;</td></tr></tbody></table><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; "></p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">在后面添加：</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; "></p><table border="0" cellspacing="0" cellpadding="6" width="95%" align="center" style="border-collapse: collapse; border-spacing: 0px; width: 641px; background-color: #ffffff; color: #000000; font-size: 14px; line-height: 26px; text-align: start; text-indent: 0px; border-style: solid; border-color: #0099cc; table-layout: fixed; "><tbody><tr><td bgcolor="#ddedfb" style="margin: 0px; padding: 5px; border-style: solid; border-color: #dddddd; word-wrap: break-word; ">&lt;link&nbsp;rel="stylesheet"&nbsp;href="&lt;?php&nbsp;bloginfo('template_url');&nbsp;?&gt;/highlight.css"&nbsp;/&gt;</td></tr></tbody></table><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; "></p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">当然，你也可以复制highlight.css中的所有代码到你主题style.css中，以上步骤就免了！</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">如认为默认的样式不符合自己的要求，可以通过修改&#8220;highlight.css&#8221;中的样式改变代码高亮、边框、背景等颜色，更个性化。</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">但需要注意的是WordPress会自动把半角符号替换为全角，别人复制下来的函数代码标点是全角的，无法使用，切记！</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">解决办法：</p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; "></p><table border="0" cellspacing="0" cellpadding="6" width="95%" align="center" style="border-collapse: collapse; border-spacing: 0px; width: 641px; background-color: #ffffff; color: #000000; font-size: 14px; line-height: 26px; text-align: start; text-indent: 0px; border-style: solid; border-color: #0099cc; table-layout: fixed; "><tbody><tr><td bgcolor="#ddedfb" style="margin: 0px; padding: 5px; border-style: solid; border-color: #dddddd; word-wrap: break-word; "><ol style="margin: 1em 0px; padding: 0px 0px 0px 30px; "><li style="margin: 0px 0px 5px; padding: 0px; list-style: inherit; ">打开并编辑&nbsp;wp-includes/formatting.php&nbsp;文件，找到以下代码：</li><li style="margin: 0px 0px 5px; padding: 0px; list-style: inherit; ">//&nbsp;static&nbsp;strings</li><li style="margin: 0px 0px 5px; padding: 0px; list-style: inherit; ">$curl&nbsp;=&nbsp;str_replace($static_characters,&nbsp;$static_replacements,&nbsp;$curl);</li><li style="margin: 0px 0px 5px; padding: 0px; list-style: inherit; ">//&nbsp;regular&nbsp;expressions</li><li style="margin: 0px 0px 5px; padding: 0px; list-style: inherit; ">$curl&nbsp;=&nbsp;preg_replace($dynamic_characters,&nbsp;$dynamic_replacements,&nbsp;$curl);</li><li style="margin: 0px 0px 5px; padding: 0px; list-style: inherit; ">将$curl&nbsp;开头的两句代码注释掉，如下：</li><li style="margin: 0px 0px 5px; padding: 0px; list-style: inherit; ">//&nbsp;static&nbsp;strings</li><li style="margin: 0px 0px 5px; padding: 0px; list-style: inherit; ">//$curl&nbsp;=&nbsp;str_replace($static_characters,&nbsp;$static_replacements,&nbsp;$curl);</li><li style="margin: 0px 0px 5px; padding: 0px; list-style: inherit; ">//&nbsp;regular&nbsp;expressions</li><li style="margin: 0px 0px 5px; padding: 0px; list-style: inherit; ">//$curl&nbsp;=&nbsp;preg_replace($dynamic_characters,&nbsp;$dynamic_replacements,&nbsp;$curl);</li></ol></td></tr></tbody></table><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; "></p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; "><strong>效果如下：</strong></p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">PHP:</p><p align="center" style="margin: 1em 0px; padding: 0px; text-indent: 2em; "><a target="_blank" href="http://upload.chinaz.com/upimg/userup/1009/1916415M558.jpg" style="color: #1c3d72; text-decoration: none; "><img border="0" alt="" width="510" height="306" src="http://upload.chinaz.com/upimg/userup/1009/1916415M558.jpg" style="border: 1px solid #999999; display: inline-block; " /></a></p><p style="margin: 1em 0px; padding: 0px; text-indent: 2em; text-align: start; ">CSS:</p><p align="center" style="margin: 1em 0px; padding: 0px; text-indent: 2em; "><a target="_blank" href="http://upload.chinaz.com/upimg/userup/1009/191642112295.jpg" style="color: #1c3d72; "><img border="0" alt="" width="510" height="385" src="http://upload.chinaz.com/upimg/userup/1009/191642112295.jpg" style="border: 1px solid #999999; display: inline-block; " /></a>&nbsp;</p><p>&nbsp;</p><img src ="http://www.blogjava.net/masy/aggbug/385792.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/masy/" target="_blank">韩麦斯</a> 2012-08-20 00:30 <a href="http://www.blogjava.net/masy/articles/385792.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>