<?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>Hacklog &#187; wp技巧</title>
	<atom:link href="http://ihacklog.com/cat/wordpress/wpskills/feed" rel="self" type="application/rss+xml" />
	<link>http://ihacklog.com</link>
	<description>荒野无灯weblog</description>
	<lastBuildDate>Sat, 04 Feb 2012 12:30:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>玩转WordPress之配置篇——9条实用配置技巧</title>
		<link>http://ihacklog.com/php/wordpress/wpskills/9-practical-wordpress-configuration-skills.html</link>
		<comments>http://ihacklog.com/php/wordpress/wpskills/9-practical-wordpress-configuration-skills.html#comments</comments>
		<pubDate>Mon, 23 Jan 2012 14:31:54 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[wp技巧]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5335</guid>
		<description><![CDATA[春节快乐，各位 好久没发文章了，这里把前些日子写的一篇日志发出来~~ WP的特点就是你可以完全按你自己的想法来建立属于你自己的博客,这里说一下几个比较实用的配置项。 新手注意事项： 不要用记事本编辑wp-config.php文件，也不要给这个文件末尾加上?&#62;标签。 以下所有涉及到要添加代码的，除非特别说明，否则，都是修改wp-config.php文件，需要添加的代码应该加在wp-config.php文件的 1/* That's all, stop editing! Happy blogging. ...]]></description>
			<content:encoded><![CDATA[<p>春节快乐，各位 <img src='http://ihacklog.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':smile:' class='wp-smiley' />  好久没发文章了，这里把前些日子写的一篇日志发出来~~</p>
<p>WP的特点就是你可以完全按你自己的想法来建立属于你自己的博客,这里说一下几个比较实用的配置项。</p>
<hr />
<p>新手注意事项：<br />
不要用记事本编辑wp-config.php文件，也不要给这个文件末尾加上<strong>?&gt;</strong>标签。<br />
以下所有涉及到要添加代码的，除非特别说明，否则，都是修改wp-config.php文件，需要添加的代码应该加在wp-config.php文件的</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">/* That's all, stop editing! Happy blogging. */</span></div></td></tr></tbody></table></div>
<p>这一条注释之上。</p>
<hr />
<h3>1.版本与语言</h3>
<p>目前英文版和中文版都能在官方下载到，不过如果你首先装的英文版，后来又想用中文版了也没关系，下载中文版的，然后把wp-content/languages目录下面的语言文件放到你博客的wp-content/languages 目录下面，再在wp-config.php中定义语言为中文即可，如：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WPLANG'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'zh_CN'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>什么？你想要前台使用中文，后面使用英文？可以，有个名叫 admin-in-english 的小插件，装上就能满足你的要求。<br />
如果要从单用户版转为多用户版，见我以前写过的文章。</p>
<h3>2.用多大内存，你说了算</h3>
<p>定义一般情况下允许wp使用的最大内存,如：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_MEMORY_LIMIT'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'30M'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>对于单用户博客，wp默认值是32M,对于多用户站点，默认是64M,你可以根据你的实际情况调整，如果你愿意的话。<br />
这个参数值最终将作用在php配置的memory_limit项上。</p>
<p>定义处理图片时允许使用的最大内存：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'WP_MAX_MEMORY_LIMIT'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'128M'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>因为wp默认是256M的，这在某些内存较小的vps上面的话，可能会导致内存超出可分配值的错误。因此，你可以根据自己的情况调整之。<br />
需要说明的是，这个限制仅用于限制imagecreatefromstring函数处理图片时的内存使用。因为GD在内存中处理图片时是没有压缩图片数据的。具体在function wp_load_image中有说明。</p>
<h3>3.博客出问题了？调试一下吧</h3>
<p>加上如下代码，WP将会老老实实的话所有错误信息显示出来：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'WP_DEBUG'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'WP_DEBUG_DISPLAY'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<h3>4.自动保存相关</h3>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">//每30秒自动保存一次：</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'AUTOSAVE_INTERVAL'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">30</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">//每周清理一次回收站（定义为0禁用回收站）：</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'EMPTY_TRASH_DAYS'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">7</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">//禁用日志修订</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_POST_REVISIONS'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<h3>5.用的Unix/Linux/BSD主机？用UNIX Socket连接mysql数据库吧</h3>
<p>如：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_HOST'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'localhost:/var/lib/mysql/mysql.sock'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<h3>6.更新插件或主题时出现“要执行请求的操作，WordPress 需要访问您网页服务器的权限。 请输入您的 FTP 登录XXXX的解决方法”</h3>
<p>这种情况一般是主机的目录所有者与php的执行者（一般是apache或lighthttpd，nginx等）不同导致的，一般采用suphp以cgi方式运行php的站点不会出现此情况。<br />
在wp-config.php中加入如下代码即可：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FS_METHOD'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'direct'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FS_CHMOD_DIR'</span><span style="color: #339933;">,</span> <span style="color: #208080;">0777</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FS_CHMOD_FILE'</span><span style="color: #339933;">,</span> <span style="color: #208080;">0777</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>另外在wp-content目录下面新建一目录upgrade并且权限设置为777，插件目录plugins和主题目录themes也要给777权限（注意只是这两个目录本身，而不是目录下面的文件及目录！）</p>
<h3>7.想要cookie-free domain的图片URL ？这个也很简单</h3>
<p>你可以在同一服务器上面新建一子站点，如<strong>static.ihacklog.com</strong> ,假设把附件保存在wp-files目录下面，wp-files的绝对路径假设为<br />
<strong>/home/ihacklog.com/www/static</strong> (这个路径要根据你自己的主机确定）<br />
在后台，“<strong>设置</strong>”－－〉“<strong>媒体选项</strong>”<br />
<strong>文件上传</strong>处，默认上传路径填写绝对路径 <strong>/home/ihacklog.com/www/static</strong><br />
注意，假如你是windows主机的话，这个路径要用这样的形式，如：<strong>D:\\htdocs\\ihacklog.com\\static</strong><br />
文件的完整 URL 地址填写：<strong>http://static.ihacklog.com/wp-files</strong><br />
这样以后，再更新数据库中的URL信息：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">UPDATE wp_posts SET post_content<span style="color: #339933;">=</span> replace<span style="color: #009900;">&#40;</span>post_content<span style="color: #339933;">,</span><span style="color: #0000ff;">'http://your-domain.com/wp-content/uploads/'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'http://static.ihacklog.com/wp-files/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>然后把你wp-content/uploads/目录下面的所有东东都移动到<strong>/home/ihacklog.com/www/static/wp-files/</strong> 目录下面即可。</p>
<h3>8.想把WP放在某个子目录下面？</h3>
<p>这个对于用cp等主机面板的用户比较实用。因为主站目录是public_html（实际上是指向www目录的一个符号链接）的话，子站的目录也是在这个目录下面。直接把WP装在这下面的话，整个站点目录就显得比较乱了。把wp安装在子目录下面比较好一些。如，把wp安装在wp目录下面：<br />
（这里假设你已经直接把wp安装在站点根目录下面了）<br />
先去后台，“常规” －－〉“常规”<br />
WordPress 地址（URL）填写： <strong>http://your-domain.com/wp</strong><br />
站点地址（URL）不变，还是：http://your-domain.com<br />
这样保存以后，在站点根目录下面新建一名为wp的目录，再把所有除.htaccess和 index.php的文件和目录全部移动到wp目录下面。<br />
修改index.php文件require语句为：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'./wp/wp-blog-header.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<h3>9.嫌默认的wp-login.php这个登录URL太麻烦？你可以修改它</h3>
<p>将以下代码放到当前主题的functions.php文件中：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_login_url_rewrite'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> wp_login_url_rewrite<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; add_rewrite_rule<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'login/?$'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp-login.php'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'top'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>然后，访问一下“设置” －－〉“固定链接”（在这里什么事也不用干，打开一下这个页面即可），让wp自动更新一下rewrite规则好让规则即时生效。<br />
好了，现在你可以在你博客域名的后面直接加上 /login来访问登录页面了。</p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5335";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5335" title="Permanent Link to 玩转WordPress之配置篇——9条实用配置技巧" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5335</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2009年03月16日  //  <a href="http://ihacklog.com/xml_html_css_js_ajax/zaitanjavascriptcifazuoyongyu.html" title="再探Javascript词法作用域 ">再探Javascript词法作用域 </a> (0)</li><li>2010年04月10日  //  <a href="http://ihacklog.com/server/setup-bind-proxy-server-under-windows-7.html" title="Windows下安装BIND作为DNS缓存服务器">Windows下安装BIND作为DNS缓存服务器</a> (11)</li><li>2011年07月21日  //  <a href="http://ihacklog.com/software/cool_software_share/patch-deadbeef-to-support-gbk-id3-tags-and-add-lyrics-support.html" title="让Deadbeef支持GBK标签,彻底解决中文乱码问题，增加歌词显示">让Deadbeef支持GBK标签,彻底解决中文乱码问题，增加歌词显示</a> (4)</li><li>2008年12月9日  //  <a href="http://ihacklog.com/php/skills/use-htaccess-file-to-set-default-index-file.html" title="通过.htaccess 文件配置默认索引文件">通过.htaccess 文件配置默认索引文件</a> (0)</li><li>2011年10月5日  //  <a href="http://ihacklog.com/linux/archlinux/wget-download-thunder-offline-server-files.html" title="wget下载迅雷离线资源">wget下载迅雷离线资源</a> (1)</li><li>2009年11月7日  //  <a href="http://ihacklog.com/php/discuz/discuz7-1php-code-highlight.html" title="discuz7.1php、C语言代码高亮方法">discuz7.1php、C语言代码高亮方法</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/wpskills/9-practical-wordpress-configuration-skills.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Super useful WordPress hacks and snippets</title>
		<link>http://ihacklog.com/php/wordpress/wpskills/super-useful-wordpress-hacks-and-snippets.html</link>
		<comments>http://ihacklog.com/php/wordpress/wpskills/super-useful-wordpress-hacks-and-snippets.html#comments</comments>
		<pubDate>Tue, 03 Jan 2012 01:56:39 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[wp技巧]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5267</guid>
		<description><![CDATA[1.免插件实现日志浏览数记录 12345678910111213141516171819202122function getPostViews&#40;$postID&#41;&#123; &#160; &#160; $count_key = 'post_views_count'; &#160; &#160; $count = get_post_meta&#40;$postID, $count_key, true&#41;; &#160; &#160; if&#40;$count==''&#41;&#12...]]></description>
			<content:encoded><![CDATA[<h3>1.免插件实现日志浏览数记录</h3>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> getPostViews<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$count_key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'post_views_count'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count_key</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$count</span><span style="color: #339933;">==</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; delete_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count_key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; add_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count_key</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;0 View&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$count</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' Views'</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">function</span> setPostViews<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$count_key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'post_views_count'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count_key</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$count</span><span style="color: #339933;">==</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; delete_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count_key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; add_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count_key</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$count</span><span style="color: #339933;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; update_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count_key</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr />
<h3>2.在contributors的日志发布后自动发邮件给他们</h3>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> wpr_authorNotification<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> get_post<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #000088;">$author</span> <span style="color: #339933;">=</span> get_userdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_author</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<br />
&nbsp; &nbsp; &nbsp; Hi &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$author</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display_name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;,<br />
&nbsp; &nbsp; &nbsp; Your post, &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_title</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; has just been published. Well done!<br />
&nbsp; &nbsp;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;wp_mail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$author</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_email</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Your article is online&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'publish_post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpr_authorNotification'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<hr />
<h3>3.用短代码实现外链网站的快照显示</h3>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #000000; font-weight: bold;">function</span> bm_sc_mshot <span style="color: #009900;">&#40;</span><span style="color: #000088;">$attributes</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$code</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <a href="http://www.php.net/extract"><span style="color: #990000;">extract</span></a><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'url'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'width'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">250</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$attributes</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000088;">$imageUrl</span> <span style="color: #339933;">=</span> bm_mshot <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$width</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$imageUrl</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;img src=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$imageUrl</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; alt=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$url</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; width=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$width</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;/&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;div class=&quot;browsershot mshot&quot;&gt;&lt;a href=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$url</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$image</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/a&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> bm_mshot <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$width</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">250</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'http://s.wordpress.com/mshots/v1/'</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/urlencode"><span style="color: #990000;">urlencode</span></a><span style="color: #009900;">&#40;</span>clean_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'?w='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$width</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span><br />
<br />
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'browsershot'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'bm_sc_mshot'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
<p>使用方法，在日志中写上如：</p>
<pre>
[browsershot url="http://ihacklog.com" width="荒野无灯weblog"]
</pre>
<p>生成的效果图：<br />
<a href="http://static.ihacklog.com/wp-files/2012/01/http-ihacklog-shot.jpg" class="tinybox2"  onclick="TINY.box.show({image:this.href,boxid:'frameless',animate:true,fixed:false});return false;"  title="Click to enlarge（点击查看大图）" ><img src="http://static.ihacklog.com/wp-files/2012/01/http-ihacklog-shot.jpg" alt="" title="http-ihacklog-shot" width="500" height="375" class="alignnone size-full wp-image-5268" /> </a></p>
<hr />
<pre class='smooth'>

http://s.wordpress.com/mshots/v1/http%3A%2F%2Fihacklog.com?w=500
</pre>
<h3>4.列出网络中的博客（适用于WP MU模式）</h3>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> wp_list_sites<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$expires</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">7200</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>is_multisite<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: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// Because the get_blog_list() function is currently flagged as deprecated</span><br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// due to the potential for high consumption of resources, we'll use</span><br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// $wpdb to roll out our own SQL query instead. Because the query can be</span><br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// memory-intensive, we'll store the results using the Transients API</span><br />
&nbsp; &nbsp;<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">===</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$site_list</span> <span style="color: #339933;">=</span> get_transient<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'multisite_site_list'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$site_list</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prepare</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SELECT * FROM wp_blogs ORDER BY blog_id'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Set the Transient cache to expire every two hours</span><br />
&nbsp; &nbsp; &nbsp; set_site_transient<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'multisite_site_list'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$site_list</span><span style="color: #339933;">,</span> <span style="color: #000088;">$expires</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #000088;">$current_site_url</span> <span style="color: #339933;">=</span> get_site_url<span style="color: #009900;">&#40;</span> get_current_blog_id<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'<br />
&lt;ul id=&quot;network-menu&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$site_list</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$site</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; switch_to_blog<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$site</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">blog_id</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$class</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> home_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$current_site_url</span> <span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">' class=&quot;current-site-item&quot;'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'<br />
&lt;li id=&quot;site-'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$site</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">blog_id</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; '</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #000088;">$class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;' . home_url() . '&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #0000ff;">' . get_bloginfo('</span>name<span style="color: #0000ff;">') . '</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span><br />
<br />
<span style="color: #0000ff;">' . &quot;\n&quot;;<br />
&nbsp; &nbsp; &nbsp; restore_current_blog();<br />
&nbsp; &nbsp;}<br />
<br />
&nbsp; &nbsp;$html .= '</span><span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span><br />
<br />
<span style="color: #339933;">&lt;!--</span><span style="color: #666666; font-style: italic;">// end #network-menu --&gt;' . &quot;\n\n&quot;;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #b1b100;">return</span> <span style="color: #000088;">$html</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>调用：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #666666; font-style: italic;">// Multisite Network Menu</span><br />
<span style="color: #000088;">$network_menu</span> <span style="color: #339933;">=</span> wp_list_sites<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$network_menu</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&lt;div id=&quot;network-menu&quot;&gt;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$network_menu</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&lt;/div&gt;<br />
<br />
&lt;!--// end #network-menu --&gt;<br />
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
<hr />
<h3>5.给有缩略图（thumbnail）的日志内容div添加一个css类选择器</h3>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> has_thumb_class<span style="color: #009900;">&#40;</span><span style="color: #000088;">$classes</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> has_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'has_thumb'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$classes</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_class'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'has_thumb_class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>本文由荒野摘选和译自:<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fwww.catswhocode.com%2Fblog%2Fsuper-useful-wordpress-hacks-and-snippets" target="_blank">http://www.catswhocode.com/blog/super-useful-wordpress-hacks-and-snippets</a></p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5267";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5267" title="Permanent Link to Super useful WordPress hacks and snippets" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5267</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2010年07月15日  //  <a href="http://ihacklog.com/server/ubuntu-server/how-to-enable-secure-shell-in-ubuntu.html" title="如何在ubuntu中启用SSH服务">如何在ubuntu中启用SSH服务</a> (0)</li><li>2009年04月14日  //  <a href="http://ihacklog.com/php/discuz/ziliaokudzchengxuwenjianmuluhanyizhenglibiao.html" title="[资料库]DZ程序文件目录含义整理表">[资料库]DZ程序文件目录含义整理表</a> (0)</li><li>2010年07月15日  //  <a href="http://ihacklog.com/server/ubuntu-server/ubuntu-server-network-configuration.html" title="ubuntu server的网络配置">ubuntu server的网络配置</a> (0)</li><li>2011年05月30日  //  <a href="http://ihacklog.com/software/fix-httplib-incompleteread-more-expected-bug-in-vimrepress.html" title="修正vimrepress的一个bug">修正vimrepress的一个bug</a> (2)</li><li>2009年11月2日  //  <a href="http://ihacklog.com/linux/ubuntu-desktop/hp-probook-4311s-4411s-ubuntu-9-10-builtin-sound.html" title="HP Probook 4311S (4411S) 在UBUNTU 9.10下内置音响不发声的解决办法">HP Probook 4311S (4411S) 在UBUNTU 9.10下内置音响不发声的解决办法</a> (2)</li><li>2010年05月9日  //  <a href="http://ihacklog.com/php/wordpress/wpskills/wordpress-2-9-2-use-3-0-get_avatar.html" title="wordpress 2.9.2先用着3.0的 get_avatar">wordpress 2.9.2先用着3.0的 get_avatar</a> (14)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/wpskills/super-useful-wordpress-hacks-and-snippets.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>2011,我到底在用哪些插件？</title>
		<link>http://ihacklog.com/php/wordpress/wpskills/wp-plugins-i-used-in-year-2011.html</link>
		<comments>http://ihacklog.com/php/wordpress/wpskills/wp-plugins-i-used-in-year-2011.html#comments</comments>
		<pubDate>Sat, 31 Dec 2011 13:04:54 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[wp技巧]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5256</guid>
		<description><![CDATA[去这里查看即可：　http://ihacklog.com/download/plugin-list 这是根据我的启用状况实时生成的列表。 （@TODO:增加缓存控制　，现在没时间了，明年再弄） 代码放出来，有需要的尽管拿去。这是用的页面模板实现的。(ps:如果你不知道什么是WP页面模板，请无视下面这些 ) 其实这是从一个名字叫wp plugin lister 的插件中取出来的代码而已，用页面模板来实现比较高效~~ 如果是simpleDark 主题的童鞋直接拿去就可以用了，非此主题的童鞋请自行修改一下。需要...]]></description>
			<content:encoded><![CDATA[<p>去这里查看即可：　<a href="http://ihacklog.com/download/plugin-list" target="_blank">http://ihacklog.com/download/plugin-list</a></p>
<p>这是根据我的启用状况实时生成的列表。<br />
（@TODO:增加缓存控制　，现在没时间了，明年再弄）</p>
<p>代码放出来，有需要的尽管拿去。这是用的页面模板实现的。(ps:如果你不知道什么是WP页面模板，请无视下面这些 <img src='http://ihacklog.com/wordpress/wp-includes/images/smilies/icon_arrow.gif' alt=':arrow:' class='wp-smiley' />  )<br />
其实这是从一个名字叫wp plugin lister 的插件中取出来的代码而已，用页面模板来实现比较高效~~ <img src='http://ihacklog.com/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=':wink:' class='wp-smiley' />  </p>
<p>如果是simpleDark 主题的童鞋直接拿去就可以用了，非此主题的童鞋请自行修改一下。需要修改的地方在第172行以下（0-172行不用动）。<br />
注意：该页面嵌入了下载文件，请访问 <a href="http://ihacklog.com/php/wordpress/wpskills/wp-plugins-i-used-in-year-2011.html">该页面</a>下载该文件。</p>
<p><a href="http://static.ihacklog.com/wp-files/2011/12/wp-plugin-lister.png" class="tinybox2"  onclick="TINY.box.show({image:this.href,boxid:'frameless',animate:true,fixed:false});return false;"  title="Click to enlarge（点击查看大图）" ><img src="http://static.ihacklog.com/wp-files/2011/12/wp-plugin-lister-461x400.png" alt="" title="wp-plugin-lister" width="461" height="400" class="alignnone size-medium wp-image-5257" /> </a></p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5256";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5256" title="Permanent Link to 2011,我到底在用哪些插件？" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5256</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2010年11月5日  //  <a href="http://ihacklog.com/software/tips/install-msn-on-win2003.html" title="win2003安装msn">win2003安装msn</a> (6)</li><li>2010年10月26日  //  <a href="http://ihacklog.com/memory/hacklog/renyueyuan.html" title="故人何在 前程那里 心事谁同">故人何在 前程那里 心事谁同</a> (4)</li><li>2009年10月29日  //  <a href="http://ihacklog.com/php/wordpress/wpskills/use-highslide-for-wordpress.html" title="给wordpress图片加上Highslide特效(修正代码)">给wordpress图片加上Highslide特效(修正代码)</a> (30)</li><li>2011年02月9日  //  <a href="http://ihacklog.com/php/wordpress/upgrade/%e6%89%8b%e5%8a%a8%e6%9b%b4%e6%96%b0wp-3-04-to-3-0-5.html" title="手动更新wp 3.04 to 3.0.5">手动更新wp 3.04 to 3.0.5</a> (4)</li><li>2008年12月25日  //  <a href="http://ihacklog.com/server/%e9%98%b2%e6%ad%a2%e7%9b%97%e9%93%be%e5%9b%be%e7%89%87%ef%bc%88%e8%af%91%ef%bc%89.html" title="防止盗链图片（译）">防止盗链图片（译）</a> (0)</li><li>2011年10月3日  //  <a href="http://ihacklog.com/software/tips/how-to-flush-the-dns-cache.html" title="刷新DNS缓存的方法">刷新DNS缓存的方法</a> (2)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/wpskills/wp-plugins-i-used-in-year-2011.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>WordPress管理员密码忘记了怎么办？删除一个符号即可</title>
		<link>http://ihacklog.com/php/wordpress/wpskills/simple-solution-to-modifying-wordpress-admin-password-when-your-have-forgot-it.html</link>
		<comments>http://ihacklog.com/php/wordpress/wpskills/simple-solution-to-modifying-wordpress-admin-password-when-your-have-forgot-it.html#comments</comments>
		<pubDate>Sat, 17 Dec 2011 14:55:45 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[wp技巧]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5134</guid>
		<description><![CDATA[上图，大家都明白的： 修改wp-includes/user.php 文件line 110 1if &#40; !wp_check_password&#40;$password, $userdata-&#62;user_pass, $userdata-&#62;ID&#41; &#41; 去掉“非”符号即可，变成： 1if &#40; wp_check_password&#40;$password, $userdata-&#62;user_pass, $userdata-&#62;ID&#41; &#41;...]]></description>
			<content:encoded><![CDATA[<p>上图，大家都明白的：<br />
<a href="http://static.ihacklog.com/wp-files/2011/12/wordpress_forget_password_solution.png" class="tinybox2"  onclick="TINY.box.show({image:this.href,boxid:'frameless',animate:true,fixed:false});return false;"  title="Click to enlarge（点击查看大图）" ><img src="http://static.ihacklog.com/wp-files/2011/12/wordpress_forget_password_solution-550x331.png" alt="" title="wordpress_forget_password_solution" width="550" height="331" class="alignnone size-medium wp-image-5135" /> </a></p>
<p>修改wp-includes/user.php 文件line 110</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>wp_check_password<span style="color: #009900;">&#40;</span><span style="color: #000088;">$password</span><span style="color: #339933;">,</span> <span style="color: #000088;">$userdata</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_pass</span><span style="color: #339933;">,</span> <span style="color: #000088;">$userdata</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span></div></td></tr></tbody></table></div>
<p>去掉“非”符号即可，变成：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> wp_check_password<span style="color: #009900;">&#40;</span><span style="color: #000088;">$password</span><span style="color: #339933;">,</span> <span style="color: #000088;">$userdata</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_pass</span><span style="color: #339933;">,</span> <span style="color: #000088;">$userdata</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span></div></td></tr></tbody></table></div>
<p>修改完后速度进后台修改完密码再改回去即可。</p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5134";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5134" title="Permanent Link to WordPress管理员密码忘记了怎么办？删除一个符号即可" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5134</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2009年11月4日  //  <a href="http://ihacklog.com/server/using-bind9-setup-cache-and-local-dns-server.html" title="bind9架設域名服务器及配置">bind9架設域名服务器及配置</a> (2)</li><li>2011年06月30日  //  <a href="http://ihacklog.com/security_optimization/discuz-x2-sql-injection-bug-20110629.html" title="Discuz! X2 SQL注射漏洞 (20110629)">Discuz! X2 SQL注射漏洞 (20110629)</a> (3)</li><li>2010年03月26日  //  <a href="http://ihacklog.com/software/tips/godaddy-domain-and-host-payment-with-alipay.html" title="Godaddy域名空间支付宝续费详细图解">Godaddy域名空间支付宝续费详细图解</a> (11)</li><li>2008年12月31日  //  <a href="http://ihacklog.com/php/%e5%88%ab%e8%a2%ab%e5%bf%bd%e6%82%a0%e4%ba%86%e7%bb%86%e7%9c%8b%e7%9c%bc%e8%8a%b1%e7%bc%ad%e4%b9%b1%e7%9a%84%e6%b6%b2%e6%99%b6%e6%98%be%e7%a4%ba%e5%99%a8%e5%8f%82%e6%95%b0.html" title="别被忽悠了!细看眼花缭乱的液晶显示器参数">别被忽悠了!细看眼花缭乱的液晶显示器参数</a> (0)</li><li>2010年07月10日  //  <a href="http://ihacklog.com/php/wordpress/wpskills/hacklog-clean-archives.html" title="免插件生成文章存档页面[飞速版]——2011-09-16更新">免插件生成文章存档页面[飞速版]——2011-09-16更新</a> (46)</li><li>2010年04月20日  //  <a href="http://ihacklog.com/php/wordpress/wpskills/none-plugin-fancy-gallery-for-wp.html" title="免插件为wp添加基于CSS3的超酷效果相册">免插件为wp添加基于CSS3的超酷效果相册</a> (13)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/wpskills/simple-solution-to-modifying-wordpress-admin-password-when-your-have-forgot-it.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>自定义smilies表情位置</title>
		<link>http://ihacklog.com/php/wordpress/wpskills/custom-smilies-src.html</link>
		<comments>http://ihacklog.com/php/wordpress/wpskills/custom-smilies-src.html#comments</comments>
		<pubDate>Fri, 16 Dec 2011 10:34:23 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[wp技巧]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5132</guid>
		<description><![CDATA[convert_smilies() 调用 translate_smiley() 这个callback来将表情代码转换为图片，图片地址获取： 1$srcurl = apply_filters&#40;'smilies_src', includes_url&#40;&#34;images/smilies/$img&#34;&#41;, $img, site_url&#40;&#41;&#41;; 因此可Hook smilies_src这个filter来改变默认的similies URL: 123456func...]]></description>
			<content:encoded><![CDATA[<p><strong>convert_smilies()</strong> 调用 <strong>translate_smiley()</strong> 这个callback来将表情代码转换为图片，图片地址获取：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$srcurl</span> <span style="color: #339933;">=</span> apply_filters<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'smilies_src'</span><span style="color: #339933;">,</span> includes_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;images/smilies/<span style="color: #006699; font-weight: bold;">$img</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$img</span><span style="color: #339933;">,</span> site_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>因此可Hook smilies_src这个filter来改变默认的similies URL:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> custom_smilies_src<span style="color: #009900;">&#40;</span><span style="color: #000088;">$src</span><span style="color: #339933;">,</span> <span style="color: #000088;">$img</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> content_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'smilies/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$img</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">//如果把表情目录smilies放在当前主题目录下面则用如下代码，这样可以不同的主题调用不同的表情</span><br />
<span style="color: #666666; font-style: italic;">//return get_stylesheet_directory_uri() . 'smilies/' . $img ;</span><br />
<span style="color: #009900;">&#125;</span><br />
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'smilies_src'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'custom_smilies_src'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 默认优先级是10, 变量数量为2，这里其实只要用到第二个变量</span></div></td></tr></tbody></table></div>
<p>　</p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5132";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5132" title="Permanent Link to 自定义smilies表情位置" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5132</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2012年01月2日  //  <a href="http://ihacklog.com/php/wordpress/theme/wordpress-theme-malicious-code-analysis.html" title="一段WordPress主题恶意代码分析（貌似很多人中招了）">一段WordPress主题恶意代码分析（貌似很多人中招了）</a> (16)</li><li>2011年12月7日  //  <a href="http://ihacklog.com/memory/music/one-person-one-flowe.html" title="阿朵《一人一花》微电影版MV">阿朵《一人一花》微电影版MV</a> (1)</li><li>2008年12月6日  //  <a href="http://ihacklog.com/php/discuz/music-plugin-installation-importing-tables.html" title="关于音乐插件的安装之数据库文件导入">关于音乐插件的安装之数据库文件导入</a> (1)</li><li>2011年04月2日  //  <a href="http://ihacklog.com/security_optimization/oyaya-cookie-injection.html" title="凹丫丫网站管理系统cookie注射">凹丫丫网站管理系统cookie注射</a> (3)</li><li>2008年12月25日  //  <a href="http://ihacklog.com/php/skills/10-things-you-probably-didn%e2%80%99t-know-about-php.html" title="10 things you (probably) didn’t know about PHP">10 things you (probably) didn’t know about PHP</a> (0)</li><li>2011年12月13日  //  <a href="http://ihacklog.com/php/wordpress/upgrade/wordpress-3-3-sonny-released.html" title="WordPress 3.3 “Sonny”正式发布">WordPress 3.3 “Sonny”正式发布</a> (4)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/wpskills/custom-smilies-src.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>跟随WP升级，继续插入[audio、media短代码按钮修正]</title>
		<link>http://ihacklog.com/php/wordpress/wpskills/audio-and-media-quicktags-button-revisioned.html</link>
		<comments>http://ihacklog.com/php/wordpress/wpskills/audio-and-media-quicktags-button-revisioned.html#comments</comments>
		<pubDate>Fri, 16 Dec 2011 10:05:39 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[wp技巧]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5130</guid>
		<description><![CDATA[由于WP升级，quicktags改变，先前文章：《在后台添加quicktags——续》中给大家的代码已经不能正常工作了。现抽时间更新之。 相应代码如下： 1234567891011121314151617181920212223242526272829303132333435&#160; &#160; //override the b-quote,it's value was too long for me &#160; &#160; &#160; &#160; edButtons&#91;40&#93;...]]></description>
			<content:encoded><![CDATA[<p>由于WP升级，quicktags改变，先前文章：<a href="http://ihacklog.com/?p=3694">《在后台添加quicktags——续<不用audio-player插件也播放mp3>》</a>中给大家的代码已经不能正常工作了。现抽时间更新之。</p>
<p>相应代码如下：</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//override the b-quote,it's value was too long for me</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; edButtons<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">40</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> QTags.<span style="color: #660066;">TagButton</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'block'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'bq'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\\</span>n&lt;blockquote&gt;'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'&lt;/blockquote&gt;<span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\\</span>n'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'q'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// id, display, arg1(callback), arg2, access_key, title, priority, instance</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; QTags.<span style="color: #660066;">addButton</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'audio'</span> <span style="color: #339933;">,</span><span style="color: #3366CC;">'audio'</span> <span style="color: #339933;">,</span>hacklogInsertAudio <span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'a'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Insert audio'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; QTags.<span style="color: #660066;">addButton</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'media'</span> <span style="color: #339933;">,</span><span style="color: #3366CC;">'media'</span> <span style="color: #339933;">,</span>hacklogInsertMedia <span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'m'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Insert media'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span> hacklogInsertAudio<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> U<span style="color: #339933;">=</span><span style="color: #000066;">prompt</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'请输入mp3 URL'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'http://'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>U<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> audio_url <span style="color: #339933;">=</span> jQuery.<span style="color: #660066;">trim</span><span style="color: #009900;">&#40;</span>U<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>audio_url <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">||</span> audio_url <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;&quot;</span> <span style="color: #339933;">||</span> audio_url <span style="color: #339933;">==</span><span style="color: #3366CC;">'http://'</span><span style="color: #009900;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'请输入正确的mp3 URL!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">else</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QTags.<span style="color: #660066;">insertContent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;[audio]&quot;</span> <span style="color: #339933;">+</span> audio_url <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;[/audio]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span> hacklogInsertMedia<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> U <span style="color: #339933;">=</span> <span style="color: #000066;">prompt</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Enter URL'</span> <span style="color: #339933;">,</span> <span style="color: #3366CC;">'http://'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; U <span style="color: #339933;">=</span> jQuery.<span style="color: #660066;">trim</span><span style="color: #009900;">&#40;</span>U<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>U<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> T <span style="color: #339933;">=</span> <span style="color: #000066;">prompt</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Enter type'</span> <span style="color: #339933;">,</span><span style="color: #3366CC;">'mp3'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> W <span style="color: #339933;">=</span> <span style="color: #000066;">prompt</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Enter width'</span> <span style="color: #339933;">,</span> <span style="color: #3366CC;">'500'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> H <span style="color: #339933;">=</span> <span style="color: #000066;">prompt</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Enter height'</span> <span style="color: #339933;">,</span> <span style="color: #3366CC;">'400'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> A <span style="color: #339933;">=</span> <span style="color: #000066;">prompt</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'auto autostart?'</span> <span style="color: #339933;">,</span> <span style="color: #3366CC;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> theTag <span style="color: #339933;">=</span> <span style="color: #3366CC;">'[media type='</span> <span style="color: #339933;">+</span> T <span style="color: #339933;">+</span> <span style="color: #3366CC;">' width='</span> <span style="color: #339933;">+</span> W <span style="color: #339933;">+</span> <span style="color: #3366CC;">' height='</span> <span style="color: #339933;">+</span> H <span style="color: #339933;">+</span> <span style="color: #3366CC;">' autostart='</span> <span style="color: #339933;">+</span> A <span style="color: #339933;">+</span><span style="color: #3366CC;">']'</span><span style="color: #339933;">+</span>U<span style="color: #339933;">+</span><span style="color: #3366CC;">'[/media]'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QTags.<span style="color: #660066;">insertContent</span><span style="color: #009900;">&#40;</span>theTag<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr />
<p><a href="http://ihacklog.com/?p=3707">《免插件为wp编辑器添加wp表情修正版[同时支持可视化编辑器和HTML编辑器]》</a>一文中的代码也失效了，将</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#quicktags'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">before</span><span style="color: #009900;">&#40;</span>smiley<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>修改为</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#wp-content-editor-container'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">before</span><span style="color: #009900;">&#40;</span>smiley<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>即可。</p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5130";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5130" title="Permanent Link to 跟随WP升级，继续插入" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5130</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2010年07月29日  //  <a href="http://ihacklog.com/php/wordpress/wpskills/page-redirect-template.html" title="wp页面重定向模板">wp页面重定向模板</a> (0)</li><li>2010年07月10日  //  <a href="http://ihacklog.com/php/wordpress/wpskills/hacklog-clean-archives.html" title="免插件生成文章存档页面[飞速版]——2011-09-16更新">免插件生成文章存档页面[飞速版]——2011-09-16更新</a> (46)</li><li>2009年04月25日  //  <a href="http://ihacklog.com/php/wordpress/wpskills/wordpresszhongcategoriesdeyongfa.html" title="Wordpress 中 categories 的用法 ">Wordpress 中 categories 的用法 </a> (1)</li><li>2011年04月26日  //  <a href="http://ihacklog.com/php/smarty/how-to-get-the-exution-time-when-use-smarty.html" title="使用Smarty时显示程序执行时间的方法">使用Smarty时显示程序执行时间的方法</a> (1)</li><li>2009年09月26日  //  <a href="http://ihacklog.com/software/onlinetools/online-wap-browser.html" title="在线Wap浏览器">在线Wap浏览器</a> (1)</li><li>2009年10月24日  //  <a href="http://ihacklog.com/linux/ubuntu-desktop/update-graphic-driver-and-play-games-under-ubuntu.html" title="更换显卡驱动，Ubuntu也玩游戏">更换显卡驱动，Ubuntu也玩游戏</a> (9)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/wpskills/audio-and-media-quicktags-button-revisioned.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>给WordPress quicktags编辑器添加自定义按钮的正确方法[3.3修正]</title>
		<link>http://ihacklog.com/php/wordpress/wpskills/the-right-way-to-insert-custom-quicktags-into-the-wordpress-editor-revisioned.html</link>
		<comments>http://ihacklog.com/php/wordpress/wpskills/the-right-way-to-insert-custom-quicktags-into-the-wordpress-editor-revisioned.html#comments</comments>
		<pubDate>Fri, 16 Dec 2011 09:01:48 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[wp技巧]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5129</guid>
		<description><![CDATA[原文见这里：《给WordPress quicktags编辑器添加自定义按钮的正确方法》 WP 3.3起,quicktags引入了新的API，添加按钮更加方便了，用法： 1QTags.addButton&#40; 'my_id', 'my button', '&#60;span&#62;', '&#60;/span&#62;' &#41;; 我添加的一些经常要用到的按钮： 12345678&#160; &#160; &#160; &#160; QTags.addButton&#40; 'pre', 'pre...]]></description>
			<content:encoded><![CDATA[<p>原文见这里：《<a href="http://ihacklog.com/?p=4860">给WordPress quicktags编辑器添加自定义按钮的正确方法</a>》</p>
<p>WP 3.3起,quicktags引入了新的API，添加按钮更加方便了，用法：</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">QTags.<span style="color: #660066;">addButton</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'my_id'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'my button'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'&lt;span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'&lt;/span&gt;'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>我添加的一些经常要用到的按钮：</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; QTags.<span style="color: #660066;">addButton</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'pre'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'pre'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&lt;pre&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&lt;/pre&gt;&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; QTags.<span style="color: #660066;">addButton</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'pre_smooth'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'pre.sm'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&lt;pre class='smooth'&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&lt;/pre&gt;&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; QTags.<span style="color: #660066;">addButton</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'&lt;'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'&lt;'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'&amp;lt;'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; QTags.<span style="color: #660066;">addButton</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'&gt;'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'&gt;'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'&amp;gt;'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; QTags.<span style="color: #660066;">addButton</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'hr'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'hr'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&lt;hr /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; QTags.<span style="color: #660066;">addButton</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'h1'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'h1'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&lt;h1&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&lt;/h1&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; QTags.<span style="color: #660066;">addButton</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'h2'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'h2'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&lt;h2&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&lt;/h2&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; QTags.<span style="color: #660066;">addButton</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'h3'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'h3'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&lt;h3&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&lt;/h3&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5129";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5129" title="Permanent Link to 给WordPress quicktags编辑器添加自定义按钮的正确方法[3.3修正]" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5129</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2009年09月22日  //  <a href="http://ihacklog.com/php/wordpress/wpskills/enable-wordpress-gzip.html" title="开启GZIP,博客访问速度提高不少">开启GZIP,博客访问速度提高不少</a> (9)</li><li>2011年07月31日  //  <a href="http://ihacklog.com/xml_html_css_js_ajax/style-your-code.html" title="定义code的CSS样式代码更有型">定义code的CSS样式代码更有型</a> (7)</li><li>2010年11月12日  //  <a href="http://ihacklog.com/software/tips/install-win7-via-harddisk.html" title="硬盘安装Win7[转]">硬盘安装Win7[转]</a> (8)</li><li>2010年04月30日  //  <a href="http://ihacklog.com/linux/ubuntu-desktop/install-and-setup-ubuntu-10-04-lts-lucid-lynx.html" title="折腾Ubuntu 10.04 LTS (Lucid Lynx) [持续更新中......]">折腾Ubuntu 10.04 LTS (Lucid Lynx) [持续更新中......]</a> (5)</li><li>2011年08月20日  //  <a href="http://ihacklog.com/php/habari/wordpress-alternative-habari.html" title="WordPress:舍我其谁？">WordPress:舍我其谁？</a> (8)</li><li>2011年12月11日  //  <a href="http://ihacklog.com/memory/hacklog/fuck-your-mama-xmedia.html" title="抓抓手机伴侣(XMedia) v4.62，你妹，还我环境变量">抓抓手机伴侣(XMedia) v4.62，你妹，还我环境变量</a> (3)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/wpskills/the-right-way-to-insert-custom-quicktags-into-the-wordpress-editor-revisioned.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>禁用admin_bar的正确方法</title>
		<link>http://ihacklog.com/php/wordpress/wpskills/the-proper-way-to-remove-the-admin-bar.html</link>
		<comments>http://ihacklog.com/php/wordpress/wpskills/the-proper-way-to-remove-the-admin-bar.html#comments</comments>
		<pubDate>Mon, 12 Dec 2011 15:02:05 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[wp技巧]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5091</guid>
		<description><![CDATA[1,普通青年 后台直接设置不显示admin_bar 2,文艺青年 remove_action(&#8216;init&#8217;,'wp_admin_bar_init&#8217;); 或 add_filter( &#8216;show_admin_bar&#8217;, &#8216;__return_false&#8217; ); 不过，有些文艺青年的做法却是错误的，如： 1&#160;remove_action&#40;'init','wp_admin_bar_init'&#41;; 这样做是不对...]]></description>
			<content:encoded><![CDATA[<p>1,普通青年<br />
后台直接设置不显示admin_bar<br />
2,文艺青年<br />
<del datetime="2011-12-12T15:06:57+00:00">remove_action(&#8216;init&#8217;,'wp_admin_bar_init&#8217;);</del><br />
或<br />
add_filter( &#8216;show_admin_bar&#8217;, &#8216;__return_false&#8217; );</p>
<p>不过，有些文艺青年的做法却是<strong>错误</strong>的，如：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;remove_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'wp_admin_bar_init'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>这样做是不对的。</p>
<p>在wp-includes/admin-bar.php文件第11、12行可以看到如下一段注释：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">/* To hide the admin bar, you're looking in the wrong place. Unhooking this function will not<br />
&nbsp;* properly remove the admin bar. For that, use show_admin_bar(false) or the show_admin_bar filter.<br />
*/</span></div></td></tr></tbody></table></div>
<p>再看第39行,再次强调了：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_wp_admin_bar_init'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Don't remove. Wrong way to disable.</span></div></td></tr></tbody></table></div>
<p>甚至已经把函数名由原来的wp_admin_bar_init改为了_wp_admin_bar_init，可能是怕大家继续用上面那种错误的方法来remove.</p>
<p>show_admin_bar这个filter是在同一文件中的<strong>is_admin_bar_showing()</strong>函数中的。</p>
<p>那么，怎么禁用admin_bar呢，很简单，看<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fcodex.wordpress.org%2FPlugin_API%2FFilter_Reference%2Fshow_admin_bar" target="_blank">官方doc</a>:<br />
直接这样就ok了：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'show_admin_bar'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'__return_false'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>这个函数是wp自定义的，作用就是返回false,在wp-includes/functions.php 第4398行：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009933; font-style: italic;">/**<br />
&nbsp;* Returns false<br />
&nbsp;*<br />
&nbsp;* Useful for returning false to filters easily<br />
&nbsp;*<br />
&nbsp;* @since 3.0.0<br />
&nbsp;* @see __return_true()<br />
&nbsp;* @return bool false<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">function</span> __return_false<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5091";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5091" title="Permanent Link to 禁用admin_bar的正确方法" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5091</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2011年04月27日  //  <a href="http://ihacklog.com/php/wordpress/upgrade/wordpress-3-1-2-manual-upgrade-package.html" title="WordPress 3.1.2手动升级包">WordPress 3.1.2手动升级包</a> (17)</li><li>2011年04月14日  //  <a href="http://ihacklog.com/server/ruijie-client-startup-as-service-version2.html" title="锐捷开机启动认证修改版">锐捷开机启动认证修改版</a> (6)</li><li>2011年12月18日  //  <a href="http://ihacklog.com/php/habari/habari-0-8-release.html" title="Habari 0.8 正式发布">Habari 0.8 正式发布</a> (0)</li><li>2009年11月2日  //  <a href="http://ihacklog.com/linux/ubuntu-desktop/tragedy.html" title="杯具">杯具</a> (2)</li><li>2009年04月25日  //  <a href="http://ihacklog.com/php/wordpress/theme/weigreen-islandzhutizengjiaxianshizifenleigongneng.html" title="为green-island主题增加显示子分类功能">为green-island主题增加显示子分类功能</a> (0)</li><li>2008年12月22日  //  <a href="http://ihacklog.com/php/separating-compilation-and-execution.html" title="实现PHP的编译执行分离">实现PHP的编译执行分离</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/wpskills/the-proper-way-to-remove-the-admin-bar.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>wordpress附件与博客主站域名分离</title>
		<link>http://ihacklog.com/php/wordpress/wpskills/use-separate-domain-name-for-attachment-and-main-site-in-wordpress.html</link>
		<comments>http://ihacklog.com/php/wordpress/wpskills/use-separate-domain-name-for-attachment-and-main-site-in-wordpress.html#comments</comments>
		<pubDate>Fri, 25 Nov 2011 13:26:11 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[wp技巧]]></category>
		<category><![CDATA[域名分离]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=4983</guid>
		<description><![CDATA[那天跟MG12 ( iNove主题作者)说起博客的附件分离一事，才发现，原来wp后台早已经有了这么一个选项： Full URL path to files 由于wp中插入附件时用的是绝对地址，因此，如果要对附件使用独立的域名的话，这个选项就有派上用场了。 有了这个选项，可以在同一服务器上实现主站与附件分别使用独立的域名。 如： 将 static.ihacklog.com 绑定到 /path-to-www-root/static 然后在wp后台设置： Store uploads in this folder...]]></description>
			<content:encoded><![CDATA[<p>那天跟MG12 ( iNove主题作者)说起<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fwww.neoease.com%2Fthirdparty-image-library-or-wordpress-gallery%2F" target="_blank">博客的附件分离一事</a>，才发现，原来wp后台早已经有了这么一个选项：<br />
<strong>Full URL path to files </strong><br />
由于wp中插入附件时用的是绝对地址，因此，如果要对附件使用独立的域名的话，这个选项就有派上用场了。<br />
有了这个选项，可以在同一服务器上实现主站与附件分别使用独立的域名。</p>
<p>如：<br />
将 static.ihacklog.com 绑定到  /path-to-www-root/static<br />
然后在wp后台设置：<br />
<strong>Store uploads in this folder</strong>填写：　<strong>/path-to-www-root/static</strong><br />
然后在<strong>Full URL path to files </strong>处填写：<strong>http://static.ihacklog.com</strong><br />
这样就实现了主站与附件站分别用不同的域名了。这样做的好处是，使用cookie-free 域来分发那些无需发送cookie的内容（图片、音乐等），可以加快网页的加载速度。</p>
<p>另说下我最近做的一个wp插件：Hacklog Remote Attachment,这个插件的作用是实现把wp附件上传到远程服务器，与本文所说的博客与附件分离是不同的。本文的情况是<strong>同一服务器</strong>，而插件适用的情况主要是<strong>不同服务器</strong>。<br />
不过都有共同的好处：cookie-free domain.</p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=4983";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=4983" title="Permanent Link to wordpress附件与博客主站域名分离" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=4983</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2010年11月7日  //  <a href="http://ihacklog.com/php/wordpress/problems/boring-3-0-1-upgrade-notify.html" title="关于3.0.1的更新提示">关于3.0.1的更新提示</a> (9)</li><li>2010年12月12日  //  <a href="http://ihacklog.com/php/eclipse-svn-version-control-plug-in-installation-and-usage.html" title="Eclipse中SVN版本控制插件的安装和使用">Eclipse中SVN版本控制插件的安装和使用</a> (4)</li><li>2010年06月20日  //  <a href="http://ihacklog.com/memory/music/lilei-andhanmeimei.html" title="李雷和韩梅梅">李雷和韩梅梅</a> (6)</li><li>2008年02月22日  //  <a href="http://ihacklog.com/php/skills/%e4%bd%bf%e7%94%a8%e4%ba%94%e7%a7%8d%e4%bb%a5%e4%b8%8a%e6%96%b9%e5%bc%8f%e8%8e%b7%e5%8f%96%e4%b8%80%e4%b8%aa%e6%96%87%e4%bb%b6%e7%9a%84%e6%89%a9%e5%b1%95%e5%90%8d.html" title="使用五种以上方式获取一个文件的扩展名">使用五种以上方式获取一个文件的扩展名</a> (0)</li><li>2008年12月19日  //  <a href="http://ihacklog.com/php/framework/%e4%bb%80%e4%b9%88%e6%98%aform.html" title="什么是ORM?">什么是ORM?</a> (0)</li><li>2009年02月11日  //  <a href="http://ihacklog.com/php/7zhongliuxingphpjichengkaifagongjuidedebijiao.html" title="7种流行PHP集成开发工具(IDE)的比较">7种流行PHP集成开发工具(IDE)的比较</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/wpskills/use-separate-domain-name-for-attachment-and-main-site-in-wordpress.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>ASCII字符也精彩——用PHP生成figlet文本</title>
		<link>http://ihacklog.com/php/wordpress/wpskills/generate-figlet-text-via-php.html</link>
		<comments>http://ihacklog.com/php/wordpress/wpskills/generate-figlet-text-via-php.html#comments</comments>
		<pubDate>Tue, 04 Oct 2011 15:05:14 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[Kohana]]></category>
		<category><![CDATA[wp技巧]]></category>
		<category><![CDATA[ASCII字符]]></category>
		<category><![CDATA[figlet]]></category>
		<category><![CDATA[shortcode]]></category>
		<category><![CDATA[短代码]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=4899</guid>
		<description><![CDATA[figlet文本在WP中的应用 先讲一下figlet文本在WP中的应用（这个大家应该比较感兴趣），如我以前用过的主题ASCIIwp中就是用figlet文本做博客标题的。 下面是我优化后的函数，用于显示figlet文本博客标题： 123456789101112131415161718192021222324function header_code&#40;&#41; &#123; &#160; &#160; $header_code_file=TEMPLATEPATH .'/header.txt'; &#1...]]></description>
			<content:encoded><![CDATA[<h3>figlet文本在WP中的应用</h3>
<p>先讲一下figlet文本在WP中的应用（这个大家应该比较感兴趣），如我以前用过的主题ASCIIwp中就是用figlet文本做博客标题的。<br />
下面是我优化后的函数，用于显示figlet文本博客标题：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> header_code<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$header_code_file</span><span style="color: #339933;">=</span>TEMPLATEPATH <span style="color: #339933;">.</span><span style="color: #0000ff;">'/header.txt'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_exists"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$header_code_file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$header_code_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'figlet.php'</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$figlet</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Text_Figlet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$retcode</span> &nbsp;<span style="color: #339933;">=</span> <span style="color: #000088;">$figlet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">LoadFont</span><span style="color: #009900;">&#40;</span>TEMPLATEPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/fonts/graffiti.flf&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$retcode</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$header_code</span><span style="color: #339933;">=</span><span style="color: #000088;">$figlet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">LineEcho</span><span style="color: #009900;">&#40;</span>get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/file_put_contents"><span style="color: #990000;">file_put_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$header_code_file</span><span style="color: #339933;">,</span><span style="color: #000088;">$header_code</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$header_code</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Error: '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$retcode</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>不单是在主题中可以应用，只要你想这样做，在日志里面也是可以使用的。<br />
如：你可以添加一个名为figlet_it的短代码，然后再添加处理此短代码的相关函数:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">// [figlet_it font=&quot;font-name&quot; outputWidth=&quot;width&quot;]the content[/figlet_it]</span><br />
figlet_it_shortcode_handler<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$atts</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$code</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$content</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/extract"><span style="color: #990000;">extract</span></a><span style="color: #009900;">&#40;</span> shortcode_atts<span style="color: #009900;">&#40;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'font'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'slant'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'outputWidth'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">400</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$atts</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'figlet.php'</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$figlet</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Text_Figlet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$retcode</span> &nbsp;<span style="color: #339933;">=</span> <span style="color: #000088;">$figlet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">LoadFont</span><span style="color: #009900;">&#40;</span>TEMPLATEPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/fonts/<span style="color: #006699; font-weight: bold;">{$font}</span>.flf&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$retcode</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$the_code</span><span style="color: #339933;">=</span><span style="color: #000088;">$figlet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">LineEcho</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;&lt;pre&gt;<span style="color: #006699; font-weight: bold;">{$the_code}</span>&lt;/pre&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'Error: can not find the font!'</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
add_shortcode<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'figlet_it'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'figlet_it_shortcode_handler'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>最后，在日志中调用：<br />
[figlet_it font="graffiti"]iHacklog[/figlet_it]</p>
<p>关于WP 短代码的相关文档：<br />
<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fcodex.wordpress.org%2FShortcode_API" target="_blank">http://codex.wordpress.org/Shortcode_API</a><br />
<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fwp.smashingmagazine.com%2F2009%2F02%2F02%2Fmastering-wordpress-shortcodes%2F" target="_blank">Mastering WordPress Shortcodes</a></p>
<p>文章完了吗？还没完。。。<br />
下面再说一下在其它地方生成figlet.</p>
<hr />
<h3>在Kohana或者zendframework中生成figlet文本</h3>
<p>ZF自带的text组件中有<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fframework.zend.com%2Fmanual%2Fen%2Fzend.text.figlet.html" target="_blank">Zend_Text_Figlet类</a>，在ZF中就不说了，说下在Konaha中怎么用：<br />
Kohana要先设置Zend目录到include目录（前面的文章介绍过的，这里不再述）。</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">class</span> Controller_Figlet <span style="color: #000000; font-weight: bold;">extends</span> Controller <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> action_index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$figlet</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Text_Figlet<span style="color: #009900;">&#40;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'font'</span><span style="color: #339933;">=&gt;</span>APPPATH <span style="color: #339933;">.</span><span style="color: #0000ff;">'vendors/Zend/Text/Figlet/slant.flf'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'outputWidth'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">600</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$text0</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$figlet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">render</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'iHacklog'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$figlet</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Text_Figlet<span style="color: #009900;">&#40;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'outputWidth'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">600</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$text1</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$figlet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">render</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'iHacklog'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">body</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;pre&gt;<span style="color: #006699; font-weight: bold;">{$text0}</span>&lt;/pre&gt;&lt;pre&gt;<span style="color: #006699; font-weight: bold;">{$text1}</span>&lt;/pre&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// End Figlet</span></div></td></tr></tbody></table></div>
<p>ok,看下生成的figlet文本：</p>
<pre>    _ __  __           __   __
   (_) / / /___ ______/ /__/ /___  ____ _
  / / /_/ / __ `/ ___/ //_/ / __ \/ __ `/
 / / __  / /_/ / /__/ ,< / / /_/ / /_/ /
/_/_/ /_/\__,_/\___/_/|_/_/\____/\__, /
                                /____/
</pre>
<pre>
  ______   __   _      ___      _____     _  __
 /_   _// | || | ||   / _ \\   / ____||  | |/ //
  -| ||-  | '--' ||  / //\ \\ / //---`'  | ' //
  _| ||_  | .--. || |  ___  ||\ \\___    | . \\
 /_____// |_|| |_|| |_||  |_|| \_____||  |_|\_\\
 `-----`  `-`  `-`  `-`   `-`   `----`   `-` --`
  __        ___      _____
 | ||      / _ \\   /  ___||
 | ||     | / \ || | // __
 | ||__   | \_/ || | \\_\ ||
 |____//   \___//   \____//
 `----`    `---`     `---`   
</pre>
<hr />
<h3>在PHP中调用PEAR包中的Text_Figlet生成figlet文本</h3>
<p>先安装<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fpear.php.net%2Fpackage%2FText_Figlet%2F" target="_blank">Text_Figlet </a>包：</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">pear <span style="color: #c20cb9; font-weight: bold;">install</span> Text_Figlet-1.0.2</div></td></tr></tbody></table></div>
<p>然后开始干活：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Text/Figlet.php'</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$figlet</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Text_Figlet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$error</span> &nbsp;<span style="color: #339933;">=</span> <span style="color: #000088;">$figlet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">LoadFont</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'slant.flf'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>PEAR<span style="color: #339933;">::</span><span style="color: #004000;">isError</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$error</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Error: '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$error</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$figlet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">LineEcho</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Hello, world!'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>字体可到<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fwww.figlet.org%2F" target="_blank">figlet官方网址</a>下载，或者到其FTP下载：<br />
<a href="http://ihacklog.com/l.php?r=1&#038;url=ftp%3A%2F%2Fftp.figlet.org%2Fpub%2Ffiglet%2F" target="_blank">ftp://ftp.figlet.org/pub/figlet/</a></p>
<hr />
<h3>在Linux / windows中生成figlet 文本</h3>
<p>以我的Archlinux为例：</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> pacman <span style="color: #660033;">-S</span> figlet</div></td></tr></tbody></table></div>
<p>安装后即可，不明白怎么用的可以man figlet .<br />
windows的话，从其ftp下载可执行文件即可了。</p>
<hr />
<h3>最后，关于中文显示</h3>
<p>这东西不是国人做的，在最新版本中虽然加入了多编码和UTF-8支持，不过我测试并不能显示中文。<br />
参考了coolwanglu 的这篇文章《<a href="http://ihacklog.com/l.php?&#038;r=1&#038;url=http%3A%2F%2Fcoolwanglu.blogspot.com%2F2007%2F05%2Ffiglet.html" target="_blank">figlet中文支持</a>》，<br />
去http://archive.debian.net/en/source/slink/figfonts 下载了gb16st.flf , gb16fs.flf 和 unshift.flc 三个文件放到字体目录( *nix 下 :  /usr/share/figlet/fonts/ )，还是没法搞定。 <img src='http://ihacklog.com/wordpress/wp-includes/images/smilies/icon_arrow.gif' alt=':arrow:' class='wp-smiley' />  </p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=4899";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=4899" title="Permanent Link to ASCII字符也精彩——用PHP生成figlet文本" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=4899</a>
            </p>
             </div><h3  class="related_post_title">相关日志</h3><ul class="related_post"><li>2010年04月27日  //  <a href="http://ihacklog.com/php/wordpress/wpskills/imagerotator-gallery.html" title="图片也一并通吃——添加wp短代码支持多种媒体文件的播放【增强版】">图片也一并通吃——添加wp短代码支持多种媒体文件的播放【增强版】</a> (22)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/wpskills/generate-figlet-text-via-php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

