Skip to:
Content

BuddyPress.org

Changeset 5309


Ignore:
Timestamp:
11/08/2011 08:39:23 PM (13 years ago)
Author:
johnjamesjacoby
Message:

bp-loader.php is a real boy! Introduce BuddyPress class to handle the loading of BuddyPress core and provide declarations to the $bp global variables. Ports several functions and methods from bbPress 2.0 into bp-core-update.php to manage the hand-off into the update routine. See #3739.

Location:
trunk
Files:
1 added
5 edited

Legend:

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

    r5223 r5309  
    44
    55class BP_Core_Setup_Wizard {
     6
     7    /**
     8     * @var int The current step of the updater
     9     */
    610    var $current_step;
     11
     12    /**
     13     *
     14     * @var array The total steps to be completed
     15     */
    716    var $steps;
    817
    9     var $database_version;
     18    /**
     19     * @var int Database version of current BuddyPress files
     20     */
     21    var $db_version;
     22
     23    /**
     24     * @var int Database version raw from the database connection
     25     */
     26    var $db_version_raw;
     27
     28    /**
     29     * @var int Are we currently network activated
     30     */
    1031    var $is_network_activate;
    11     var $new_version;
     32
     33    /**
     34     * @var string What kind of setup/update are we performing
     35     */
    1236    var $setup_type;
     37
     38    /** Functions *************************************************************/
    1339
    1440    function bp_core_setup_wizard() {
     
    2450
    2551        // Get current DB version
    26         $this->database_version = !empty( $bp->database_version ) ? (int) $bp->database_version : 0;
     52        $this->db_version_raw = !empty( $bp->db_version_raw ) ? (int) $bp->db_version_raw : 0;
    2753
    2854        if ( !empty( $bp->is_network_activate ) ) {
     
    3460        }
    3561
    36         $this->new_version  = constant( 'BP_DB_VERSION' );
     62        $this->db_version   = bp_get_db_version();
    3763        $this->setup_type   = !empty( $bp->maintenance_mode ) ? $bp->maintenance_mode : '';
    3864        $this->current_step = $this->current_step();
     
    82108                $steps[] = __( 'Multisite Update', 'buddypress' );
    83109
    84             if ( $this->database_version < (int) $this->new_version )
     110            if ( $this->db_version_raw < (int) $this->db_version )
    85111                $steps[] = __( 'Database Update', 'buddypress' );
    86112
    87113            // New for BP 1.5
    88             if ( $this->database_version < 1801 || !bp_core_get_directory_page_ids() ) {
     114            if ( $this->db_version_raw < 1801 || !bp_core_get_directory_page_ids() ) {
    89115                $steps[] = __( 'Components', 'buddypress' );
    90116                $steps[] = __( 'Pages', 'buddypress' );
     
    92118
    93119            // New for BP 1.6
    94             if ( $this->database_version < 5222 && !defined( 'BP_USE_WP_ADMIN_BAR' ) )
     120            if ( $this->db_version_raw < 5222 && !defined( 'BP_USE_WP_ADMIN_BAR' ) )
    95121                $steps[] = __( 'Admin Bar', 'buddypress' );
    96122
     
    805831            bp_core_install();
    806832
    807             if ( $this->database_version < 1801 )
     833            if ( $this->db_version_raw < 1801 )
    808834                $this->update_1_5();
    809835
     
    829855            // Transfer important settings from blog options to site options
    830856            $options = array(
    831                 'bp-db-version'        => $this->database_version,
     857                '_bp_db_version'       => $this->db_version,
    832858                'bp-active-components' => $active_components,
    833859                'avatar-default'       => get_option( 'avatar-default' )
     
    844870                // Move bp-pages data from the blog options table to site options
    845871                $existing_pages = bp_get_option( 'bp-pages' );
    846 
    847872                $bp_pages       = $this->setup_pages( (array)$_POST['bp_pages'] );
    848873                $bp_pages       = array_merge( (array)$existing_pages, (array)$bp_pages );
     
    856881            }
    857882
     883            // Delete the old site option
     884            delete_site_option( 'bp-db-version' );
     885
     886            // Update the active components
    858887            bp_update_option( 'bp-active-components', $active_components );
    859888
     
    10921121            // Update the DB version in the database
    10931122            // Stored in sitemeta. Do not use bp_update_option()
    1094             update_site_option( 'bp-db-version', $this->new_version );
     1123            update_site_option( 'bp-db-version', $this->db_version );
    10951124            delete_site_option( 'bp-core-db-version' );
    10961125
  • trunk/bp-core/bp-core-functions.php

    r5305 r5309  
    11<?php
     2
     3/**
     4 * BuddyPress Common Functions
     5 *
     6 * @package BuddyPress
     7 * @subpackage Functions
     8 */
     9
    210// Exit if accessed directly
    311if ( !defined( 'ABSPATH' ) ) exit;
     12
     13/** Versions ******************************************************************/
     14
     15/**
     16 * Output the BuddyPress version
     17 *
     18 * @since BuddyPress (1.6)
     19 * @uses bp_get_version() To get the BuddyPress version
     20 */
     21function bp_version() {
     22    echo bp_get_version();
     23}
     24    /**
     25     * Return the BuddyPress version
     26     *
     27     * @since BuddyPress (1.6)
     28     * @global BuddyPress $bp
     29     * @retrun string The BuddyPress version
     30     */
     31    function bp_get_version() {
     32        global $bp;
     33        return $bp->version;
     34    }
     35
     36/**
     37 * Output the BuddyPress database version
     38 *
     39 * @since BuddyPress (1.6)
     40 * @uses bp_get_version() To get the BuddyPress version
     41 */
     42function bp_db_version() {
     43    echo bp_get_db_version();
     44}
     45    /**
     46     * Return the BuddyPress database version
     47     *
     48     * @since BuddyPress (1.6)
     49     * @global BuddyPress $bp
     50     * @retrun string The BuddyPress version
     51     */
     52    function bp_get_db_version() {
     53        global $bp;
     54        return $bp->db_version;
     55    }
     56
     57/** Functions *****************************************************************/
    458
    559/**
     
    11201174 */
    11211175function bp_is_root_blog( $blog_id = 0 ) {
     1176
    11221177    // Assume false
    11231178    $is_root_blog = false;
     
    11401195 * @since 1.5
    11411196 *
    1142  * @param int $blog_id Optional. Defaults to the current blog id.
    11431197 * @return bool $is_root_blog Returns true if this is bp_get_root_blog_id().
    11441198 */
    1145 function bp_get_root_blog_id( $blog_id = false ) {
     1199function bp_get_root_blog_id() {
     1200
     1201    // Default to 1
     1202    $root_blog_id = 1;
    11461203
    11471204    // Define on which blog ID BuddyPress should run
     
    11561213        } elseif ( is_multisite() && bp_is_multiblog_mode() ) {
    11571214            $root_blog_id = get_current_blog_id();
    1158 
    1159         // Root blog is the only blog on this network
    1160         } elseif( !is_multisite() ) {
    1161             $root_blog_id = 1;
    11621215        }
    11631216
  • trunk/bp-core/bp-core-hooks.php

    r5300 r5309  
    160160}
    161161
     162/** Activation Actions ********************************************************/
     163
     164/**
     165 * Runs on BuddyPress activation
     166 *
     167 * @since BuddyPress (1.6)
     168 *
     169 * @uses do_action() Calls 'bp_activation' hook
     170 */
     171function bp_activation() {
     172    do_action( 'bp_activation' );
     173}
     174
     175/**
     176 * Runs on BuddyPress deactivation
     177 *
     178 * @since BuddyPress (1.6)
     179 *
     180 * @uses do_action() Calls 'bp_deactivation' hook
     181 */
     182function bp_deactivation() {
     183    do_action( 'bp_deactivation' );
     184}
     185
     186/**
     187 * Runs when uninstalling BuddyPress
     188 *
     189 * @since BuddyPress (1.6)
     190 *
     191 * @uses do_action() Calls 'bp_uninstall' hook
     192 */
     193function bp_uninstall() {
     194    do_action( 'bp_uninstall' );
     195}
     196
    162197?>
  • trunk/bp-core/bp-core-loader.php

    r5300 r5309  
    77require( BP_PLUGIN_DIR . '/bp-core/bp-core-hooks.php'      );
    88require( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php'      );
     9require( BP_PLUGIN_DIR . '/bp-core/bp-core-update.php'     );
    910require( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php'    );
    1011require( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php'    );
     
    3031    bp_update_option( 'bp-active-components', $active_components );
    3132
    32 /** "And now for something completely different" ******************************/
    33 
    3433class BP_Core extends BP_Component {
    3534
  • trunk/bp-loader.php

    r5298 r5309  
    11<?php
     2
     3/**
     4 * The BuddyPress Plugin
     5 *
     6 * BuddyPress is social networking software with a twist from the creators of WordPress.
     7 *
     8 * @package BuddyPress
     9 * @subpackage Main
     10 */
     11
    212/**
    313 * Plugin Name: BuddyPress
     
    515 * Description: Social networking in a box. Build a social network for your company, school, sports team or niche community all based on the power and flexibility of WordPress.
    616 * Author:      The BuddyPress Community
     17 * Author URI:  http://buddypress.org/community/members/
    718 * Version:     1.6-bleeding
    8  * Author URI:  http://buddypress.org/community/members/
     19 * Text Domain: buddypress
     20 * Domain Path: /bp-languages/
    921 * Network:     true
    1022 */
     
    1426
    1527/** Constants *****************************************************************/
    16 global $wpdb;
    17 
    18 // Define the BuddyPress version
    19 if ( !defined( 'BP_VERSION' ) )
    20     define( 'BP_VERSION', '1.6-bleeding' );
    21 
    22 // Define the database version
    23 if ( !defined( 'BP_DB_VERSION' ) )
    24     define( 'BP_DB_VERSION', 5249 );
    25 
    26 // Place your custom code (actions/filters) in a file called
    27 // '/plugins/bp-custom.php' and it will be loaded before anything else.
    28 if ( file_exists( WP_PLUGIN_DIR . '/bp-custom.php' ) )
    29     require( WP_PLUGIN_DIR . '/bp-custom.php' );
    30 
    31 // Define on which blog ID BuddyPress should run
    32 if ( !defined( 'BP_ROOT_BLOG' ) ) {
    33 
    34     // Root blog is the main site on this network
    35     if ( is_multisite() && !defined( 'BP_ENABLE_MULTIBLOG' ) ) {
    36         $current_site = get_current_site();
    37         $root_blog_id = $current_site->blog_id;
    38 
    39     // Root blog is every site on this network
    40     } elseif ( is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) ) {
    41         $root_blog_id = get_current_blog_id();
    42 
    43     // Root blog is the only blog on this network
    44     } elseif( !is_multisite() ) {
    45         $root_blog_id = 1;
     28
     29if ( !class_exists( 'BuddyPress' ) ) :
     30/**
     31 * Main BuddyPress Class
     32 *
     33 * Tap tap tap... Is this thing on?
     34 *
     35 * @since BuddyPress (1.6)
     36 */
     37class BuddyPress {
     38
     39    /**
     40     * Note to Plugin and Theme authors:
     41     *
     42     * Do not directly reference the variables below in your code. Their names
     43     * and locations in the BuddyPress class are subject to change at any time.
     44     *
     45     * Most of them have reference functions located in bp-core-functions.php.
     46     * The ones that don't can be accessed via their respective WordPress API's.
     47     *
     48     * Components are encouraged to store their data in the $bp global rather
     49     * than new globals to keep all BuddyPress data in one place.
     50     */
     51
     52    /** Version ***************************************************************/
     53
     54    /**
     55     * @var string BuddyPress version
     56     */
     57    public $version = '1.6-bleeding';
     58
     59    /**
     60     * @var int Database version of current BuddyPress files
     61     */
     62    public $db_version = 5249;
     63   
     64    /**
     65     * @var int Database version raw from database connection
     66     */
     67    public $db_version_raw = 0;
     68   
     69    /**
     70     * @var string State of BuddyPress installation
     71     */
     72    public $maintenance_mode = '';
     73
     74    /** Paths *****************************************************************/
     75
     76    /**
     77     * @var string Basename of the BuddyPress plugin directory
     78     */
     79    public $basename = '';
     80
     81    /**
     82     * @var string Absolute path to the BuddyPress plugin directory
     83     */
     84    public $plugin_dir = '';
     85
     86    /**
     87     * @var string Absolute path to the BuddyPress themes directory
     88     */
     89    public $themes_dir = '';
     90
     91    /**
     92     * @var string Absolute path to the BuddyPress language directory
     93     */
     94    public $lang_dir = '';
     95
     96    /** URLs ******************************************************************/
     97
     98    /**
     99     * @var string URL to the BuddyPress plugin directory
     100     */
     101    public $plugin_url = '';
     102
     103    /**
     104     * @var string URL to the BuddyPress themes directory
     105     */
     106    public $themes_url = '';
     107
     108    /** Users *****************************************************************/
     109
     110    /**
     111     * @var object Current user
     112     */
     113    public $current_user = array();
     114
     115    /**
     116     * @var object Displayed user
     117     */
     118    public $displayed_user = array();
     119
     120    /** Errors ****************************************************************/
     121
     122    /**
     123     * @var WP_Error Used to log and display errors
     124     */
     125    public $errors = array();
     126
     127    /** Forms *****************************************************************/
     128
     129    /**
     130     * @var int The current tab index for form building
     131     */
     132    public $tab_index = 0;
     133
     134    /** Theme Compat **********************************************************/
     135
     136    /**
     137     * @var string Theme to use for theme compatibility
     138     */
     139    public $theme_compat = '';
     140
     141    /** Extensions ************************************************************/
     142
     143    /**
     144     * @var mixed BuddyPress add-ons should append globals to this
     145     */
     146    public $extend = false;
     147
     148    /** Option Overload *******************************************************/
     149
     150    /**
     151     * @var array Optional Overloads default options retrieved from get_option()
     152     */
     153    public $options = array();
     154
     155    /** Permastructs **********************************************************/
     156
     157    /**
     158     * @var string User struct
     159     */
     160    public $user_id = '';
     161
     162    /**
     163     * @var string Edit struct
     164     */
     165    public $edit_id = '';
     166
     167    /** Statuses **************************************************************/
     168
     169    /**
     170     * @var string Public post status id. Used by forums, topics, and replies.
     171     */
     172    public $public_status_id = '';
     173
     174    /**
     175     * @var string Pending post status id. Used by topics and replies
     176     */
     177    public $pending_status_id = '';
     178
     179    /**
     180     * @var string Private post status id. Used by forums and topics.
     181     */
     182    public $private_status_id = '';
     183
     184    /**
     185     * @var string Closed post status id. Used by topics.
     186     */
     187    public $closed_status_id = '';
     188
     189    /**
     190     * @var string Spam post status id. Used by topics and replies.
     191     */
     192    public $spam_status_id = '';
     193
     194    /**
     195     * @var string Trash post status id. Used by topics and replies.
     196     */
     197    public $trash_status_id = '';
     198
     199    /**
     200     * @var string Orphan post status id. Used by topics and replies.
     201     */
     202    public $orphan_status_id = '';
     203
     204    /**
     205     * @var string Hidden post status id. Used by forums.
     206     */
     207    public $hidden_status_id = '';
     208
     209    /** Functions *************************************************************/
     210
     211    /**
     212     * The main BuddyPress loader
     213     *
     214     * @since BuddyPress (1.6)
     215     *
     216     * @uses BuddyPress::constants() Setup legacy constants
     217     * @uses BuddyPress::setup_globals() Setup globals needed
     218     * @uses BuddyPress::includes() Includ required files
     219     * @uses BuddyPress::setup_actions() Setup hooks and actions
     220     */
     221    public function __construct() {
     222        $this->constants();
     223        $this->setup_globals();
     224        $this->includes();
     225        $this->setup_actions();
    46226    }
    47227
    48     define( 'BP_ROOT_BLOG', $root_blog_id );
    49 }
    50 
    51 // Path and URL
    52 if ( !defined( 'BP_PLUGIN_DIR' ) )
    53     define( 'BP_PLUGIN_DIR', WP_PLUGIN_DIR . '/buddypress' );
    54 
    55 if ( !defined( 'BP_PLUGIN_URL' ) )
    56     define( 'BP_PLUGIN_URL', plugins_url( 'buddypress' ) );
    57 
    58 // The search slug has to be defined nice and early because of the way search requests are loaded
    59 if ( !defined( 'BP_SEARCH_SLUG' ) )
    60     define( 'BP_SEARCH_SLUG', 'search' );
    61 
    62 /** Loader ********************************************************************/
    63 
    64 // Load the WP abstraction file so BuddyPress can run on all WordPress setups.
    65 require( BP_PLUGIN_DIR . '/bp-core/bp-core-wpabstraction.php' );
    66 
    67 // Test to see whether this is a new installation or an upgraded version of BuddyPress
    68 if ( !$bp->database_version = get_site_option( 'bp-db-version' ) ) {
    69     if ( $bp->database_version = get_option( 'bp-db-version' ) ) {
    70         $bp->is_network_activate = 1;
    71     } else {
    72         $bp->database_version = get_site_option( 'bp-core-db-version' );  // BP 1.2 option
     228    /**
     229     * Legacy BuddyPress constants
     230     *
     231     * Try to avoid using these. Their values have been moved into variables
     232     * in the $bp global, and have matching functions to get/set their value.
     233     *
     234     * @since BuddyPress (1.6)
     235     *
     236     * @uses is_multisite()
     237     * @uses get_current_site()
     238     * @uses get_current_blog_id()
     239     * @uses plugin_dir_path()
     240     * @uses plugin_dir_url()
     241     */
     242    public function constants() {
     243
     244        // Define the BuddyPress version
     245        if ( !defined( 'BP_VERSION' ) )
     246            define( 'BP_VERSION', $this->version );
     247
     248        // Define the database version
     249        if ( !defined( 'BP_DB_VERSION' ) )
     250            define( 'BP_DB_VERSION', $this->db_version );
     251
     252        // Place your custom code (actions/filters) in a file called
     253        // '/plugins/bp-custom.php' and it will be loaded before anything else.
     254        if ( file_exists( WP_PLUGIN_DIR . '/bp-custom.php' ) )
     255            require( WP_PLUGIN_DIR . '/bp-custom.php' );
     256
     257        // Define on which blog ID BuddyPress should run
     258        if ( !defined( 'BP_ROOT_BLOG' ) ) {
     259
     260            // Default to 1
     261            $root_blog_id = 1;
     262           
     263            // Root blog is the main site on this network
     264            if ( is_multisite() && !defined( 'BP_ENABLE_MULTIBLOG' ) ) {
     265                $current_site = get_current_site();
     266                $root_blog_id = $current_site->blog_id;
     267
     268            // Root blog is every site on this network
     269            } elseif ( is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) ) {
     270                $root_blog_id = get_current_blog_id();
     271            }
     272
     273            define( 'BP_ROOT_BLOG', $root_blog_id );
     274        }
     275
     276        // Path and URL
     277        if ( !defined( 'BP_PLUGIN_DIR' ) )
     278            define( 'BP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
     279
     280        if ( !defined( 'BP_PLUGIN_URL' ) )
     281            define( 'BP_PLUGIN_URL', plugin_dir_url ( __FILE__ ) );
     282
     283        // The search slug has to be defined nice and early because of the way
     284        // search requests are loaded
     285        //
     286        // @todo Maxe this better
     287        if ( !defined( 'BP_SEARCH_SLUG' ) )
     288            define( 'BP_SEARCH_SLUG', 'search' );   
     289    }
     290
     291    /**
     292     * Component global variables
     293     *
     294     * @since BuddyPress (1.6)
     295     * @access private
     296     *
     297     * @uses plugin_dir_path() To generate BuddyPress plugin path
     298     * @uses plugin_dir_url() To generate BuddyPress plugin url
     299     * @uses apply_filters() Calls various filters
     300     */
     301    private function setup_globals() {
     302
     303        /** Paths *************************************************************/
     304
     305        // BuddyPress root directory
     306        $this->file       = __FILE__;
     307        $this->basename   = plugin_basename( $this->file );
     308        $this->plugin_dir = plugin_dir_path( $this->file );
     309        $this->plugin_url = plugin_dir_url ( $this->file );
     310
     311        // Themes
     312        $this->themes_dir = $this->plugin_dir . 'bp-themes';
     313        $this->themes_url = $this->plugin_url . 'bp-themes';
     314
     315        // Languages
     316        $this->lang_dir   = $this->plugin_dir . 'bp-languages';
     317
     318        /** Identifiers *******************************************************/
     319
     320        // Status identifiers
     321        $this->spam_status_id     = apply_filters( 'bp_spam_post_status',    'spam'    );
     322        $this->closed_status_id   = apply_filters( 'bp_closed_post_status',  'closed'  );
     323        $this->orphan_status_id   = apply_filters( 'bp_orphan_post_status',  'orphan'  );
     324        $this->public_status_id   = apply_filters( 'bp_public_post_status',  'publish' );
     325        $this->pending_status_id  = apply_filters( 'bp_pending_post_status', 'pending' );
     326        $this->private_status_id  = apply_filters( 'bp_private_post_status', 'private' );
     327        $this->hidden_status_id   = apply_filters( 'bp_hidden_post_status',  'hidden'  );
     328        $this->trash_status_id    = apply_filters( 'bp_trash_post_status',   'trash'   );
     329
     330        // Other identifiers
     331        $this->user_id            = apply_filters( 'bp_user_id', 'bp_user' );
     332        $this->edit_id            = apply_filters( 'bp_edit_id', 'edit'     );
     333
     334        /** Misc **************************************************************/
     335
     336        // Errors
     337        $this->errors             = new WP_Error();
     338
     339        // Tab Index
     340        $this->tab_index          = apply_filters( 'bp_default_tab_index', 100 );
     341    }
     342
     343    /**
     344     * Include required files
     345     *
     346     * @since BuddyPress (1.6)
     347     * @access private
     348     *
     349     * @uses is_admin() If in WordPress admin, load additional file
     350     */
     351    private function includes() {
     352
     353        // Load the WP abstraction file so BuddyPress can run on all WordPress setups.
     354        require( BP_PLUGIN_DIR . '/bp-core/bp-core-wpabstraction.php' );
     355
     356        // Get the possible DB versions
     357        $versions               = array();
     358        $versions['1.2']        = get_site_option( 'bp-core-db-version' );
     359        $versions['1.5-single'] = get_site_option( 'bp-db-version'      );
     360        $versions['1.5-multi']  = get_option     ( 'bp-db-version'      );
     361        $versions['1.6']        = get_option     ( '_bp_db_version'     );
     362
     363        // Remove empty array items
     364        $versions = array_filter( $versions );
     365
     366        // Get the largest version
     367        $this->db_version_raw      = (int) max( $versions );
     368
     369        // Are we network activated?
     370        $this->is_network_activate = !empty( $versions['1.5-multi'] );
     371           
     372        // This is a new installation
     373        if ( empty( $this->db_version_raw ) ) {
     374            $this->maintenance_mode = 'install';
     375            require( $this->plugin_dir . '/bp-core/admin/bp-core-update.php' );
     376
     377        // There is a previous installation
     378        } else {
     379
     380            // Setup the BuddyPress theme directory
     381            register_theme_directory( $this->themes_dir );
     382
     383            // Load core
     384            require( $this->plugin_dir . '/bp-core/bp-core-loader.php' );
     385
     386            // Check if an update is required
     387            if ( (int) $this->db_version_raw < (int) $this->db_version || ( !empty( $this->is_network_activate ) ) ) {
     388                $this->maintenance_mode = 'update';
     389                require( $this->plugin_dir . '/bp-core/admin/bp-core-update.php' );
     390            }
     391        }       
     392    }
     393
     394    /**
     395     * Setup the default hooks and actions
     396     *
     397     * @since BuddyPress (1.6)
     398     * @access private
     399     *
     400     * @uses register_activation_hook() To register the activation hook
     401     * @uses register_deactivation_hook() To register the deactivation hook
     402     * @uses add_action() To add various actions
     403     */
     404    private function setup_actions() {
     405
     406        // Add actions to plugin activation and deactivation hooks
     407        add_action( 'activate_'   . $this->basename, 'bp_activation'   );
     408        add_action( 'deactivate_' . $this->basename, 'bp_deactivation' );
     409
     410        // If BuddyPress is being deactivated, do not add any actions
     411        if ( bp_is_deactivation( $this->basename ) )
     412            return;
     413
     414        // Array of BuddyPress core actions
     415        $actions = array(
     416            'setup_current_user',       // Setup currently logged in user
     417            'register_post_types',      // Register post types
     418            'register_post_statuses',   // Register post statuses
     419            'register_taxonomies',      // Register taxonomies
     420            'register_views',           // Register the views
     421            'register_theme_directory', // Register the theme directory
     422            'load_textdomain',          // Load textdomain
     423            'add_rewrite_tags',         // Add rewrite tags
     424            'generate_rewrite_rules'    // Generate rewrite rules
     425        );
     426
     427        // Add the actions
     428        foreach( $actions as $class_action )
     429            add_action( 'bp_' . $class_action, array( $this, $class_action ), 5 );
    73430    }
    74431}
    75432
    76 // This is a new installation.
    77 if ( empty( $bp->database_version ) ) {
    78     $bp->maintenance_mode = 'install';
    79     require( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-update.php' );
    80 
    81 // There is a previous installation
    82 } else {
    83 
    84     // Setup the BuddyPress theme directory
    85     register_theme_directory( BP_PLUGIN_DIR . '/bp-themes' );
    86 
    87     // Load core
    88     require( BP_PLUGIN_DIR . '/bp-core/bp-core-loader.php' );
    89 
    90     // Check if an update is required
    91     if ( (int)$bp->database_version < (int)constant( 'BP_DB_VERSION' ) || isset( $bp->is_network_activate ) ) {
    92         $bp->maintenance_mode = 'update';
    93         require( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-update.php' );
    94     }
    95 }
     433// "And now for something completely different"
     434$_GLOBALS['bp'] = new BuddyPress;
     435
     436endif;
    96437
    97438/** Activation ****************************************************************/
     439
     440// @todo Move this code into bp-core-update.php
    98441
    99442if ( !function_exists( 'bp_loader_activate' ) ) :
Note: See TracChangeset for help on using the changeset viewer.