<?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>henkude &#187; hack</title>
	<atom:link href="http://henkude.com/blog/tag/hack/feed/" rel="self" type="application/rss+xml" />
	<link>http://henkude.com</link>
	<description>hen - very, ku - cool, de - 的</description>
	<lastBuildDate>Fri, 21 May 2010 14:41:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>在 BuddyPress 中启用原生 theme editor 和 plugin editor 的最佳方案</title>
		<link>http://henkude.com/blog/2009/11/18/%e5%9c%a8-buddypress-%e4%b8%ad%e5%90%af%e7%94%a8%e5%8e%9f%e7%94%9f-theme-editor-%e5%92%8c-plugin-editor-%e7%9a%84%e6%9c%80%e4%bd%b3%e6%96%b9%e6%a1%88/</link>
		<comments>http://henkude.com/blog/2009/11/18/%e5%9c%a8-buddypress-%e4%b8%ad%e5%90%af%e7%94%a8%e5%8e%9f%e7%94%9f-theme-editor-%e5%92%8c-plugin-editor-%e7%9a%84%e6%9c%80%e4%bd%b3%e6%96%b9%e6%a1%88/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 06:34:58 +0000</pubDate>
		<dc:creator>Kude Hen</dc:creator>
				<category><![CDATA[BuddyPress]]></category>
		<category><![CDATA[hack]]></category>

		<guid isPermaLink="false">http://henkude.com/?p=127</guid>
		<description><![CDATA[前面有介绍过如何在 BuddyPress 控制面板中唤回失落的 theme editor 和 plugin editor 链接，经过一番查询，终于寻获一个最安全的方案，无需触碰 core code，算是最好的 hack 了，实际上是用了 WPMU 默认加载  mu-plugins 的办法，步骤十分之简便，只需将下列代码添加到一个空的 PHP 文件: 12345&#60;?php add_action&#40; 'admin_init', create_function&#40;'$pages', 'if(is_site_admin()) return remove_action(&#34;admin_init&#34;,&#34;disable_some_pages&#34;);'&#41;,1&#41;; add_action&#40; '_admin_menu', create_function&#40;'$theme_menu', 'return add_theme_page( &#34;主题编辑器&#34;, &#34;主题编辑器&#34;, &#34;edit_themes&#34;, &#34;theme-editor.php&#34;);' &#41;&#41;; add_action&#40; '_admin_menu', create_function&#40;'$plugin_menu', 'return add_submenu_page( &#34;plugins.php&#34;, &#34;插件编辑器&#34;, &#34;插件编辑器&#34;, &#34;edit_plugins&#34;, &#34;plugin-editor.php&#34;);' &#41;&#41;; ?&#62; 代码中的中文单词可以换成你自己的翻译，然后保存为 .php 文件 (注意文件编码于主程序安装编码一致)，文件名随意取，比如我用 give_admin_theme_editor_plugin_editor.php，长是长了点，一目了然，呵呵。最后把文件上传到 /wp-content/mu-plugins/ 里，万事大吉。 [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://henkude.com/blog/2009/11/17/%E5%A6%82%E4%BD%95%E5%9C%A8-buddypress-%E4%B8%AD%E5%90%AF%E7%94%A8-wp-%E5%8E%9F%E7%94%9F%E7%9A%84-theme-editor/" target="_blank">前面有介绍过</a>如何在 BuddyPress 控制面板中唤回失落的 theme editor 和 plugin editor 链接，经过一番查询，终于寻获一个最安全的方案，无需触碰 core code，算是最好的 hack 了，实际上是用了 WPMU 默认加载  mu-plugins 的办法，步骤十分之简便，只需将下列代码添加到一个空的 PHP 文件:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><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 /></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 />
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'admin_init'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/create_function"><span style="color: #990000;">create_function</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'$pages'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'if(is_site_admin()) return remove_action(&quot;admin_init&quot;,&quot;disable_some_pages&quot;);'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'_admin_menu'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/create_function"><span style="color: #990000;">create_function</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'$theme_menu'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'return add_theme_page( &quot;主题编辑器&quot;, &quot;主题编辑器&quot;, &quot;edit_themes&quot;, &quot;theme-editor.php&quot;);'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'_admin_menu'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/create_function"><span style="color: #990000;">create_function</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'$plugin_menu'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'return add_submenu_page( &quot;plugins.php&quot;, &quot;插件编辑器&quot;, &quot;插件编辑器&quot;, &quot;edit_plugins&quot;, &quot;plugin-editor.php&quot;);'</span> <span style="color: #009900;">&#41;</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>代码中的中文单词可以换成你自己的翻译，然后保存为 .php 文件 (注意文件编码于主程序安装编码一致)，文件名随意取，比如我用 <em>give_admin_theme_editor_plugin_editor.php</em>，长是长了点，一目了然，呵呵。最后把文件上传到 <strong>/wp-content/mu-plugins/</strong> 里，万事大吉。</p>
<p><a href="http://mu.wordpress.org/forums/topic/14647" target="_blank"><em>via</em></a></p>
<div class="shr-publisher-127"></div>]]></content:encoded>
			<wfw:commentRss>http://henkude.com/blog/2009/11/18/%e5%9c%a8-buddypress-%e4%b8%ad%e5%90%af%e7%94%a8%e5%8e%9f%e7%94%9f-theme-editor-%e5%92%8c-plugin-editor-%e7%9a%84%e6%9c%80%e4%bd%b3%e6%96%b9%e6%a1%88/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何在 BuddyPress 中启用 WP 原生的 theme editor</title>
		<link>http://henkude.com/blog/2009/11/17/%e5%a6%82%e4%bd%95%e5%9c%a8-buddypress-%e4%b8%ad%e5%90%af%e7%94%a8-wp-%e5%8e%9f%e7%94%9f%e7%9a%84-theme-editor/</link>
		<comments>http://henkude.com/blog/2009/11/17/%e5%a6%82%e4%bd%95%e5%9c%a8-buddypress-%e4%b8%ad%e5%90%af%e7%94%a8-wp-%e5%8e%9f%e7%94%9f%e7%9a%84-theme-editor/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 13:19:28 +0000</pubDate>
		<dc:creator>Kude Hen</dc:creator>
				<category><![CDATA[BuddyPress]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[WPMU]]></category>

		<guid isPermaLink="false">http://henkude.com/?p=71</guid>
		<description><![CDATA[由于 BuddyPress 是基于 WPMU，因此后台和 WPMU 一样隐藏并禁用了 WP 原生的 theme editor，如果想在 BuddyPress 里使用 WP 原生的 theme editor，只要遵循以下步骤 (基于 BuddyPress 1.1.2/WPMU 2.8.5.2): 注释掉 /wp-admin/includes/mu.php 第556行: 1unset&#40; $submenu&#91;'themes.php'&#93;&#91;10&#93; &#41;; // always remove the themes editor 替换成 1//unset( $submenu['themes.php'][10] ); // always remove the themes editor 仍然在这个文件中，第1128行: 1if &#40; strpos&#40; $_SERVER&#91;'PHP_SELF'&#93;, $page &#41; &#41; &#123; 替换成 1if &#40; strpos&#40; [...]]]></description>
			<content:encoded><![CDATA[<p>由于 BuddyPress 是基于 WPMU，因此后台和 WPMU 一样隐藏并禁用了 WP 原生的 theme editor，如果想在 BuddyPress 里使用 WP 原生的 theme editor，只要遵循以下步骤 (基于 BuddyPress 1.1.2/WPMU 2.8.5.2):</p>
<ol>
<li>注释掉 /wp-admin/includes/mu.php 第556行:
<div class="codecolorer-container php default" style="border:1px solid #9F9F9F;"><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/unset"><span style="color: #990000;">unset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$submenu</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'themes.php'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// always remove the themes editor</span></div></td></tr></tbody></table></div>
<p>替换成</p>
<div class="codecolorer-container php default" style="border:1px solid #9F9F9F;"><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;">//unset( $submenu['themes.php'][10] ); // always remove the themes editor</span></div></td></tr></tbody></table></div>
</li>
<li>仍然在这个文件中，第1128行:
<div class="codecolorer-container php default" style="border:1px solid #9F9F9F;"><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> <a href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_SELF'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$page</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></td></tr></tbody></table></div>
<p>替换成</p>
<div class="codecolorer-container php default" style="border:1px solid #9F9F9F;"><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> <a href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_SELF'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$page</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>is_site_admin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></td></tr></tbody></table></div>
</li>
</ol>
<p>这样可以确保只有在站点管理员 (Site Admin) 的后台界面才显示并激活原生的 theme editor。</p>
<p>另外，如果同时注释掉第555行:</p>
<ul>
<li>
<div class="codecolorer-container php default" style="border:1px solid #9F9F9F;"><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/unset"><span style="color: #990000;">unset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$submenu</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'plugins.php'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">15</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// always remove the plugin editor</span></div></td></tr></tbody></table></div>
<p>替换成</p>
<div class="codecolorer-container php default" style="border:1px solid #9F9F9F;"><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;">//unset( $submenu['plugins.php'][15] ); // always remove the plugin editor</span></div></td></tr></tbody></table></div>
</li>
</ul>
<p>那么可以同时激活原生的 plugin editor, ooops  <img src='http://henkude.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>参考: <a href="http://mu.wordpress.org/forums/topic/13318" target="_blank">http://mu.wordpress.org/forums/topic/13318</a></p>
<p><span style="color: #ff0000"><strong>Update:</strong></span> 以上代码位置在 BuddyPress 1.1.2/WPMU 2.8.6 没有变动。</p>
<div class="shr-publisher-71"></div>]]></content:encoded>
			<wfw:commentRss>http://henkude.com/blog/2009/11/17/%e5%a6%82%e4%bd%95%e5%9c%a8-buddypress-%e4%b8%ad%e5%90%af%e7%94%a8-wp-%e5%8e%9f%e7%94%9f%e7%9a%84-theme-editor/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

