<?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>dipplum.com &#187; wordpress</title>
	<atom:link href="http://dipplum.com/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://dipplum.com</link>
	<description>Be  the change you wanna see in the world</description>
	<lastBuildDate>Sat, 12 Nov 2011 07:38:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>用crond运行WordPress中的计划任务</title>
		<link>http://dipplum.com/2010/09/10/wodpress-use-cron/</link>
		<comments>http://dipplum.com/2010/09/10/wodpress-use-cron/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 13:49:05 +0000</pubDate>
		<dc:creator>li</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://dipplum.com/?p=881</guid>
		<description><![CDATA[WordPress站点运行时需要偶尔在后台定时运行一些任务，如定时发布文章，清空Cache的内容，同步别的站点的RSS Feed等。传统来说，计划任务可以通过Linux系统下的crond实现，但考虑到不是所有的网站托管服务都能让用户设定crontab，因此Wordpress中自带了一套计划任务引擎，姑且称之为WP-Cron，这是Wordpress自带的一套函数，和单独的wp-cron插件不是一回事。 WP-Cron的原理是这样的：虽然用户不能通过crond设置计划任务，但网站随时可能会有用户在点击，只要在用户点击的时候，判断当时是否有需要运行的后台任务，如果则在后台运行该任务，就可以实现类似crond的效果。WP-Cron的实现还是比较轻量级的，虽然后台任务是被用户的访问激活的，但后台任务的执行并不会影响用户的访问速度，因为Wordpress在处理用户请求时，发起单独的一个HTTP请求访问wp-cron.php页面后，并不等待wp-cron.php将后台任务执行完毕，也不继续接收由wp-cron.php返回的数据，而是立即处理用户的访问请求。相关细节可以参见wp-includes/cron.php文件。 虽然WP-Cron有着这么多优点，我还是想把它禁用，原因有2: 首先，我的可以直接使用系统的crond，而WP-Cron最多只是没有时的凑合方案(Workaround)；其次，WP-Cron最大的缺点是不能保证任务定时执行，当网站没有用户访问时，WP-Cron就不起作用了。 禁用WP-Cron很简单，编辑wp-config.php，加入一下一行: define&#40;'DISABLE_WP_CRON', true&#41;; 然后在你后台系统的crontab文件里，增加下面的内容： */15 * * * * YOUR_USER /usr/bin/wget -q --post-data '' http://YOUR_SITE/wp-cron.php?doing_wp_cron -O /dev/null 上面配置指示，每15分钟，调用wget命令访问站点的wp-cron.php文件，post-data参数指示wget用POST方法，而不是GET方法，这样可以避免WP-Super-Cache这样的缓存插件影响后台任务的正确执行，但post-data传输的数据必须是空内容，否则wp-cron.php会拒绝执行。 相关阅读： WordPress Support: Can I disable cron job? Run wordpress from real cron job (Page 1) Run wordpress from real cron job (Page 2)]]></description>
			<content:encoded><![CDATA[<p>WordPress站点运行时需要偶尔在后台定时运行一些任务，如定时发布文章，清空Cache的内容，同步别的站点的RSS Feed等。传统来说，计划任务可以通过Linux系统下的crond实现，但考虑到不是所有的网站托管服务都能让用户设定crontab，因此Wordpress中自带了一套计划任务引擎，姑且称之为<a href="http://codex.wordpress.org/Category:WP-Cron_Functions">WP-Cron</a>，这是Wordpress自带的一套函数，和单独的<a href="http://wordpress.org/extend/plugins/wp-cron/">wp-cron插件</a>不是一回事。<span id="more-881"></span></p>
<p>WP-Cron的原理是这样的：虽然用户不能通过crond设置计划任务，但网站随时可能会有用户在点击，只要在用户点击的时候，判断当时是否有需要运行的后台任务，如果则在后台运行该任务，就可以实现类似crond的效果。WP-Cron的实现还是比较轻量级的，虽然后台任务是被用户的访问激活的，但后台任务的执行并不会影响用户的访问速度，因为Wordpress在处理用户请求时，发起单独的一个HTTP请求访问wp-cron.php页面后，并不等待wp-cron.php将后台任务执行完毕，也不继续接收由wp-cron.php返回的数据，而是立即处理用户的访问请求。相关细节可以参见wp-includes/cron.php文件。</p>
<p>虽然WP-Cron有着这么多优点，我还是想把它禁用，原因有2: 首先，我的可以直接使用系统的crond，而WP-Cron最多只是没有时的凑合方案(Workaround)；其次，WP-Cron最大的缺点是不能保证任务定时执行，当网站没有用户访问时，WP-Cron就不起作用了。</p>
<p>禁用WP-Cron很简单，编辑wp-config.php，加入一下一行:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DISABLE_WP_CRON'</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></pre></div></div>

<p>然后在你后台系统的crontab文件里，增加下面的内容：</p>

<div class="wp_syntax"><div class="code"><pre class="crontab" style="font-family:monospace;">*/15 * * * * YOUR_USER /usr/bin/wget -q --post-data '' http://YOUR_SITE/wp-cron.php?doing_wp_cron -O /dev/null</pre></div></div>

<p>上面配置指示，每15分钟，调用wget命令访问站点的wp-cron.php文件，post-data参数指示wget用POST方法，而不是GET方法，这样可以避免WP-Super-Cache这样的缓存插件影响后台任务的正确执行，但post-data传输的数据必须是空内容，否则wp-cron.php会拒绝执行。</p>
<p>相关阅读：</p>
<ul>
<li><a href="http://wordpress.org/support/topic/can-i-disable-cron-job">WordPress Support: Can I disable cron job?</a></li>
<li><a href="http://blog.dreamdevil.com/index.php/2010/01/29/run-wordpress-tasks-from-real-cron-job/">Run wordpress from real cron job (Page 1)</a></li>
<li><a href="http://blog.dreamdevil.com/index.php/2010/01/29/run-wordpress-tasks-from-real-cron-job/2/">Run wordpress from real cron job (Page 2)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://dipplum.com/2010/09/10/wodpress-use-cron/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WP-Mobile-Pack在Multisite模式下的修正</title>
		<link>http://dipplum.com/2010/09/08/fix-wordpress-mobile-pack-with-multisite/</link>
		<comments>http://dipplum.com/2010/09/08/fix-wordpress-mobile-pack-with-multisite/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 11:46:26 +0000</pubDate>
		<dc:creator>li</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp-plugin]]></category>

		<guid isPermaLink="false">http://dipplum.com/2010/09/08/fix-wordpress-mobile-pack-with-multisite/</guid>
		<description><![CDATA[WordPress Mobile Pack插件为Wordpress站点提供适合移动设备浏览的页面. WPMP支持3种检测模式: 1. 根据浏览器User-Agent决定博客输出, 2. 为博客单独设置一个Mobile域名, 根据用户访问的域名决定输出, 3. 上述基于浏览器和基于域名的结合. 从3.0版本开始, WordPress支持Multisite模模式, 也就是原先的Wordpress-MU的延续. 在Multisite模式下, 可以用同一套Wordpress软件和数据库同时管理多个Blog. 通过domain_mapping插件, 还可以为每个Blog设置多个域名. domain_mapping插件可以为每个Blog设置一个主域名, 并且将其他域名的访问请求通过&#8221;Permanent Redirect&#8221;的方法重定向到主域名上, 据说这样可以提高站点的Pagerank. Anyway, 这个功能一般推荐选上, 如下图所示: 不过, domain_mapping插件的Permanent Redirect功能和WPMP的Mobile域名功能冲突, 当用户访问WPMP给站点设置的Mobile域名的时候, 会被domain_mapping插件重定向到主域名. 解决WPMP插件和domain_mapping插件之间的冲突, 需要首先修改domain_mapping.php中redirect_to_mapped_domain函数的实现, 或者下载我已经改好的文件: function redirect_to_mapped_domain&#40;&#41; &#123; global $current_blog, $wpdb; if &#40; !isset&#40; $_SERVER&#91; 'HTTPS' &#93; &#41; &#41; $_SERVER&#91; 'HTTPS' &#93; = &#34;off&#34;; $protocol = &#40; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://wordpress.org/extend/plugins/wordpress-mobile-pack/">WordPress Mobile Pack</a>插件为Wordpress站点提供适合移动设备浏览的页面. WPMP支持3种检测模式:</p>
<p>1. 根据浏览器User-Agent决定博客输出,<br />
2. 为博客单独设置一个Mobile域名, 根据用户访问的域名决定输出,<br />
3. 上述基于浏览器和基于域名的结合.</p>
<p>从3.0版本开始, WordPress支持Multisite模模式, 也就是原先的Wordpress-MU的延续. 在Multisite模式下, 可以用同一套Wordpress软件和数据库同时管理多个Blog. 通过<a href="http://plugins.svn.wordpress.org/wordpress-mu-domain-mapping/trunk/">domain_mapping插件</a>, 还可以为每个Blog设置多个域名. domain_mapping插件可以为每个Blog设置一个主域名, 并且将其他域名的访问请求通过&#8221;Permanent Redirect&#8221;的方法重定向到主域名上, 据说这样可以提高站点的Pagerank. Anyway, 这个功能一般推荐选上, 如下图所示: <span id="more-863"></span></p>
<p><img src="http://dipplum.com/files/2010/09/domain_mapping.jpeg" alt="domain_mappging setting" width="539" height="448" /></p>
<p>不过, domain_mapping插件的Permanent Redirect功能和WPMP的Mobile域名功能冲突, 当用户访问WPMP给站点设置的Mobile域名的时候, 会被domain_mapping插件重定向到主域名.</p>
<p>解决WPMP插件和domain_mapping插件之间的冲突, 需要首先修改domain_mapping.php中redirect_to_mapped_domain函数的实现, 或者下载我已经改好的文件:</p>
Note: There is a file embedded within this post, please visit this post to download the file.

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> redirect_to_mapped_domain<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$current_blog</span><span style="color: #339933;">,</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span> <span style="color: #0000ff;">'HTTPS'</span> <span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
                <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span> <span style="color: #0000ff;">'HTTPS'</span> <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;off&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$protocol</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'on'</span> <span style="color: #339933;">==</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTPS'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'https://'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'http://'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> domain_mapping_siteurl<span style="color: #009900;">&#40;</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$urltmp</span> <span style="color: #339933;">=</span> untrailingslashit<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$protocol</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$current_blog</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>domain <span style="color: #339933;">.</span> <span style="color: #000088;">$current_blog</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>path <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$is_alias</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wpmp_switcher_domains'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$is_alias</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$current_blog</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>domain <span style="color: #339933;">==</span> wpmp_switcher_domains<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mobile'</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> <span style="color: #000088;">$current_blog</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>domain <span style="color: #339933;">==</span> wpmp_switcher_domains<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'desktop'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$url</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$url</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$urltmp</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$is_alias</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$redirect</span> <span style="color: #339933;">=</span> get_site_option<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'dm_301_redirect'</span> <span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'301'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'302'</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'VHOST'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">constant</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;VHOST&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'yes'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'SUBDOMAIN_INSTALL'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">constant</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'SUBDOMAIN_INSTALL'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span> <span style="color: #0000ff;">'REQUEST_URI'</span> <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$current_blog</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>path<span style="color: #339933;">,</span> <span style="color: #0000ff;">'/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span> <span style="color: #0000ff;">'REQUEST_URI'</span> <span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;Location: <span style="color: #006699; font-weight: bold;">{$url}</span>{<span style="color: #006699; font-weight: bold;">$_SERVER</span>[ 'REQUEST_URI' ]}&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #000088;">$redirect</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>除此之外, WPMP插件自身在Mobile域名模式下也有一些bug, 导致用户不能在Mobile站点和普通站点之间进行正确的切换. 下载下面的文件, 替换wordpress-mobile-pack插件子目录plugins/wpmp_switcher/下的wpmp_switcher.php文件, 可以解决上述bug. 具体修改参见如下patch：</p>
Note: There is a file embedded within this post, please visit this post to download the file.

<div class="wp_syntax"><div class="code"><pre class="diff" style="font-family:monospace;">diff --git a/wp-content/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/wpmp_switcher.php b/wp-content/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/wpmp_switcher.php
index ed<span style="color: #440088;">46c88</span>..2949ebb <span style="">100755</span>
<span style="color: #888822;">--- a/wp-content/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/wpmp_switcher.php</span>
<span style="color: #888822;">+++ b/wp-content/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/wpmp_switcher.php</span>
<span style="color: #440088;">@@ -92,12 +92,10 @@ function wpmp_switcher_init<span style="">&#40;</span><span style="">&#41;</span> <span style="">&#123;</span></span>
       wpmp_switcher_mobile_interstitial<span style="">&#40;</span><span style="">&#41;</span>;
       break;
     case WPMP_SWITCHER_REDIRECT_TO_MOBILE:
<span style="color: #991111;">-      wpmp_switcher_set_cookie<span style="">&#40;</span>'mobile'<span style="">&#41;</span>;</span>
       $target_url = &quot;http://&quot; . wpmp_switcher_domains<span style="">&#40;</span>'mobile', true<span style="">&#41;</span> . wpmp_switcher_current_path_plus_cgi<span style="">&#40;</span><span style="">&#41;</span>;
       header<span style="">&#40;</span>&quot;Location: $target_url&quot;<span style="">&#41;</span>;
       exit;
     case WPMP_SWITCHER_REDIRECT_TO_DESKTOP:
<span style="color: #991111;">-      wpmp_switcher_set_cookie<span style="">&#40;</span>'desktop'<span style="">&#41;</span>;</span>
       $target_url = &quot;http://&quot; . wpmp_switcher_domains<span style="">&#40;</span>'desktop', true<span style="">&#41;</span> . wpmp_switcher_current_path_plus_cgi<span style="">&#40;</span><span style="">&#41;</span>;
       header<span style="">&#40;</span>&quot;Location: $target_url&quot;<span style="">&#41;</span>;
       exit;
<span style="color: #440088;">@@ -373,13 +371,13 @@ function wpmp_switcher_outcome_process<span style="">&#40;</span>$switcher_mode, $desktop_domain, $mobile_</span>
     case 'browserdomain':
       if <span style="">&#40;</span>$desktop_domain<span style="">&#41;</span> <span style="">&#123;</span>
         if <span style="">&#40;</span>$desktop_browser<span style="">&#41;</span> <span style="">&#123;</span>
<span style="color: #991111;">-          if <span style="">&#40;</span><span style="">&#40;</span>$mobile_cookie &amp;&amp; !$cgi<span style="">&#41;</span> || $cgi == 'mobile'<span style="">&#41;</span> <span style="">&#123;</span></span>
<span style="color: #00b000;">+          if <span style="">&#40;</span>$mobile_cookie &amp;&amp; !$cgi<span style="">&#41;</span> <span style="">&#123;</span></span>
             return WPMP_SWITCHER_REDIRECT_TO_MOBILE;
           <span style="">&#125;</span> else <span style="">&#123;</span>
             return WPMP_SWITCHER_DESKTOP_PAGE;
           <span style="">&#125;</span>
         <span style="">&#125;</span> else <span style="">&#123;</span>
<span style="color: #991111;">-          if <span style="">&#40;</span><span style="">&#40;</span>$desktop_cookie &amp;&amp; !$cgi<span style="">&#41;</span> || $cgi == 'desktop'<span style="">&#41;</span> <span style="">&#123;</span></span>
<span style="color: #00b000;">+          if <span style="">&#40;</span>$cgi || $desktop_cookie<span style="">&#41;</span> <span style="">&#123;</span></span>
             return WPMP_SWITCHER_DESKTOP_PAGE;
           <span style="">&#125;</span> else <span style="">&#123;</span>
             if <span style="">&#40;</span>$mobile_cookie<span style="">&#41;</span> <span style="">&#123;</span>
<span style="color: #440088;">@@ -474,7 +472,7 @@ function wpmp_switcher_is_cgi_parameter_present<span style="">&#40;</span><span style="">&#41;</span> <span style="">&#123;</span></span>
&nbsp;
 function wpmp_switcher_link<span style="">&#40;</span>$type, $label<span style="">&#41;</span> <span style="">&#123;</span>
   $cookie = WPMP_SWITCHER_COOKIE_VAR . &quot;=$type;path=/;expires=Tue, 01-01-<span style="">2030</span> 00:00:00 GMT&quot;;
<span style="color: #991111;">-  $target_url = &quot;http://&quot; . wpmp_switcher_domains<span style="">&#40;</span>'desktop', true<span style="">&#41;</span> . wpmp_switcher_current_path_plus_cgi<span style="">&#40;</span>'', $type<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+  $target_url = &quot;http://&quot; . wpmp_switcher_domains<span style="">&#40;</span>$type, true<span style="">&#41;</span> . wpmp_switcher_current_path_plus_cgi<span style="">&#40;</span>'', $type<span style="">&#41;</span>;</span>
   if <span style="">&#40;</span>$target_url<span style="">&#41;</span> <span style="">&#123;</span>
     return &quot;&lt;a onclick='document.cookie=\&quot;$cookie\&quot;;' href='$target_url'&gt;$label&lt;/a&gt;&quot;;
   <span style="">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://dipplum.com/2010/09/08/fix-wordpress-mobile-pack-with-multisite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress 3.0 Update Network超时</title>
		<link>http://dipplum.com/2010/09/01/wordpress-3-update-network-timeout/</link>
		<comments>http://dipplum.com/2010/09/01/wordpress-3-update-network-timeout/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 11:26:34 +0000</pubDate>
		<dc:creator>li</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://dipplum.com/?p=853</guid>
		<description><![CDATA[最近将Blog升级到Wordpress 3.0. 新版本支持multisite模式, 我正好可以把几个Blog合并管理. 激活多站点模式后, WordPress管理菜单中新出现了Super Admin菜单, 下面包含Update菜单项, 在Wordpress升级后, 可以通过Update Network功能同时更新当前站点下的所有Blog. 不过最近使用Update Network功能从来没有成功过, 猜测是超时的问题. 我服务器使用的是nginx + php5-fpm, nginx的error.log中相关错误是ms-upgrade-network.php脚本产生的upstream timed out: 2010/08/18 08:39:37 [error] 1962#0: *39882 upstream timed out (110: Connection timed out) while reading upstream, client: 192.168.1.1 server: example.com, request: &#34;GET /wp-admin/ms-upgrade-network.php?action=upgrade HTTP/1.0&#34;, upstream: &#34;fastcgi://127.0.0.1:9000&#34;, host: &#34;example.com&#34;, referrer: &#34;http://example.com/wp-admin/ms-upgrade-network.php&#34; 解决方法包括两方面. 首先增加php脚本的时间限制, 相关参数主要有: max_execution_time, max_input_time. 默认是30还是60秒, [...]]]></description>
			<content:encoded><![CDATA[<p>最近将Blog升级到Wordpress 3.0. 新版本支持<a href="http://codex.wordpress.org/Create_A_Network">multisite</a>模式, 我正好可以把几个Blog合并管理. 激活多站点模式后, WordPress管理菜单中新出现了Super Admin菜单, 下面包含Update菜单项, 在Wordpress升级后, 可以通过<a href="http://codex.wordpress.org/Super_Admin_Update_SubPanel">Update Network</a>功能同时更新当前站点下的所有Blog.</p>
<p>不过最近使用Update Network功能从来没有成功过, 猜测是超时的问题. 我服务器使用的是nginx + php5-fpm, nginx的error.log中相关错误是ms-upgrade-network.php脚本产生的upstream timed out: <span id="more-853"></span></p>

<div class="wp_syntax"><div class="code"><pre class="syslog" style="font-family:monospace;">2010/08/18 08:39:37 [error] 1962#0: *39882 upstream timed out (110: Connection timed out) while reading upstream, client: 192.168.1.1 server: example.com, request: &quot;GET /wp-admin/ms-upgrade-network.php?action=upgrade HTTP/1.0&quot;, upstream: &quot;fastcgi://127.0.0.1:9000&quot;, host: &quot;example.com&quot;, referrer: &quot;http://example.com/wp-admin/ms-upgrade-network.php&quot;</pre></div></div>

<p>解决方法包括两方面. 首先增加php脚本的时间限制, 相关参数主要有: <a href="http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time">max_execution_time</a>, <a href="http://www.php.net/manual/en/info.configuration.php#ini.max-input-time">max_input_time</a>. 默认是30还是60秒, 对于Update Network来说可能不够, 所以要修改php-fpm的配置(/etc/php5/fpm/php.ini):</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000099;">max_execution_time</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 300</span>
<span style="color: #000099;">max_input_time</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 600</span></pre></div></div>

<p>还有就是增加nginx等待的超时限制, 参见<a href="http://wiki.nginx.org/NginxHttpFcgiModule">Nginx的文档</a>, 主要有fastcgi_read_timeout, fastcgi_send_timeout, 可能和上面的php参数是对应的(read对应execution, send对应input):</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">location ~ \.<span style="color: #202020;">php</span>$ <span style="color: #009900;">&#123;</span>
	fastcgi_pass   127.0.0.1<span style="color: #339933;">:</span><span style="color: #0000dd;">9000</span><span style="color: #339933;">;</span>
        ...
        <span style="color: #202020;">fastcgi_read_timeout</span> <span style="color: #0000dd;">300</span><span style="color: #339933;">;</span>
        fastcgi_send_timeout <span style="color: #0000dd;">600</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>修改完成之后重启nginx和php5-fpm服务器, Update Network可以正常结束.</p>
]]></content:encoded>
			<wfw:commentRss>http://dipplum.com/2010/09/01/wordpress-3-update-network-timeout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>装了个代码语法高亮插件</title>
		<link>http://dipplum.com/2009/02/01/wp-syntax-ftest/</link>
		<comments>http://dipplum.com/2009/02/01/wp-syntax-ftest/#comments</comments>
		<pubDate>Sun, 01 Feb 2009 11:59:00 +0000</pubDate>
		<dc:creator>li</dc:creator>
				<category><![CDATA[乱七八糟]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://dipplum.com/?p=110</guid>
		<description><![CDATA[1 2 3 4 5 6 #include &#60;stdio.h&#62; &#160; int main&#40;&#41; &#123; printf&#40;&#34;hello, world!\n&#34;&#41;; &#125;]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;hello, world!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://dipplum.com/2009/02/01/wp-syntax-ftest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

