Skip to:
Content

BuddyPress.org

Ticket #2789: 2789.009.patch

File 2789.009.patch, 14.0 KB (added by boonebgorges, 9 years ago)
  • bp-themes/bp-default/functions.php

     
    4040 * Temporary work-around to prevent errors with bp-default being active
    4141 * when BuddyPress is not installed.
    4242 */
    43 if ( !constant( 'BP_VERSION' ) || !get_site_option( 'bp-db-version' ) ) {
     43/*if ( !constant( 'BP_VERSION' ) || !get_site_option( 'bp-db-version' ) ) {
    4444        switch_theme( 'twentyten', 'twentyten' );
    4545        wp_redirect( $_SERVER['HTTP_REFERER'] );
    4646        exit;
    47 }
     47}*/
    4848
    4949if ( !function_exists( 'bp_dtheme_setup' ) ) :
    5050/**
  • bp-core/admin/bp-core-update.php

     
    11<?php
    22
    3 if ( !defined( 'BP_ROOT_BLOG' ) )
    4         define( 'BP_ROOT_BLOG', 1 );
    5 
    6 require_once( dirname( dirname( __FILE__ ) ) . '/bp-core-wpabstraction.php' );
    7 
    8 register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' );
    9 
    10 // Install site options on activation
    11 bp_core_activate_site_options( array( 'bp-disable-account-deletion' => 0, 'bp-disable-avatar-uploads' => 0, 'bp-disable-blogforum-comments' => 0,  'bp-disable-forum-directory' => 0,  'bp-disable-profile-sync' => 0 ) );
    12 
    13 /**
    14  * When switching from single to multisite we need to copy blog options to
    15  * site options.
    16  *
    17  * @package BuddyPress Core
    18  */
    19 function bp_core_activate_site_options( $keys = array() ) {
    20         global $bp;
    21 
    22         $bp->site_options = bp_core_get_site_options();
    23 
    24         if ( !empty( $keys ) && is_array( $keys ) ) {
    25                 $errors = false;
    26 
    27                 foreach ( $keys as $key => $default ) {
    28                         if ( empty( $bp->site_options[ $key ] ) ) {
    29                                 $bp->site_options[ $key ] = get_blog_option( BP_ROOT_BLOG, $key, $default );
    30 
    31                                 if ( !update_site_option( $key, $bp->site_options[ $key ] ) )
    32                                         $errors = true;
    33                         }
    34                 }
    35 
    36                 if ( empty( $errors ) )
    37                         return true;
    38         }
    39 
    40         return false;
    41 }
    42 
    433class BP_Core_Setup_Wizard {
    444        var $current_step;
    455        var $steps;
     
    11474                        if ( $this->current_version < $this->new_version )
    11575                                $steps[] = __( 'Database Update', 'buddypress' );
    11676
    117                         if ( $this->current_version < 1225 )
     77                        if ( $this->current_version < 1225 || ( function_exists( 'bp_core_get_page_meta' ) && !bp_core_get_page_meta() ) )
    11878                                $steps[] = __( 'Pages', 'buddypress' );
    11979
    12080                        $steps[] = __( 'Finish', 'buddypress' );
     
    151111                                $result = $this->step_finish_save();
    152112                                break;
    153113                }
    154 
     114               
    155115                if ( !$result && $this->current_step )
    156116                        $this->current_step--;
    157117
     
    460420                $disabled_components = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) );
    461421
    462422                // Check for defined slugs
    463                 if ( defined( 'BP_MEMBERS_SLUG' ) )
     423                if ( defined( 'BP_MEMBERS_SLUG' ) && BP_MEMBERS_SLUG )
    464424                        $members_slug = constant( 'BP_MEMBERS_SLUG' );
    465425                else
    466426                        $members_slug = __( 'members', 'buddypress' );
    467427
    468                 if ( defined( 'BP_GROUPS_SLUG' ) )
     428                if ( defined( 'BP_GROUPS_SLUG' ) && BP_GROUPS_SLUG )
    469429                        $groups_slug = constant( 'BP_GROUPS_SLUG' );
    470430                else
    471431                        $groups_slug = __( 'groups', 'buddypress' );
    472432
    473                 if ( defined( 'BP_ACTIVITY_SLUG' ) )
     433                if ( defined( 'BP_ACTIVITY_SLUG' ) && BP_ACTIVITY_SLUG )
    474434                        $activity_slug = constant( 'BP_ACTIVITY_SLUG' );
    475435                else
    476436                        $activity_slug = __( 'activity', 'buddypress' );
    477437
    478                 if ( defined( 'BP_FORUMS_SLUG' ) )
     438                if ( defined( 'BP_FORUMS_SLUG' ) && BP_FORUMS_SLUG )
    479439                        $forums_slug = constant( 'BP_FORUMS_SLUG' );
    480440                else
    481441                        $forums_slug = __( 'forums', 'buddypress' );
    482442
    483                 if ( defined( 'BP_BLOGS_SLUG' ) )
     443                if ( defined( 'BP_BLOGS_SLUG' ) && BP_BLOGS_SLUG )
    484444                        $blogs_slug = constant( 'BP_BLOGS_SLUG' );
    485445                else
    486446                        $blogs_slug = __( 'blogs', 'buddypress' );
    487447
    488                 if ( defined( 'BP_REGISTER_SLUG' ) )
     448                if ( defined( 'BP_REGISTER_SLUG' ) && BP_REGISTER_SLUG )
    489449                        $register_slug = constant( 'BP_REGISTER_SLUG' );
    490450                else
    491451                        $register_slug = __( 'register', 'buddypress' );
    492452
    493                 if ( defined( 'BP_ACTIVATION_SLUG' ) )
     453                if ( defined( 'BP_ACTIVATION_SLUG' ) && BP_ACTIVATION_SLUG )
    494454                        $activation_slug = constant( 'BP_ACTIVATION_SLUG' );
    495455                else
    496456                        $activation_slug = __( 'activate', 'buddypress' );
     
    786746        <?php
    787747        }
    788748
    789         function step_finish() {
     749        function step_finish() {                       
     750                // Update the DB version in the database
     751                update_site_option( 'bp-db-version', constant( 'BP_DB_VERSION' ) );
     752                delete_site_option( 'bp-core-db-version' );
     753       
    790754                if ( !current_user_can( 'activate_plugins' ) )
    791755                        return false;
    792756
     
    828792
    829793                        if ( $this->current_version < 1225 )
    830794                                $this->update_1_3();
    831 
     795                               
    832796                        return true;
    833797                }
    834798
     
    917881                                switch_to_blog( BP_ROOT_BLOG );
    918882
    919883                        // Delete any existing pages
    920                         $existing_pages = get_option( 'bp-pages' );
     884                        $existing_pages = bp_core_update_get_page_meta( 'bp-pages' );
    921885
    922886                        foreach ( (array)$existing_pages as $page_id )
    923887                                wp_delete_post( $page_id, true );
     
    10601024        function step_finish_save() {
    10611025                if ( isset( $_POST['submit'] ) ) {
    10621026                        check_admin_referer( 'bpwizard_finish' );
    1063 
     1027                       
    10641028                        // Delete the setup cookie
    10651029                        @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH );
    10661030
     
    11211085}
    11221086add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_core_setup_wizard_init', 7 );
    11231087
    1124 
    11251088function bp_core_install( $disabled = false ) {
    11261089        global $wpdb;
    11271090
     
    11981161}
    11991162
    12001163/**
    1201  * bp_core_add_admin_menu_page()
    1202  *
    12031164 * A better version of add_admin_menu_page() that allows positioning of menus.
    12041165 *
    12051166 * @package BuddyPress Core
    12061167 */
    1207 function bp_core_add_admin_menu_page( $args = '' ) {
     1168function bp_core_update_add_admin_menu_page( $args = '' ) {
    12081169        global $menu, $admin_page_hooks, $_registered_pages;
    12091170
    12101171        $defaults = array(
     
    12711232 * @global $wpdb WordPress DB access object.
    12721233 * @uses add_submenu_page() WP function to add a submenu item
    12731234 */
    1274 function bp_core_add_admin_menu() {
     1235function bp_core_update_add_admin_menu() {
    12751236        global $bp_wizard;
    12761237
     1238        // Only load this version of the menu if this is an upgrade or a new installation
     1239        if ( ( !defined( 'BP_IS_UPGRADE' ) || !BP_IS_UPGRADE ) && ( !defined( 'BP_IS_INSTALL' ) || !BP_IS_INSTALL ) )
     1240                return false;
     1241       
    12771242        if ( !current_user_can( 'activate_plugins' ) )
    12781243                return false;
    12791244
     
    12831248                $status = __( 'Update', 'buddypress' );
    12841249
    12851250        // Add the administration tab under the "Site Admin" tab for site administrators
    1286         bp_core_add_admin_menu_page( array(
     1251        bp_core_update_add_admin_menu_page( array(
    12871252                'menu_title'   => __( 'BuddyPress', 'buddypress' ),
    12881253                'page_title'   => __( 'BuddyPress', 'buddypress' ),
    12891254                'capability'   => 'manage_options',
     
    12951260        $hook = add_submenu_page( 'bp-wizard', $status, $status, 'manage_options', 'bp-wizard', array( $bp_wizard, 'html' ) );
    12961261
    12971262        // Add a hook for css/js
    1298         add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );
     1263        add_action( "admin_print_styles-$hook", 'bp_core_update_add_admin_menu_styles' );
    12991264}
    1300 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu',  'bp_core_add_admin_menu', 9 );
     1265add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu',  'bp_core_update_add_admin_menu', 9 );
    13011266
    1302 function bp_core_add_admin_menu_styles() {
     1267function bp_core_update_add_admin_menu_styles() {
    13031268        if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG )
    13041269                wp_enqueue_style( 'bp-admin-css', apply_filters( 'bp_core_admin_css', plugins_url( $path = '/buddypress' ) . '/bp-core/css/admin.dev.css' ) );
    13051270        else
     
    13301295}
    13311296add_action( 'admin_head', 'bp_core_add_admin_menu_styles' );
    13321297
     1298/**
     1299 * Fetches BP pages from the meta table, depending on setup
     1300 *
     1301 * @package BuddyPress Core
     1302 * @since 1.3
     1303 *
     1304 * @return array $page_ids
     1305 */
     1306function bp_core_update_get_page_meta() {
     1307        if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && is_multisite() )
     1308                $page_ids = get_blog_option( BP_ROOT_BLOG, 'bp-pages' );
     1309        else
     1310                $page_ids = get_option( 'bp-pages' );
     1311
     1312        return $page_ids;
     1313}
     1314
     1315/**
     1316 * Adds an admin nag about running the BP upgrade/install wizard
     1317 *
     1318 * @package BuddyPress Core
     1319 * @since 1.3
     1320 * @global $pagenow The current admin page
     1321 */
     1322function bp_core_update_nag() {
     1323        global $pagenow;
     1324
     1325        if ( !is_super_admin() )
     1326                return;
     1327       
     1328        if ( 'admin.php' == $pagenow && ( empty( $_GET['page'] ) || 'bp-wizard' == $_GET['page'] ) )
     1329                return;
     1330       
     1331        if ( defined( 'BP_IS_UPGRADE' ) && BP_IS_UPGRADE )
     1332                $msg = sprintf( __( 'BuddyPress has been updated! Please run the <a href="%s">upgrade wizard</a>.', 'buddypress' ), admin_url( 'admin.php?page=bp-wizard' ) );
     1333        else if ( defined( 'BP_IS_INSTALL' ) && BP_IS_INSTALL )
     1334                $msg = sprintf( __( 'BuddyPress has been installed! Please run the <a href="%s">upgrade wizard</a>.', 'buddypress' ), admin_url( 'admin.php?page=bp-wizard' ) );
     1335                 
     1336        echo "<div class='update-nag'>$msg</div>";
     1337}
     1338add_action( 'admin_notices', 'bp_core_update_nag', 5 );
     1339
     1340
    13331341?>
  • bp-loader.php

     
    1010*/
    1111
    1212define( 'BP_VERSION', '1.3-bleeding' );
    13 define( 'BP_DB_VERSION', 1225 );
     13define( 'BP_DB_VERSION', 3705 );
    1414
    1515// Define on which blog ID BuddyPress should run
    1616if ( !defined( 'BP_ROOT_BLOG' ) )
    1717        define( 'BP_ROOT_BLOG', 1 );
    1818
    19 /***
    20  * Check if this is the first time BuddyPress has been loaded, or the first time
    21  * since an update. If so, load the install/update routine only.
    22  */
    23 if ( get_site_option( 'bp-db-version' ) < constant( 'BP_DB_VERSION' ) ) {
     19// Register BuddyPress themes contained within the bp-themes folder
     20register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' );
     21         
     22// Test to see whether this is a new installation or an upgraded version of BuddyPress
     23$bp_db_version = get_site_option( 'bp-db-version' );
     24if ( ! $bp_db_version )
     25        $bp_db_version = get_site_option( 'bp-core-db-version' );  // BP 1.2 option name
     26         
     27if ( ! $bp_db_version ) {
     28        // This is a new installation. Run the wizard before loading BP core files
     29        define( 'BP_IS_INSTALL', true );
    2430        require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' );
    25 
    26 /***
    27  * If the install or update routine is completed and everything is up to date
    28  * continue loading BuddyPress as normal.
    29  */
    3031} else {
    3132        /***
    3233         * This file will load in each BuddyPress component based on which
     
    6465        // Extended Profiles
    6566        if ( !isset( $bp_deactivated['bp-xprofile.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') )
    6667                include( BP_PLUGIN_DIR . '/bp-xprofile.php' );
     68               
     69        // If this is an upgrade, load the upgrade file
     70        if ( $bp_db_version < constant( 'BP_DB_VERSION' ) ) {
     71                define( 'BP_IS_UPGRADE', true );
     72                require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' );
     73        }
    6774
    6875        add_action( 'plugins_loaded', 'bp_loaded', 20 );
    6976}
     
    135142        return apply_filters( 'bp_core_get_site_options', $site_options );
    136143}
    137144
    138 // Activation Function
     145/**
     146 * Defines BP's activation routine.
     147 *
     148 * Most of BP's crucial setup is handled by the setup wizard. This function takes care of some
     149 * issues with incompatible legacy themes, and provides a hook for other functions to know that
     150 * BP has been activated.
     151 *
     152 * @package BuddyPress Core
     153*/
    139154function bp_loader_activate() {
    140155        // Force refresh theme roots.
    141156        delete_site_transient( 'theme_roots' );
    142157
     158        if ( !function_exists( 'get_blog_option' ) )
     159                require ( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-wpabstraction.php' );
     160
    143161        // Switch the user to the new bp-default if they are using the old
    144162        // bp-default on activation.
    145163        if ( 'bp-sn-parent' == get_blog_option( BP_ROOT_BLOG, 'template' ) && 'bp-default' == get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) )
  • bp-blogs.php

     
    1313
    1414        if ( !defined( 'BP_BLOGS_SLUG' ) && isset( $bp->pages->blogs->slug ) )
    1515                define ( 'BP_BLOGS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->blogs->slug ) );
    16         else if( !defined( 'BP_BLOGS_SLUG' ) )
     16        else if ( !defined( 'BP_BLOGS_SLUG' ) )
    1717                define ( 'BP_BLOGS_SLUG', 'blogs' );
    1818
    1919        // For internal identification
  • bp-core.php

     
    4343if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) )
    4444        require ( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' );
    4545
    46 // Register BuddyPress themes contained within the bp-theme folder
    47 register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' );
    48 
    4946/** "And now for something completely different" ******************************/
    5047
    5148/**
     
    207204 * Define the slugs used for BuddyPress pages, based on the slugs of the WP pages used.
    208205 * These can be overridden manually by defining these slugs in wp-config.php.
    209206 *
     207 * The fallback values are only used during initial BP page creation, when no slugs have been
     208 * explicitly defined.
     209 *
    210210 * @package BuddyPress Core Core
    211211 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    212212 */
     
    215215
    216216        if ( !defined( 'BP_MEMBERS_SLUG' ) )
    217217                define( 'BP_MEMBERS_SLUG', $bp->pages->members->slug );
    218 
     218       
    219219        if ( !defined( 'BP_REGISTER_SLUG' ) )
    220220                define( 'BP_REGISTER_SLUG', $bp->pages->register->slug );
    221 
     221       
    222222        if ( !defined( 'BP_ACTIVATION_SLUG' ) )
    223223                define( 'BP_ACTIVATION_SLUG', $bp->pages->activate->slug );
     224       
    224225}
    225226add_action( 'bp_setup_globals', 'bp_core_define_slugs' );
    226227
     
    347348function bp_core_add_admin_menu() {
    348349        if ( !is_super_admin() )
    349350                return false;
     351       
     352        // Don't add this version of the admin menu if a BP upgrade is in progress
     353        // See bp_core_update_add_admin_menu()
     354        if ( defined( 'BP_IS_UPGRADE' ) && BP_IS_UPGRADE )
     355                return false;
    350356
    351357        // Add the administration tab under the "Site Admin" tab for site administrators
    352358        $hook = bp_core_add_admin_menu_page( array(