Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/10/2011 03:58:53 PM (15 years ago)
Author:
boonebgorges
Message:

Introduces bp_core_do_network_admin() and bp_core_admin_hook() for better BP_ENABLE_MULTIBLOG and multinetwork admin support. Changes BP admin menu to load in slot 3, so as not to override Dashboard menu on site admin. Props wpmuguru for help testing and thinking through

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-functions.php

    r4400 r4482  
    160160}
    161161
     162function bp_core_do_network_admin() {
     163        $do_network_admin = false;
     164       
     165        if ( is_multisite() && ( !defined( 'BP_ENABLE_MULTIBLOG' ) || !BP_ENABLE_MULTIBLOG ) )
     166                $do_network_admin = true;
     167       
     168        return apply_filters( 'bp_core_do_network_admin', $do_network_admin );
     169}
     170
     171function bp_core_admin_hook() {
     172        $hook = bp_core_do_network_admin() ? 'network_admin_menu' : 'admin_menu';
     173       
     174        return apply_filters( 'bp_core_admin_hook', $hook );
     175}
     176
    162177/**
    163178 * Initializes the wp-admin area "BuddyPress" menus and sub menus.
     
    169184        if ( !is_super_admin() )
    170185                return false;
     186       
     187        add_action( bp_core_admin_hook(), 'bp_core_add_admin_menu', 9 );
    171188
    172189        require ( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-admin.php' );
    173190}
    174 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_core_admin_menu_init' );
     191add_action( 'bp_init', 'bp_core_admin_menu_init' );
    175192
    176193/**
     
    194211
    195212        // Add the administration tab under the "Site Admin" tab for site administrators
    196         $hooks[] = add_menu_page( __( 'BuddyPress', 'buddypress' ), __( 'BuddyPress', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_component_setup', '', 2 );
     213        $hooks[] = add_menu_page( __( 'BuddyPress', 'buddypress' ), __( 'BuddyPress', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_component_setup', '', 4 );
    197214
    198215        $hooks[] = add_submenu_page( 'bp-general-settings', __( 'Components', 'buddypress' ), __( 'Components', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_component_setup'  );
     
    203220                add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );
    204221}
    205 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_core_add_admin_menu', 9 );
    206222
    207223/**
     
    225241                return;
    226242       
    227         // On multisite installs, don't show on the Site Admin of a non-root blog
    228         if ( !bp_is_root_blog() )
     243        // On multisite installs, don't show on the Site Admin of a non-root blog, unless
     244        // do_network_admin is overridden
     245        if ( is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog() )
    229246                return;
    230247               
     
    284301        if ( !is_super_admin() )
    285302                return;
    286        
    287         // On multisite installs, don't log on a non-root blog
    288         if ( !bp_is_root_blog() )
     303               
     304        // On multisite installs, don't load on a non-root blog, unless do_network_admin is
     305        // overridden
     306        if ( is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog() )
    289307                return;
    290308               
     
    361379                }
    362380               
    363                 $notice = sprintf( __( 'Some of your WordPress pages are linked to BuddyPress components that have been disabled. These pages may continue to show up in your site navigation. Consider <a href="%1$s">reactivating the components</a>, or unpublishing the pages: <strong>%2$s</strong>', 'buddypress' ), network_admin_url( 'admin.php?page=bp-general-settings' ), implode( ', ', $edit_pages_links ) );
     381                $admin_url = bp_core_do_network_admin() ? network_admin_url( 'admin.php?page=bp-general-settings' ) : admin_url( 'admin.php?page=bp-general-settings' );
     382               
     383                $notice = sprintf( __( 'Some of your WordPress pages are linked to BuddyPress components that have been disabled. These pages may continue to show up in your site navigation. Consider <a href="%1$s">reactivating the components</a>, or unpublishing the pages: <strong>%2$s</strong>', 'buddypress' ), $admin_url, implode( ', ', $edit_pages_links ) );
    364384               
    365385                bp_core_add_admin_notice( $notice );
     
    404424       
    405425        if ( !empty( $orphaned_components ) ) {
    406                 $notice = sprintf( __( 'Some BuddyPress components must be associated with WordPress pages for your site to work properly. The following components are missing their required WP pages: <strong>%1$s</strong>. Visit the <a href="%2$s">BuddyPress Components</a> panel, where you can either deactivate unused components or complete the page setup.', 'buddypress' ), implode( ', ', $orphaned_components ), network_admin_url( 'admin.php?page=bp-general-settings' ) );
     426                $admin_url = bp_core_do_network_admin() ? network_admin_url( 'admin.php?page=bp-general-settings' ) : admin_url( 'admin.php?page=bp-general-settings' );
     427               
     428                $notice = sprintf( __( 'Some BuddyPress components must be associated with WordPress pages for your site to work properly. The following components are missing their required WP pages: <strong>%1$s</strong>. Visit the <a href="%2$s">BuddyPress Components</a> panel, where you can either deactivate unused components or complete the page setup.', 'buddypress' ), implode( ', ', $orphaned_components ), $admin_url );
    407429               
    408430                bp_core_add_admin_notice( $notice );
Note: See TracChangeset for help on using the changeset viewer.