Blog

如何在 BuddyPress 中启用 WP 原生的 theme editor

由于 BuddyPress 是基于 WPMU,因此后台和 WPMU 一样隐藏并禁用了 WP 原生的 theme editor,如果想在 BuddyPress 里使用 WP 原生的 theme editor,只要遵循以下步骤 (基于 BuddyPress 1.1.2/WPMU 2.8.5.2):

  1. 注释掉 /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
  2. 仍然在这个文件中,第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 没有变动。

有 1 篇 “如何在 BuddyPress 中启用 WP 原生的 theme editor” 的评论

  1. [...] 前面有介绍过如何在 BuddyPress 控制面板中唤回失落的 theme editor 和 pluin editor 链接,经过一番查询,终于寻获一个最安全的方案,无需触碰 core code,算是最好的 hack 了,实际上是用了 WPMU 默认加载  mu-plugins 的办法,步骤十分之简便,只需将下列代码添加到一个空的 PHP 文件: 12345<?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( "<strong>主题编辑器</strong>", "<strong>主题编辑器</strong>", "edit_themes", "theme-editor.php");' )); add_action( '_admin_menu', create_function('$plugin_menu', 'return add_submenu_page( "plugins.php", "<strong>插件编辑器</strong>", "<strong>插件编辑器</strong>", "edit_plugins", "plugin-editor.php");' )); ?> [...]

发表评论

Twitter 用户
请点击下方按钮并使用你的 Twitter 帐号信息登录本站