Ticket #4470: 4470.2.patch
File 4470.2.patch, 11.3 KB (added by , 12 years ago) |
---|
-
bp-loader.php
34 34 */ 35 35 class BuddyPress { 36 36 37 /** 38 * Note to Plugin and Theme authors: 39 * 40 * Do not directly reference the variables below in your code. Their names 41 * and locations in the BuddyPress class are subject to change at any time. 42 * 43 * Most of them have reference functions located in bp-core-functions.php. 44 * The ones that don't can be accessed via their respective WordPress API's. 45 * 46 * Components are encouraged to store their data in the $bp global rather 47 * than new globals to keep all BuddyPress data in one place. 48 */ 37 /** Magic *****************************************************************/ 49 38 50 /** Version ***************************************************************/51 52 39 /** 53 * @var string BuddyPress version 54 */ 55 public $version = '1.7'; 56 57 /** 58 * @var int Database version of current BuddyPress files 59 */ 60 public $db_version = 6066; 61 62 /** 63 * @var int Database version raw from database connection 64 */ 65 public $db_version_raw = 0; 66 67 /** 68 * @var string State of BuddyPress installation 69 */ 70 public $maintenance_mode = ''; 71 72 /** 73 * @var bool Include deprecated BuddyPress files or not 74 */ 75 public $load_deprecated = true; 76 77 /** Root ******************************************************************/ 78 79 /** 80 * @var int The root blog ID 81 */ 82 public $root_blog_id = 1; 83 84 /** Paths *****************************************************************/ 85 86 /** 87 * The absolute path and filename of this file. 40 * BuddyPress uses many variables, most of which can be filtered to customize 41 * the way that it works. To prevent unauthorized access, these variables 42 * are stored in a private array that is magically updated using PHP 5.2+ 43 * methods. This is to prevent third party plugins from tampering with 44 * essential information indirectly, which would cause issues later. 88 45 * 89 * @s ince BuddyPress (1.6)90 * @var string46 * @see BuddyPress::setup_globals() 47 * @var array 91 48 */ 92 p ublic $file;49 private $data; 93 50 94 /** 95 * @var string Basename of the BuddyPress plugin directory 96 */ 97 public $basename = ''; 51 /** Not Magic *************************************************************/ 98 52 99 53 /** 100 * @var string Absolute path to the BuddyPress plugin directory54 * @var array Primary BuddyPress navigation 101 55 */ 102 public $ plugin_dir = '';56 public $bp_nav = array(); 103 57 104 58 /** 105 * @var string Absolute path to the BuddyPress themes directory59 * @var array Secondary BuddyPress navigation to $bp_nav 106 60 */ 107 public $ themes_dir = '';61 public $bp_options_nav = array(); 108 62 109 63 /** 110 * @var string Absolute path to the BuddyPress language directory 64 * @var array The unfiltered URI broken down into chunks 65 * @see bp_core_set_uri_globals() 111 66 */ 112 public $ lang_dir = '';67 public $unfiltered_uri = array(); 113 68 114 /** URLs ******************************************************************/115 116 69 /** 117 * @var string URL to the BuddyPress plugin directory 70 * @var array The canonical URI stack 71 * @see bp_redirect_canonical() 72 * @see bp_core_new_nav_item() 118 73 */ 119 public $ plugin_url = '';74 public $canonical_stack = array(); 120 75 121 76 /** 122 * @var string URL to the BuddyPress themes directory77 * @var array Additional navigation elements (supplemental) 123 78 */ 124 public $ themes_url = '';79 public $action_variables = array(); 125 80 126 /** Users *****************************************************************/127 128 81 /** 129 * @var object Current user82 * @var array Required components (core, members) 130 83 */ 131 public $ current_user = null;84 public $required_components = array(); 132 85 133 86 /** 134 * @var object Displayed user87 * @var array Additional active components 135 88 */ 136 public $ displayed_user = null;89 public $loaded_components = array(); 137 90 138 /** Navigation ************************************************************/91 /** Option Overload *******************************************************/ 139 92 140 93 /** 141 * @var array Primary BuddyPress navigation94 * @var array Optional Overloads default options retrieved from get_option() 142 95 */ 143 public $ bp_nav= array();96 public $options = array(); 144 97 145 /** 146 * @var array Secondary BuddyPress navigation to $bp_nav 147 */ 148 public $bp_options_nav = array(); 98 /** Singleton *************************************************************/ 149 99 150 /** Toolbar ***************************************************************/151 152 100 /** 153 * @var string The primary toolbar ID101 * @var BuddyPress The one true BuddyPress 154 102 */ 155 p ublic $my_account_menu_id = '';103 private static $instance; 156 104 157 /** URI's *****************************************************************/158 159 105 /** 160 * @var array The unfiltered URI broken down into chunks 161 * @see bp_core_set_uri_globals() 106 * Main BuddyPress Instance 107 * 108 * BuddyPress is great 109 * Please load it only one time 110 * For this, we thank you 111 * 112 * Insures that only one instance of BuddyPress exists in memory at any one 113 * time. Also prevents needing to define globals all over the place. 114 * 115 * @since BuddyPress (1.7) 116 * 117 * @staticvar array $instance 118 * @uses BuddyPress::constants() Setup the constants (mostly deprecated) 119 * @uses BuddyPress::setup_globals() Setup the globals needed 120 * @uses BuddyPress::includes() Include the required files 121 * @uses BuddyPress::setup_actions() Setup the hooks and actions 122 * @see buddypress() 123 * 124 * @return The one true BuddyPress 162 125 */ 163 public $unfiltered_uri = array(); 126 public static function instance() { 127 if ( ! isset( self::$instance ) ) { 128 self::$instance = new BuddyPress; 129 self::$instance->constants(); 130 self::$instance->setup_globals(); 131 self::$instance->includes(); 132 self::$instance->setup_actions(); 133 } 134 return self::$instance; 135 } 164 136 165 /** 166 * @var int The current offset of the URI 167 * @see bp_core_set_uri_globals() 168 */ 169 public $unfiltered_uri_offset = 0; 137 /** Magic Methods *********************************************************/ 170 138 171 139 /** 172 * @var bool Are status headers already sent? 140 * A dummy constructor to prevent BuddyPress from being loaded more than once. 141 * 142 * @since BuddyPress (1.7) 143 * @see BuddyPress::instance() 144 * @see buddypress() 173 145 */ 174 p ublic $no_status_set = false;146 private function __construct() { /* Do nothing here */ } 175 147 176 148 /** 177 * @var array The canonical URI stack178 * @see bp_redirect_canonical()179 * @s ee bp_core_new_nav_item()149 * A dummy magic method to prevent BuddyPress from being cloned 150 * 151 * @since BuddyPress (1.7) 180 152 */ 181 public $canonical_stack = array();153 public function __clone() { _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'buddypress' ), '1.7' ); } 182 154 183 /** Components ************************************************************/184 185 155 /** 186 * @var string Name of the current BuddyPress component (primary) 156 * A dummy magic method to prevent BuddyPress from being unserialized 157 * 158 * @since BuddyPress (1.7) 187 159 */ 188 public $current_component = '';160 public function __wakeup() { _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'buddypress' ), '1.7' ); } 189 161 190 162 /** 191 * @var string Name of the current BuddyPress item (secondary) 163 * Magic method for checking the existence of a certain custom field 164 * 165 * @since BuddyPress (1.7) 192 166 */ 193 public $current_item = '';167 public function __isset( $key ) { return isset( $this->data[$key] ); } 194 168 195 169 /** 196 * @var string Name of the current BuddyPress action (tertiary) 170 * Magic method for getting BuddyPress varibles 171 * 172 * @since BuddyPress (1.7) 197 173 */ 198 public $current_action = '';174 public function __get( $key ) { return isset( $this->data[$key] ) ? $this->data[$key] : null; } 199 175 200 176 /** 201 * @var array Additional navigation elements (supplemental) 177 * Magic method for setting BuddyPress varibles 178 * 179 * @since BuddyPress (1.7) 202 180 */ 203 public $action_variables = array();181 public function __set( $key, $value ) { $this->data[$key] = $value; } 204 182 205 /** 206 * @var bool Displaying custom 2nd level navigation menu (I.E a group) 207 */ 208 public $is_single_item = false; 183 /** Private Methods *******************************************************/ 209 184 210 /** Option Overload *******************************************************/211 212 185 /** 213 * @var array Optional Overloads default options retrieved from get_option()214 */215 public $options = array();216 217 /** Functions *************************************************************/218 219 /**220 * The main BuddyPress loader221 *222 * @since BuddyPress (1.6)223 *224 * @uses BuddyPress::constants() Setup legacy constants225 * @uses BuddyPress::setup_globals() Setup globals needed226 * @uses BuddyPress::includes() Includ required files227 * @uses BuddyPress::setup_actions() Setup hooks and actions228 */229 public function __construct() {230 $this->constants();231 $this->setup_globals();232 $this->includes();233 $this->setup_actions();234 }235 236 /**237 186 * Legacy BuddyPress constants 238 187 * 239 188 * Try to avoid using these. Their values have been moved into variables … … 315 264 */ 316 265 private function setup_globals() { 317 266 267 /** Versions **********************************************************/ 268 269 $this->version = '1.7'; 270 $this->db_version = 6066; 271 $this->db_version_raw = 0; 272 273 /** Loading ***********************************************************/ 274 275 $this->maintenance_mode = ''; 276 $this->load_deprecated = true; 277 278 /** Toolbar ***********************************************************/ 279 280 /** 281 * @var string The primary toolbar ID 282 */ 283 $this->my_account_menu_id = ''; 284 285 /** URI's *************************************************************/ 286 287 /** 288 * @var int The current offset of the URI 289 * @see bp_core_set_uri_globals() 290 */ 291 $this->unfiltered_uri_offset = 0; 292 293 /** 294 * @var bool Are status headers already sent? 295 */ 296 $this->no_status_set = false; 297 298 /** Components ********************************************************/ 299 300 /** 301 * @var string Name of the current BuddyPress component (primary) 302 */ 303 $this->current_component = ''; 304 305 /** 306 * @var string Name of the current BuddyPress item (secondary) 307 */ 308 $this->current_item = ''; 309 310 /** 311 * @var string Name of the current BuddyPress action (tertiary) 312 */ 313 $this->current_action = ''; 314 315 /** 316 * @var bool Displaying custom 2nd level navigation menu (I.E a group) 317 */ 318 $this->is_single_item = false; 319 318 320 /** Root **************************************************************/ 319 321 320 322 // BuddyPress Root blog ID … … 481 483 } 482 484 } 483 485 484 // "And now for something completely different" 485 $GLOBALS['bp'] = new BuddyPress; 486 /** 487 * The main function responsible for returning the one true BuddyPress Instance 488 * to functions everywhere. 489 * 490 * Use this function like you would a global variable, except without needing 491 * to declare the global. 492 * 493 * Example: <?php $bp = buddypress(); ?> 494 * 495 * @return The one true BuddyPress Instance 496 */ 497 function buddypress() { 498 return buddypress::instance(); 499 } 486 500 487 endif; 501 /** 502 * Hook BuddyPress early onto the 'plugins_loaded' action. 503 * 504 * This gives all other plugins the chance to load before BuddyPress, to get 505 * their actions, filters, and overrides setup without BuddyPress being in the 506 * way. 507 */ 508 if ( defined( 'BUDDYPRESS_LATE_LOAD' ) ) { 509 add_action( 'plugins_loaded', 'buddypress', (int) BUDDYPRESS_LATE_LOAD ); 488 510 489 ?> 511 // "And now here's something we hope you'll really like!" 512 } else { 513 $GLOBALS['bp'] = &buddypress(); 514 } 515 516 endif;