Skip to:
Content

BuddyPress.org

Changeset 6343


Ignore:
Timestamp:
09/19/2012 06:52:23 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Wizard:

  • Remove theme selection; theme compat negates this.
  • Fix $bp_pages issues with wizard when using existing pages.
  • Bail early if not correct $_POST conditions rather than huge wrapping if () statements.
  • Remove find.png theme image.
  • Use buddypress() function in place of global $bp in changed files.
  • Bump DB version.
Location:
trunk
Files:
1 deleted
5 edited

Legend:

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

    r6342 r6343  
    173173                        break;
    174174        }
    175 
    176         // The setup wizard uses different, more descriptive text
    177         if ( bp_get_maintenance_mode() ) : ?>
    178 
    179                 <h3><?php _e( 'Available Components', 'buddypress' ); ?></h3>
    180 
    181                 <p><?php _e( 'Each component has a unique purpose, and your community may not need each one.', 'buddypress' ); ?></p>
    182 
    183         <?php endif ?>
    184 
    185                 <ul class="subsubsub">
    186                         <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'all'      ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'all'      ) : ?>class="current"<?php endif; ?>><?php printf( _nx( 'All <span class="count">(%s)</span>',      'All <span class="count">(%s)</span>',      $all_count,         'plugins', 'buddypress' ), number_format_i18n( $all_count                    ) ); ?></a> | </li>
    187                         <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'active'   ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'active'   ) : ?>class="current"<?php endif; ?>><?php printf( _n(  'Active <span class="count">(%s)</span>',   'Active <span class="count">(%s)</span>',   count( $active_components   ), 'buddypress' ), number_format_i18n( count( $active_components   ) ) ); ?></a> | </li>
    188                         <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'inactive' ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'inactive' ) : ?>class="current"<?php endif; ?>><?php printf( _n(  'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', count( $inactive_components ), 'buddypress' ), number_format_i18n( count( $inactive_components ) ) ); ?></a> | </li>
    189                         <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'mustuse'  ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'mustuse'  ) : ?>class="current"<?php endif; ?>><?php printf( _n(  'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', count( $required_components ), 'buddypress' ), number_format_i18n( count( $required_components ) ) ); ?></a></li>
    190                 </ul>
    191 
    192                 <table class="widefat fixed plugins" cellspacing="0">
    193                         <thead>
    194                                 <tr>
    195                                         <th scope="col" id="cb" class="manage-column column-cb check-column">&nbsp;</th>
    196                                         <th scope="col" id="name" class="manage-column column-name" style="width: 190px;"><?php _e( 'Component', 'buddypress' ); ?></th>
    197                                         <th scope="col" id="description" class="manage-column column-description"><?php _e( 'Description', 'buddypress' ); ?></th>
     175       
     176        if ( ! bp_get_maintenance_mode() ) : ?>
     177
     178        <ul class="subsubsub">
     179                <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'all'      ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'all'      ) : ?>class="current"<?php endif; ?>><?php printf( _nx( 'All <span class="count">(%s)</span>',      'All <span class="count">(%s)</span>',      $all_count,         'plugins', 'buddypress' ), number_format_i18n( $all_count                    ) ); ?></a> | </li>
     180                <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'active'   ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'active'   ) : ?>class="current"<?php endif; ?>><?php printf( _n(  'Active <span class="count">(%s)</span>',   'Active <span class="count">(%s)</span>',   count( $active_components   ), 'buddypress' ), number_format_i18n( count( $active_components   ) ) ); ?></a> | </li>
     181                <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'inactive' ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'inactive' ) : ?>class="current"<?php endif; ?>><?php printf( _n(  'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', count( $inactive_components ), 'buddypress' ), number_format_i18n( count( $inactive_components ) ) ); ?></a> | </li>
     182                <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'mustuse'  ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'mustuse'  ) : ?>class="current"<?php endif; ?>><?php printf( _n(  'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', count( $required_components ), 'buddypress' ), number_format_i18n( count( $required_components ) ) ); ?></a></li>
     183        </ul>
     184
     185        <?php endif; ?>
     186
     187        <table class="widefat fixed plugins" cellspacing="0">
     188                <thead>
     189                        <tr>
     190                                <th scope="col" id="cb" class="manage-column column-cb check-column">&nbsp;</th>
     191                                <th scope="col" id="name" class="manage-column column-name" style="width: 190px;"><?php _e( 'Component', 'buddypress' ); ?></th>
     192                                <th scope="col" id="description" class="manage-column column-description"><?php _e( 'Description', 'buddypress' ); ?></th>
     193                        </tr>
     194                </thead>
     195
     196                <tfoot>
     197                        <tr>
     198                                <th scope="col" class="manage-column column-cb check-column">&nbsp;</th>
     199                                <th scope="col" class="manage-column column-name" style="width: 190px;"><?php _e( 'Component', 'buddypress' ); ?></th>
     200                                <th scope="col" class="manage-column column-description"><?php _e( 'Description', 'buddypress' ); ?></th>
     201                        </tr>
     202                </tfoot>
     203
     204                <tbody id="the-list">
     205
     206                        <?php if ( !empty( $current_components ) ) : ?>
     207
     208                                <?php foreach ( $current_components as $name => $labels ) : ?>
     209
     210                                        <?php if ( !in_array( $name, array( 'core', 'members' ) ) ) :
     211                                                $class = isset( $active_components[esc_attr( $name )] ) ? 'active' : 'inactive';
     212                                        else :
     213                                                $class = 'active';
     214                                        endif; ?>
     215
     216                                        <tr id="<?php echo $name; ?>" class="<?php echo $name . ' ' . $class; ?>">
     217                                                <th scope="row">
     218
     219                                                        <?php if ( !in_array( $name, array( 'core', 'members' ) ) ) : ?>
     220
     221                                                                <input type="checkbox" id="bp_components[<?php echo esc_attr( $name ); ?>]" name="bp_components[<?php echo esc_attr( $name ); ?>]" value="1"<?php checked( isset( $active_components[esc_attr( $name )] ) ); ?> />
     222
     223                                                        <?php endif; ?>
     224
     225                                                        <label class="screen-reader-text" for="bp_components[<?php echo esc_attr( $name ); ?>]"><?php sprintf( __( 'Select %s', 'buddypress' ), esc_html( $labels['title'] ) );  ?></label>
     226                                                </th>
     227                                                <td class="plugin-title" style="width: 190px;">
     228                                                        <span></span>
     229                                                        <strong><?php echo esc_html( $labels['title'] ); ?></strong>
     230                                                        <div class="row-actions-visible">
     231
     232                                                        </div>
     233                                                </td>
     234
     235                                                <td class="column-description desc">
     236                                                        <div class="plugin-description">
     237                                                                <p><?php echo $labels['description']; ?></p>
     238                                                        </div>
     239                                                        <div class="active second plugin-version-author-uri">
     240
     241                                                        </div>
     242                                                </td>
     243                                        </tr>
     244
     245                                <?php endforeach ?>
     246
     247                        <?php else : ?>
     248
     249                                <tr class="no-items">
     250                                        <td class="colspanchange" colspan="3"><?php _e( 'No components found.', 'buddypress' ); ?></td>
    198251                                </tr>
    199                         </thead>
    200 
    201                         <tfoot>
    202                                 <tr>
    203                                         <th scope="col" class="manage-column column-cb check-column">&nbsp;</th>
    204                                         <th scope="col" class="manage-column column-name" style="width: 190px;"><?php _e( 'Component', 'buddypress' ); ?></th>
    205                                         <th scope="col" class="manage-column column-description"><?php _e( 'Description', 'buddypress' ); ?></th>
    206                                 </tr>
    207                         </tfoot>
    208 
    209                         <tbody id="the-list">
    210 
    211                                 <?php if ( !empty( $current_components ) ) : ?>
    212 
    213                                         <?php foreach ( $current_components as $name => $labels ) : ?>
    214 
    215                                                 <?php if ( !in_array( $name, array( 'core', 'members' ) ) ) :
    216                                                         $class = isset( $active_components[esc_attr( $name )] ) ? 'active' : 'inactive';
    217                                                 else :
    218                                                         $class = 'active';
    219                                                 endif; ?>
    220 
    221                                                 <tr id="<?php echo $name; ?>" class="<?php echo $name . ' ' . $class; ?>">
    222                                                         <th scope="row">
    223 
    224                                                                 <?php if ( !in_array( $name, array( 'core', 'members' ) ) ) : ?>
    225 
    226                                                                         <input type="checkbox" id="bp_components[<?php echo esc_attr( $name ); ?>]" name="bp_components[<?php echo esc_attr( $name ); ?>]" value="1"<?php checked( isset( $active_components[esc_attr( $name )] ) ); ?> />
    227 
    228                                                                 <?php endif; ?>
    229 
    230                                                                 <label class="screen-reader-text" for="bp_components[<?php echo esc_attr( $name ); ?>]"><?php sprintf( __( 'Select %s', 'buddypress' ), esc_html( $labels['title'] ) );  ?></label>
    231                                                         </th>
    232                                                         <td class="plugin-title" style="width: 190px;">
    233                                                                 <span></span>
    234                                                                 <strong><?php echo esc_html( $labels['title'] ); ?></strong>
    235                                                                 <div class="row-actions-visible">
    236 
    237                                                                 </div>
    238                                                         </td>
    239 
    240                                                         <td class="column-description desc">
    241                                                                 <div class="plugin-description">
    242                                                                         <p><?php echo $labels['description']; ?></p>
    243                                                                 </div>
    244                                                                 <div class="active second plugin-version-author-uri">
    245 
    246                                                                 </div>
    247                                                         </td>
    248                                                 </tr>
    249 
    250                                         <?php endforeach ?>
    251 
    252                                 <?php else : ?>
    253 
    254                                         <tr class="no-items">
    255                                                 <td class="colspanchange" colspan="3"><?php _e( 'No components found.', 'buddypress' ); ?></td>
    256                                         </tr>
    257 
    258                                 <?php endif; ?>
    259 
    260                         </tbody>
    261                 </table>
     252
     253                        <?php endif; ?>
     254
     255                </tbody>
     256        </table>
    262257
    263258        <input type="hidden" name="bp_components[members]" value="1" />
  • trunk/bp-core/admin/bp-core-functions.php

    r6342 r6343  
    131131 * @since BuddyPress (1.5)
    132132 *
    133  * @global BuddyPress $bp The one true BuddyPress instance
    134133 * @uses bp_current_user_can() to check current user permissions before showing the notices
    135134 * @uses bp_is_root_blog()
    136135 */
    137136function bp_core_print_admin_notices() {
    138         global $bp;
     137        $bp = buddypress();
    139138
    140139        // Only the super admin should see messages
     
    171170 * @since BuddyPress (1.5)
    172171 *
    173  * @global BuddyPress $bp The one true BuddyPress instance
    174172 * @param string $notice The notice you are adding to the queue
    175173 */
    176174function bp_core_add_admin_notice( $notice ) {
    177         global $bp;
     175        $bp = buddypress();
    178176
    179177        if ( empty( $bp->admin->notices ) ) {
     
    197195 */
    198196function bp_core_activation_notice() {
    199         global $wp_rewrite, $wpdb, $bp;
     197        global $wp_rewrite, $wpdb;
     198
     199        $bp = buddypress();
    200200
    201201        // Only the super admin gets warnings
     
    242242
    243243        // Only components with 'has_directory' require a WP page to function
    244         foreach( $bp->loaded_components as $component_id => $is_active ) {
     244        foreach( array_keys( $bp->loaded_components ) as $component_id ) {
    245245                if ( !empty( $bp->{$component_id}->has_directory ) ) {
    246246                        $wp_page_components[] = array(
     
    296296
    297297        if ( !empty( $dupes ) ) {
    298                 foreach( $dupes as $dupe_component => $dupe_id ) {
     298                foreach( array_keys( $dupes ) as $dupe_component ) {
    299299                        $dupe_names[] = $bp->pages->{$dupe_component}->title;
    300300                }
  • trunk/bp-core/admin/bp-core-update.php

    r6342 r6343  
    5858                                __( 'Pages',      'buddypress' ),
    5959                                __( 'Permalinks', 'buddypress' ),
    60                                 __( 'Theme',      'buddypress' ),
    6160                                __( 'Finish',     'buddypress' )
    6261                        );
     
    106105                        case 'permalinks':
    107106                                $result = $this->step_permalinks_save();
    108                                 break;
    109 
    110                         case 'theme':
    111                                 $result = $this->step_theme_save();
    112107                                break;
    113108
     
    214209                                                        break;
    215210
    216                                                 case __( 'Theme', 'buddypress') :
    217                                                         $this->step_theme();
    218                                                         break;
    219 
    220211                                                case __( 'Toolbar', 'buddypress' ) :
    221212                                                        $this->step_admin_bar();
     
    255246
    256247                if ( !function_exists( 'bp_core_admin_components_options' ) )
    257                         require ( BP_PLUGIN_DIR . 'bp-core/admin/bp-core-components.php' ); ?>
    258 
    259                 <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>
    260 
    261                 <?php bp_core_admin_components_options(); ?>
     248                        require ( BP_PLUGIN_DIR . 'bp-core/admin/bp-core-components.php' );
     249
     250                bp_core_admin_components_options(); ?>
    262251
    263252                <div class="submit clear">
     
    324313                        jQuery( document ).ready( function() {
    325314                                jQuery( 'select' ).change( function() {
    326                                         jQuery( this ).siblings( 'input[@type=radio]' ).click();
     315                                        jQuery( this ).siblings( 'input[type=radio]' ).click();
    327316                                });
    328317                        });
    329318                </script>
    330319
    331                 <p><?php _e( 'BuddyPress uses WordPress pages to display directories. This allows you to easily change their titles and relocate them.', 'buddypress' ); ?></p>
    332 
    333                 <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>
     320                <?php if ( bp_get_maintenance_mode() ) : ?>
     321
     322                        <p><?php _e( 'BuddyPress uses WordPress pages to display directories. This allows you to easily change their titles and relocate them.', 'buddypress' ); ?></p>
     323                        <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>
     324
     325                <?php endif; ?>
    334326
    335327                <table class="form-table">
     
    345337                                        <?php if ( $members_page_dropdown = wp_dropdown_pages( "name=bp-members-page&echo=0&selected={$existing_pages['members']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?>
    346338
    347                                                 <p><label><input type="radio" name="bp_pages[members]" <?php checked( !empty( $existing_pages['members'] ) ); ?> value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $members_page_dropdown ?></label></p>
     339                                                <p><label><input type="radio" name="bp_pages[members]" <?php checked( !empty( $existing_pages['members'] ) ); ?> value="<?php echo get_post_field( 'post_name', $existing_pages['members'] ); ?>" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $members_page_dropdown ?></label></p>
    348340
    349341                                        <?php endif ?>
     
    362354
    363355                                                <?php if ( $groups_page_dropdown = wp_dropdown_pages( "name=bp-groups-page&echo=0&selected={$existing_pages['groups']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?>
    364                                                         <p><label><input type="radio" name="bp_pages[groups]" <?php checked( !empty( $existing_pages['groups'] ) ); ?> value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $groups_page_dropdown ?></label></p>
     356                                                        <p><label><input type="radio" name="bp_pages[groups]" <?php checked( !empty( $existing_pages['groups'] ) ); ?> value="<?php echo get_post_field( 'post_name', $existing_pages['groups'] ); ?>" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $groups_page_dropdown ?></label></p>
    365357                                                <?php endif ?>
    366358                                        </td>
     
    381373
    382374                                                <?php if ( $blogs_page_dropdown = wp_dropdown_pages( "name=bp-blogs-page&echo=0&selected={$existing_pages['blogs']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?>
    383                                                         <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>
     375                                                        <p><label><input type="radio" name="bp_pages[blogs]" <?php checked( !empty( $existing_pages['blogs'] ) ); ?> value="<?php echo get_post_field( 'post_name', $existing_pages['blogs'] ); ?>" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $blogs_page_dropdown ?></label></p>
    384376                                                <?php endif ?>
    385377                                        </td>
     
    399391
    400392                                                <?php if ( $activity_page_dropdown = wp_dropdown_pages( "name=bp-activity-page&echo=0&selected={$existing_pages['activity']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?>
    401                                                         <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>
     393                                                        <p><label><input type="radio" name="bp_pages[activity]" <?php checked( !empty( $existing_pages['activity'] ) ); ?> value="<?php echo get_post_field( 'post_name', $existing_pages['activity'] ); ?>" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $activity_page_dropdown ?></label></p>
    402394                                                <?php endif ?>
    403395                                        </td>
     
    417409
    418410                                                <?php if ( $forums_page_dropdown = wp_dropdown_pages( "name=bp-forums-page&echo=0&selected={$existing_pages['forums']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?>
    419                                                         <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>
     411                                                        <p><label><input type="radio" name="bp_pages[forums]" <?php checked( !empty( $existing_pages['forums'] ) ); ?> value="<?php echo get_post_field( 'post_name', $existing_pages['forums'] ); ?>" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $forums_page_dropdown ?></label></p>
    420412                                                <?php endif ?>
    421413                                        </td>
     
    433425
    434426                                        <?php if ( $register_page_dropdown = wp_dropdown_pages( "name=bp-register-page&echo=0&selected={$existing_pages['register']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?>
    435                                                 <p><label><input type="radio" name="bp_pages[register]" <?php checked( !empty( $existing_pages['register'] ) ); ?> value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $register_page_dropdown ?></label></p>
     427                                                <p><label><input type="radio" name="bp_pages[register]" <?php checked( !empty( $existing_pages['register'] ) ); ?> value="<?php echo get_post_field( 'post_name', $existing_pages['register'] ); ?>" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $register_page_dropdown ?></label></p>
    436428                                        <?php endif ?>
    437429                                </td>
     
    447439
    448440                                        <?php if ( $activate_page_dropdown = wp_dropdown_pages( "name=bp-activate-page&echo=0&selected={$existing_pages['activate']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?>
    449                                                 <p><label><input type="radio" name="bp_pages[activate]" <?php checked( !empty( $existing_pages['activate'] ) ); ?> value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $activate_page_dropdown ?></label></p>
     441                                                <p><label><input type="radio" name="bp_pages[activate]" <?php checked( !empty( $existing_pages['activate'] ) ); ?> value="<?php echo get_post_field( 'post_name', $existing_pages['activate'] ); ?>" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $activate_page_dropdown ?></label></p>
    450442                                        <?php endif ?>
    451443                                </td>
     
    472464                $structures          = array( '', $prefix . '/%year%/%monthnum%/%day%/%postname%/', $prefix . '/%year%/%monthnum%/%postname%/', $prefix . '/archives/%post_id%' );
    473465
    474                 // If we're using permalinks already, adjust text accordingly
    475                 if ( !empty( $permalink_structure ) )
    476                         $permalink_setup_text = __( 'Your permalink settings are compatible with BuddyPress.', 'buddypress' );
    477                 else
    478                         $permalink_setup_text = __( 'Pretty permalinks must be active on your site.', 'buddypress' );
    479 
    480466                if ( !got_mod_rewrite() && !iis7_supports_permalinks() )
    481467                        $prefix = '/index.php'; ?>
    482468
    483                 <p><?php echo $permalink_setup_text; ?></p>
     469                <p><?php
     470
     471                        // If we're using permalinks already, adjust text accordingly
     472                        if ( !empty( $permalink_structure ) ) {
     473                                _e( 'Your permalink settings are compatible with BuddyPress.', 'buddypress' );
     474                        } else {
     475                                _e( 'Pretty permalinks must be active on your site.', 'buddypress' );
     476                        }
     477
     478                ?></p>
    484479                <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' ) ); ?>
    485480
    486481                <table class="form-table">
     482                       
     483                        <?php if ( !empty( $permalink_structure ) && ! in_array( $permalink_structure, $structures ) ) : ?>
     484                                <tr>
     485                                        <th><label><input name="permalink_structure" type="radio" checked="checked" value="<?php echo esc_attr( $permalink_structure ); ?>" class="tog" <?php checked( true ); ?> />&nbsp;<?php _e( 'Current' ); ?></label></th>
     486                                        <td><code><?php echo get_home_url() . $prefix . $permalink_structure; ?></code></td>
     487                                </tr>
     488                        <?php endif; ?>
     489
    487490                        <tr>
    488491                                <th><label><input name="permalink_structure" type="radio"<?php if ( empty( $permalink_structure ) || false != strpos( $permalink_structure, $structures[1] ) ) : ?> checked="checked" <?php endif; ?>value="<?php echo esc_attr( $structures[1] ); ?>" class="tog" <?php checked( $structures[1], $permalink_structure ); ?> />&nbsp;<?php _e( 'Day and name' ); ?></label></th>
     
    516519        }
    517520
    518         function step_theme() {
    519                 global $bp;
    520 
    521                 $installed_plugins = get_plugins();
    522                 $installed_themes  = wp_get_themes();
    523                 $bp_themes         = array();
    524 
    525                 $template_pack_installed = false;
    526                 $bp_theme_installed      = false;
    527 
    528                 foreach ( (array) $installed_plugins as $plugin ) {
    529                         if ( 'BuddyPress Template Pack' == $plugin['Name'] ) {
    530                                 $template_pack_installed = true;
    531                         }
    532                 }
    533 
    534                 foreach ( (array) $installed_themes as $theme ) {
    535                         foreach ( (array) $theme['Tags'] as $tag ) {
    536                                 if ( ( 'BuddyPress Default' != $theme['Name'] ) && ( 'buddypress' == $tag ) ) {
    537                                         $bp_theme_installed = true;
    538                                         $bp_themes[] = $theme;
    539                                 }
    540                         }
    541                 }
    542 
    543                 // Get theme screenshot
    544                 $current_theme = wp_get_theme();
    545                 $screenshot    = '';
    546 
    547                 if ( !empty( $installed_themes[$current_theme->stylesheet]['Screenshot'] ) ) {
    548                         $screenshot = trailingslashit( get_stylesheet_directory_uri() ) . $installed_themes[$current_theme->stylesheet]['Screenshot'];
    549                 } ?>
    550 
    551                 <script type="text/javascript">
    552                         jQuery( document ).ready( function() {
    553                                 jQuery( 'select' ).change( function() {
    554                                         jQuery( this ).siblings( 'input[@type=radio]' ).click();
    555                                 });
    556                         });
    557                 </script>
    558 
    559                 <table class="form-table">
    560                         <tr>
    561                                 <th>
    562                                         <h5><?php _e( 'Use BuddyPress Default', 'buddypress' ); ?></h5>
    563                                         <img src="<?php echo plugins_url( 'bp-themes/bp-default/screenshot.png', $bp->file ); ?>" alt="<?php _e( 'BuddyPress Default', 'buddypress' ); ?>" />
    564                                 </th>
    565                                 <td>
    566                                         <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>
    567                                         <p><strong><?php _e( 'This is the best choice if you want to start using BuddyPress immediately.', 'buddypress' ); ?></strong></p>
    568                                         <p><label><input type="radio" name="theme" value="bp_default" checked="checked" /> <?php _e( 'Yes, please!', 'buddypress' ); ?></label></p>
    569                                 </td>
    570                         </tr>
    571 
    572                         <?php if ( !empty( $bp_theme_installed ) ) : ?>
    573 
    574                                 <tr>
    575                                         <th>
    576                                                 <h5><?php _e( 'Other themes', 'buddypress' ); ?></h5>
    577                                                 <img src="<?php echo plugins_url( 'bp-core/admin/images/find.png', $bp->file ); ?>" alt="<?php _e( 'A BuddyPress theme', 'buddypress' ); ?>" />
    578                                         </th>
    579                                         <td>
    580                                                 <p><?php _e( "You have some other BuddyPress compatible themes available. Pick one of them from this list to use it.", 'buddypress' ); ?></p>
    581                                                 <p>
    582                                                         <label>
    583                                                                 <input type="radio" name="theme" value="3rd_party" /> <?php _e( 'Use this theme', 'buddypress' ); ?>
    584                                                         </label>
    585                                                         <select name="3rd_party_theme">
    586 
    587                                                                 <?php foreach( (array) $bp_themes as $theme ) : ?>
    588 
    589                                                                         <option value="<?php echo $theme['Template'] . ',' . $theme['Stylesheet']; ?>"><?php echo $theme['Name']; ?></option>
    590 
    591                                                                 <?php endforeach; ?>
    592 
    593                                                         </select>
    594                                                 </p>
    595                                         </td>
    596                                 </tr>
    597 
    598                         <?php endif; ?>
    599 
    600                         <?php if ( ! current_theme_supports( 'buddypress' ) ) : ?>
    601 
    602                                 <tr>
    603                                         <th>
    604                                                 <h5><?php _e( 'Manually update current theme', 'buddypress' ); ?></h5>
    605 
    606                                                 <?php if ( !empty( $screenshot ) ) : ?>
    607 
    608                                                         <img src="<?php echo esc_url( $screenshot ); ?>" alt="<?php _e( 'Your existing theme', 'buddypress' ); ?>" />
    609 
    610                                                 <?php endif; ?>
    611 
    612                                         </th>
    613                                         <td>
    614                                                 <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>
    615 
    616                                                 <?php if ( empty( $template_pack_installed ) ) : ?>
    617 
    618                                                         <p><a id="bp-template-pack" class="thickbox onclick button" href="<?php echo network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=bp-template-pack&TB_iframe=true&width=640&height=500' ); ?>"><?php _e( 'Install BuddyPress Template Pack', 'buddypress' ); ?></a></p>
    619 
    620                                                 <?php else : ?>
    621 
    622                                                         <p><label><input type="radio" name="theme" value="manual_wp" /> <?php _e( 'Choose this option (go to Appearance &rarr; BP Compatibility after setup is complete)', 'buddypress' ); ?></label></p>
    623                                                         <p><a id="bp-template-pack" class="button installed disabled" href="javascript:void();"><span></span><?php _e( 'Plugin Installed', 'buddypress' ); ?></a></p>
    624 
    625                                                 <?php endif; ?>
    626 
    627                                         </td>
    628                                 </tr>
    629 
    630                         <?php endif; ?>
    631 
    632                         <tr>
    633                                 <th>
    634                                         <h5><?php _e( 'Do not change theme', 'buddypress' ) ?></h5>
    635                                 </th>
    636                                 <td>
    637                                         <p><?php _e( "You are happy with your current theme and plan on changing it later.", 'buddypress' ); ?></p>
    638                                         <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>
    639 
    640                                         <p><label><input type="radio" name="theme" value="do_not_change" /> <?php _e( "Don't change my current theme", 'buddypress' ); ?></label></p>
    641 
    642                                 </td>
    643                         </tr>
    644                 </table>
    645 
    646                 <div class="submit clear">
    647                         <input type="hidden" name="save" value="theme" />
    648                         <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step() ) ?>" />
    649 
    650                         <?php wp_nonce_field( 'bpwizard_theme' ) ?>
    651 
    652                 </div>
    653 
    654         <?php
    655         }
    656 
    657521        /**
    658522         * When upgrading to BP 1.6, prompt the admin to switch to WordPress' Toolbar.
     
    711575        function step_db_update_save() {
    712576
    713                 if ( isset( $_POST['submit'] ) ) {
    714                         check_admin_referer( 'bpwizard_db_update' );
    715 
    716                         // Run the schema install to update tables
    717                         bp_core_install();
    718 
    719                         // Update to 1.5
    720                         if ( bp_get_db_version_raw() < 1801 )
    721                                 $this->update_1_5();
    722 
    723                         // Update to 1.6
    724                         if ( bp_get_db_version_raw() < bp_get_db_version() )
    725                                 $this->update_1_6();
    726 
    727                         return true;
    728                 }
    729 
    730                 return false;
     577                if ( ! isset( $_POST['submit'] ) )
     578                        return false;
     579
     580                check_admin_referer( 'bpwizard_db_update' );
     581
     582                // Run the schema install to update tables
     583                bp_core_install();
     584
     585                // Update to 1.5
     586                if ( bp_get_db_version_raw() < 1801 )
     587                        $this->update_1_5();
     588
     589                // Update to 1.6
     590                if ( bp_get_db_version_raw() < bp_get_db_version() )
     591                        $this->update_1_6();
     592
     593                return true;
    731594        }
    732595
    733596        function step_components_save() {
    734597
    735                 if ( isset( $_POST['submit'] ) && isset( $_POST['bp_components'] ) ) {
    736 
    737                         check_admin_referer( 'bpwizard_components' );
    738 
    739                         $active_components = array();
    740 
    741                         // Settings form submitted, now save the settings.
    742                         foreach ( (array) $_POST['bp_components'] as $key => $value ) {
    743                                 $active_components[$key] = 1;
    744                         }
    745 
    746                         bp_update_option( 'bp-active-components', $active_components );
    747 
    748                         wp_cache_flush();
    749                         bp_core_install();
    750 
    751                         return true;
    752                 }
    753 
    754                 return false;
     598                if ( ! isset( $_POST['submit'] ) || ! isset( $_POST['bp_components'] ) )
     599                        return false;
     600
     601                check_admin_referer( 'bpwizard_components' );
     602
     603                $active_components = array();
     604
     605                // Settings form submitted, now save the settings.
     606                foreach ( (array) $_POST['bp_components'] as $key => $value ) {
     607                        $active_components[$key] = 1;
     608                }
     609
     610                bp_update_option( 'bp-active-components', $active_components );
     611
     612                wp_cache_flush();
     613                bp_core_install();
     614
     615                return true;
    755616        }
    756617
    757618        function step_pages_save() {
    758                 global $wpdb;
    759 
    760                 if ( isset( $_POST['submit'] ) && isset( $_POST['bp_pages'] ) ) {
    761                         check_admin_referer( 'bpwizard_pages' );
    762 
    763                         // Make sure that the pages are created on the bp_get_root_blog_id(), no matter which Dashboard the setup is being run on
    764                         if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != bp_get_root_blog_id() ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) )
    765                                 switch_to_blog( bp_get_root_blog_id() );
    766 
    767                         // Delete any existing pages
    768                         $existing_pages = bp_core_get_directory_page_ids();
    769 
    770                         foreach ( (array) $existing_pages as $page_id ) {
    771                                 wp_delete_post( $page_id, true );
    772                         }
    773 
    774                         $blog_pages   = $this->setup_pages( (array) $_POST['bp_pages'] );
    775                         bp_update_option( 'bp-pages', $blog_pages );
    776 
    777                         if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != bp_get_root_blog_id() ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) )
    778                                 restore_current_blog();
    779 
    780                         return true;
    781                 }
    782 
    783                 return false;
     619
     620                if ( ! isset( $_POST['submit'] ) || ! isset( $_POST['bp_pages'] ) )
     621                        return false;
     622
     623                check_admin_referer( 'bpwizard_pages' );
     624
     625                // Make sure that the pages are created on the bp_get_root_blog_id()
     626                //no matter which Dashboard the setup is being run on.
     627                if ( !defined( 'BP_ENABLE_MULTIBLOG' ) )
     628                        switch_to_blog( bp_get_root_blog_id() );
     629
     630                $blog_pages = $this->setup_pages( (array) $_POST['bp_pages'] );
     631                bp_update_option( 'bp-pages', $blog_pages );
     632
     633                if ( !defined( 'BP_ENABLE_MULTIBLOG' ) )
     634                        restore_current_blog();
     635
     636                return true;
    784637        }
    785638
     
    790643                $iis7_permalinks = $usingpi = $writable = false;
    791644
    792                 if ( isset( $_POST['submit'] ) ) {
    793                         check_admin_referer( 'bpwizard_permalinks' );
    794 
    795                         $home_path       = get_home_path();
    796                         $iis7_permalinks = iis7_supports_permalinks();
    797 
    798                         if ( isset( $_POST['permalink_structure'] ) ) {
    799                                 $permalink_structure = $_POST['permalink_structure'];
    800 
    801                                 if ( !empty( $permalink_structure ) )
    802                                         $permalink_structure = preg_replace( '#/+#', '/', '/' . $_POST['permalink_structure'] );
    803 
    804                                 if ( ( defined( 'VHOST' ) && constant( 'VHOST' ) == 'no' ) && $permalink_structure != '' && $current_site->domain . $current_site->path == $current_blog->domain . $current_blog->path )
    805                                         $permalink_structure = '/blog' . $permalink_structure;
    806 
    807                                 $wp_rewrite->set_permalink_structure( $permalink_structure );
     645                if ( ! isset( $_POST['submit'] ) )
     646                        return false;
     647
     648                check_admin_referer( 'bpwizard_permalinks' );
     649
     650                $home_path       = get_home_path();
     651                $iis7_permalinks = iis7_supports_permalinks();
     652
     653                if ( isset( $_POST['permalink_structure'] ) ) {
     654                        $permalink_structure = $_POST['permalink_structure'];
     655
     656                        if ( !empty( $permalink_structure ) )
     657                                $permalink_structure = preg_replace( '#/+#', '/', '/' . $_POST['permalink_structure'] );
     658
     659                        if ( ( defined( 'VHOST' ) && constant( 'VHOST' ) == 'no' ) && $permalink_structure != '' && $current_site->domain . $current_site->path == $current_blog->domain . $current_blog->path )
     660                                $permalink_structure = '/blog' . $permalink_structure;
     661
     662                        $wp_rewrite->set_permalink_structure( $permalink_structure );
     663                }
     664
     665                if ( !empty( $iis7_permalinks ) ) {
     666                        if ( ( !file_exists( $home_path . 'web.config' ) && win_is_writable( $home_path ) ) || win_is_writable( $home_path . 'web.config' ) ) {
     667                                $writable = true;
    808668                        }
    809 
    810                         if ( !empty( $iis7_permalinks ) ) {
    811                                 if ( ( !file_exists( $home_path . 'web.config' ) && win_is_writable( $home_path ) ) || win_is_writable( $home_path . 'web.config' ) ) {
    812                                         $writable = true;
    813                                 }
     669                } else {
     670                        if ( ( !file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) {
     671                                $writable = true;
     672                        }
     673                }
     674
     675                if ( $wp_rewrite->using_index_permalinks() )
     676                        $usingpi = true;
     677
     678                $wp_rewrite->flush_rules();
     679
     680                if ( !empty( $iis7_permalinks ) || ( empty( $usingpi ) && empty( $writable ) ) ) {
     681
     682                        function _bp_core_wizard_step_permalinks_message() {
     683                                global $wp_rewrite; ?>
     684
     685                                <div id="message" class="updated fade"><p>
     686
     687                                        <?php
     688                                                _e( 'Oops, there was a problem creating a configuration file. ', 'buddypress' );
     689
     690                                                if ( !empty( $iis7_permalinks ) ) {
     691
     692                                                        if ( !empty( $permalink_structure ) && empty( $usingpi ) && empty( $writable ) ) {
     693
     694                                                                _e( 'If your <code>web.config</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn&#8217;t so this is the url rewrite rule you should have in your <code>web.config</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this rule inside of the <code>/&lt;configuration&gt;/&lt;system.webServer&gt;/&lt;rewrite&gt;/&lt;rules&gt;</code> element in <code>web.config</code> file.' ); ?>
     695
     696                                                                <br /><br />
     697
     698                                                                <textarea rows="9" class="large-text readonly" style="background: #fff;" name="rules" id="rules" readonly="readonly"><?php echo esc_html( $wp_rewrite->iis7_url_rewrite_rules() ); ?></textarea>
     699
     700                                                        <?php
     701
     702                                                        } else if ( !empty( $permalink_structure ) && empty( $usingpi ) && !empty( $writable ) ); {
     703                                                                _e( 'Permalink structure updated. Remove write access on web.config file now!' );
     704                                                        }
     705
     706                                                } else {
     707
     708                                                        _e( 'If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn&#8217;t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.' ); ?>
     709
     710                                                        <br /><br />
     711
     712                                                        <textarea rows="6" class="large-text readonly" style="background: #fff;" name="rules" id="rules" readonly="readonly"><?php echo esc_html( $wp_rewrite->mod_rewrite_rules() ); ?></textarea>
     713
     714                                                <?php } ?>
     715
     716                                        <br /><br />
     717
     718                                        <?php
     719                                                if ( empty( $iis7_permalinks ) )
     720                                                        _e( 'Paste all these rules into a new <code>.htaccess</code> file in the root of your WordPress installation and save the file. Once you\'re done, please hit the "Save and Next" button to continue.', 'buddypress' );
     721                                        ?>
     722
     723                                </p></div>
     724
     725                        <?php
     726                        }
     727
     728                        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && !empty( $_POST['skip-htaccess'] ) ) {
     729                                return true;
    814730                        } else {
    815                                 if ( ( !file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) {
    816                                         $writable = true;
    817                                 }
     731                                add_action( 'bp_admin_notices', '_bp_core_wizard_step_permalinks_message' );
     732                                return false;
    818733                        }
    819 
    820                         if ( $wp_rewrite->using_index_permalinks() )
    821                                 $usingpi = true;
    822 
    823                         $wp_rewrite->flush_rules();
    824 
    825                         if ( !empty( $iis7_permalinks ) || ( empty( $usingpi ) && empty( $writable ) ) ) {
    826 
    827                                 function _bp_core_wizard_step_permalinks_message() {
    828                                         global $wp_rewrite; ?>
    829 
    830                                         <div id="message" class="updated fade"><p>
    831 
    832                                                 <?php
    833                                                         _e( 'Oops, there was a problem creating a configuration file. ', 'buddypress' );
    834 
    835                                                         if ( !empty( $iis7_permalinks ) ) {
    836 
    837                                                                 if ( !empty( $permalink_structure ) && empty( $usingpi ) && empty( $writable ) ) {
    838 
    839                                                                         _e( 'If your <code>web.config</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn&#8217;t so this is the url rewrite rule you should have in your <code>web.config</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this rule inside of the <code>/&lt;configuration&gt;/&lt;system.webServer&gt;/&lt;rewrite&gt;/&lt;rules&gt;</code> element in <code>web.config</code> file.' ); ?>
    840 
    841                                                                         <br /><br />
    842 
    843                                                                         <textarea rows="9" class="large-text readonly" style="background: #fff;" name="rules" id="rules" readonly="readonly"><?php echo esc_html( $wp_rewrite->iis7_url_rewrite_rules() ); ?></textarea>
    844 
    845                                                                 <?php
    846 
    847                                                                 } else if ( !empty( $permalink_structure ) && empty( $usingpi ) && !empty( $writable ) ); {
    848                                                                         _e( 'Permalink structure updated. Remove write access on web.config file now!' );
    849                                                                 }
    850 
    851                                                         } else {
    852 
    853                                                                 _e( 'If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn&#8217;t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.' ); ?>
    854 
    855                                                                 <br /><br />
    856 
    857                                                                 <textarea rows="6" class="large-text readonly" style="background: #fff;" name="rules" id="rules" readonly="readonly"><?php echo esc_html( $wp_rewrite->mod_rewrite_rules() ); ?></textarea>
    858 
    859                                                         <?php } ?>
    860 
    861                                                 <br /><br />
    862 
    863                                                 <?php
    864                                                         if ( empty( $iis7_permalinks ) )
    865                                                                 _e( 'Paste all these rules into a new <code>.htaccess</code> file in the root of your WordPress installation and save the file. Once you\'re done, please hit the "Save and Next" button to continue.', 'buddypress' );
    866                                                 ?>
    867 
    868                                         </p></div>
    869 
    870                                 <?php
    871                                 }
    872 
    873                                 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && !empty( $_POST['skip-htaccess'] ) ) {
    874                                         return true;
    875                                 } else {
    876                                         add_action( 'bp_admin_notices', '_bp_core_wizard_step_permalinks_message' );
    877                                         return false;
    878                                 }
    879                         }
    880 
    881                         return true;
    882                 }
    883 
    884                 return false;
    885         }
    886 
    887         function step_theme_save() {
    888                 global $bp;
    889 
    890                 if ( isset( $_POST['submit'] ) && isset( $_POST['theme'] ) ) {
    891                         check_admin_referer( 'bpwizard_theme' );
    892 
    893                         if ( is_multisite() && bp_get_root_blog_id() != get_current_blog_id() )
    894                                 switch_to_blog( bp_get_root_blog_id() );
    895 
    896                         switch ( $_POST['theme'] ) {
    897 
    898                                 // Activate the bp-default theme
    899                                 case 'bp_default' :
    900                                         register_theme_directory( $bp->themes_dir );
    901                                         switch_theme( 'bp-default', 'bp-default' );
    902                                         break;
    903 
    904                                 // Activate Template Pack plugin
    905                                 case 'manual_wp' :
    906 
    907                                         // Include
    908                                         require_once( ABSPATH . WPINC . '/plugin.php' );
    909                                         $installed_plugins = get_plugins();
    910 
    911                                         foreach ( $installed_plugins as $key => $plugin ) {
    912                                                 if ( 'BuddyPress Template Pack' == $plugin['Name'] ) {
    913                                                         activate_plugin( $key );
    914                                                 }
    915                                         }
    916                                         break;
    917 
    918                                 // Pick a theme from the repo
    919                                 case '3rd_party' :
    920                                         if ( empty( $_POST['3rd_party_theme'] ) )
    921                                                 return false;
    922 
    923                                         $theme = explode( ',', $_POST['3rd_party_theme'] );
    924                                         switch_theme( $theme[0], $theme[1] );
    925                                         break;
    926 
    927                                 // Keep existing theme
    928                                 case 'do_not_change' :
    929                                         return true;
    930                                         break;
    931                         }
    932 
    933                         if ( is_multisite() )
    934                                 restore_current_blog();
    935 
    936                         return true;
    937                 }
    938 
    939                 return false;
     734                }
     735
     736                return true;
    940737        }
    941738
     
    947744         */
    948745        function step_admin_bar_save() {
    949                 if ( isset( $_POST['submit'] ) ) {
    950                         check_admin_referer( 'bpwizard_admin_bar' );
    951 
    952                         if ( !empty( $_POST['keep_buddybar'] ) ) {
    953                                 bp_update_option( '_bp_force_buddybar', 1 );
    954                         }
    955 
    956                         return true;
    957                 }
    958 
    959                 return false;
     746                if ( ! isset( $_POST['submit'] ) )
     747                        return false;
     748
     749                check_admin_referer( 'bpwizard_admin_bar' );
     750
     751                if ( !empty( $_POST['keep_buddybar'] ) )
     752                        bp_update_option( '_bp_force_buddybar', 1 );
     753
     754                return true;
    960755        }
    961756
    962757        function step_finish_save() {
    963758
    964                 if ( isset( $_POST['submit'] ) ) {
    965 
    966                         check_admin_referer( 'bpwizard_finish' );
    967 
    968                         // Update the DB version in the database
    969                         bp_version_bump();
    970 
    971                         // Delete the setup cookie
    972                         @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH );
    973 
    974                         // Redirect to the BuddyPress dashboard
    975                         $redirect = bp_core_do_network_admin() ? network_admin_url( 'settings.php' ) : admin_url( 'options-general.php' );
    976                         $redirect = add_query_arg( array( 'page' => 'bp-components' ), $redirect  );
    977 
    978                         wp_safe_redirect( $redirect );
    979 
    980                         // That's all!
    981                         exit();
    982                 }
    983 
    984                 return false;
     759                if ( ! isset( $_POST['submit'] ) )
     760                        return false;
     761
     762                check_admin_referer( 'bpwizard_finish' );
     763
     764                // Update the DB version in the database
     765                bp_version_bump();
     766
     767                // Delete the setup cookie
     768                @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH );
     769
     770                // Redirect to the BuddyPress dashboard
     771                $redirect = bp_core_do_network_admin() ? network_admin_url( 'settings.php' ) : admin_url( 'options-general.php' );
     772                $redirect = add_query_arg( array( 'page' => 'bp-components' ), $redirect  );
     773
     774                wp_safe_redirect( $redirect );
     775
     776                // That's all!
     777                exit();
    985778        }
    986779
     
    989782                $bp_pages = array();
    990783
     784                // Delete any existing pages
     785                foreach ( (array) bp_core_get_directory_page_ids() as $page_id ) {
     786                        wp_delete_post( $page_id, true );
     787                }
     788                bp_delete_option( 'bp-pages' );
     789
    991790                foreach ( $pages as $key => $value ) {
     791
     792                        // Check for the selected page
    992793                        if ( 'page' == $value ) {
    993                                 // Check for the selected page
    994                                 if ( !empty( $_POST['bp-' . $key . '-page'] ) )
     794                                if ( !empty( $_POST['bp-' . $key . '-page'] ) ) {
    995795                                        $bp_pages[$key] = (int) $_POST['bp-' . $key . '-page'];
    996                                 else
     796                                } else {
    997797                                        $bp_pages[$key] = wp_insert_post( array( 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_title' => ucwords( $key ), 'post_status' => 'publish', 'post_type' => 'page' ) );
     798                                }
     799
     800                        // Create a new page
    998801                        } else {
    999                                 // Create a new page
    1000802                                $bp_pages[$key] = wp_insert_post( array( 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_title' => ucwords( $value ), 'post_status' => 'publish', 'post_type' => 'page' ) );
    1001803                        }
     
    1007809        // Database update methods based on version numbers
    1008810        function update_1_5() {
    1009 
    1010                 // Delete old database version options
    1011811                delete_site_option( 'bp-activity-db-version' );
    1012812                delete_site_option( 'bp-blogs-db-version'    );
     
    1044844 * Get the wizard
    1045845 *
    1046  * @global type $bp
    1047846 * @return boolean
    1048847 */
    1049848function bp_get_wizard() {
    1050         global $bp;
     849        $bp = buddypress();
    1051850
    1052851        if ( !empty( $bp->admin->wizard ) )
  • trunk/bp-core/bp-core-admin.php

    r6342 r6343  
    8383         */
    8484        private function setup_globals() {
    85                 global $bp;
    86 
    87                 // Admin url
    88                 $this->admin_dir  = trailingslashit( $bp->plugin_dir . 'bp-core/admin' );
    89 
    90                 // Admin url
    91                 $this->admin_url  = trailingslashit( $bp->plugin_url . 'bp-core/admin' );
    92 
    93                 // Admin images URL
    94                 $this->images_url = trailingslashit( $this->admin_url . 'images' );
    95 
    96                 // Admin css URL
    97                 $this->css_url    = trailingslashit( $this->admin_url . 'css'    );
    98 
    99                 // Admin css URL
    100                 $this->js_url     = trailingslashit( $this->admin_url . 'js'     );
     85                $bp               = buddypress();
     86                $this->admin_dir  = trailingslashit( $bp->plugin_dir  . 'bp-core/admin' ); // Admin path
     87                $this->admin_url  = trailingslashit( $bp->plugin_url  . 'bp-core/admin' ); // Admin url
     88                $this->images_url = trailingslashit( $this->admin_url . 'images'        ); // Admin images URL
     89                $this->css_url    = trailingslashit( $this->admin_url . 'css'           ); // Admin css URL
     90                $this->js_url     = trailingslashit( $this->admin_url . 'js'            ); // Admin css URL
    10191        }
    10292
     
    150140                add_action( bp_core_admin_hook(),    array( $this, 'admin_menus' ), 5 );
    151141
    152                 // Add notice if not using a BuddyPress theme
     142                // Add notice if an update is needed
    153143                add_action( 'admin_notices',         array( $this, 'admin_notices' ) );
    154144                add_action( 'network_admin_notices', array( $this, 'admin_notices' ) );
     
    186176                if ( bp_get_maintenance_mode() ) {
    187177
    188                         if ( !current_user_can( 'manage_options' ) )
     178                        if ( !current_user_can( 'manage_options' ) ) {
    189179                                return;
    190 
    191                         if ( bp_get_maintenance_mode() == 'install' )
     180                        }
     181
     182                        if ( bp_get_maintenance_mode() == 'install' ) {
    192183                                $status = __( 'BuddyPress Setup', 'buddypress' );
    193                         else
     184                        } else {
    194185                                $status = __( 'Update BuddyPress',  'buddypress' );
     186                        }
    195187
    196188                        if ( bp_get_wizard() ) {
     
    206198
    207199                        // Bail if user cannot moderate
    208                         if ( ! bp_current_user_can( 'manage_options' ) )
     200                        if ( ! bp_current_user_can( 'manage_options' ) ) {
    209201                                return;
     202                        }
    210203
    211204                        $hooks = array();
     
    477470                        // Update text
    478471                        case 'update' :
    479                                 $msg = sprintf( __( 'BuddyPress has been updated! Please run the <a href="%s">update wizard</a>.', 'buddypress' ), $url );
     472                                $msg = sprintf( __( 'BuddyPress has been updated! Please run the <a href="%s">update wizard</a>.', 'buddypress' ), esc_url( $url ) );
    480473                                break;
    481474
    482475                        // First install text
    483476                        case 'install' : default :
    484                                 $msg = sprintf( __( 'BuddyPress was successfully activated! Please run the <a href="%s">installation wizard</a>.', 'buddypress' ), $url );
     477                                $msg = sprintf( __( 'BuddyPress was successfully activated! Please run the <a href="%s">installation wizard</a>.', 'buddypress' ), esc_url( $url ) );
    485478                                break;
    486479                } ?>
     
    501494 */
    502495function bp_admin() {
    503         global $bp;
    504 
    505         $bp->admin = new BP_Admin();
     496        buddypress()->admin = new BP_Admin();
    506497}
  • trunk/bp-loader.php

    r6334 r6343  
    273273
    274274                $this->version    = '1.7-bleeding-6326';
    275                 $this->db_version = 6066;
     275                $this->db_version = 6067;
    276276
    277277                /** Loading ***********************************************************/
Note: See TracChangeset for help on using the changeset viewer.