Skip to:
Content

BuddyPress.org

Ticket #3219: 3219.1.patch

File 3219.1.patch, 12.8 KB (added by boonebgorges, 13 years ago)
  • bp-core/admin/bp-core-admin.php

    add_action( 'in_plugin_update_message-buddypress/bp-loader.php', 'bp_core_update 
    1616 * @package BuddyPress Core
    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
    2226                <div id="bp-admin-header">
    function bp_core_admin_dashboard() { ?> 
    2630
    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>
    3236                        </div>
    function bp_core_admin_component_setup_handler() { 
    193197                        bp_core_update_page_meta( $directory_pages );
    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}
    199205add_action( 'admin_init', 'bp_core_admin_component_setup_handler' );
    function bp_core_admin_component_options() { 
    356362function bp_core_admin_page_options() {
    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();
    366367
    function bp_core_admin_page_options() { 
    448449        </table>
    449450
    450451        <?php
    451        
    452         if ( isset( $bp->is_switched ) ) {
    453                 restore_current_blog();
    454                 unset( $bp->is_switched );
    455         }
    456452}
    457453
    458454/**
  • bp-core/admin/bp-core-update.php

    class BP_Core_Setup_Wizard { 
    145145
    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
    151151                        <form action="<?php echo $form_action; ?>" method="post" id="bp-admin-form">
    class BP_Core_Setup_Wizard { 
    10021002                        require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-loader.php' );
    10031003
    10041004                        // Redirect to the BuddyPress dashboard
    1005                         $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' ) );
     1005                        $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' ) );
    10061006
    10071007                        wp_redirect( $redirect );
    10081008
    function bp_core_setup_wizard_init() { 
    10531053
    10541054        $bp_wizard = new BP_Core_Setup_Wizard;
    10551055}
    1056 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_core_setup_wizard_init', 7 );
     1056add_action( bp_core_update_admin_hook(), 'bp_core_setup_wizard_init', 7 );
    10571057
    10581058function bp_core_install( $active_components = false ) {
    10591059        global $wpdb;
    add_action( 'bp_admin_notices', 'bp_core_wizard_message' ); 
    11471147// Alter thickbox screens so the entire plugin download and install
    11481148// interface is contained within.
    11491149function bp_core_wizard_thickbox() {
    1150         $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' ) ); ?>
     1150        $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' ) ); ?>
    11511151
    11521152        <script type="text/javascript">
    11531153                jQuery('p.action-button a').attr( 'target', '' );
    function bp_core_update_add_admin_menu() { 
    11971197        // Add a hook for css/js
    11981198        add_action( "admin_print_styles-$hook", 'bp_core_update_add_admin_menu_styles' );
    11991199}
    1200 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu',  'bp_core_update_add_admin_menu', 9 );
     1200add_action( bp_core_update_admin_hook(),  'bp_core_update_add_admin_menu', 9 );
    12011201
    12021202function bp_core_update_add_admin_menu_styles() {
    12031203        if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG )
    function bp_core_update_get_page_meta() { 
    12501250        return apply_filters( 'bp_core_update_get_page_meta', $blog_page_ids );
    12511251}
    12521252
     1253function bp_core_update_do_network_admin() {
     1254        $do_network_admin = false;
     1255       
     1256        if ( is_multisite() && ( !defined( 'BP_ENABLE_MULTIBLOG' ) || !BP_ENABLE_MULTIBLOG ) )
     1257                $do_network_admin = true;
     1258       
     1259        return apply_filters( 'bp_core_do_network_admin', $do_network_admin );
     1260}
     1261
     1262function bp_core_update_admin_hook() {
     1263        $hook = bp_core_update_do_network_admin() ? 'network_admin_menu' : 'admin_menu';
     1264       
     1265        return apply_filters( 'bp_core_admin_hook', $hook );
     1266}
     1267
    12531268/**
    12541269 * Adds an admin nag about running the BP upgrade/install wizard
    12551270 *
    function bp_core_update_nag() { 
    12661281        if ( 'admin.php' == $pagenow && ( empty( $_GET['page'] ) || 'bp-wizard' == $_GET['page'] ) )
    12671282                return;
    12681283
    1269         $url = is_multisite() ? network_admin_url( 'admin.php?page=bp-wizard' ) : admin_url( 'admin.php?page=bp-wizard' );
     1284        $url = bp_core_update_do_network_admin() ? network_admin_url( 'admin.php?page=bp-wizard' ) : admin_url( 'admin.php?page=bp-wizard' );
    12701285
    12711286        switch( $bp->maintenence_mode ) {
    12721287                case 'update':
  • bp-core/bp-core-functions.php

    function bp_core_component_slug_from_root_slug( $root_slug ) { 
    159159        return apply_filters( 'bp_core_component_slug_from_root_slug', $slug, $root_slug );
    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.
    164179 *
    function bp_core_component_slug_from_root_slug( $root_slug ) { 
    168183function bp_core_admin_menu_init() {
    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/**
    177194 * Adds the "BuddyPress" admin submenu item to the Site Admin tab.
    function bp_core_add_admin_menu() { 
    202219        foreach( $hooks as $hook )
    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/**
    208224 * Print admin messages to admin_notices or network_admin_notices
    function bp_core_print_admin_notices() { 
    224240        if ( !is_super_admin() )
    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               
    231248        // Show the messages
    function bp_core_activation_notice() { 
    283300        // Only the super admin gets warnings
    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               
    291309        // Don't show these messages during setup or upgrade
  • bp-forums/bp-forums-admin.php

    function bp_forums_add_admin_menu() { 
    1010        $hook = add_submenu_page( 'bp-general-settings', __( 'Forums Setup', 'buddypress' ), __( 'Forums Setup', 'buddypress' ), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin" );
    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( is_multisite() && bp_core_do_network_admin() ? 'network_admin_menu' : 'admin_menu', '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">
    1925                <?php screen_icon( 'buddypress' ); ?>
    function bp_forums_bbpress_admin() { 
    3541
    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
    4147                <?php endif; ?>
  • bp-xprofile/bp-xprofile-buddybar.php

    function xprofile_add_admin_menu() { 
    2424        $hook = add_submenu_page( 'bp-general-settings', __( 'Profile Fields', 'buddypress' ), __( 'Profile Fields', 'buddypress' ), 'manage_options', 'bp-profile-setup', 'xprofile_admin' );
    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/**
    3030 * Adds an admin bar menu to any profile page providing site admin options
  • bp-xprofile/bp-xprofile-cssjs.php

    function xprofile_add_admin_css() { 
    77                        wp_enqueue_style( 'xprofile-admin-css', BP_PLUGIN_URL . '/bp-xprofile/admin/css/admin.css', array(), BP_VERSION );
    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() {
    1313        if ( !empty( $_GET['page'] ) && strpos( $_GET['page'], 'bp-profile-setup' ) !== false ) {
    function xprofile_add_admin_js() { 
    2424                        wp_enqueue_script( 'xprofile-admin-js', BP_PLUGIN_URL . '/bp-xprofile/admin/js/admin.js', array( 'jquery', 'jquery-ui-sortable' ), BP_VERSION );
    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?>
     29 No newline at end of file