Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/11/2012 08:10:10 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Tweak the BuddyPress installation and update wizard:

  • Rename new 'bp-force-buddybar' option to '_bp_force_buddybar' to fit naming scheme
  • Remove single-site to multi-site wizard step, since the page-nag will take care of this
  • Remove any previous db versions when updating
  • Use bp_get_option() in bp-core-options.php
File:
1 edited

Legend:

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

    r5717 r5721  
    2727
    2828    /**
    29      * @var int Are we currently network activated
    30      */
    31     var $is_network_activate;
    32 
    33     /**
    3429     * @var string What kind of setup/update are we performing
    3530     */
     
    5247        $this->db_version_raw = !empty( $bp->db_version_raw ) ? (int) $bp->db_version_raw : 0;
    5348
    54         if ( !empty( $bp->is_network_activate ) ) {
    55             $this->is_network_activate = $bp->is_network_activate;
    56 
    57         } elseif ( !$this->current_step() ) {
    58             setcookie( 'bp-wizard-step', 0, time() + 60 * 60 * 24, COOKIEPATH );
    59             $_COOKIE['bp-wizard-step'] = 0;
    60         }
     49        setcookie( 'bp-wizard-step', 0, time() + 60 * 60 * 24, COOKIEPATH );
     50        $_COOKIE['bp-wizard-step'] = 0;
    6151
    6252        $this->db_version   = bp_get_db_version();
    63         $this->setup_type   = !empty( $bp->maintenance_mode ) ? $bp->maintenance_mode : '';
     53        $this->setup_type   = $bp->maintenance_mode;
    6454        $this->current_step = $this->current_step();
    6555
     
    7969            $current_step = (int)$_POST['step'] + 1;
    8070        } else {
    81             if ( !empty( $_COOKIE['bp-wizard-step'] ) )
     71            if ( !empty( $_COOKIE['bp-wizard-step'] ) ) {
    8272                $current_step = $_COOKIE['bp-wizard-step'];
    83             else
     73            } else {
    8474                $current_step = 0;
     75            }
    8576        }
    8677
     
    10495        // Update wizard steps
    10596        } else {
    106             if ( $this->is_network_activate )
    107                 $steps[] = __( 'Multisite Update', 'buddypress' );
    10897
    10998            if ( $this->db_version_raw < (int) $this->db_version )
     
    113102            if ( $this->db_version_raw < 1801 || !bp_core_get_directory_page_ids() ) {
    114103                $steps[] = __( 'Components', 'buddypress' );
    115                 $steps[] = __( 'Pages', 'buddypress' );
     104                $steps[] = __( 'Pages',      'buddypress' );
    116105            }
    117106
     
    134123                break;
    135124
    136             case 'ms_update':
    137                 $result = $this->step_ms_update_save();
    138                 break;
    139 
    140             case 'ms_pages':
    141                 $result = $this->step_ms_update_save();
    142                 break;
    143 
    144125            case 'components':
    145126                $result = $this->step_components_save();
     
    244225                            break;
    245226
    246                         case __( 'Multisite Update', 'buddypress') :
    247                             $this->step_ms_update();
    248                             break;
    249 
    250                         case __( 'Site Directory', 'buddypress') :
    251                             $this->step_ms_update();
    252                             break;
    253 
    254227                        case __( 'Components', 'buddypress') :
    255228                            $this->step_components();
     
    303276    }
    304277
    305     function step_ms_update() {
    306         global $wpdb;
     278    function step_components() {
     279        if ( !current_user_can( 'activate_plugins' ) )
     280            return false;
     281
     282        if ( !function_exists( 'bp_core_admin_components_options' ) )
     283            require ( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-components.php' ); ?>
     284
     285        <p><?php _e( "BuddyPress bundles several individual social components together, each one adding a distinct feature. This first step decides which features are enabled on your site; all features are enabled by default. Don't worry, you can change your mind at any point in the future.", 'buddypress' ); ?></p>
     286
     287        <?php bp_core_admin_components_options(); ?>
     288
     289        <div class="submit clear">
     290            <input type="hidden" name="save" value="components" />
     291            <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ); ?>" />
     292
     293            <?php wp_nonce_field( 'bpwizard_components' ); ?>
     294
     295        </div>
     296
     297    <?php
     298    }
     299
     300    function step_pages() {
     301        global $bp, $wpdb;
    307302
    308303        // Make sure that page info is pulled from bp_get_root_blog_id() (except when in
     
    314309            return false;
    315310
    316         $active_components = bp_get_option( 'bp-active-components' );
    317 
    318         if ( defined( 'BP_BLOGS_SLUG' ) )
    319             $blogs_slug = constant( 'BP_BLOGS_SLUG' );
    320         else
    321             $blogs_slug = 'blogs';
    322 
    323         // Call up old bp-pages to see if a page has been previously linked to Blogs
    324         $existing_pages = bp_get_option( 'bp-pages' );
     311        $existing_pages = bp_core_update_get_page_meta();
     312
     313        // Provide empty indexes to avoid PHP errors with wp_dropdown_pages()
     314        $indexes = array( 'members', 'activity', 'groups', 'forums', 'blogs', 'register', 'activate' );
     315        foreach ( $indexes as $index ) {
     316            if ( !isset( $existing_pages[$index] ) ) {
     317                $existing_pages[$index] = '';
     318            }
     319        }
    325320
    326321        if ( !empty( $existing_pages['blogs'] ) )
     
    328323        else
    329324            $existing_blog_page = '';
     325
     326        // Get active components
     327        $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
     328
     329        // Check for defined slugs
     330        $members_slug    = !empty( $bp->members->slug    ) ? $bp->members->slug    : __( 'members',  'buddypress' );
     331
     332        // Groups
     333        $groups_slug     = !empty( $bp->groups->slug     ) ? $bp->groups->slug     : __( 'groups',   'buddypress' );
     334
     335        // Activity
     336        $activity_slug   = !empty( $bp->activity->slug   ) ? $bp->activity->slug   : __( 'activity', 'buddypress' );
     337
     338        // Forums
     339        $forums_slug     = !empty( $bp->forums->slug     ) ? $bp->forums->slug     : __( 'forums',   'buddypress' );
     340
     341        // Blogs
     342        $blogs_slug      = !empty( $bp->blogs->slug      ) ? $bp->blogs->slug      : __( 'blogs',    'buddypress' );
     343
     344        // Register
     345        $register_slug   = !empty( $bp->register->slug   ) ? $bp->register->slug   : __( 'register', 'buddypress' );
     346
     347        // Activation
     348        $activation_slug = !empty( $bp->activation->slug ) ? $bp->activation->slug : __( 'activate', 'buddypress' );
     349
    330350        ?>
    331351
     
    338358        </script>
    339359
    340         <p><?php printf( __( 'BuddyPress has detected a recent change to WordPress Multisite, which allows members of your community to have their own WordPress sites. You can enable or disable this feature at any time at <a href="%s">Network Options</a>.', 'buddypress' ), network_admin_url( 'settings.php' ) ); ?></p>
    341 
    342         <p><?php __( "Please select the WordPress page you would like to use to display the site directory. You can either choose an existing page or let BuddyPress auto-create a page for you. If you'd like, you can go to manually create pages now, and return to this step when you are finished.", 'buddypress' ) ?></p>
    343 
    344         <p><strong><?php _e( 'Please Note:', 'buddypress' ) ?></strong> <?php _e( "If you have manually added BuddyPress navigation links in your theme you may need to remove these from your header.php to avoid duplicate links.", 'buddypress' ) ?></p>
    345 
    346         <p><?php _e( 'Would you like to enable site tracking, which tracks blog posts and comments from across your network?', 'buddypress' ); ?></p>
    347 
    348         <table class="form-table">
    349 
    350             <tr valign="top">
    351                 <th scope="row"><?php _e( "Enable Site Tracking?", 'buddypress' ) ?></th>
    352 
    353                 <td>
    354                     <label for="bp_components[blogs]">
    355                         <input id="site-tracking-enabled" type="checkbox" id="bp_components[blogs]" name="bp_components[blogs]" value="1"<?php checked( isset( $active_components['blogs'] ) ); ?> />
    356 
    357                         <?php _e( "Track new sites, new posts and new comments across your entire network.", 'buddypress' ) ?>
    358 
    359                     </label>
    360 
    361                 </td>
    362             </tr>
    363 
    364             <tr valign="top" id="site-tracking-page-selector">
    365                 <th scope="row"><?php _e( 'Select a WordPress page for the Sites directory.', 'buddypress' ); ?></th>
    366 
    367                 <td>
    368                     <p><input type="radio" name="bp_pages[blogs]" checked="checked" value="<?php echo $blogs_slug; ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ); ?> <?php echo site_url( $blogs_slug ); ?>/</p>
    369                    
    370                     <?php if ( $page_dropdown = wp_dropdown_pages( "name=bp-blogs-page&echo=0&show_option_none=" . __( '- Select -', 'buddypress' ) . $existing_blog_page ) ) : ?>                 
    371 
    372                         <p><input type="radio" name="bp_pages[blogs]" value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?><?php echo $page_dropdown ?></p>
    373 
    374                     <?php endif ?>
    375                 </td>
    376             </tr>
    377 
    378         </table>
    379 
    380 
    381         <div class="submit clear">
    382             <input type="hidden" name="save" value="ms_update" />
    383             <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ); ?>" />
    384 
    385             <?php wp_nonce_field( 'bpwizard_ms_update' ); ?>
    386 
    387         </div>
    388 
    389         <?php
    390 
    391         restore_current_blog();
    392     }
    393 
    394     function step_components() {
    395         if ( !current_user_can( 'activate_plugins' ) )
    396             return false;
    397 
    398         if ( !function_exists( 'bp_core_admin_components_options' ) )
    399             require ( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-components.php' ); ?>
    400 
    401         <p><?php _e( "BuddyPress bundles several individual social components together, each one adding a distinct feature. This first step decides which features are enabled on your site; all features are enabled by default. Don't worry, you can change your mind at any point in the future.", 'buddypress' ); ?></p>
    402 
    403         <?php bp_core_admin_components_options(); ?>
    404 
    405         <div class="submit clear">
    406             <input type="hidden" name="save" value="components" />
    407             <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ); ?>" />
    408 
    409             <?php wp_nonce_field( 'bpwizard_components' ); ?>
    410 
    411         </div>
    412 
    413     <?php
    414     }
    415 
    416     function step_pages() {
    417         global $bp, $wpdb;
    418 
    419         // Make sure that page info is pulled from bp_get_root_blog_id() (except when in
    420         // multisite mode)
    421         if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != bp_get_root_blog_id() ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) )
    422             switch_to_blog( bp_get_root_blog_id() );
    423 
    424         if ( !current_user_can( 'activate_plugins' ) )
    425             return false;
    426 
    427         $existing_pages = bp_core_update_get_page_meta();
    428 
    429         // Provide empty indexes to avoid PHP errors with wp_dropdown_pages()
    430         $indexes = array( 'members', 'activity', 'groups', 'forums', 'blogs', 'register', 'activate' );
    431         foreach ( $indexes as $index ) {
    432             if ( !isset( $existing_pages[$index] ) )
    433                 $existing_pages[$index] = '';
    434         }
    435 
    436         if ( !empty( $existing_pages['blogs'] ) )
    437             $existing_blog_page = '&selected=' . $existing_pages['blogs'];
    438         else
    439             $existing_blog_page = '';
    440 
    441         // Get active components
    442         $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
    443 
    444         // Check for defined slugs
    445         $members_slug    = !empty( $bp->members->slug    ) ? $bp->members->slug    : __( 'members',  'buddypress' );
    446 
    447         // Groups
    448         $groups_slug     = !empty( $bp->groups->slug     ) ? $bp->groups->slug     : __( 'groups',   'buddypress' );
    449 
    450         // Activity
    451         $activity_slug   = !empty( $bp->activity->slug   ) ? $bp->activity->slug   : __( 'activity', 'buddypress' );
    452 
    453         // Forums
    454         $forums_slug     = !empty( $bp->forums->slug     ) ? $bp->forums->slug     : __( 'forums',   'buddypress' );
    455 
    456         // Blogs
    457         $blogs_slug      = !empty( $bp->blogs->slug      ) ? $bp->blogs->slug      : __( 'blogs',    'buddypress' );
    458 
    459         // Register
    460         $register_slug   = !empty( $bp->register->slug   ) ? $bp->register->slug   : __( 'register', 'buddypress' );
    461 
    462         // Activation
    463         $activation_slug = !empty( $bp->activation->slug ) ? $bp->activation->slug : __( 'activate', 'buddypress' );
    464 
    465         ?>
    466 
    467         <script type="text/javascript">
    468             jQuery( document ).ready( function() {
    469                 jQuery( 'select' ).change( function() {
    470                     jQuery( this ).siblings( 'input[@type=radio]' ).click();
    471                 });
    472             });
    473         </script>
    474 
    475         <p><?php _e( 'BuddyPress now uses WordPress pages to display content. This allows you to easily change the names of pages or move them to a sub page.', 'buddypress' ); ?></p>
    476 
    477         <p><?php _e( 'Either choose an existing page or let BuddyPress auto-create pages for you. To manually create custom pages, come back to this step once you are finished.', 'buddypress' ); ?></p>
    478 
    479         <p><strong><?php _e( 'Please Note:', 'buddypress' ); ?></strong> <?php _e( 'If you have manually added BuddyPress navigation links in your theme you may need to remove these from your header.php to avoid duplicate links.', 'buddypress' ); ?></p>
     360        <p><?php _e( 'BuddyPress uses WordPress pages to display directories. This allows you to easily change their titles and relocate them.', 'buddypress' ); ?></p>
     361
     362        <p><?php _e( 'Choose an existing page, have one auto-created, or create them manually and come back here once you are finished.', 'buddypress' ); ?></p>
    480363
    481364        <table class="form-table">
     
    496379                </td>
    497380            </tr>
    498 
    499             <?php if ( isset( $active_components['activity'] ) ) : ?>
    500 
    501                 <tr valign="top">
    502                     <th scope="row">
    503                         <h5><?php _e( 'Site Activity', 'buddypress' ); ?></h5>
    504                         <p><?php _e( "Displays the activity for the entire site, a member's friends, groups and @mentions.", 'buddypress' ); ?></p>
    505                     </th>
    506                     <td>
    507                         <p><label><input type="radio" name="bp_pages[activity]" <?php checked( empty( $existing_pages['activity'] ) ); ?>  value="<?php echo $activity_slug; ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ); ?> <?php echo home_url( $activity_slug ); ?>/</label></p>
    508                        
    509                         <?php if ( $activity_page_dropdown = wp_dropdown_pages( "name=bp-blogs-page&echo=0&selected={$existing_pages['activity']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?>
    510                             <p><label><input type="radio" name="bp_pages[activity]" <?php checked( !empty( $existing_pages['activity'] ) ); ?> value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $activity_page_dropdown ?></label></p>
    511                         <?php endif ?>
    512                     </td>
    513                 </tr>
    514 
    515             <?php endif; ?>
    516381
    517382            <?php if ( isset( $active_components['groups'] ) ) : ?>
     
    533398            <?php endif; ?>
    534399
     400            <?php /* The Blogs component only needs a directory page when Multisite is enabled */ ?>
     401            <?php if ( is_multisite() && isset( $active_components['blogs'] ) ) : ?>
     402
     403                <tr valign="top">
     404                    <th scope="row">
     405                        <h5><?php _e( 'Blogs', 'buddypress' ); ?></h5>
     406                        <p><?php _e( 'Displays a directory of the blogs in your network.', 'buddypress' ); ?></p>
     407                    </th>
     408                    <td>
     409                        <p><label><input type="radio" name="bp_pages[blogs]" <?php checked( empty( $existing_pages['blogs'] ) ); ?>  value="<?php echo $blogs_slug; ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ); ?> <?php echo home_url( $blogs_slug ); ?>/</label></p>
     410                       
     411                        <?php if ( $blogs_page_dropdown = wp_dropdown_pages( "name=bp-blogs-page&echo=0&selected={$existing_pages['blogs']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?>
     412                            <p><label><input type="radio" name="bp_pages[blogs]" <?php checked( !empty( $existing_pages['blogs'] ) ); ?> value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $blogs_page_dropdown ?></label></p>
     413                        <?php endif ?>
     414                    </td>
     415                </tr>
     416
     417            <?php endif; ?>
     418
     419            <?php if ( isset( $active_components['activity'] ) ) : ?>
     420
     421                <tr valign="top">
     422                    <th scope="row">
     423                        <h5><?php _e( 'Activity', 'buddypress' ); ?></h5>
     424                        <p><?php _e( "Displays the activity for the entire site, a member's friends, groups and @mentions.", 'buddypress' ); ?></p>
     425                    </th>
     426                    <td>
     427                        <p><label><input type="radio" name="bp_pages[activity]" <?php checked( empty( $existing_pages['activity'] ) ); ?>  value="<?php echo $activity_slug; ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ); ?> <?php echo home_url( $activity_slug ); ?>/</label></p>
     428                       
     429                        <?php if ( $activity_page_dropdown = wp_dropdown_pages( "name=bp-blogs-page&echo=0&selected={$existing_pages['activity']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?>
     430                            <p><label><input type="radio" name="bp_pages[activity]" <?php checked( !empty( $existing_pages['activity'] ) ); ?> value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $activity_page_dropdown ?></label></p>
     431                        <?php endif ?>
     432                    </td>
     433                </tr>
     434
     435            <?php endif; ?>
     436
    535437            <?php if ( isset( $active_components['forums'] ) ) : ?>
    536438
     
    545447                        <?php if ( $forums_page_dropdown = wp_dropdown_pages( "name=bp-blogs-page&echo=0&selected={$existing_pages['forums']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?>
    546448                            <p><label><input type="radio" name="bp_pages[forums]" <?php checked( !empty( $existing_pages['forums'] ) ); ?> value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $forums_page_dropdown ?></label></p>
    547                         <?php endif ?>
    548                     </td>
    549                 </tr>
    550 
    551             <?php endif; ?>
    552 
    553             <?php /* The Blogs component only needs a directory page when Multisite is enabled */ ?>
    554             <?php if ( is_multisite() && isset( $active_components['blogs'] ) ) : ?>
    555 
    556                 <tr valign="top">
    557                     <th scope="row">
    558                         <h5><?php _e( 'Sites', 'buddypress' ); ?></h5>
    559                         <p><?php _e( 'Displays a directory of the sites in your network.', 'buddypress' ); ?></p>
    560                     </th>
    561                     <td>
    562                         <p><label><input type="radio" name="bp_pages[blogs]" <?php checked( empty( $existing_pages['blogs'] ) ); ?>  value="<?php echo $blogs_slug; ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ); ?> <?php echo home_url( $blogs_slug ); ?>/</label></p>
    563                        
    564                         <?php if ( $blogs_page_dropdown = wp_dropdown_pages( "name=bp-blogs-page&echo=0&selected={$existing_pages['blogs']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?>
    565                             <p><label><input type="radio" name="bp_pages[blogs]" <?php checked( !empty( $existing_pages['blogs'] ) ); ?> value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $blogs_page_dropdown ?></label></p>
    566449                        <?php endif ?>
    567450                    </td>
     
    622505        // If we're using permalinks already, adjust text accordingly
    623506        if ( !empty( $permalink_structure ) )
    624             $permalink_setup_text = __( 'Congratulations! You are already using pretty permalinks, which BuddyPress requires. If you\'d like to change your settings, you may do so now. If you\'re happy with your current settings, click Save &amp; Next to continue.', 'buddypress' );
     507            $permalink_setup_text = __( 'Your permalink settings are compatible with BuddyPress.', 'buddypress' );
    625508        else
    626             $permalink_setup_text = __( 'To make sure the pages created in the previous step work correctly, pretty permalinks must be active on your site.', 'buddypress' );
     509            $permalink_setup_text = __( 'Pretty permalinks must be active on your site.', 'buddypress' );
    627510
    628511        if ( !got_mod_rewrite() && !iis7_supports_permalinks() )
     
    630513
    631514        <p><?php echo $permalink_setup_text; ?></p>
    632         <p><?php printf( __( 'Please select the permalink setting you would like to use. For more advanced options please visit the <a href="%s">permalink settings page</a> first, and complete this setup wizard later.', 'buddypress' ), admin_url( 'options-permalink.php' ) ); ?>
     515        <p><?php printf( __( 'For more advanced options please visit the <a href="%s">permalink settings page</a> now and come back here later.', 'buddypress' ), admin_url( 'options-permalink.php' ) ); ?>
    633516
    634517        <table class="form-table">
     
    707590        </script>
    708591
    709         <p><?php _e( "BuddyPress introduces a whole range of new screens to display content. To display these screens, you need to decide how you want to handle them in your current theme.", 'buddypress' ); ?></p>
    710 
    711592        <table class="form-table">
    712593            <tr>
     
    716597                </th>
    717598                <td>
    718                     <p><?php _e( 'BuddyPress Default contains everything you need to get up and running out of the box. It supports all features and is highly customizable.', 'buddypress' ); ?></p>
    719                     <p><strong><?php _e( 'This is the best choice if you do not have an existing WordPress theme, or want to start using BuddyPress immediately.', 'buddypress' ); ?></strong></p>
     599                    <p><?php _e( 'The default BuddyPress theme comes with the basics, to get up and running out of the box. It supports all features and is highly customizable.', 'buddypress' ); ?></p>
     600                    <p><strong><?php _e( 'This is the best choice if you want to start using BuddyPress immediately.', 'buddypress' ); ?></strong></p>
    720601                    <p><label><input type="radio" name="theme" value="bp_default" checked="checked" /> <?php _e( 'Yes, please!', 'buddypress' ); ?></label></p>
    721602                </td>
     
    729610                    </th>
    730611                    <td>
    731                         <p><?php _e( "We've found that you already have some other BuddyPress-compatible themes available. To use one of those, pick it from this list.", 'buddypress' ); ?></p>
     612                        <p><?php _e( "You have some other BuddyPress compatible themes available. Pick one of them from this list to use it.", 'buddypress' ); ?></p>
    732613                        <p>
    733614                            <label>
     
    737618
    738619                                <?php foreach( (array) $bp_themes as $theme ) : ?>
     620
    739621                                    <option value="<?php echo $theme['Template'] . ',' . $theme['Stylesheet']; ?>"><?php echo $theme['Name']; ?></option>
     622
    740623                                <?php endforeach; ?>
    741624
     
    749632                <th>
    750633                    <h5><?php _e( 'Manually update current theme', 'buddypress' ); ?></h5>
     634
    751635                    <?php if ( !empty( $screenshot ) ) : ?>
     636
    752637                        <img src="<?php echo esc_url( $screenshot ); ?>" alt="<?php _e( 'Your existing theme', 'buddypress' ); ?>" />
     638
    753639                    <?php endif; ?>
     640
    754641                </th>
    755642                <td>
    756                     <p><?php _e( 'The BuddyPress Template Pack plugin will guide you through the process of manually upgrading your existing WordPress theme. This usually involves following the step-by-step instructions and copying the BuddyPress template files into your theme. This option requires a working knowledge of CSS and HTML, as you will need to tweak the new templates to match your existing theme.', 'buddypress' ); ?></p>
     643                    <p><?php _e( 'The BuddyPress Template Pack will guide you through the process of manually editing your existing theme. It comes with a step-by-step guide and involves copying the BuddyPress template files into your theme. <strong>This option requires knowledge of CSS and HTML.</strong> You will need to tweak the new templates to match your existing theme.', 'buddypress' ); ?></p>
    757644
    758645                    <?php if ( empty( $template_pack_installed ) ) : ?>
     
    776663                <td>
    777664                    <p><?php _e( "You are happy with your current theme and plan on changing it later.", 'buddypress' ); ?></p>
    778                     <p><strong><?php _e( 'This is the best choice if you have a highly customized theme on your site already, and want to later manually integrate BuddyPress into your site.', 'buddypress' ); ?></strong></p>
     665                    <p><strong><?php _e( 'This is the best choice if you have a custom theme already and want to manually integrate BuddyPress later.', 'buddypress' ); ?></strong></p>
    779666
    780667                    <p><label><input type="radio" name="theme" value="do_not_change" /> <?php _e( "Don't change my current theme", 'buddypress' ); ?></label></p>
     
    870757    }
    871758
    872     function step_ms_update_save() {
    873         global $wpdb;
    874 
    875         if ( isset( $_POST['submit'] ) ) {
    876             check_admin_referer( 'bpwizard_ms_update' );
    877 
    878             if ( !$active_components = bp_get_option( 'bp-active-components' ) )
    879                 $active_components = array();
    880 
    881             // Transfer important settings from blog options to site options
    882             $options = array(
    883                 '_bp_db_version'       => $this->db_version,
    884                 'bp-active-components' => $active_components,
    885                 'avatar-default'       => get_option( 'avatar-default' )
    886             );
    887             bp_core_activate_site_options( $options );
    888 
    889             if ( isset( $_POST['bp_components']['blogs'] ) ) {
    890                 $active_components['blogs'] = 1;
    891 
    892                 // Make sure that the pages are created on the bp_get_root_blog_id(), no matter which Dashboard the setup is being run on
    893                 if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != bp_get_root_blog_id() ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) )
    894                     switch_to_blog( bp_get_root_blog_id() );
    895 
    896                 // Move bp-pages data from the blog options table to site options
    897                 $existing_pages = bp_get_option( 'bp-pages' );
    898                 $bp_pages       = $this->setup_pages( (array)$_POST['bp_pages'] );
    899                 $bp_pages       = array_merge( (array)$existing_pages, (array)$bp_pages );
    900 
    901                 bp_update_option( 'bp-pages', $bp_pages );
    902 
    903                 if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != bp_get_root_blog_id() ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) )
    904                     restore_current_blog();
    905 
    906                 bp_core_install( $active_components );
    907             }
    908 
    909             // Delete the old site option
    910             delete_site_option( 'bp-db-version' );
    911 
    912             // Update the active components
    913             bp_update_option( 'bp-active-components', $active_components );
    914 
    915             return true;
    916         }
    917 
    918         return false;
    919     }
    920 
    921 
    922759    function step_components_save() {
    923760
     
    1139976            check_admin_referer( 'bpwizard_admin_bar' );
    1140977
    1141             if ( !empty( $_POST['keep_buddybar'] ) )
    1142                 bp_update_option( 'bp-force-buddybar', 1 );
     978            if ( !empty( $_POST['keep_buddybar'] ) ) {
     979                bp_update_option( '_bp_force_buddybar', 1 );
     980            }
    1143981
    1144982            return true;
     
    1149987
    1150988    function step_finish_save() {
     989
    1151990        if ( isset( $_POST['submit'] ) ) {
     991
    1152992            check_admin_referer( 'bpwizard_finish' );
     993
     994            // Delete possible site options
     995            delete_site_option( 'bp-db-version'       );
     996            delete_site_option( '_bp_db_version'      );
     997            delete_site_option( 'bp-core-db-version'  );
     998            delete_site_option( '_bp-core-db-version' );
     999
     1000            // Delete possible blog options
     1001            delete_blog_option( bp_get_root_blog_id(), 'bp-db-version'       );
     1002            delete_blog_option( bp_get_root_blog_id(), 'bp-core-db-version'  );
     1003            delete_site_option( bp_get_root_blog_id(), '_bp-core-db-version' );
     1004            delete_site_option( bp_get_root_blog_id(), '_bp_db_version'      );
    11531005
    11541006            // Update the DB version in the database
    11551007            // Stored in sitemeta. Do not use bp_update_option()
    1156             update_site_option( 'bp-db-version', $this->db_version );
    1157             delete_site_option( 'bp-core-db-version' );
     1008            update_blog_option( bp_get_root_blog_id(), '_bp_db_version', $this->db_version );
    11581009
    11591010            // Delete the setup cookie
     
    11681019            $redirect = bp_core_update_do_network_admin() ? add_query_arg( array( 'page' => 'bp-components' ), network_admin_url( 'settings.php' ) ) : add_query_arg( array( 'page' => 'bp-components' ), admin_url( 'options-general.php' ) );
    11691020
    1170             wp_redirect( $redirect );
     1021            wp_safe_redirect( $redirect );
    11711022
    11721023            return true;
     
    13321183add_action( 'admin_footer', 'bp_core_wizard_thickbox' );
    13331184
     1185function bp_core_update_add_admin_menu_styles() {
     1186    if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
     1187        wp_enqueue_style( 'bp-admin-css', apply_filters( 'bp_core_admin_css', plugins_url( '/buddypress' ) . '/bp-core/css/admin.dev.css' ), array(), '20110723' );
     1188        wp_enqueue_script( 'bp-update-js', apply_filters( 'bp_core_update_js', plugins_url( '/buddypress' ) . '/bp-core/js/update.dev.js' ), array( 'jquery' ), '20110723' );
     1189    } else {
     1190        wp_enqueue_style( 'bp-admin-css', apply_filters( 'bp_core_admin_css', plugins_url( '/buddypress' ) . '/bp-core/css/admin.css' ), array(), '20110723' );
     1191        wp_enqueue_script( 'bp-update-js', apply_filters( 'bp_core_update_js', plugins_url( '/buddypress' ) . '/bp-core/js/update.js' ), array( 'jquery' ), '20110723' );
     1192    }
     1193
     1194    wp_enqueue_script( 'thickbox' );
     1195    wp_enqueue_style( 'thickbox' ); ?>
     1196
     1197    <style type="text/css">
     1198        /* Wizard Icon */
     1199        ul#adminmenu li.toplevel_page_bp-wizard .wp-menu-image a img { display: none; }
     1200        ul#adminmenu li.toplevel_page_bp-wizard .wp-menu-image a { background-image: url( <?php echo plugins_url( 'buddypress/bp-core/images/admin_menu_icon.png' ) ?> ) !important; background-position: -1px -32px; }
     1201        ul#adminmenu li.toplevel_page_bp-wizard:hover .wp-menu-image a,
     1202        ul#adminmenu li.toplevel_page_bp-wizard.wp-has-current-submenu .wp-menu-image a {
     1203            background-position: -1px 0;
     1204        }
     1205
     1206        /* Settings Icon */
     1207        ul#adminmenu li.toplevel_page_bp-general-config .wp-menu-image a img { display: none; }
     1208        ul#adminmenu li.toplevel_page_bp-general-config .wp-menu-image a { background-image: url( <?php echo plugins_url( 'buddypress/bp-core/images/admin_menu_icon.png' ) ?> ) !important; background-position: -1px -32px; }
     1209        ul#adminmenu li.toplevel_page_bp-general-config:hover .wp-menu-image a,
     1210        ul#adminmenu li.toplevel_page_bp-general-config.wp-has-current-submenu .wp-menu-image a {
     1211            background-position: -1px 0;
     1212        }
     1213    </style>
     1214
     1215<?php
     1216}
     1217add_action( 'admin_head', 'bp_core_update_add_admin_menu_styles' );
     1218
     1219/**
     1220 * Fetches BP pages from the meta table
     1221 *
     1222 * @package BuddyPress Core
     1223 * @since 1.5
     1224 *
     1225 * @return array $page_ids
     1226 */
     1227function bp_core_update_get_page_meta() {
     1228    $page_ids = bp_get_option( 'bp-pages' );
     1229    if ( empty( $page_ids ) )
     1230        $page_ids = array();
     1231
     1232    return apply_filters( 'bp_core_update_get_page_meta', $page_ids );
     1233}
     1234
     1235function bp_core_update_do_network_admin() {
     1236    $do_network_admin = false;
     1237
     1238    if ( is_multisite() && ( !defined( 'BP_ENABLE_MULTIBLOG' ) || !BP_ENABLE_MULTIBLOG ) )
     1239        $do_network_admin = true;
     1240
     1241    return apply_filters( 'bp_core_do_network_admin', $do_network_admin );
     1242}
     1243
     1244function bp_core_update_admin_hook() {
     1245    $hook = bp_core_update_do_network_admin() ? 'network_admin_menu' : 'admin_menu';
     1246
     1247    return apply_filters( 'bp_core_admin_hook', $hook );
     1248}
     1249
    13341250/**
    13351251 * Adds the "BuddyPress" admin submenu item to the Site Admin tab.
     
    13471263        return false;
    13481264
    1349     if ( !current_user_can( 'activate_plugins' ) )
     1265    if ( !current_user_can( 'manage_options' ) )
    13501266        return false;
    13511267
    13521268    if ( 'install' == $bp_wizard->setup_type )
    1353         $status = __( 'Setup', 'buddypress' );
     1269        $status = __( 'BuddyPress Setup', 'buddypress' );
    13541270    else
    1355         $status = __( 'Update', 'buddypress' );
     1271        $status = __( 'Update BuddyPress', 'buddypress' );
    13561272
    13571273    // Add the administration tab under the "Site Admin" tab for site administrators
    1358     add_menu_page( __( 'BuddyPress', 'buddypress' ), __( 'BuddyPress', 'buddypress' ), 'manage_options', 'bp-wizard', '' );
    1359     $hook = add_submenu_page( 'bp-wizard', $status, $status, 'manage_options', 'bp-wizard', array( $bp_wizard, 'html' ) );
     1274    if ( ! is_multisite() || bp_is_multiblog_mode() )
     1275        $hook = add_dashboard_page( $status, $status, 'manage_options', 'bp-wizard', array( $bp_wizard, 'html' ) );
     1276    else
     1277        $hook = add_submenu_page( 'update-core.php', $status, $status, 'manage_options', 'bp-wizard', array( $bp_wizard, 'html' ) );
    13601278
    13611279    // Add a hook for css/js
     
    13631281}
    13641282add_action( bp_core_update_admin_hook(),  'bp_core_update_add_admin_menu', 9 );
    1365 
    1366 function bp_core_update_add_admin_menu_styles() {
    1367     if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
    1368         wp_enqueue_style( 'bp-admin-css', apply_filters( 'bp_core_admin_css', plugins_url( '/buddypress' ) . '/bp-core/css/admin.dev.css' ), array(), '20110723' );
    1369         wp_enqueue_script( 'bp-update-js', apply_filters( 'bp_core_update_js', plugins_url( '/buddypress' ) . '/bp-core/js/update.dev.js' ), array( 'jquery' ), '20110723' );
    1370     } else {
    1371         wp_enqueue_style( 'bp-admin-css', apply_filters( 'bp_core_admin_css', plugins_url( '/buddypress' ) . '/bp-core/css/admin.css' ), array(), '20110723' );
    1372         wp_enqueue_script( 'bp-update-js', apply_filters( 'bp_core_update_js', plugins_url( '/buddypress' ) . '/bp-core/js/update.js' ), array( 'jquery' ), '20110723' );
    1373     }
    1374 
    1375     wp_enqueue_script( 'thickbox' );
    1376     wp_enqueue_style( 'thickbox' ); ?>
    1377 
    1378     <style type="text/css">
    1379         /* Wizard Icon */
    1380         ul#adminmenu li.toplevel_page_bp-wizard .wp-menu-image a img { display: none; }
    1381         ul#adminmenu li.toplevel_page_bp-wizard .wp-menu-image a { background-image: url( <?php echo plugins_url( 'buddypress/bp-core/images/admin_menu_icon.png' ) ?> ) !important; background-position: -1px -32px; }
    1382         ul#adminmenu li.toplevel_page_bp-wizard:hover .wp-menu-image a,
    1383         ul#adminmenu li.toplevel_page_bp-wizard.wp-has-current-submenu .wp-menu-image a {
    1384             background-position: -1px 0;
    1385         }
    1386 
    1387         /* Settings Icon */
    1388         ul#adminmenu li.toplevel_page_bp-general-config .wp-menu-image a img { display: none; }
    1389         ul#adminmenu li.toplevel_page_bp-general-config .wp-menu-image a { background-image: url( <?php echo plugins_url( 'buddypress/bp-core/images/admin_menu_icon.png' ) ?> ) !important; background-position: -1px -32px; }
    1390         ul#adminmenu li.toplevel_page_bp-general-config:hover .wp-menu-image a,
    1391         ul#adminmenu li.toplevel_page_bp-general-config.wp-has-current-submenu .wp-menu-image a {
    1392             background-position: -1px 0;
    1393         }
    1394     </style>
    1395 
    1396 <?php
    1397 }
    1398 add_action( 'admin_head', 'bp_core_update_add_admin_menu_styles' );
    1399 
    1400 /**
    1401  * Fetches BP pages from the meta table
    1402  *
    1403  * @package BuddyPress Core
    1404  * @since 1.5
    1405  *
    1406  * @return array $page_ids
    1407  */
    1408 function bp_core_update_get_page_meta() {
    1409     if ( !$page_ids = bp_get_option( 'bp-pages' ) )
    1410         $page_ids = array();
    1411 
    1412     return apply_filters( 'bp_core_update_get_page_meta', $page_ids );
    1413 }
    1414 
    1415 function bp_core_update_do_network_admin() {
    1416     $do_network_admin = false;
    1417 
    1418     if ( is_multisite() && ( !defined( 'BP_ENABLE_MULTIBLOG' ) || !BP_ENABLE_MULTIBLOG ) )
    1419         $do_network_admin = true;
    1420 
    1421     return apply_filters( 'bp_core_do_network_admin', $do_network_admin );
    1422 }
    1423 
    1424 function bp_core_update_admin_hook() {
    1425     $hook = bp_core_update_do_network_admin() ? 'network_admin_menu' : 'admin_menu';
    1426 
    1427     return apply_filters( 'bp_core_admin_hook', $hook );
    1428 }
    14291283
    14301284/**
     
    14381292    global $bp_wizard, $pagenow;
    14391293
     1294    // Bail if no wizard
    14401295    if ( empty( $bp_wizard->setup_type ) )
    14411296        return;
    14421297
    1443     if ( !bp_current_user_can( 'bp_moderate' ) )
     1298    // Bail if user cannot manage options
     1299    if ( ! current_user_can( 'manage_options' ) )
    14441300        return;
    14451301
    1446     if ( 'admin.php' == $pagenow && ( empty( $_GET['page'] ) || 'bp-wizard' == $_GET['page'] ) )
    1447         return;
    1448 
    1449     $url = bp_core_update_do_network_admin() ? network_admin_url( 'admin.php?page=bp-wizard' ) : admin_url( 'admin.php?page=bp-wizard' );
    1450 
     1302    // Are we looking at a network?
     1303    if ( bp_core_update_do_network_admin() ) {
     1304       
     1305        // Bail if looking at wizard page
     1306        if ( ( 'admin.php' == $pagenow ) && ( !empty( $_GET['page'] ) && ( 'bp-wizard' == $_GET['page'] ) ) ) {
     1307            return;
     1308        }
     1309
     1310        // Set the url for the nag
     1311        $url = network_admin_url( 'admin.php?page=bp-wizard' );
     1312       
     1313    // Single site
     1314    } else {
     1315
     1316        // Bail if looking at wizard page
     1317        if ( ( 'index.php' == $pagenow ) && ( !empty( $_GET['page'] ) && ( 'bp-wizard' == $_GET['page'] ) ) ) {
     1318            return;
     1319        }
     1320
     1321        // Set the url for the nag
     1322        $url = admin_url( 'index.php?page=bp-wizard' );
     1323    }
     1324
     1325    // What does the nag say?
    14511326    switch( $bp_wizard->setup_type ) {
    1452         case 'update':
     1327
     1328        // Update text
     1329        case 'update' :
    14531330            $msg = sprintf( __( 'BuddyPress has been updated! Please run the <a href="%s">update wizard</a>.', 'buddypress' ), $url );
    14541331            break;
    14551332
    1456         default:
    1457         case 'install':
    1458             $msg = sprintf( __( 'BuddyPress was successfully installed! Please run the <a href="%s">installation wizard</a>.', 'buddypress' ), $url );
     1333        // First install text
     1334        case 'install' : default :
     1335            $msg = sprintf( __( 'BuddyPress was successfully activated! Please run the <a href="%s">installation wizard</a>.', 'buddypress' ), $url );
    14591336            break;
    1460     }
    1461 
    1462     echo '<div class="update-nag">' . $msg . '</div>';
     1337    } ?>
     1338
     1339    <div class="update-nag"><?php echo $msg; ?></div>
     1340
     1341<?php
    14631342}
    1464 add_action( 'admin_notices', 'bp_core_update_nag', 5 );
     1343add_action( 'admin_notices',         'bp_core_update_nag', 5 );
    14651344add_action( 'network_admin_notices', 'bp_core_update_nag', 5 );
    14661345
Note: See TracChangeset for help on using the changeset viewer.