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

<channel>
	<title>细柳营 &#187; WordPress</title>
	<atom:link href="http://huang.yunsong.net/category/wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://huang.yunsong.net</link>
	<description>前尘往昔逝如烟 曾忆风云舞九天</description>
	<lastBuildDate>Mon, 02 Jan 2012 17:49:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Rocks! WordPress MU + HyperDB</title>
		<link>http://huang.yunsong.net/2009/wpmu-hyperdb.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wpmu-hyperdb</link>
		<comments>http://huang.yunsong.net/2009/wpmu-hyperdb.html#comments</comments>
		<pubDate>Sun, 22 Mar 2009 07:56:03 +0000</pubDate>
		<dc:creator>Richard Huang</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://huang.yunsong.net/2009/wpmu-hyperdb.html</guid>
		<description><![CDATA[Indeed it&#8217;s very easy to get WPMU installed and up, but you&#8217;ll find the number of tables in WPMU database increases every time a new blog is created. If you&#8217;re providing public blogging service, the number of tables is going &#8230; <a href="http://huang.yunsong.net/2009/wpmu-hyperdb.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Indeed it&#8217;s very easy to get WPMU installed and up, but you&#8217;ll find the number of tables in WPMU database increases every time a new blog is created. If you&#8217;re providing public blogging service, the number of tables is going to 100, 1000, &#8230; very soon. Yes, WPMU is great, but the tables keep increasing, that may drive you mad. I was mad, at least.</p>
<p>In WPMU version 2.7, there are 9 global tables: blogs, blog_versions, registration_log, signups, site, sitecategories, sitemeta, usermeta, users. These 9 tables are fixed and serving for WPMU system globally. Every blog has its own 8 tables: comments, links, options, postmeta, posts, terms, term_relationships, term_taxonomy. These 8 tables are created over and over every new blog is created.</p>
<p>This designing is cool and useful from scalability view, especially for those big blogging service providers, <a href="http://wordpress.com" target="_blank">wordpress.com</a> is a good example. But WPMU uses only one database by default, it&#8217;s hard to manage the excessive tables in one database, and the performance should also not be good. OK, here comes <a href="http://wordpress.org/extend/plugins/hyperdb/" target="_blank">HyperDB</a>, which can solve this problem. Actually HyperDB is derived from the code using by wordpress.com.</p>
<p>Before starting installing and configuring, we need to define a rule for databases. In this post, the rule is:</p>
<ul>
<li>One database (wpmu_db0) for the global tables and the tables of first blog. It can be called global database.</li>
<li>Additional 3 databases (wpmu_db1, wpmu_db2, wpmu_db3) for the tables of other blogs, each database serves 2 blogs.</li>
</ul>
<p>Of course, you can define your own rules based-on your needs. It&#8217;s flexible.</p>
<p>We can start now. The first thing is to set up a standard WPMU using the global database in the installation wizard. After that, go to WordPress website and download HyperDB. The version I&#8217;m using is 2008-11-27. There are three files in HyperDB package:</p>
<ul>
<li><span style="font-family: courier new,courier;">db.php</span>, which needs to be uploaded to <span style="font-family: courier new,courier;">wp-content</span> directory</li>
<li><span style="font-family: courier new,courier;">db-settings.php</span>, which needs to be uploaded to the directory that holds <span style="font-family: courier new,courier;">wp-config.php</span></li>
<li><span style="font-family: courier new,courier;">readme.txt</span>, oh, you know what it means</li>
</ul>
<p>Then add the following lines near the top of <span style="font-family: courier new,courier;">wp-config.php</span></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;">'WPMU'</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: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'db-settings.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Then add the blow code at the bottom of <span style="font-family: courier new,courier;">db-settings.php</span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// a handy function for mapping blog tables to dataset</span>
<span style="color: #000000; font-weight: bold;">function</span> add_blog_tables<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ds</span><span style="color: #339933;">,</span> <span style="color: #000088;">$blog_id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  add_db_table<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ds</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$blog_id</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  add_db_table<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ds</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$blog_id</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_links'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  add_db_table<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ds</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$blog_id</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_options'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  add_db_table<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ds</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$blog_id</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_postmeta'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  add_db_table<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ds</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$blog_id</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_posts'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  add_db_table<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ds</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$blog_id</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_terms'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  add_db_table<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ds</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$blog_id</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_term_relationships'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  add_db_table<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ds</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$blog_id</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_term_taxonomy'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// add databases</span>
add_db_server<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'global'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mysql3326_1'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'localhost:3326'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpmu_db0'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpuser'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thepwd'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_db_server<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'s1'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mysql3326_2'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'localhost:3326'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpmu_db1'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpuser'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thepwd'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_db_server<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'s2'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mysql3306_1'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'localhost:3306'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpmu_db2'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpuser'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thepwd'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_db_server<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'s3'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mysql3306_2'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'localhost:3306'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpmu_db3'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpuser'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thepwd'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// add global tables which are in global database</span>
add_db_table<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'global'</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">'wp_blogs'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_db_table<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'global'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_blog_versions'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_db_table<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'global'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_registration_log'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_db_table<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'global'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_signups'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_db_table<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'global'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_site'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_db_table<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'global'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_sitecategories'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_db_table<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'global'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_sitemeta'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_db_table<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'global'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_usermeta'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// add the tables for the first blog (created during wpmu installation)</span>
<span style="color: #666666; font-style: italic;">// the first blog's tables are in global database</span>
<span style="color: #666666; font-style: italic;">// of course, you can move it to any database you want</span>
add_blog_tables<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'global'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$dbsnum</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 3 additional databases</span>
<span style="color: #000088;">$blogs_per_db</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// each database serves 2 blogs</span>
&nbsp;
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$db_id</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #000088;">$db_id</span><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span><span style="color: #000088;">$dbsnum</span><span style="color: #339933;">;</span> <span style="color: #000088;">$db_id</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$dataset</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'s'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$db_id</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$max</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$db_id</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$blogs_per_db</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// include</span>
  <span style="color: #000088;">$min</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$max</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$blogs_per_db</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// include</span>
  <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$blog_id</span><span style="color: #339933;">=</span><span style="color: #000088;">$min</span><span style="color: #339933;">;</span> <span style="color: #000088;">$blog_id</span><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span><span style="color: #000088;">$max</span><span style="color: #339933;">;</span> <span style="color: #000088;">$blog_id</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    add_blog_tables<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dataset</span><span style="color: #339933;">,</span> <span style="color: #000088;">$blog_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>That&#8217;s it!</p>
]]></content:encoded>
			<wfw:commentRss>http://huang.yunsong.net/2009/wpmu-hyperdb.html/feed</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>WordPress MU Local Installation</title>
		<link>http://huang.yunsong.net/2009/wpmu-local-install.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wpmu-local-install</link>
		<comments>http://huang.yunsong.net/2009/wpmu-local-install.html#comments</comments>
		<pubDate>Wed, 11 Mar 2009 09:25:48 +0000</pubDate>
		<dc:creator>Richard Huang</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://huang.yunsong.net/2009/wpmu-local-install.html</guid>
		<description><![CDATA[Resovling Domain Names Locally Wanna try WPMU on local machine? If you use localhost or 127.0.0.1 as the server address directly, you always get a message similar to the following: Do not use an IP address (like 127.0.0.1) as your &#8230; <a href="http://huang.yunsong.net/2009/wpmu-local-install.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Resovling Domain Names Locally</strong></p>
<p>Wanna try <a href="http://mu.wordpress.org" target="_blank">WPMU</a> on local machine? If you use localhost or 127.0.0.1 as the server address directly, you always get a message similar to the following:</p>
<blockquote><p>Do not use an IP address (like 127.0.0.1) as your server address. Do not use a single word hostname like localhost.</p></blockquote>
<p>That means a FQDN is needed, the good thing is that it&#8217;s easy to resolve domain names virtually locally. Open the <span style="font-family: courier new,courier;">hosts</span> file:</p>
<ul>
<li><span style="font-family: courier new,courier;">C:\WINDOWS\system32\drivers\etc\hosts</span> (Windows)</li>
<li><span style="font-family: courier new,courier;">/etc/hosts</span> (Linux)</li>
</ul>
<p>Add or modify something, and make sure there is a line like the following in the file:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">127.0.0.1    localhost hys.lan bloga.hys.lan blogb.hys.lan blogc.hys.lan blogd.hys.lan</pre></div></div>

<p>Here, hys.lan is used to install WPMU, blog(a-d).hys.lan are addresses for testing, I&#8217;ll use these four to create weblogs.</p>
<p><strong>Configuring Apache</strong></p>
<p>Make sure two things:</p>
<ul>
<li>Apache is listening on port 80, because WPMU doesn&#8217;t support server address with port number.</li>
<li>mod_rewrite is enabled.</li>
</ul>
<p>Then adds a virtual host section:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
  <span style="color: #00007f;">DocumentRoot</span> /opt/wordpress-mu
  <span style="color: #00007f;">ServerName</span> hys.lan
  <span style="color: #00007f;">ServerAlias</span> *.hys.lan
  &lt;<span style="color: #000000; font-weight:bold;">Directory</span> <span style="color: #7f007f;">&quot;/opt/wordpress-mu&quot;</span>&gt;
    <span style="color: #00007f;">AllowOverride</span> FileInfo
    <span style="color: #00007f;">Order</span> <span style="color: #00007f;">allow</span>,<span style="color: #00007f;">deny</span>
    <span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span>
  &lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</pre></div></div>

<p><strong>Preparing Database</strong></p>
<p>Create an empty database, and grant permissions to a database user.</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">create</span> <span style="color: #990099; font-weight: bold;">database</span> wpmu_db<span style="color: #000033;">;</span>
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">grant</span> <span style="color: #990099; font-weight: bold;">all</span> <span style="color: #990099; font-weight: bold;">privileges</span> <span style="color: #990099; font-weight: bold;">on</span> wpmu_db.<span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">to</span> wpuser@<span style="color: #008000;">'<span style="color: #008080; font-weight: bold;">%</span>'</span> identified by <span style="color: #008000;">'thepwd'</span><span style="color: #000033;">;</span>
mysql<span style="color: #CC0099;">&gt;</span> flush <span style="color: #990099; font-weight: bold;">privileges</span><span style="color: #000033;">;</span></pre></div></div>

<p><strong>Installing WPMU</strong></p>
<p>It&#8217;s very easy to get WPMU up. Open your browser, and type the server address, in my case, it&#8217;s http://hys.lan. Provide the required information, and press the &#8220;Submit&#8221; button to go. Waiting for a while, WPMU is installed and runs successfully.</p>
]]></content:encoded>
			<wfw:commentRss>http://huang.yunsong.net/2009/wpmu-local-install.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Upgrade TinyMCE for WordPress</title>
		<link>http://huang.yunsong.net/2007/upgrade-tinymce-for-wordpress.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=upgrade-tinymce-for-wordpress</link>
		<comments>http://huang.yunsong.net/2007/upgrade-tinymce-for-wordpress.html#comments</comments>
		<pubDate>Fri, 12 Jan 2007 05:05:57 +0000</pubDate>
		<dc:creator>Richard Huang</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://huang.yunsong.net/2007/upgrade-tinymce-for-wordpress.html</guid>
		<description><![CDATA[WP 中内置了 TinyMCE 作为它的 rich editor ，这很好， 恰巧 TinyMCE 也是我最喜欢的 editor ，而且 WP 团队还很认真地开发了一个 plugin for TinyMCE ，算得上严谨负责，可惜的是，他们依然过于小心了。大约是为了防止用户在编辑中使用一些特殊字符， WP 在初始化 TinyMCE 时作了很多过滤和严格的限制。这导致了无法在 WP 的内置 TinyMCE 中直接写 xml/html 代码。还有一个问题就是， WP 的内置 TinyMCE 版本太老，居然是2005年12月发布的 2.0 RC 版。 基于以上理由，我决定抛弃 WP 内置的 TinyMCE ，使用最新的 &#8230; <a href="http://huang.yunsong.net/2007/upgrade-tinymce-for-wordpress.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>WP 中内置了 <a title="TinyMCE" href="http://tinymce.moxiecode.com" target="_blank">TinyMCE</a> 作为它的 rich editor ，这很好， 恰巧 TinyMCE 也是我最喜欢的 editor ，而且 WP 团队还很认真地开发了一个 plugin for TinyMCE ，算得上严谨负责，可惜的是，他们依然<a title="WordPress 的过度转换" href="http://huang.yunsong.net/2007/wp-replacing-too-much.html" target="_blank">过于小心</a>了。大约是为了防止用户在编辑中使用一些特殊字符， WP 在初始化 TinyMCE 时作了很多过滤和严格的限制。这导致了无法在 WP 的内置 TinyMCE 中直接写 xml/html 代码。还有一个问题就是， WP 的内置 TinyMCE 版本太老，居然是2005年12月发布的 2.0 RC 版。</p>
<p>基于以上理由，我决定抛弃 WP 内置的 TinyMCE ，使用最新的 TinyMCE 2.0.9 来作为俺的 editor.</p>
<p><strong>1 Disable WP built-in TinyMCE</strong></p>
<p>登录 WP 控制台，然后进入 Options -&gt; Writing ，在 Formatting 中清除对 &#8220;Users should use the visual rich editor by default&#8221; 项的选择。</p>
<p>进入 Users ，在 Personal Options 中清除对 &#8220;Use the visual rich editor when writing&#8221; 项的选择。</p>
<p><strong>2 Download the latest TinyMCE</strong></p>
<p>到其官方站下载最新版，我此时的是 2.0.9。</p>
<p><strong>3 Install TinyMCE</strong></p>
<p>解开下载包<br />
<span style="font-family: courier new,courier;">$ unzip tinymce_2_0_9.zip<br />
$ unzip tinymce_lpackage.zip</span> （如果你也下载了语言包的话）</p>
<p>把 jscripts 目录下的 tiny_mce 复制到 <span style="font-family: courier new,courier;">$WP_HOME/wp-includes/js/</span> 下。其实可以复制到任意能通过 browser 访问的地方，但是为了看起来比较一致，我将它复制到了 WP 用来放 javascript 的地方。<br />
<span style="font-family: courier new,courier;">$ cd tinymce/jscripts<br />
$ cp -fr tiny_mce $WP_HOME/wp-includes/js/</span></p>
<p>改个名字，好区分这是我自己安装的<br />
<span style="font-family: courier new,courier;">$ cd $WP_HOME/wp-includes/js/<br />
$ mv tiny_mce tinymce209hys</span></p>
<p><strong>4 Confiure TinyMCE</strong></p>
<p>在 <span style="font-family: courier new,courier;">$WP_HOME/wp-includes/js/</span> 下新建一个文件 init_tinymce209hys.js ，同样，这个脚本文件可以放到任意能通过 browser 访问的地方，文件名也随便。</p>
<p>该文件是用来配置新安装的 TinyMCE 的，至于如何配置 TinyMCE ，可以访问其<a title="TinyMCE Documentation" href="http://wiki.moxiecode.com/index.php/TinyMCE:Index" target="_blank">官方 WIKI</a> 来获取帮助。以下是我的配置：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">tinyMCE.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
  mode <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;exact&quot;</span><span style="color: #339933;">,</span>
  elements <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;content&quot;</span><span style="color: #339933;">,</span>
  theme <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;advanced&quot;</span><span style="color: #339933;">,</span>
  language <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;zh_cn_utf8&quot;</span><span style="color: #339933;">,</span>
  width <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;100%&quot;</span><span style="color: #339933;">,</span>
  height <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;400&quot;</span><span style="color: #339933;">,</span>
  plugins <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;paste,table&quot;</span><span style="color: #339933;">,</span>
  theme_advanced_buttons1 <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;cut, copy, paste, pastetext, separator, fontselect, fontsizeselect, separator, bold, italic, underline, strikethrough, separator, bullist, numlist, separator, justifyleft, justifycenter, justifyright, separator, forecolor, backcolor, separator, link, unlink, separator, table, row_props, cell_props, separator, charmap, image, removeformat, code&quot;</span><span style="color: #339933;">,</span>
  theme_advanced_buttons2 <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span>
  theme_advanced_toolbar_location <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;top&quot;</span><span style="color: #339933;">,</span>
  theme_advanced_toolbar_align <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;left&quot;</span><span style="color: #339933;">,</span>
  theme_advanced_statusbar_location <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;none&quot;</span><span style="color: #339933;">,</span>
  theme_advanced_path <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span>
  relative_urls <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span>
  remove_script_host <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>5 Modify $WP_HOME/wp-admin/admin-header.php</strong></p>
<p>将第49行</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$editing</span> <span style="color: #339933;">&amp;&amp;</span> user_can_richedit<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>修改为</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$editing</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>即，去除对用户是否使用 rich editor 的判断。</p>
<p>将第50行</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;../wp-includes/js/tinymce/tiny_mce_gzip.php?ver=20051211&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>修改为</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;../wp-includes/js/tinymce209hys/tiny_mce.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;../wp-includes/js/init_tinymce209hys.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>完工！</p>
<p>附注：我的 WP 是 2.0.5 版。</p>
]]></content:encoded>
			<wfw:commentRss>http://huang.yunsong.net/2007/upgrade-tinymce-for-wordpress.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress 的过度转换</title>
		<link>http://huang.yunsong.net/2007/wp-replacing-too-much.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wp-replacing-too-much</link>
		<comments>http://huang.yunsong.net/2007/wp-replacing-too-much.html#comments</comments>
		<pubDate>Thu, 11 Jan 2007 10:42:58 +0000</pubDate>
		<dc:creator>Richard Huang</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://huang.yunsong.net/2007/wp-replacing-too-much.html</guid>
		<description><![CDATA[用了一段时间的 WordPress，总体感觉很好，是一个不错的个人 blogging 工具，但是 WordPress 对于特殊字符的处理似乎有点过于小心了，比如在命令行中经常有的 &#8220;&#8211;&#8221; ， WordPress 在呈现时会将其替换成 &#8220;&#38;#8211;&#8221; ，这样在浏览器中展示的就不再是两条短线、而是一条略长的线了 &#8220;–&#8221; ，丧失了其原义。所以，我修改了一下 functions-formatting.php ，注销了转换的几行，在我使用的 WordPress 2.0.5 版本中，是第13、14、15行。 类似这样的问题还不少，比如单引号也如此，相应地，我注销了第31、36行。]]></description>
			<content:encoded><![CDATA[<p>用了一段时间的 WordPress，总体感觉很好，是一个不错的个人 blogging 工具，但是 WordPress 对于特殊字符的处理似乎有点过于小心了，比如在命令行中经常有的 &#8220;&#8211;&#8221; ， WordPress 在呈现时会将其替换成 &#8220;&amp;#8211;&#8221; ，这样在浏览器中展示的就不再是<strong>两条</strong>短线、而是<strong>一条</strong>略长的线了 &#8220;–&#8221; ，丧失了其原义。所以，我修改了一下 functions-formatting.php ，注销了转换的几行，在我使用的 WordPress 2.0.5 版本中，是第13、14、15行。</p>
<p>类似这样的问题还不少，比如单引号也如此，相应地，我注销了第31、36行。</p>
]]></content:encoded>
			<wfw:commentRss>http://huang.yunsong.net/2007/wp-replacing-too-much.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress 2.0.5 Installation</title>
		<link>http://huang.yunsong.net/2006/wordpress_2_0_5_install.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wordpress_2_0_5_install</link>
		<comments>http://huang.yunsong.net/2006/wordpress_2_0_5_install.html#comments</comments>
		<pubDate>Sat, 30 Dec 2006 05:41:56 +0000</pubDate>
		<dc:creator>Richard Huang</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://huang.yunsong.net/2006/wordpress_2_0_5_install.html</guid>
		<description><![CDATA[WordPress 极易安装，不过也有些需要注意的地方。 编辑 $WP_HOME/wp-config.php 若无此文件，就复制相同目录下的 wp-config-sample.php 新建一个。在该文件中指定数据库名、用户名、密码、数据库服务器主机名或IP即可。很简单的。唯一需要指出的是，若你的 MySQL 不是监听默认的 3306 端口，那么在指定 DB_HOST 是需要指出其端口，比如： define(&#39;DB_HOST&#39;, &#39;localhost:3366&#39;); 字符集问题 为了避免出现乱码现象，创建 MySQL 数据库时需要使用 utf8 作为默认字符集。 另外还需要修改 $WP_HOME/wp-includes/wp-db.php 文件，强制 WP 在连接数据库时使用 utf8找到如下一行 $this-&#62;dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);应该是在第 43 行。在该行下加一行$this-&#62;query(&#34;set names &#39;utf8&#39;&#34;);即可。 控制板 当进入 WP 的控制板时，它会自动从 &#8230; <a href="http://huang.yunsong.net/2006/wordpress_2_0_5_install.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>WordPress 极易安装，不过也有些需要注意的地方。</p>
<p><strong>编辑 $WP_HOME/wp-config.php</strong></p>
<p>若无此文件，就复制相同目录下的 wp-config-sample.php 新建一个。<br />在该文件中指定数据库名、用户名、密码、数据库服务器主机名或IP即可。很简单的。唯一需要指出的是，若你的 MySQL 不是监听默认的 3306 端口，那么在指定 DB_HOST 是需要指出其端口，比如：</p>
<p>define(&#39;DB_HOST&#39;, &#39;localhost:3366&#39;);</p>
<p><strong>字符集问题</strong></p>
<p>为了避免出现乱码现象，创建 MySQL 数据库时需要使用 utf8 作为默认字符集。</p>
<p>另外还需要修改 $WP_HOME/wp-includes/wp-db.php 文件，强制 WP 在连接数据库时使用 utf8<br />找到如下一行 <br />$this-&gt;dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);<br />应该是在第 43 行。<br />在该行下加一行<br />$this-&gt;query(&quot;set names &#39;utf8&#39;&quot;);<br />即可。</p>
<p><strong>控制板</strong></p>
<p>当进入 WP 的控制板时，它会自动从 technorati.com, wordpress.org 上获取一些与 WP 有关的最新信息，这当然是很好的，但是因为从中国访问这两个网站的速度都不太理想，所以导致每次进入控制板时速度很慢。而且我们也并非每次进入控制板时都需要看有关 WP 的最新信息，再说了，哪会有那么多的 WP 相关信息更新啊。因此，为了速度计，我决定取消信息攫取。</p>
<p>打开 $WP_HOME/wp-admin/index.php<br />搜寻字符串 $rss = @fetch_rss<br />应该有三行，分别在 18, 129, 146.<br />把这三行注释掉即可。</p>
<p>好了，现在可以启动 WP 的安装向导了。Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://huang.yunsong.net/2006/wordpress_2_0_5_install.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

