Skip to:
Content

BuddyPress.org

Ticket #3219: 3219.2.patch

File 3219.2.patch, 15.1 KB (added by boonebgorges, 14 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 { 
    10041004                        require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-loader.php' );
    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 );
    10101010
    function bp_core_setup_wizard_init() { 
    10551055
    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 ) {
    10611061        global $wpdb;
    add_action( 'bp_admin_notices', 'bp_core_wizard_message' ); 
    11501150// Alter thickbox screens so the entire plugin download and install
    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">
    11561156                jQuery('p.action-button a').attr( 'target', '' );
    function bp_core_update_add_admin_menu() { 
    12001200        // Add a hook for css/js
    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() {
    12061206        if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG )
    function bp_core_update_get_page_meta() { 
    12531253        return apply_filters( 'bp_core_update_get_page_meta', $blog_page_ids );
    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
    12581273 *
    function bp_core_update_nag() { 
    12691284        if ( 'admin.php' == $pagenow && ( empty( $_GET['page'] ) || 'bp-wizard' == $_GET['page'] ) )
    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 ) {
    12751290                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
    function bp_core_activation_notice() { 
    360378                        $edit_pages_links[] = sprintf( '<a href="%1$s">%2$s</a>', admin_url( 'post.php?action=edit&post=' . $op['id'] ), $op['title'] );
    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 );
    366386        }
    function bp_core_activation_notice() { 
    403423        }
    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 );
    409431        }
  • 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