Blog
You are browsing the archive for hack.
十一月 18, 2009
前面有介绍过如何在 BuddyPress 控制面板中唤回失落的 theme editor 和 plugin editor 链接,经过一番查询,终于寻获一个最安全的方案,无需触碰 core code,算是最好的 hack 了,实际上是用了 WPMU 默认加载 mu-plugins 的办法,步骤十分之简便,只需将下列代码添加到一个空的 PHP 文件:
1 2 3 4 5
| <?php
add_action ( 'admin_init', create_function('$pages', 'if(is_site_admin()) return remove_action("admin_init","disable_some_pages");'),1);
add_action ( '_admin_menu', create_function('$theme_menu', 'return add_theme_page( "主题编辑器", "主题编辑器", "edit_themes", "theme-editor.php");' ));
add_action ( '_admin_menu', create_function('$plugin_menu', 'return add_submenu_page( "plugins.php", "插件编辑器", "插件编辑器", "edit_plugins", "plugin-editor.php");' ));
?> |
代码中的中文单词可以换成你自己的翻译,然后保存为 .php 文件 (注意文件编码于主程序安装编码一致),文件名随意取,比如我用 give_admin_theme_editor_plugin_editor.php,长是长了点,一目了然,呵呵。最后把文件上传到 /wp-content/mu-plugins/ 里,万事大吉。
via
Posted in BuddyPress | No Comments »
十一月 17, 2009
由于 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行:
1
| unset( $submenu['themes.php'][10] ); // always remove the themes editor |
替换成
1
| //unset( $submenu['themes.php'][10] ); // always remove the themes editor |
- 仍然在这个文件中,第1128行:
1
| if ( strpos( $_SERVER['PHP_SELF'], $page ) ) { |
替换成
1
| if ( strpos( $_SERVER['PHP_SELF'], $page ) && !is_site_admin () ) { |
这样可以确保只有在站点管理员 (Site Admin) 的后台界面才显示并激活原生的 theme editor。
另外,如果同时注释掉第555行:
-
1
| unset( $submenu['plugins.php'][15] ); // always remove the plugin editor |
替换成
1
| //unset( $submenu['plugins.php'][15] ); // always remove the plugin editor |
那么可以同时激活原生的 plugin editor, ooops
参考: http://mu.wordpress.org/forums/topic/13318
Update: 以上代码位置在 BuddyPress 1.1.2/WPMU 2.8.6 没有变动。
Posted in BuddyPress | 1 Comment »
近期评论