<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>轶侠的网上小窝 &#187; WordPress</title>
	<atom:link href="http://e-xia.com/category/it/wordpress-it/feed/" rel="self" type="application/rss+xml" />
	<link>http://e-xia.com</link>
	<description>写给家人和朋友，记录生活</description>
	<lastBuildDate>Fri, 18 Jun 2010 00:23:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>wordpress用户注册成功后的页面跳转</title>
		<link>http://e-xia.com/2010/03/wordpress-redirect-on-success-register-users/</link>
		<comments>http://e-xia.com/2010/03/wordpress-redirect-on-success-register-users/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 04:52:39 +0000</pubDate>
		<dc:creator>轶侠</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://e-xia.com/?p=712</guid>
		<description><![CDATA[并非完美解决，大概就这么个意思，凑合看吧。 function register_success_login_redirect&#40;$errors&#41; &#123; $pos = strpos&#40;$errors,'Registration complete'&#41;; if&#40;$pos === false&#41; return $errors; else return $errors.'&#60;script type=&#34;text/javascript&#34;&#62;window.location.href = &#34;/?p=251&#34;;&#60;/script&#62;'; &#125; add_filter&#40;'login_messages', 'register_success_login_redirect'&#41;;]]></description>
			<content:encoded><![CDATA[<p>并非完美解决，大概就这么个意思，凑合看吧。</p>
<div class="justcolor" style="border:1px solid #ccc;background:#fcffff;padding:15px 0;margin:5px 0;overflow:auto;overflow-x:auto;overflow-y:hidden;"><pre class="justcolor php" style="margin: 0 10px; font-family: 'Courier New', Courier, Fixed;"><span style="color: #000000; font-weight: bold;">function</span> register_success_login_redirect<span style="color: #009900;">&#40;</span><span style="color: #000033;">$errors</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000033;">$pos</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$errors</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Registration complete'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$pos</span> <span style="color: #339933;">===</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #000033;">$errors</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">return</span> <span style="color: #000033;">$errors</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;script type=&quot;text/javascript&quot;&gt;window.location.href = &quot;/?p=251&quot;;&lt;/script&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'login_messages'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'register_success_login_redirect'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div>
]]></content:encoded>
			<wfw:commentRss>http://e-xia.com/2010/03/wordpress-redirect-on-success-register-users/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MU搬家以及和WP合并</title>
		<link>http://e-xia.com/2009/11/change-mu-domain-and-merge-with-wordpres/</link>
		<comments>http://e-xia.com/2009/11/change-mu-domain-and-merge-with-wordpres/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 12:36:45 +0000</pubDate>
		<dc:creator>轶侠</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[301]]></category>
		<category><![CDATA[merge]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[mu]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://e-xia.com/?p=647</guid>
		<description><![CDATA[因为365memo.com域名到期，又不想花钱了，决定把mu整站搬到utmemory.com，并且把utmemory.com原来的wp直接并到mu里面作为主站。 准备数据 首先是mu改域名，如果在数据库里一个一个改，难倒是不难，就是太烦。几个外国哥们儿挺聪明的，提供方法如下，用mysql dump（可以用phpmyadmin或者其他客户端）把sql弄下来，然后查找旧域名，换成新的域名。在另一边的server建数据库，导入数据。 然后倒入wp数据。故技重施，直接备份wp_comments，wp_links，wp_postmeta，wp_posts，wp_terms，wp_term_relationships，wp_term_taxonomy这7个table，把wp_替换成wp_1_。然后把mu数据库里的wp_1_开头的这7个table删除。运行替换过的sql，重新生成这7个表。 到这里数据初步准备完毕。 准备文件 建一个index.html告知网站正在维护。 把所有wp的文件copy到备份目录，然后释放mu的文件，域名/index.php开始安装，没啥花头。 在cpanel里面建*的subdomain，不然没法做二级域名的mu。 把原站的wp-content目录，和wp的wp-content目录都搬到mu的wp-content，ok，准备工作基本就绪。 登陆后台启动正确的插件，theme，widget等，新站基本完成。 最后是把mu主站blog的作者id改成相对应的mu userid。如果mu里没有这个用户，先新建一个，然后用update wp_1_posts set post_author=x，如果多作者跟where。 测试一下新站是否全部正常，不正常的google。正常就删掉index.html。 做重定向 在原先域名的根目录下建.htaccess，内容如下 &#60;IfModule mod_rewrite.c&#62; RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^(.*)\.old\.com [nc] RewriteRule ^(.*)$ http://%1.new.com/$1 [R=301,L] &#60;/IfModule&#62; 注意%和$的位置，这里卡了挺久。刚开始最好不要加R=301，万一写错了浏览器cache有些烦，成功了再加301]]></description>
			<content:encoded><![CDATA[<p>因为365memo.com域名到期，又不想花钱了，决定把mu整站搬到utmemory.com，并且把utmemory.com原来的wp直接并到mu里面作为主站。</p>
<h3>准备数据</h3>
<p>首先是mu改域名，如果在数据库里一个一个改，难倒是不难，就是太烦。几个外国哥们儿挺聪明的，提供方法如下，用mysql dump（可以用phpmyadmin或者其他客户端）把sql弄下来，然后查找旧域名，换成新的域名。在另一边的server建数据库，导入数据。</p>
<p>然后倒入wp数据。故技重施，直接备份wp_comments，wp_links，wp_postmeta，wp_posts，wp_terms，wp_term_relationships，wp_term_taxonomy这7个table，把wp_替换成wp_1_。然后把mu数据库里的wp_1_开头的这7个table删除。运行替换过的sql，重新生成这7个表。</p>
<p>到这里数据初步准备完毕。</p>
<h3>准备文件</h3>
<p>建一个index.html告知网站正在维护。</p>
<p>把所有wp的文件copy到备份目录，然后释放mu的文件，域名/index.php开始安装，没啥花头。</p>
<p>在cpanel里面建*的subdomain，不然没法做二级域名的mu。</p>
<p>把原站的wp-content目录，和wp的wp-content目录都搬到mu的wp-content，ok，准备工作基本就绪。</p>
<p>登陆后台启动正确的插件，theme，widget等，新站基本完成。</p>
<p>最后是把mu主站blog的作者id改成相对应的mu userid。如果mu里没有这个用户，先新建一个，然后用<code>update wp_1_posts set post_author=x</code>，如果多作者跟where。</p>
<p>测试一下新站是否全部正常，不正常的google。正常就删掉index.html。</p>
<h3>做重定向</h3>
<p>在原先域名的根目录下建.htaccess，内容如下</p>
<div class="justcolor" style="border:1px solid #ccc;background:#fcffff;padding:15px 0;margin:5px 0;overflow:auto;overflow-x:auto;overflow-y:hidden;"><pre class="justcolor txt" style="margin: 0 10px; font-family: 'Courier New', Courier, Fixed;">&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(.*)\.old\.com [nc]
RewriteRule ^(.*)$ http://%1.new.com/$1 [R=301,L]
&lt;/IfModule&gt;</pre></div>
<p>注意%和$的位置，这里卡了挺久。刚开始最好不要加R=301，万一写错了浏览器cache有些烦，成功了再加301</p>
]]></content:encoded>
			<wfw:commentRss>http://e-xia.com/2009/11/change-mu-domain-and-merge-with-wordpres/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>关于模板路径</title>
		<link>http://e-xia.com/2009/07/parent-child-theme-path/</link>
		<comments>http://e-xia.com/2009/07/parent-child-theme-path/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 05:31:18 +0000</pubDate>
		<dc:creator>轶侠</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://e-xia.com/?p=604</guid>
		<description><![CDATA[更新了wp和PageNavi后，我突然PageNavi的样式丢失了，花了几分钟看了下代码，作者是这样写的： function pagenavi_stylesheets&#40;&#41; &#123; if&#40;@file_exists&#40;TEMPLATEPATH.'/pagenavi-css.css'&#41;&#41; &#123; wp_enqueue_style&#40;'wp-pagenavi', get_stylesheet_directory_uri&#40;&#41;.'/pagenavi-css.css', false, '2.50', 'all'&#41;; &#125; else &#123; wp_enqueue_style&#40;'wp-pagenavi', plugins_url&#40;'wp-pagenavi/pagenavi-css.css'&#41;, false, '2.50', 'all'&#41;; &#125; &#125; TEMPLATEPATH指向了父模板的路径，但是get_stylesheet_directory_uri给的是子模板的链接。查了一下api，理了一下思路，应该先查看子目录下pagenavi-css.css，再看父模板下pagenavi-css.css，最后采用默认css，改代码如下： function pagenavi_stylesheets&#40;&#41; &#123; if&#40;@file_exists&#40;STYLESHEETPATH.'/pagenavi-css.css'&#41;&#41; &#123; wp_enqueue_style&#40;'wp-pagenavi', get_stylesheet_directory_uri&#40;&#41;.'/pagenavi-css.css', false, '2.50', 'all'&#41;; &#125; else if&#40;@file_exists&#40;TEMPLATEPATH.'/pagenavi-css.css'&#41;&#41; &#123; wp_enqueue_style&#40;'wp-pagenavi', get_template_directory_uri&#40;&#41;.'/pagenavi-css.css', false, '2.50', 'all'&#41;; &#125; else &#123; wp_enqueue_style&#40;'wp-pagenavi', plugins_url&#40;'wp-pagenavi/pagenavi-css.css'&#41;, false, '2.50', 'all'&#41;; &#125; &#125; 总结： STYLESHEETPATH 和 get_stylesheet_directory_uri [...]]]></description>
			<content:encoded><![CDATA[<p>更新了wp和PageNavi后，我突然PageNavi的样式丢失了，花了几分钟看了下代码，作者是这样写的：</p>
<div class="justcolor" style="border:1px solid #ccc;background:#fcffff;padding:15px 0;margin:5px 0;overflow:auto;overflow-x:auto;overflow-y:hidden;"><pre class="justcolor php" style="margin: 0 10px; font-family: 'Courier New', Courier, Fixed;"><span style="color: #000000; font-weight: bold;">function</span> pagenavi_stylesheets<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">@</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span>TEMPLATEPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'/pagenavi-css.css'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      wp_enqueue_style<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-pagenavi'</span><span style="color: #339933;">,</span> get_stylesheet_directory_uri<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/pagenavi-css.css'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'2.50'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'all'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
      wp_enqueue_style<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-pagenavi'</span><span style="color: #339933;">,</span> plugins_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-pagenavi/pagenavi-css.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'2.50'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'all'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>   
<span style="color: #009900;">&#125;</span></pre></div>
<p><code>TEMPLATEPATH</code>指向了父模板的路径，但是<code>get_stylesheet_directory_uri</code>给的是子模板的链接。查了一下api，理了一下思路，应该先查看子目录下<code>pagenavi-css.css</code>，再看父模板下<code>pagenavi-css.css</code>，最后采用默认css，改代码如下：</p>
<div class="justcolor" style="border:1px solid #ccc;background:#fcffff;padding:15px 0;margin:5px 0;overflow:auto;overflow-x:auto;overflow-y:hidden;"><pre class="justcolor php" style="margin: 0 10px; font-family: 'Courier New', Courier, Fixed;"><span style="color: #000000; font-weight: bold;">function</span> pagenavi_stylesheets<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">@</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span>STYLESHEETPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'/pagenavi-css.css'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      wp_enqueue_style<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-pagenavi'</span><span style="color: #339933;">,</span> get_stylesheet_directory_uri<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/pagenavi-css.css'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'2.50'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'all'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">@</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span>TEMPLATEPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'/pagenavi-css.css'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      wp_enqueue_style<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-pagenavi'</span><span style="color: #339933;">,</span> get_template_directory_uri<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/pagenavi-css.css'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'2.50'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'all'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
      wp_enqueue_style<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-pagenavi'</span><span style="color: #339933;">,</span> plugins_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-pagenavi/pagenavi-css.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'2.50'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'all'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>   
<span style="color: #009900;">&#125;</span></pre></div>
<p>总结：</p>
<ul>
<li>STYLESHEETPATH 和 get_stylesheet_directory_uri 指向子模板</li>
<li>TEMPLATEPATH 和 get_template_directory_uri 指向父模板</li>
</ul>
<p>给作者发了贴，不知道他会不会改。</p>
]]></content:encoded>
			<wfw:commentRss>http://e-xia.com/2009/07/parent-child-theme-path/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>定时备份mu数据库</title>
		<link>http://e-xia.com/2009/04/auto-backup-mu-db/</link>
		<comments>http://e-xia.com/2009/04/auto-backup-mu-db/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 06:53:07 +0000</pubDate>
		<dc:creator>轶侠</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[电脑]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[google app]]></category>
		<category><![CDATA[mu]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://e-xia.com/?p=488</guid>
		<description><![CDATA[一直没有找到好用的mu数据库备份插件，mu官方给的方法是这样滴： DATE=`date &#124; tr &#34; &#34; _` echo $DATE mysqldump wordpress --add-drop-table -h localhost -u wpdbuser -pyourpasswd &#124; gzip &#62; db.$DATE.gz tar cvfz code.$DATE.gz 不过这只有备份打包，没有发送到email得功能，最近我找到了这个：AutoMySQLBackup，一个shellscript，可以自动备份数据库，并发送到email，和WP-DB-Backup的功能一样了哦，不过怎样能定时运行嗫？在询问了site5客服后，得到的回复是——建个cron job。 先根据提示修改automysqlbackup.sh.2.5，写入数据库信息，上传到服务器合适的目录，例如：~/etc 修改权限：chmod +x ~/etc/automysqlbackup.sh运行一下看看有没有收到备份email，如果有问题，继续修改automysqlbackup.sh ssh到服务器，输入crontab -e开始编辑，0 2 * * * ~/etc/automysqlbackup.sh（每天晚上2点运行），保存，退出，第二天看看有没有收到email。 关于cron的命令： crontab -l #显示当前的cron job crontab -e #编辑 关于cron的定时问题： * * * * * /home/milch/tmpmail #每分钟执行这个命令（分 小时 日 [...]]]></description>
			<content:encoded><![CDATA[<p>一直没有找到好用的mu数据库备份插件，<a href="http://codex.wordpress.org/Backup_WPMU">mu官方给的方法是这样滴</a>：</p>
<div class="justcolor" style="border:1px solid #ccc;background:#fcffff;padding:15px 0;margin:5px 0;overflow:auto;overflow-x:auto;overflow-y:hidden;"><pre class="justcolor bash" style="margin: 0 10px; font-family: 'Courier New', Courier, Fixed;"><span style="color: #007800;">DATE=</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #ff0000;">&quot; &quot;</span> _<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$DATE</span>
mysqldump wordpress --add-drop-table -h localhost -u wpdbuser -pyourpasswd <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">gzip</span> <span style="color: #000000; font-weight: bold;">&gt;</span> db.<span style="color: #007800;">$DATE</span>.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> cvfz code.<span style="color: #007800;">$DATE</span>.gz</pre></div>
<p>不过这只有备份打包，没有发送到email得功能，最近我找到了这个：<a href="http://sourceforge.net/projects/automysqlbackup/">AutoMySQLBackup</a>，一个shellscript，可以自动备份数据库，并发送到email，和<a href="http://wordpress.org/extend/plugins/wp-db-backup/">WP-DB-Backup</a>的功能一样了哦，不过怎样能定时运行嗫？在询问了site5客服后，得到的回复是——建个cron job。</p>
<ul>
<li>先根据提示修改automysqlbackup.sh.2.5，写入数据库信息，上传到服务器合适的目录，例如：<code>~/etc</code></li>
<li>修改权限：<code>chmod +x ~/etc/automysqlbackup.sh</code>运行一下看看有没有收到备份email，如果有问题，继续修改automysqlbackup.sh</li>
<li>ssh到服务器，输入<code>crontab -e</code>开始编辑，<code>0 2 * * * ~/etc/automysqlbackup.sh</code>（每天晚上2点运行），保存，退出，第二天看看有没有收到email。</li>
</ul>
<p><span id="more-488"></span><br />
关于cron的命令：</p>
<div class="justcolor" style="border:1px solid #ccc;background:#fcffff;padding:15px 0;margin:5px 0;overflow:auto;overflow-x:auto;overflow-y:hidden;"><pre class="justcolor bash" style="margin: 0 10px; font-family: 'Courier New', Courier, Fixed;">crontab -l <span style="color: #666666; font-style: italic;">#显示当前的cron job</span>
crontab -e <span style="color: #666666; font-style: italic;">#编辑</span></pre></div>
<p>关于cron的定时问题：</p>
<div class="justcolor" style="border:1px solid #ccc;background:#fcffff;padding:15px 0;margin:5px 0;overflow:auto;overflow-x:auto;overflow-y:hidden;"><pre class="justcolor txt" style="margin: 0 10px; font-family: 'Courier New', Courier, Fixed;">* * * * * /home/milch/tmpmail #每分钟执行这个命令（分 小时 日 月 周 [用户] 命令）
其中的星号（*）是通配符，表示cron将忽略这个字段。
12 3 * * * #每天的凌晨3点12分（03:12）
30 15 13 6 1 * #6月13日周一的15:30运行
30 15 13 Jun Mon * #6月13日周一的15:30运行
15 * * * * #每小时的第15分钟
#每两小时就运行某个程序，可以在小时字段里使用 */2。
0 */2 * * * #在2点，4点，6点……22点，24点运行。
#cron语句中还可以使用逗号（,）来指定多个时间。
15,30 * * * * #每小时的15分和30分
15,30 */2 1-7 * * #每月的第1-7日每两小时的15分和30分（02:15，02:30……22: 15，22:30等）。
#如果你想在每天的16:18执行一个脚本集合，把所有要执行的脚本放到一个目录中（如 /home/username/cron），可以使用：
18 16 * * * root run-parts /home/username/cron &gt;&gt; /dev/null 2&gt;&amp;1</pre></div>
]]></content:encoded>
			<wfw:commentRss>http://e-xia.com/2009/04/auto-backup-mu-db/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>给WP加上Google广告代码</title>
		<link>http://e-xia.com/2009/02/add-google-adsense-to-wordpress/</link>
		<comments>http://e-xia.com/2009/02/add-google-adsense-to-wordpress/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 03:59:28 +0000</pubDate>
		<dc:creator>轶侠</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[电脑]]></category>

		<guid isPermaLink="false">http://e-xia.com/?p=448</guid>
		<description><![CDATA[刚给自己的blog加了Google广告，第一天就收入了1分美金，开心啊，照这样一个月3毛，一年3块6，Google 100美金给寄支票，那么30年左右我就能拿到我的第一张Google支票啦！ 要给每篇post加上Google广告其实蛮容易的，代码如下： &#60;?php add_filter&#40;'the_content', 'google_ads'&#41;; function google_ads&#40;$content&#41;&#123; if&#40;is_page&#40;&#41;&#124;&#124;is_single&#40;&#41;&#41;&#123; ob_start&#40;&#41;; ?&#62; &#60;div class=&#34;google center&#34;&#62; &#60;!--Google AdSense Code HERE--&#62; &#60;/div&#62; &#60;?php $content = ob_get_contents&#40;&#41;.$content; ob_end_clean&#40;&#41;; &#125; return $content; &#125; ?&#62; 明天有空接着讲对直接访问和搜索引擎来的用户显示不同尺寸广告的代码。]]></description>
			<content:encoded><![CDATA[<p>刚给自己的blog加了Google广告，第一天就收入了1分美金，开心啊，照这样一个月3毛，一年3块6，Google 100美金给寄支票，那么30年左右我就能拿到我的第一张Google支票啦！</p>
<p>要给每篇post加上Google广告其实蛮容易的，代码如下：</p>
<div class="justcolor" style="border:1px solid #ccc;background:#fcffff;padding:15px 0;margin:5px 0;overflow:auto;overflow-x:auto;overflow-y:hidden;"><pre class="justcolor php" style="margin: 0 10px; font-family: 'Courier New', Courier, Fixed;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'google_ads'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> google_ads<span style="color: #009900;">&#40;</span><span style="color: #000033;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>is_page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span>is_single<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;google center&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;!--</span>Google AdSense Code HERE<span style="color: #339933;">--&gt;</span>
<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #000033;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ob_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000033;">$content</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">ob_end_clean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000033;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div>
<p>明天有空接着讲对直接访问和搜索引擎来的用户显示不同尺寸广告的代码。</p>
]]></content:encoded>
			<wfw:commentRss>http://e-xia.com/2009/02/add-google-adsense-to-wordpress/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>去掉域名里的www（.htaccess）</title>
		<link>http://e-xia.com/2009/02/no-www-through-htaccess/</link>
		<comments>http://e-xia.com/2009/02/no-www-through-htaccess/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 06:28:37 +0000</pubDate>
		<dc:creator>轶侠</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[电脑]]></category>
		<category><![CDATA[301]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[redirect]]></category>

		<guid isPermaLink="false">http://e-xia.com/?p=421</guid>
		<description><![CDATA[前段时间偷偷去掉了域名里的www，看了ma.tt的文章，修改了WP的index.php（后来才发现ma.tt写了个插件WordPress no-www）。头几天挺好，PR也过来了，不过再后来PR就消失了，Leo说是PR没刷新，我晕，等等吧，怎么等也不见好，这时候唐唐说他转的域名PR恢复了，我突然反应过来升级WP该不是把我改的index.php覆盖了吧，一看果然是。重新Google .htaccess的解决方式吧。 # 301 redirect to domain without 'www.' RewriteCond %{HTTP_HOST} ^www.example.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [R=301,L] 参见《301 Redirect With No WWW Using Htaccess》 也不知道有用没用。]]></description>
			<content:encoded><![CDATA[<p>前段时间偷偷去掉了域名里的www，看了ma.tt的文章，修改了WP的index.php（后来才发现ma.tt写了个插件<a href="http://ma.tt/2006/06/wordpress-no-www/" target="_blank">WordPress no-www</a>）。头几天挺好，PR也过来了，不过再后来PR就消失了，Leo说是PR没刷新，我晕，等等吧，怎么等也不见好，这时候唐唐说他转的域名PR恢复了，我突然反应过来升级WP该不是把我改的index.php覆盖了吧，一看果然是。重新Google .htaccess的解决方式吧。</p>
<pre>
  # 301 redirect to domain without 'www.'
  RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
  RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
</pre>
<p>参见<a href="http://vision-media.ca/resources/seo/301-redirect-with-no-www-using-htaccess" target="_blank">《301 Redirect With No WWW Using Htaccess》</a></p>
<p>也不知道有用没用。</p>
]]></content:encoded>
			<wfw:commentRss>http://e-xia.com/2009/02/no-www-through-htaccess/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>WP空白首页历险记</title>
		<link>http://e-xia.com/2009/02/blank-wordpress-default-pag/</link>
		<comments>http://e-xia.com/2009/02/blank-wordpress-default-pag/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 06:05:30 +0000</pubDate>
		<dc:creator>轶侠</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[电脑]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://e-xia.com/?p=418</guid>
		<description><![CDATA[今天又碰到个郁闷错误，瞳妈紧张兮兮的在QQ上说：花蕾怎么连不上了？一片白啊！ 我一看，那叫一个白啊，⊙﹏⊙b汗！啥都没有啊。 想了想，先升级wp，后台一跑，挺好的呀。顺利升级，刷新，还是一片白。OK，我的theme写得有问题（用了都快1年的theme，怎么会突然有问题？不管了），启动default，还是一片白。那么？？禁用插件，还是白的，Orz。 在大脑空白n分钟后到群里吼，然后开始google，关键词：“wordpress blank page”，结果有个外国哥们儿写，wp每个月都会定时不定时的来那么一次blank page，搞得和大姨妈一样，写了几个处理办法，我一看不外乎就是升级禁用插件，不过还写了看看php和mysql的版本。到cpanel里看了看，也没问题啊。那叫一个郁闷啊。 这时群里一群友说：“好像就是首页出了问题。”这算怎么回事儿啊。 决定全删掉，重装wp，顺手开了cpanel的文件管理（windows时代的，command line用不好），一个一个文件钩，突然我发现一个index.html，长度0，圈圈你个叉叉，谁放了个index.html在根目录？（曈妈，是你不？）删了，那丢失的主页又回来了，曈曈，优优，你们的笑脸真漂亮啊。 所以，同志们，有时候很多错误真的是很白。]]></description>
			<content:encoded><![CDATA[<p>今天又碰到个郁闷错误，瞳妈紧张兮兮的在QQ上说：<a href="http://utmemory.com" target="_blank">花蕾</a>怎么连不上了？一片白啊！</p>
<p>我一看，那叫一个白啊，⊙﹏⊙b汗！啥都没有啊。</p>
<p>想了想，先升级wp，后台一跑，挺好的呀。顺利升级，刷新，还是一片白。OK，我的theme写得有问题（用了都快1年的theme，怎么会突然有问题？不管了），启动default，还是一片白。那么？？禁用插件，还是白的，Orz。</p>
<p>在大脑空白n分钟后到群里吼，然后开始google，关键词：“wordpress blank page”，结果有个外国哥们儿写，wp每个月都会定时不定时的来那么一次blank page，搞得和大姨妈一样，写了几个处理办法，我一看不外乎就是升级禁用插件，不过还写了看看php和mysql的版本。到cpanel里看了看，也没问题啊。那叫一个郁闷啊。</p>
<p>这时群里一群友说：“好像就是首页出了问题。”这算怎么回事儿啊。</p>
<p>决定全删掉，重装wp，顺手开了cpanel的文件管理（windows时代的，command line用不好），一个一个文件钩，突然我发现一个<strong>index.html</strong>，长度0，<del datetime="2009-02-16T05:53:31+00:00">圈圈你个叉叉，</del>谁放了个index.html在根目录？（曈妈，是你不？）删了，那丢失的主页又回来了，曈曈，优优，你们的笑脸真漂亮啊。</p>
<p>所以，同志们，有时候很多错误真的是很白。</p>
]]></content:encoded>
			<wfw:commentRss>http://e-xia.com/2009/02/blank-wordpress-default-pag/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>[BUG]is_front_page</title>
		<link>http://e-xia.com/2009/02/is_front_page/</link>
		<comments>http://e-xia.com/2009/02/is_front_page/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 04:50:01 +0000</pubDate>
		<dc:creator>轶侠</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[电脑]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://e-xia.com/?p=409</guid>
		<description><![CDATA[今又碰到一个wp的bug，也不知道说是wp的bug好还是我的数据库bug。 做顶部的“首页”链接的时候，我选择了is_front_page做为判断，不过失败了，换了is_home就好了，然后我就陷入了无限郁闷当中。看了一眼代码： function is_front_page &#40;&#41; &#123; // most likely case if &#40; 'posts' == get_option&#40;'show_on_front'&#41; &#38;&#38; is_home&#40;&#41; &#41; return true; elseif &#40; 'page' == get_option&#40;'show_on_front'&#41; &#38;&#38; get_option&#40;'page_on_front'&#41; &#38;&#38; is_page&#40;get_option&#40;'page_on_front'&#41;&#41; &#41; return true; else return false; &#125; 咋用了get_option('show_on_front')嗫，跑到后台一看，在“Setting - Reading”里面的“front page displays”里一个都没有选。再看数据库，果然，没有show_on_front这一条。剩下就是提交bug，然后改代码。 迂回的解决方法：if(get_option('show_on_front')?is_front_page():is_home()){}]]></description>
			<content:encoded><![CDATA[<p>今又碰到一个wp的bug，也不知道说是wp的bug好还是我的数据库bug。</p>
<p>做顶部的“首页”链接的时候，我选择了<code>is_front_page</code>做为判断，不过失败了，换了<code>is_home</code>就好了，然后我就陷入了无限郁闷当中。看了一眼代码：</p>
<div class="justcolor" style="border:1px solid #ccc;background:#fcffff;padding:15px 0;margin:5px 0;overflow:auto;overflow-x:auto;overflow-y:hidden;"><pre class="justcolor php" style="margin: 0 10px; font-family: 'Courier New', Courier, Fixed;"><span style="color: #000000; font-weight: bold;">function</span> is_front_page <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// most likely case</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'posts'</span> <span style="color: #339933;">==</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'show_on_front'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> is_home<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'page'</span> <span style="color: #339933;">==</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'show_on_front'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page_on_front'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> is_page<span style="color: #009900;">&#40;</span>get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page_on_front'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div>
<p>咋用了<code>get_option('show_on_front')</code>嗫，跑到后台一看，在“Setting - Reading”里面的“front page displays”里一个都没有选。再看数据库，果然，没有show_on_front这一条。剩下就是提交bug，然后改代码。</p>
<p>迂回的解决方法：<code>if(get_option('show_on_front')?is_front_page():is_home()){}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://e-xia.com/2009/02/is_front_page/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>3种方式改变默认avatar图片</title>
		<link>http://e-xia.com/2009/02/3-ways-to-change-default-avatar/</link>
		<comments>http://e-xia.com/2009/02/3-ways-to-change-default-avatar/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 12:00:08 +0000</pubDate>
		<dc:creator>轶侠</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[avatar]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://e-xia.com/?p=398</guid>
		<description><![CDATA[第一种，增加后台的默认avatar选项，然后到后台的Settings-Comment设置里面选中，保存。这个比较适合自己网站有固定的默认头像图片，换任何theme都用这一个图片的情况。代码： add_filter&#40; 'avatar_defaults', 'fb_addgravatar' &#41;; function fb_addgravatar&#40; $avatar_defaults &#41; &#123; $myavatar = 'http://e-xia.com/avatar.jpg';//avatar地址 $avatar_defaults&#91;$myavatar&#93; = 'Avatar';//avatar名称 return $avatar_defaults; &#125; 第二种，通过get_avatar这个函数，设置第三个参数为默认头像的地址。这个适合需要默认头像配合当前模板来获得最大视觉效果情况，完全忽略后台设置，超级适用于对MU统一的默认头像管理。代码： &#60;?php echo get_avatar&#40; $id_or_email, $size = '96', $default = '&#60;path_to_url&#62;' &#41;; ?&#62; 第三种，通过filterget_avatar来设置默认头像的地址。这个适合2.7中使用了默认的wp_list_comments()，或者作为子模板，不能直接调用get_avatar()，或者代码中多次使用了get_avatar()，想做统一修改的。代码： &#60;?php add_filter&#40;'get_avatar', 'change_default_avatar', 1000, 4&#41;; function change_default_avatar&#40;$avatar, $id_or_email, $size, $default&#41;&#123; return str_replace&#40;urlencode&#40;$default&#41;, urlencode&#40;&#34;&#60;path_to_url&#62;&#34;&#41;, $avatar&#41;; &#125; ?&#62;]]></description>
			<content:encoded><![CDATA[<p>第一种，增加后台的默认avatar选项，然后到后台的Settings-Comment设置里面选中，保存。这个比较适合自己网站有固定的默认头像图片，换任何theme都用这一个图片的情况。代码：</p>
<div class="justcolor" style="border:1px solid #ccc;background:#fcffff;padding:15px 0;margin:5px 0;overflow:auto;overflow-x:auto;overflow-y:hidden;"><pre class="justcolor php" style="margin: 0 10px; font-family: 'Courier New', Courier, Fixed;">add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'avatar_defaults'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fb_addgravatar'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> fb_addgravatar<span style="color: #009900;">&#40;</span> <span style="color: #000033;">$avatar_defaults</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000033;">$myavatar</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://e-xia.com/avatar.jpg'</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//avatar地址</span>
  <span style="color: #000033;">$avatar_defaults</span><span style="color: #009900;">&#91;</span><span style="color: #000033;">$myavatar</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Avatar'</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//avatar名称</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000033;">$avatar_defaults</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div>
<p>第二种，通过<a href="http://codex.wordpress.org/Using_Gravatars" target="_blank"><code>get_avatar</code></a>这个函数，设置第三个参数为默认头像的地址。这个适合需要默认头像配合当前模板来获得最大视觉效果情况，完全忽略后台设置，超级适用于对MU统一的默认头像管理。代码：</p>
<div class="justcolor" style="border:1px solid #ccc;background:#fcffff;padding:15px 0;margin:5px 0;overflow:auto;overflow-x:auto;overflow-y:hidden;"><pre class="justcolor php" style="margin: 0 10px; font-family: 'Courier New', Courier, Fixed;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
  <span style="color: #990000;">echo</span> get_avatar<span style="color: #009900;">&#40;</span> <span style="color: #000033;">$id_or_email</span><span style="color: #339933;">,</span> <span style="color: #000033;">$size</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'96'</span><span style="color: #339933;">,</span> <span style="color: #000033;">$default</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;path_to_url&gt;'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div>
<p>第三种，通过filter<code>get_avatar</code>来设置默认头像的地址。这个适合2.7中使用了默认的<code>wp_list_comments()</code>，或者作为子模板，不能直接调用<code>get_avatar()</code>，或者代码中多次使用了<code>get_avatar()</code>，想做统一修改的。代码：</p>
<div class="justcolor" style="border:1px solid #ccc;background:#fcffff;padding:15px 0;margin:5px 0;overflow:auto;overflow-x:auto;overflow-y:hidden;"><pre class="justcolor php" style="margin: 0 10px; font-family: 'Courier New', Courier, Fixed;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'get_avatar'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'change_default_avatar'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1000</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> change_default_avatar<span style="color: #009900;">&#40;</span><span style="color: #000033;">$avatar</span><span style="color: #339933;">,</span> <span style="color: #000033;">$id_or_email</span><span style="color: #339933;">,</span> <span style="color: #000033;">$size</span><span style="color: #339933;">,</span> <span style="color: #000033;">$default</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$default</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;path_to_url&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000033;">$avatar</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div>
]]></content:encoded>
			<wfw:commentRss>http://e-xia.com/2009/02/3-ways-to-change-default-avatar/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Easy Picasa插件发布</title>
		<link>http://e-xia.com/2009/01/easy-picasa-published/</link>
		<comments>http://e-xia.com/2009/01/easy-picasa-published/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 06:40:36 +0000</pubDate>
		<dc:creator>轶侠</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[电脑]]></category>
		<category><![CDATA[picasa]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://e-xia.com/?p=380</guid>
		<description><![CDATA[发布地址：Easy Picasa 具体情况请看：Easy Picasa Picasa相关知识请看：Picasa外链及我的WP插件Easy Picasa]]></description>
			<content:encoded><![CDATA[<p>发布地址：<a href="http://wordpress.org/extend/plugins/easy-picasa/">Easy Picasa</a></p>
<p>具体情况请看：<a href="http://e-xia.com/plugins/easy-picasa/">Easy Picasa</a></p>
<p>Picasa相关知识请看：<a href="http://e-xia.com/2009/01/picasa-and-easy-picasa/">Picasa外链及我的WP插件Easy Picasa</a></p>
]]></content:encoded>
			<wfw:commentRss>http://e-xia.com/2009/01/easy-picasa-published/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Picasa外链及我的WP插件Easy Picasa</title>
		<link>http://e-xia.com/2009/01/picasa-and-easy-picasa/</link>
		<comments>http://e-xia.com/2009/01/picasa-and-easy-picasa/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 13:30:59 +0000</pubDate>
		<dc:creator>轶侠</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[电脑]]></category>
		<category><![CDATA[picasa]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://e-xia.com/?p=347</guid>
		<description><![CDATA[最近研究了一下picasa的外链，发现在实际应用中真是妙用无穷。 首先，picasa是google的免费相簿，google提供了同名的软件，帮助修改照片和上传，基本上还是很好用的。但是如果直接复制图片的链接，有时候外链会出现大叉，是不是google真的这么小气不提供外链呢？其实不是这样的，而是google提供了更贴心的服务。 一般复制下来的图片链接是这样的：http://lh5.ggpht.com/_jOzRPgTdRmo/SWL6LnO8WYI/AAAAAAAAA3Q/14LVMgVPZ5c/cover.jpg，引用就是一个叉，这里的关键就是要加参数，在图片名之前加入尺寸参数，变成http://lh5.ggpht.com/_jOzRPgTdRmo/SWL6LnO8WYI/AAAAAAAAA3Q/14LVMgVPZ5c/s400/cover.jpg，就可以外链了。 加入参数后会发现图片最大的一边边长变成了400px。这样做的好处是什么呢，就是可以控制引用图片的大小，便于插入网页，也加快浏览速度。小尺寸的照片总是比较容易摆放，下载也更快。特别是当一个页面引用了很多图片的时候，小尺寸的优势那就更突出了。光说没用，咱们看实例。http://hello.365memo.com是我用wp帮朋友做的一个图片浏览站。在首页，我引用了s400尺寸的图片来控制图片大小。接下来就是重点了，http://hello.365memo.com/2009/01/ 是零九年一月份的列表，有31张缩略图，如果是别的站点外链的原尺寸的图片，每张少算点儿50K（其实很多照片都1M朝上），30张就是1500K，将近1.5兆了吧。而现在我加入了s64-c的参数，每张图片就才2K都不到了，60k轻松下载，数据还是很诱人的吧。 具体说说参数，刚才说了s400就是最大边长400px，以此类推，s64就是最大边长64px，可是s64-c呢？-c就是裁切，把图片裁切成64px边长的正方形。所以那个月列表上的图片可以是全方的，达到堪称完美的效果。不过不是所有的尺寸随便填写的，这里给出一张图表，参考：《Exploring Picasa Web Albums - Thumbnails and Other Hidden Options》，《Picasa Web Albums query parameters reference》 不过每次加参数还是很麻烦？我专门为picassa写了个wordpress plugin，其中还有一个我写的jQuery的plugin，以解决某些同学觉得加参数麻烦的问题。具体请看：Easy Picasa（一定要看，自我感觉这个插件属于超水平发挥，还有在线的测试页面哦，不用wp的同学可能也可以用到的）。]]></description>
			<content:encoded><![CDATA[<p>最近研究了一下picasa的外链，发现在实际应用中真是妙用无穷。</p>
<p>首先，picasa是google的免费相簿，google提供了同名的软件，帮助修改照片和上传，基本上还是很好用的。但是如果直接复制图片的链接，有时候外链会出现大叉，是不是google真的这么小气不提供外链呢？其实不是这样的，而是google提供了更贴心的服务。</p>
<p>一般复制下来的图片链接是这样的：http://lh5.ggpht.com/_jOzRPgTdRmo/SWL6LnO8WYI/AAAAAAAAA3Q/14LVMgVPZ5c/cover.jpg，引用就是一个叉，这里的关键就是要加参数，在图片名之前加入尺寸参数，变成http://lh5.ggpht.com/_jOzRPgTdRmo/SWL6LnO8WYI/AAAAAAAAA3Q/14LVMgVPZ5c/<span style="color:red;font-weight:bold">s400</span>/cover.jpg，就可以外链了。</p>
<p>加入参数后会发现图片最大的一边边长变成了400px。这样做的好处是什么呢，就是可以控制引用图片的大小，便于插入网页，也加快浏览速度。小尺寸的照片总是比较容易摆放，下载也更快。特别是当一个页面引用了很多图片的时候，小尺寸的优势那就更突出了。光说没用，咱们看实例。<a href="http://hello.365memo.com" target="blank">http://hello.365memo.com</a>是我用wp帮朋友做的一个图片浏览站。在首页，我引用了s400尺寸的图片来控制图片大小。接下来就是重点了，<a href="http://hello.365memo.com/2009/01/" target="blank">http://hello.365memo.com/2009/01/</a> 是零九年一月份的列表，有31张缩略图，如果是别的站点外链的原尺寸的图片，每张少算点儿50K（其实很多照片都1M朝上），30张就是1500K，将近1.5兆了吧。而现在我加入了s64-c的参数，每张图片就才2K都不到了，60k轻松下载，数据还是很诱人的吧。</p>
<p>具体说说参数，刚才说了s400就是最大边长400px，以此类推，s64就是最大边长64px，可是s64-c呢？-c就是裁切，把图片裁切成64px边长的正方形。所以那个月列表上的图片可以是全方的，达到堪称完美的效果。不过不是所有的尺寸随便填写的，这里给出一张图表，参考：<a href="http://tkhere.blogspot.com/2007/11/exploring-picasa-web-albums-thumbnails.html">《Exploring Picasa Web Albums - Thumbnails and Other Hidden Options》</a>，<a href="http://code.google.com/intl/zh-CN/apis/picasaweb/reference.html#Parameters">《Picasa Web Albums query parameters reference》</a><br />
<img src="http://e-xia.com/blog/wp-content/uploads/2009/01/picasa.png" alt="picasa" title="picasa" width="298" height="241" class="aligncenter size-full wp-image-375" /></p>
<p>不过每次加参数还是很麻烦？我专门为picassa写了个wordpress plugin，其中还有一个我写的jQuery的plugin，以解决某些同学觉得加参数麻烦的问题。具体请看：<a href="/plugins/easy-picasa/">Easy Picasa</a>（一定要看，自我感觉这个插件属于超水平发挥，还有在线的测试页面哦，不用wp的同学可能也可以用到的）。</p>
]]></content:encoded>
			<wfw:commentRss>http://e-xia.com/2009/01/picasa-and-easy-picasa/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>2.7升级成功</title>
		<link>http://e-xia.com/2009/01/wp27-updated/</link>
		<comments>http://e-xia.com/2009/01/wp27-updated/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 10:32:09 +0000</pubDate>
		<dc:creator>轶侠</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://e-xia.com/?p=298</guid>
		<description><![CDATA[原来以为要改很多东西，没想到用默认theme很快就做到了所有想要的，不错不错自我表扬一个。]]></description>
			<content:encoded><![CDATA[<p>原来以为要改很多东西，没想到用默认theme很快就做到了所有想要的，不错不错自我表扬一个。</p>
]]></content:encoded>
			<wfw:commentRss>http://e-xia.com/2009/01/wp27-updated/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>本地安装MU</title>
		<link>http://e-xia.com/2009/01/install-mu-on-localhost/</link>
		<comments>http://e-xia.com/2009/01/install-mu-on-localhost/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 12:55:32 +0000</pubDate>
		<dc:creator>轶侠</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[电脑]]></category>
		<category><![CDATA[mu]]></category>
		<category><![CDATA[sub-domain]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[xampp]]></category>

		<guid isPermaLink="false">http://www.e-xia.com/?p=280</guid>
		<description><![CDATA[环境：windows xp + XAMPP 目标，复制server上的数据进行本地测试，要求本地可以实现二级域名 把server上mu目录下整个内容的copy到xampp\htdocs目录下，也就是index.php覆盖原index.php，favicon覆盖原favicon 把服务器上的数据库copy到本地，为避免麻烦我用了同样的数据库名，用户名和密码 编辑文件C:\WINDOWS\system32\drivers\etc\hosts，添加两行： 127.0.0.1 localhost.test 127.0.0.1 test.localhost.test 经事实证明，写*无效 编辑文件xampp\apache\conf\httpd.conf，两个地方： 找到LoadModule rewrite_module modules/mod_rewrite.so大概在118行的样字，去掉前面的# 找到第一个AllowOverride None大概在188行的样子，改成AllowOverride FileInfo Options 现在启动Apache和MySql，在浏览器输入http://localhost.test，报错说这个domain没有，打开数据库，修改两个table wp-site，就一条记录，把domain的内容改成localhost.test wp-blogs，把要测试的blog的主域名改成localhost.test（可以写个UPDATE语句，我比较懒，只改了需要的）（好吧，花30秒把sql写了）UPDATE wp_blogs SET domain = REPLACE(domain,'原域名','localhost.test') 至此应该都完成了。]]></description>
			<content:encoded><![CDATA[<p>环境：windows xp + XAMPP</p>
<p>目标，复制server上的数据进行本地测试，要求本地可以实现二级域名</p>
<ol>
<li>把server上mu目录下整个内容的copy到xampp\htdocs目录下，也就是index.php覆盖原index.php，favicon覆盖原favicon</li>
<li>把服务器上的数据库copy到本地，为避免麻烦我用了同样的数据库名，用户名和密码</li>
<li>编辑文件C:\WINDOWS\system32\drivers\etc\hosts，添加两行：
<pre>127.0.0.1       localhost.test
127.0.0.1       test.localhost.test</pre>
<p>经事实证明，写*无效</p>
</li>
<li>编辑文件xampp\apache\conf\httpd.conf，两个地方：
<ol>
<li>找到<code>LoadModule rewrite_module modules/mod_rewrite.so</code>大概在118行的样字，去掉前面的#</li>
<li>找到第一个<code>AllowOverride None</code>大概在188行的样子，改成<code>AllowOverride FileInfo Options</code></li>
</ol>
</li>
<li>现在启动Apache和MySql，在浏览器输入<code>http://localhost.test</code>，报错说这个domain没有，打开数据库，修改两个table
<ol>
<li>wp-site，就一条记录，把domain的内容改成localhost.test</li>
<li>wp-blogs，把要测试的blog的主域名改成localhost.test<del datetime="2009-01-10T13:03:17+00:00">（可以写个UPDATE语句，我比较懒，只改了需要的）</del>（好吧，花30秒把sql写了）<code>UPDATE wp_blogs SET domain = REPLACE(domain,'原域名','localhost.test')</code></li>
</ol>
</li>
</ol>
<p>至此应该都完成了。</p>
]]></content:encoded>
			<wfw:commentRss>http://e-xia.com/2009/01/install-mu-on-localhost/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>wp-db-back到Google App</title>
		<link>http://e-xia.com/2008/11/wp-db-back-to-google-app/</link>
		<comments>http://e-xia.com/2008/11/wp-db-back-to-google-app/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 01:56:54 +0000</pubDate>
		<dc:creator>轶侠</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[google app]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp-db-backup]]></category>

		<guid isPermaLink="false">http://www.e-xia.com/?p=238</guid>
		<description><![CDATA[Google App真的是好东西，极大地满足了我想有自己域名email又不想花时间设置的懒人作风，进一步增强了我作为Google Fans的理由。 花了几分钟申请了Google App，一切运行良好，在域名商那里按照google的说明改掉了MX设置。从gmail和hotmail各发了个邮件，状态良好。很开心。不过bug王立刻又开始发威了，我开了个beifen[at]e-xia.com的email，然后跑到wordpress后台把db backup的email地址设到了这个email地址下，结果就是收不到备份邮件。 根本没有当回事儿，不过仍旧想用Google App提供的email（7G，不用白不用啊）作为备份，当时的做法是备份邮件发到gmail信箱，然后通过设置filter转到自己域名下的备份邮箱。运行良好。 昨天给另一个域名申请Google App的时候又碰到了一样的问题，而很凑巧的在Google的“更改邮件交换 (MX) 记录”的说明文件的下拉框里看到了“cPanel”字样，引起了我一些些的注意。马上跑到主机的cPanel面板里“Email Management Tools” - “MX Entry Maintenance”一看，果然，Current MX Entries里赫然写着自己的域名，也就意味着主机供应商很自然的把发送到自己域名的email都作为内部email处理了，根本就没有往外送。接下来问题就好解决了，按照google的说明： 登录到您的 cPanel 帐户。 点击 Mail。 点击 Modify Mail Exchanger (MX Entry)。随即会显示当前 MX 记录列表。 点击 Change an MX Entry。 在 Change MX for... 字段中，输入 ASPMX.L.GOOGLE.COM。 点击 Change。 做完以后，千万注意要把原来的那个指向自己域名的纪录删掉。（一定要先加再删，不然删除会失败。）回到wp后台试试，现在可以直接备份到自己域名下的备份邮箱啦！！！ 补充：我用了edong注册的域名，服务还是不错的，但是不得不说，界面设计的很有点儿恶心。设置的地方全部用了中文，可怜大部分的教程、说明什么的都是用英文的。我给写两个常用的对照吧：邮件记录：MX（在“子域名管理”下）、别名：CNAME，这两个是困扰我时间最久的两项。另外，域名解析是免费的，但是也要作为服务象征性的“买”一下，但是买的地方很不好找，最后在最下面的链接：“直接购物通道：域名注册”点进去，然后把页面卷到底：“域名解析：0元/年”，选加入购物车，时间5年。（每次这个地方要找好久，写下来给自己做个笔记）。]]></description>
			<content:encoded><![CDATA[<p>Google App真的是好东西，极大地满足了我想有自己域名email又不想花时间设置的懒人作风，进一步增强了我作为Google Fans的理由。</p>
<p>花了几分钟申请了Google App，一切运行良好，在域名商那里按照google的说明改掉了MX设置。从gmail和hotmail各发了个邮件，状态良好。很开心。不过bug王立刻又开始发威了，我开了个beifen[at]e-xia.com的email，然后跑到wordpress后台把db backup的email地址设到了这个email地址下，结果就是收不到备份邮件。</p>
<p>根本没有当回事儿，不过仍旧想用Google App提供的email（7G，不用白不用啊）作为备份，当时的做法是备份邮件发到gmail信箱，然后通过设置filter转到自己域名下的备份邮箱。运行良好。</p>
<p>昨天给另一个域名申请Google App的时候又碰到了一样的问题，而很凑巧的在Google的“更改邮件交换 (MX) 记录”的说明文件的下拉框里看到了“cPanel”字样，引起了我一些些的注意。马上跑到主机的cPanel面板里“Email Management Tools” - “MX Entry Maintenance”一看，果然，Current MX Entries里赫然写着自己的域名，也就意味着主机供应商很自然的把发送到自己域名的email都作为内部email处理了，根本就没有往外送。接下来问题就好解决了，按照google的说明：</p>
<ol>
<li>登录到您的 cPanel 帐户。</li>
<li>点击 Mail。</li>
<li>点击 Modify Mail Exchanger (MX Entry)。随即会显示当前 MX 记录列表。</li>
<li>点击 Change an MX Entry。</li>
<li>在 Change MX for... 字段中，输入 ASPMX.L.GOOGLE.COM。</li>
<li>点击 Change。</li>
</ol>
<p>做完以后，千万注意要把原来的那个指向自己域名的纪录删掉。（一定要先加再删，不然删除会失败。）回到wp后台试试，现在可以直接备份到自己域名下的备份邮箱啦！！！</p>
<p>补充：我用了edong注册的域名，服务还是不错的，但是不得不说，界面设计的很有点儿恶心。设置的地方全部用了中文，可怜大部分的教程、说明什么的都是用英文的。我给写两个常用的对照吧：邮件记录：MX（在“子域名管理”下）、别名：CNAME，这两个是困扰我时间最久的两项。另外，域名解析是免费的，但是也要作为服务象征性的“买”一下，但是买的地方很不好找，最后在最下面的链接：“直接购物通道：域名注册”点进去，然后把页面卷到底：“域名解析：0元/年”，选加入购物车，时间5年。（每次这个地方要找好久，写下来给自己做个笔记）。</p>
]]></content:encoded>
			<wfw:commentRss>http://e-xia.com/2008/11/wp-db-back-to-google-app/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>再写“最近评论”widget</title>
		<link>http://e-xia.com/2008/09/recent-comments-widget-2/</link>
		<comments>http://e-xia.com/2008/09/recent-comments-widget-2/#comments</comments>
		<pubDate>Sat, 13 Sep 2008 07:44:07 +0000</pubDate>
		<dc:creator>轶侠</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[电脑]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[widget]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.e-xia.com/?p=165</guid>
		<description><![CDATA[好多“最近评论”的widget了，有外国人写的，还有咱们自己的小糖糖维护的中文工具箱，我自已也写了替换wordpress默认的widgets，干嘛还说，因为我觉得原来的截断太复杂，我就是不喜欢那个utf8_trim的function，时不时的出点这样那样的问题，相当困扰。 其实mysql自带的截断那是相当的好用，让我隆重介绍LEFT(str,len)，简单安全，老幼咸宜，咳咳，广告时间结束，我们看实例： SELECT concat&#40;comment_author,''&#41;, comment_author_url, comment_ID, comment_post_ID, CONCAT&#40; @ex:=LEFT&#40;comment_content,30&#41;, IF&#40;LENGTH&#40;comment_content&#41;=LENGTH&#40;@ex&#41;,'','...'&#41; &#41; AS comment, FROM wp_comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 10 SQL略有小复杂，容我慢慢讲，前5行没有花头，就这样。从CONCAT开始首先用LEFT(str,len)截取了留言的前30个字。然后我想给截取过的留言加三个点，所以用IF(expr1,expr2,expr3)比较截取的部分和原留言是不是一样长，因为留言原本就只有20个字（小于30）那么截取后的留言也是20个字，长度就相等。最后用CONCAT(str1,str2,...)把两部分连接起来，大功告成 缺点：在MYSQL4.1.0以前的版本对unicode支持不好，这个query一样能跑，但是，得到的汉字长度=截取长度/3，所以截取长度要设为想要的汉字长度的3倍（谁还用那么老版本的mysql，汗，我的一个服务器就是4.0.27版本）。如果你的服务器是4.1.0以后版本，包括4.1.0，恭喜你，你将完全得到你想要的结果。 上代码了： function yixia_widget_recent_comments&#40;$args&#41;&#123; global $wpdb, $comments, $comment; extract&#40;$args, EXTR_SKIP&#41;; $options = get_option&#40;'widget_recent_comments'&#41;; $title = empty&#40;$options&#91;'title'&#93;&#41; ? __&#40;'Recent Comments'&#41; : $options&#91;'title'&#93;; if &#40; !$number = &#40;int&#41; $options&#91;'number'&#93; &#41; $number [...]]]></description>
			<content:encoded><![CDATA[<p>好多“最近评论”的widget了，有外国人写的，还有咱们自己的小糖糖维护的<a href="http://www.charlestang.cn/wp-kit-cn.htm">中文工具箱</a>，我自已也写了<a href="http://www.e-xia.com/2008/06/replace_default_wordpress_widgets/">替换wordpress默认的widgets</a>，干嘛还说，因为我觉得原来的截断太复杂，我就是不喜欢那个utf8_trim的function，时不时的出点这样那样的问题，相当困扰。</p>
<p>其实mysql自带的截断那是相当的好用，让我隆重介绍<code>LEFT(str,len)</code>，简单安全，老幼咸宜，咳咳，广告时间结束，我们看实例：<span id="more-165"></span></p>
<div class="justcolor" style="border:1px solid #ccc;background:#fcffff;padding:15px 0;margin:5px 0;overflow:auto;overflow-x:auto;overflow-y:hidden;"><pre class="justcolor sql" style="margin: 0 10px; font-family: 'Courier New', Courier, Fixed;"><span style="color: #993333; font-weight: bold;">SELECT</span> 
    concat<span style="color: #66cc66;">&#40;</span>comment_author<span style="color: #66cc66;">,</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
    comment_author_url<span style="color: #66cc66;">,</span>
    comment_ID<span style="color: #66cc66;">,</span>
    comment_post_ID<span style="color: #66cc66;">,</span>
    CONCAT<span style="color: #66cc66;">&#40;</span>
        @ex:<span style="color: #66cc66;">=</span><span style="color: #993333; font-weight: bold;">LEFT</span><span style="color: #66cc66;">&#40;</span>comment_content<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">30</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
        <span style="color: #993333; font-weight: bold;">IF</span><span style="color: #66cc66;">&#40;</span>LENGTH<span style="color: #66cc66;">&#40;</span>comment_content<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">=</span>LENGTH<span style="color: #66cc66;">&#40;</span>@ex<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'...'</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> comment<span style="color: #66cc66;">,</span>
<span style="color: #993333; font-weight: bold;">FROM</span> wp_comments
<span style="color: #993333; font-weight: bold;">WHERE</span> comment_approved <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'1'</span> 
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> comment_date_gmt <span style="color: #993333; font-weight: bold;">DESC</span> 
<span style="color: #993333; font-weight: bold;">LIMIT</span> <span style="color: #cc66cc;">10</span></pre></div>
<p>SQL略有小复杂，容我慢慢讲，前5行没有花头，就这样。从<code>CONCAT</code>开始首先用<code>LEFT(str,len)</code>截取了留言的前30个字。然后我想给截取过的留言加三个点，所以用<code>IF(expr1,expr2,expr3)</code>比较截取的部分和原留言是不是一样长，因为留言原本就只有20个字（小于30）那么截取后的留言也是20个字，长度就相等。最后用<code>CONCAT(str1,str2,...)</code>把两部分连接起来，大功告成 <img src='http://e-xia.com/blog/wp-includes/images/smilies/icon_exclaim.gif' alt=':!:' class='wp-smiley' />  </p>
<p>缺点：在MYSQL4.1.0以前的版本对unicode支持不好，这个query一样能跑，但是，得到的汉字长度=截取长度/3，所以截取长度要设为想要的汉字长度的3倍（谁还用那么老版本的mysql，汗，我的一个服务器就是4.0.27版本）。如果你的服务器是4.1.0以后版本，包括4.1.0，恭喜你，你将完全得到你想要的结果。</p>
<p>上代码了：</p>
<div class="justcolor" style="border:1px solid #ccc;background:#fcffff;padding:15px 0;margin:5px 0;overflow:auto;overflow-x:auto;overflow-y:hidden;"><pre class="justcolor php" style="margin: 0 10px; font-family: 'Courier New', Courier, Fixed;"><span style="color: #000000; font-weight: bold;">function</span> yixia_widget_recent_comments<span style="color: #009900;">&#40;</span><span style="color: #000033;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #990000;">global</span> <span style="color: #000033;">$wpdb</span><span style="color: #339933;">,</span> <span style="color: #000033;">$comments</span><span style="color: #339933;">,</span> <span style="color: #000033;">$comment</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$args</span><span style="color: #339933;">,</span> EXTR_SKIP<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000033;">$options</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_recent_comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000033;">$title</span> <span style="color: #339933;">=</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Recent Comments'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000033;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000033;">$number</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000033;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'number'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #000033;">$number</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000033;">$number</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #000033;">$number</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000033;">$number</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">15</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #000033;">$number</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">15</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000033;">$length</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000033;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'length'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #000033;">$length</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">16</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000033;">$length</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">6</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #000033;">$length</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000033;">$length</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">60</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #000033;">$length</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000033;">$comments</span> <span style="color: #339933;">=</span> wp_cache_get<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'recent_comments'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'widget'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000033;">$comments</span> <span style="color: #339933;">=</span> <span style="color: #000033;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT comment_author,comment_author_url,comment_ID,comment_post_ID,CONCAT(@ex:=LEFT(comment_content,$length),IF(LENGTH(comment_content)=LENGTH(@ex),'','...')) as comment_content FROM $wpdb-&gt;comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    wp_cache_add<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'recent_comments'</span><span style="color: #339933;">,</span> <span style="color: #000033;">$comments</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'widget'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #990000;">echo</span> <span style="color: #000033;">$before_widget</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">echo</span> <span style="color: #000033;">$before_title</span> <span style="color: #339933;">.</span> <span style="color: #000033;">$title</span> <span style="color: #339933;">.</span> <span style="color: #000033;">$after_title</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">echo</span> <span style="color: #0000ff;">'&lt;ul id=&quot;recentcomments&quot;&gt;'</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000033;">$comments</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000033;">$comments</span> <span style="color: #b1b100;">as</span> <span style="color: #000033;">$comment</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
    <span style="color: #000033;">$comment_content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000033;">$comment_content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$comment_content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">echo</span>  <span style="color: #0000ff;">'&lt;li class=&quot;recentcomments&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'%1$s: %2$s'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> get_comment_author_link<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;a href=&quot;'</span><span style="color: #339933;">.</span> get_permalink<span style="color: #009900;">&#40;</span><span style="color: #000033;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_post_ID</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'#comment-'</span> <span style="color: #339933;">.</span> <span style="color: #000033;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_ID</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; title=&quot;'</span><span style="color: #339933;">.</span> get_the_title<span style="color: #009900;">&#40;</span><span style="color: #000033;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_post_ID</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000033;">$comment_content</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">echo</span> <span style="color: #0000ff;">'&lt;/ul&gt;'</span><span style="color: #339933;">.</span><span style="color: #000033;">$after_widget</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> yixia_widget_recent_comments_control<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000033;">$options</span> <span style="color: #339933;">=</span> <span style="color: #000033;">$newoptions</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_recent_comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000033;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;recent-comments-submit&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000033;">$newoptions</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;recent-comments-title&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000033;">$newoptions</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'number'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000033;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;recent-comments-number&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000033;">$newoptions</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'length'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000033;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;recent-comments-length&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000033;">$options</span> <span style="color: #339933;">!=</span> <span style="color: #000033;">$newoptions</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000033;">$options</span> <span style="color: #339933;">=</span> <span style="color: #000033;">$newoptions</span><span style="color: #339933;">;</span>
    update_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_recent_comments'</span><span style="color: #339933;">,</span> <span style="color: #000033;">$options</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    wp_delete_recent_comments_cache<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000033;">$title</span> <span style="color: #339933;">=</span> attribute_escape<span style="color: #009900;">&#40;</span><span style="color: #000033;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000033;">$number</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000033;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'number'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #000033;">$number</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000033;">$length</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000033;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'length'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #000033;">$length</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">16</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
      <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;&lt;</span>label <span style="color: #b1b100;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;recent-comments-title&quot;</span><span style="color: #339933;">&gt;&lt;</span>?php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Title:'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> <span style="color: #339933;">&lt;</span>input <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;widefat&quot;</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;recent-comments-title&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;recent-comments-title&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo $title; ?&gt;&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>label<span style="color: #339933;">&gt;&lt;/</span>p<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>
        <span style="color: #339933;">&lt;</span>label <span style="color: #b1b100;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;recent-comments-number&quot;</span><span style="color: #339933;">&gt;&lt;</span>?php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Number of comments to show:'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> <span style="color: #339933;">&lt;</span>input style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;width: 25px; text-align: center;&quot;</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;recent-comments-number&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;recent-comments-number&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo $number; ?&gt;&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>label<span style="color: #339933;">&gt;</span>
        <span style="color: #339933;">&lt;</span>br <span style="color: #339933;">/&gt;</span>
        <span style="color: #339933;">&lt;</span>small<span style="color: #339933;">&gt;&lt;</span>?php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'(at most 15)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> ?<span style="color: #339933;">&gt;&lt;/</span>small<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>
        <span style="color: #339933;">&lt;</span>label <span style="color: #b1b100;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;recent-comments-number&quot;</span><span style="color: #339933;">&gt;&lt;</span>?php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Length of comments to show:'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> <span style="color: #339933;">&lt;</span>input style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;width: 25px; text-align: center;&quot;</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;recent-comments-length&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;recent-comments-length&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo $length; ?&gt;&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>label<span style="color: #339933;">&gt;</span>
        <span style="color: #339933;">&lt;</span>br <span style="color: #339933;">/&gt;</span>
        <span style="color: #339933;">&lt;</span>small<span style="color: #339933;">&gt;&lt;</span>?php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'(6 ~ 60)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> ?<span style="color: #339933;">&gt;&lt;/</span>small<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hidden&quot;</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;recent-comments-submit&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;recent-comments-submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;1&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> yixia_widgets_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  unregister_sidebar_widget<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'recent-comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000033;">$widget_ops</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'classname'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'widget_recent_comments'</span><span style="color: #339933;">,</span> 
    <span style="color: #0000ff;">'description'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'The most recent comments'</span> <span style="color: #009900;">&#41;</span> 
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  wp_register_sidebar_widget<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'recent-comments'</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Recent Comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'yixia_widget_recent_comments'</span><span style="color: #339933;">,</span> <span style="color: #000033;">$widget_ops</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  wp_register_widget_control<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'recent-comments'</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Recent Comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'yixia_widget_recent_comments_control'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'yixia_widgets_init'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div>
]]></content:encoded>
			<wfw:commentRss>http://e-xia.com/2008/09/recent-comments-widget-2/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>WordPress主题制作小伎俩（一）</title>
		<link>http://e-xia.com/2008/09/wordpress-theme-trick-1/</link>
		<comments>http://e-xia.com/2008/09/wordpress-theme-trick-1/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 22:37:28 +0000</pubDate>
		<dc:creator>轶侠</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[电脑]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[utf8]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.e-xia.com/?p=153</guid>
		<description><![CDATA[做了不少主题了，从来没有写过心得，很不好，从今天开始每天写一点点吧。 今天说说关于UTF8格式。 不管是作模板还是写插件，如果有中文内容的话就得把文件转成utf8格式保存，不然就会显示一个一个小方块。可是有时候整页 php就那么一两个中文，或者说css里面就两个中文字“宋体”，就为了这么两个字，文件体积突然变大，不划算啊。那么就说说小伎俩1：如何不转utf8输出中文。 先介绍个转换工具。在左上角的框里面输入需要转的中文，然后点Convert，就出现很多奇形怪状的代码。这就是我们要用的。 在php里面可以直接输出hex，例如echo "\xE6\xB5\x8B\xE8\xAF\x95"会输出“测试”这两个字，注意是双引号，单引号在php里不转意的。那么在转换工具里我会选“Percent encoding for URIs”下面的内容，然后把百分号%都换成\x。 Html也可以直接输出unicode的，跟&#38;写成&#38;amp;一样，“测试”可以写成&#27979;&#35797;，是转换工具里面的“Decimal NCRs”。 那么CSS嗫？看到最右下角的“CSS escapes”了不？在左上角的方框里输入“宋体”点“Convert”，在右下角的框里就出现\5B8B \4F53 ，复制到css里去吧，以后再也不用为了这两个字把整个文件转成utf8格式了！]]></description>
			<content:encoded><![CDATA[<p>做了不少主题了，从来没有写过心得，很不好，从今天开始每天写一点点吧。</p>
<p>今天说说关于UTF8格式。</p>
<p>不管是作模板还是写插件，如果有中文内容的话就得把文件转成utf8格式保存，不然就会显示一个一个小方块。可是有时候整页 php就那么一两个中文，或者说css里面就两个中文字“宋体”，就为了这么两个字，文件体积突然变大，不划算啊。那么就说说小伎俩1：如何不转utf8输出中文。</p>
<p>先介绍个<a title="utf8转换工具" href="http://rishida.net/scripts/uniview/conversion.php" target="_blank">转换工具</a>。在左上角的框里面输入需要转的中文，然后点Convert，就出现很多奇形怪状的代码。这就是我们要用的。</p>
<p>在php里面可以直接输出hex，例如<code>echo "\xE6\xB5\x8B\xE8\xAF\x95"</code>会输出“测试”这两个字，注意是双引号，单引号在php里不转意的。那么在转换工具里我会选“Percent encoding for URIs”下面的内容，然后把百分号<code>%</code>都换成<code>\x</code>。</p>
<p>Html也可以直接输出unicode的，跟<code>&amp;</code>写成<code>&amp;amp;</code>一样，“测试”可以写成<code>&#27979;&#35797;</code>，是<a title="utf8转换工具" href="http://rishida.net/scripts/uniview/conversion.php" target="_blank">转换工具</a>里面的“Decimal NCRs”。</p>
<p>那么CSS嗫？看到最右下角的“CSS escapes”了不？在左上角的方框里输入“宋体”点“Convert”，在右下角的框里就出现<code>\5B8B \4F53 </code>，复制到css里去吧，以后再也不用为了这两个字把整个文件转成utf8格式了！ <img src='http://e-xia.com/blog/wp-includes/images/smilies/icon_mrgreen.gif' alt=':mrgreen:' class='wp-smiley' />  </p>
]]></content:encoded>
			<wfw:commentRss>http://e-xia.com/2008/09/wordpress-theme-trick-1/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
