Skip to:
Content

BuddyPress.org

Changeset 5223 for trunk


Ignore:
Timestamp:
10/08/2011 06:46:09 PM (14 years ago)
Author:
djpaul
Message:

Switch to use the WP Admin Bar by default. See #3661

Location:
trunk
Files:
4 edited

Legend:

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

    r5151 r5223  
    7979            return false;
    8080
     81        // "Switch to Admin Bar" is an optional option, so handle it here
     82        if ( !empty( $_POST['bp-admin']['bp-force-buddybar'] ) ) {
     83            unset( $_POST['bp-admin']['bp-force-buddybar'] );
     84
     85            // Switch to the WP Admin Bar by removing the BuddyBar override
     86            bp_delete_option( 'bp-force-buddybar' );
     87        }
     88
    8189        // Settings form submitted, now save the settings.
    8290        foreach ( (array)$_POST['bp-admin'] as $key => $value )
     
    164172                    <?php endif; ?>
    165173
     174                    <?php if ( (bool) bp_get_option( 'bp-force-buddybar', false ) ) : ?>
     175                        <tr>
     176                            <th scope="row"><?php _e( 'Switch the site to the WordPress Admin Bar?', 'buddypress' ); ?></th>
     177                            <td>
     178                                <input type="checkbox" name="bp-admin[bp-force-buddybar]" value="1" id="bp-switch-to-admin-bar" />
     179                            </td>
     180                        </tr>
     181                    <?php endif; ?>
     182
    166183                    <?php do_action( 'bp_core_admin_screen_fields' ) ?>
    167184
  • trunk/bp-core/admin/bp-core-update.php

    r5202 r5223  
    8585                $steps[] = __( 'Database Update', 'buddypress' );
    8686
     87            // New for BP 1.5
    8788            if ( $this->database_version < 1801 || !bp_core_get_directory_page_ids() ) {
    8889                $steps[] = __( 'Components', 'buddypress' );
     
    9091            }
    9192
     93            // New for BP 1.6
     94            if ( $this->database_version < 5222 && !defined( 'BP_USE_WP_ADMIN_BAR' ) )
     95                $steps[] = __( 'Admin Bar', 'buddypress' );
     96
    9297            $steps[] = __( 'Finish', 'buddypress' );
    9398        }
     
    100105        // Save any posted values
    101106        switch ( $step_name ) {
    102             case 'db_update': default:
     107            case 'db_update':
    103108                $result = $this->step_db_update_save();
    104109                break;
    105110
    106             case 'ms_update': default:
     111            case 'ms_update':
    107112                $result = $this->step_ms_update_save();
    108113                break;
    109114
    110             case 'ms_pages': default:
     115            case 'ms_pages':
    111116                $result = $this->step_ms_update_save();
    112117                break;
    113118
    114             case 'components': default:
     119            case 'components':
    115120                $result = $this->step_components_save();
    116121                break;
    117122
    118             case 'pages': default:
     123            case 'pages':
    119124                $result = $this->step_pages_save();
    120125                break;
    121126
    122             case 'permalinks': default:
     127            case 'permalinks':
    123128                $result = $this->step_permalinks_save();
    124129                break;
    125130
    126             case 'theme': default:
     131            case 'theme':
    127132                $result = $this->step_theme_save();
    128133                break;
    129134
    130             case 'finish': default:
     135            case 'admin_bar':
     136                $result = $this->step_admin_bar_save();
     137                break;
     138
     139            case 'finish':
     140            default:
    131141                $result = $this->step_finish_save();
    132142                break;
     
    233243                            break;
    234244
     245                        case __( 'Admin Bar', 'buddypress' ) :
     246                            $this->step_admin_bar();
     247                            break;
     248
    235249                        case __( 'Finish', 'buddypress') :
    236250                            $this->step_finish();
    237251                            break;
    238 
    239252                    } ?>
    240253
     
    730743    }
    731744
     745    /**
     746     * When upgrading to BP 1.6, prompt the admin to switch to WordPress' admin bar.
     747     *
     748     * @since 1.6
     749     */
     750    function step_admin_bar() {
     751        if ( !current_user_can( 'activate_plugins' ) )
     752            return false;
     753        ?>
     754
     755        <p><?php _e( "BuddyPress now uses WordPress' Admin Bar; this sits at the top of your site and contains various links to useful admin screens. We've turbo-charged the Admin Bar by adding social items to help your users explore your site, and manage their content.", 'buddypress' ); ?></p>
     756
     757        <p><?php _e( "We've noticed that your site uses the old bar from earlier versions of BuddyPress.", 'buddypress' ); ?></p>
     758
     759        <p>
     760            <label>
     761                <input type="checkbox" name="keep_buddybar" value="1" />
     762                <?php _e( "If you'd prefer to not switch to the WordPress Admin bar just yet, check this box. Don't worry, you can change your mind later.", 'buddypress' ); ?>
     763            </label>
     764        </p>
     765
     766        <div class="submit clear">
     767            <input type="hidden" name="save" value="admin_bar" />
     768            <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ); ?>" />
     769
     770            <?php wp_nonce_field( 'bpwizard_admin_bar' ) ?>
     771        </div>
     772
     773        <?php
     774    }
     775
    732776    function step_finish() {
    733777        if ( !current_user_can( 'activate_plugins' ) )
     
    10161060            if ( is_multisite() )
    10171061                restore_current_blog();
     1062
     1063            return true;
     1064        }
     1065
     1066        return false;
     1067    }
     1068
     1069    /**
     1070     * When upgrading to BP 1.6, the admin is prompted to switch to WordPress' admin bar.
     1071     * If they choose not to, record that preference in the options table.
     1072     *
     1073     * @since 1.6
     1074     */
     1075    function step_admin_bar_save() {
     1076        if ( isset( $_POST['submit'] ) ) {
     1077            check_admin_referer( 'bpwizard_admin_bar' );
     1078
     1079            if ( !empty( $_POST['keep_buddybar'] ) )
     1080                bp_update_option( 'bp-force-buddybar', 1 );
    10181081
    10191082            return true;
  • trunk/bp-core/bp-core-functions.php

    r5221 r5223  
    12891289 *
    12901290 * The WP Admin Bar, introduced in WP 3.1, is fully supported in BuddyPress as of BP 1.5.
    1291  *
    1292  * For the BP 1.5 development cycle, the BuddyBar will remain the default navigation for BP
    1293  * installations. In the future, this behavior will be changed, so that the WP Admin Bar is the
    1294  * default.
    1295  *
    1296  * @package BuddyPress
    1297  * @since 1.5
    1298  *
     1291 * For BP 1.6, the WP Admin Bar is the default.
     1292 *
     1293 * @return bool False when WP Admin Bar support is disabled; true when enabled (default)
     1294 * @since 1.5
    12991295 * @uses apply_filters() Filter 'bp_use_wp_admin_bar' to alter
    1300  * @return bool False when WP Admin Bar support is disabled (default); true when enabled
    13011296 */
    13021297function bp_use_wp_admin_bar() {
    1303     return apply_filters( 'bp_use_wp_admin_bar', defined( 'BP_USE_WP_ADMIN_BAR' ) && BP_USE_WP_ADMIN_BAR );
     1298    $use_admin_bar = true;
     1299
     1300    // Has the WP Admin Bar constant been explicity set?
     1301    if ( defined( 'BP_USE_WP_ADMIN_BAR' ) && ! BP_USE_WP_ADMIN_BAR )
     1302        $use_admin_bar = false;
     1303
     1304    // Has the admin chosen to use the BuddyBar during an upgrade?
     1305    elseif ( (bool) bp_get_option( 'bp-force-buddybar', false ) )
     1306        $use_admin_bar = false;
     1307
     1308    return apply_filters( 'bp_use_wp_admin_bar', $use_admin_bar );
    13041309}
    13051310
  • trunk/bp-loader.php

    r5222 r5223  
    2222// Define the database version
    2323if ( !defined( 'BP_DB_VERSION' ) )
    24     define( 'BP_DB_VERSION', 3820 );
     24    define( 'BP_DB_VERSION', 5222 );
    2525
    2626// Place your custom code (actions/filters) in a file called
Note: See TracChangeset for help on using the changeset viewer.