Skip to:
Content

BuddyPress.org

Changeset 4482


Ignore:
Timestamp:
06/10/2011 03:58:53 PM (13 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

Location:
trunk
Files:
6 edited

Legend:

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

    r4466 r4482  
    1717 * @since {@internal Unknown}}
    1818 */
    19 function bp_core_admin_dashboard() { ?>
     19function bp_core_admin_dashboard() {
     20    $base_url = bp_core_do_network_admin() ? network_admin_url( 'admin.php' ) : admin_url( 'admin.php' );
     21   
     22    $action = add_query_arg( array( 'page' => 'bp-general-settings' ), $base_url );
     23    ?>
    2024    <div class="wrap" id="bp-admin">
    2125
     
    2731        <?php do_action( 'bp_admin_notices' ); ?>
    2832
    29         <form action="<?php echo network_admin_url( 'admin.php?page=bp-general-settings' ) ?>" method="post" id="bp-admin-form">
     33        <form action="<?php echo $action ?>" method="post" id="bp-admin-form">
    3034            <div id="bp-admin-content">
    3135                <p>[TODO: All sorts of awesome things will go here. Latest plugins and themes, stats, version check, support topics, news, tips]</p>
     
    194198        }
    195199
    196         wp_redirect( network_admin_url( add_query_arg( array( 'page' => 'bp-general-settings', 'updated' => 'true' ), 'admin.php' ) ) );
     200        $base_url = bp_core_do_network_admin() ? network_admin_url( 'admin.php' ) : admin_url( 'admin.php' );
     201
     202        wp_redirect( add_query_arg( array( 'page' => 'bp-general-settings', 'updated' => 'true' ), $base_url ) );
    197203    }
    198204}
     
    357363    global $bp;
    358364   
    359     if ( !bp_is_root_blog() ) {
    360         $bp->is_switched = 1;
    361         switch_to_blog( BP_ROOT_BLOG );
    362     }
    363        
    364365    // Get the existing WP pages
    365366    $existing_pages = bp_core_get_page_meta();
     
    449450
    450451    <?php
    451    
    452     if ( isset( $bp->is_switched ) ) {
    453         restore_current_blog();
    454         unset( $bp->is_switched );
    455     }
    456452}
    457453
  • trunk/bp-core/admin/bp-core-update.php

    r4466 r4482  
    146146                $step_count  = count( $this->steps ) - 1;
    147147                $wiz_or_set  = $this->current_step >= $step_count ? 'bp-general-settings' : 'bp-wizard';
    148                 $form_action = is_multisite() ? network_admin_url( add_query_arg( array( 'page' => $wiz_or_set ), 'admin.php' ) ) : admin_url( add_query_arg( array( 'page' => $wiz_or_set ), 'admin.php' ) );
     148                $form_action = bp_core_update_do_network_admin() ? network_admin_url( add_query_arg( array( 'page' => $wiz_or_set ), 'admin.php' ) ) : admin_url( add_query_arg( array( 'page' => $wiz_or_set ), 'admin.php' ) );
    149149            ?>
    150150
     
    10051005
    10061006            // Redirect to the BuddyPress dashboard
    1007             $redirect = is_multisite() ? add_query_arg( array( 'page' => 'bp-general-settings' ), network_admin_url( 'admin.php' ) ) : add_query_arg( array( 'page' => 'bp-general-settings' ), admin_url( 'admin.php' ) );
     1007            $redirect = bp_core_update_do_network_admin() ? add_query_arg( array( 'page' => 'bp-general-settings' ), network_admin_url( 'admin.php' ) ) : add_query_arg( array( 'page' => 'bp-general-settings' ), admin_url( 'admin.php' ) );
    10081008
    10091009            wp_redirect( $redirect );
     
    10561056    $bp_wizard = new BP_Core_Setup_Wizard;
    10571057}
    1058 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_core_setup_wizard_init', 7 );
     1058add_action( bp_core_update_admin_hook(), 'bp_core_setup_wizard_init', 7 );
    10591059
    10601060function bp_core_install( $active_components = false ) {
     
    11511151// interface is contained within.
    11521152function bp_core_wizard_thickbox() {
    1153     $form_action = is_multisite() ? network_admin_url( add_query_arg( array( 'page' => 'bp-wizard', 'updated' => '1' ), 'admin.php' ) ) : admin_url( add_query_arg( array( 'page' => 'bp-wizard', 'updated' => '1' ), 'admin.php' ) ); ?>
     1153    $form_action = bp_core_update_do_network_admin() ? network_admin_url( add_query_arg( array( 'page' => 'bp-wizard', 'updated' => '1' ), 'admin.php' ) ) : admin_url( add_query_arg( array( 'page' => 'bp-wizard', 'updated' => '1' ), 'admin.php' ) ); ?>
    11541154
    11551155    <script type="text/javascript">
     
    12011201    add_action( "admin_print_styles-$hook", 'bp_core_update_add_admin_menu_styles' );
    12021202}
    1203 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu',  'bp_core_update_add_admin_menu', 9 );
     1203add_action( bp_core_update_admin_hook(),  'bp_core_update_add_admin_menu', 9 );
    12041204
    12051205function bp_core_update_add_admin_menu_styles() {
     
    12541254}
    12551255
     1256function bp_core_update_do_network_admin() {
     1257    $do_network_admin = false;
     1258   
     1259    if ( is_multisite() && ( !defined( 'BP_ENABLE_MULTIBLOG' ) || !BP_ENABLE_MULTIBLOG ) )
     1260        $do_network_admin = true;
     1261   
     1262    return apply_filters( 'bp_core_do_network_admin', $do_network_admin );
     1263}
     1264
     1265function bp_core_update_admin_hook() {
     1266    $hook = bp_core_update_do_network_admin() ? 'network_admin_menu' : 'admin_menu';
     1267   
     1268    return apply_filters( 'bp_core_admin_hook', $hook );
     1269}
     1270
    12561271/**
    12571272 * Adds an admin nag about running the BP upgrade/install wizard
     
    12701285        return;
    12711286
    1272     $url = is_multisite() ? network_admin_url( 'admin.php?page=bp-wizard' ) : admin_url( 'admin.php?page=bp-wizard' );
     1287    $url = bp_core_update_do_network_admin() ? network_admin_url( 'admin.php?page=bp-wizard' ) : admin_url( 'admin.php?page=bp-wizard' );
    12731288
    12741289    switch( $bp->maintenence_mode ) {
  • 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 );
  • trunk/bp-forums/bp-forums-admin.php

    r4421 r4482  
    1111    add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );
    1212}
    13 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_forums_add_admin_menu' );
     13add_action( bp_core_admin_hook(), 'bp_forums_add_admin_menu' );
    1414
    1515function bp_forums_bbpress_admin() {
    16     global $bp; ?>
     16    global $bp;
     17   
     18    $base_url = bp_core_do_network_admin() ? network_admin_url( 'admin.php' ) : admin_url( 'admin.php' );
     19   
     20    $action = add_query_arg( array( 'page' => 'bb-forums-setup', 'reinstall' => '1' ), $base_url );
     21   
     22    ?>
    1723
    1824    <div class="wrap">
     
    3642        else : ?>
    3743
    38             <p><?php printf( __( 'bbPress forum integration in BuddyPress has been set up correctly. If you are having problems you can <a href="%s" title="Reinstall bbPress">re-install</a>', 'buddypress' ), network_admin_url( 'admin.php?page=bb-forums-setup&reinstall=1' ) ); ?>
     44            <p><?php printf( __( 'bbPress forum integration in BuddyPress has been set up correctly. If you are having problems you can <a href="%s" title="Reinstall bbPress">re-install</a>.', 'buddypress' ), $action ); ?>
    3945            <p><?php _e( 'NOTE: The forums directory will only work if your bbPress tables are in the same database as your WordPress tables. If you are not using an existing bbPress install you can ignore this message.', 'buddypress' ) ?></p>
    4046
  • trunk/bp-xprofile/bp-xprofile-buddybar.php

    r4400 r4482  
    2525    add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );
    2626}
    27 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'xprofile_add_admin_menu' );
     27add_action( bp_core_admin_hook(), 'xprofile_add_admin_menu' );
    2828
    2929/**
  • trunk/bp-xprofile/bp-xprofile-cssjs.php

    r3777 r4482  
    88    }
    99}
    10 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'xprofile_add_admin_css' );
     10add_action( bp_core_admin_hook(), 'xprofile_add_admin_css' );
    1111
    1212function xprofile_add_admin_js() {
     
    2525    }
    2626}
    27 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'xprofile_add_admin_js', 1 );
     27add_action( bp_core_admin_hook(), 'xprofile_add_admin_js', 1 );
    2828?>
Note: See TracChangeset for help on using the changeset viewer.