Changeset 12535
- Timestamp:
- 01/20/2020 06:58:31 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/class-buddypress.php
r12471 r12535 114 114 public static function instance() { 115 115 116 // Store the instance locally to avoid private static replication 116 // Store the instance locally to avoid private static replication. 117 117 static $instance = null; 118 118 119 // Only run these methods if they haven't been run previously 119 // Only run these methods if they haven't been run previously. 120 120 if ( null === $instance ) { 121 121 $instance = new BuddyPress; … … 127 127 } 128 128 129 // Always return the instance 129 // Always return the instance. 130 130 return $instance; 131 131 … … 227 227 } 228 228 229 // Path and URL 229 // Path and URL. 230 230 if ( ! defined( 'BP_PLUGIN_DIR' ) ) { 231 231 define( 'BP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); … … 246 246 } 247 247 248 // Only applicable to those running trunk 248 // Only applicable to those running trunk. 249 249 if ( ! defined( 'BP_SOURCE_SUBDIRECTORY' ) ) { 250 250 define( 'BP_SOURCE_SUBDIRECTORY', '' ); 251 251 } 252 252 253 // Define on which blog ID BuddyPress should run 253 // Define on which blog ID BuddyPress should run. 254 254 if ( ! defined( 'BP_ROOT_BLOG' ) ) { 255 255 256 // Default to use current blog ID 257 // Fulfills non-network installs and BP_ENABLE_MULTIBLOG installs 256 // Default to use current blog ID. 257 // Fulfills non-network installs and BP_ENABLE_MULTIBLOG installs. 258 258 $root_blog_id = get_current_blog_id(); 259 259 260 // Multisite check 260 // Multisite check. 261 261 if ( is_multisite() ) { 262 262 263 // Multiblog isn't enabled 263 // Multiblog isn't enabled. 264 264 if ( ! defined( 'BP_ENABLE_MULTIBLOG' ) || ( defined( 'BP_ENABLE_MULTIBLOG' ) && (int) constant( 'BP_ENABLE_MULTIBLOG' ) === 0 ) ) { 265 265 // Check to see if BP is network-activated … … 267 267 // /wp-admin/includes/plugin.php file in order to use that function. 268 268 269 // get network-activated plugins269 // Get network-activated plugins. 270 270 $plugins = get_site_option( 'active_sitewide_plugins'); 271 271 272 // basename272 // Basename. 273 273 $basename = basename( constant( 'BP_PLUGIN_DIR' ) ) . '/bp-loader.php'; 274 274 275 // plugin is network-activated; use main site ID instead275 // Plugin is network-activated; use main site ID instead. 276 276 if ( isset( $plugins[ $basename ] ) ) { 277 277 $current_site = get_current_site(); … … 286 286 287 287 // The search slug has to be defined nice and early because of the way 288 // search requests are loaded 288 // search requests are loaded. 289 289 // 290 // @todo Make this better 290 // @todo Make this better. 291 291 if ( ! defined( 'BP_SEARCH_SLUG' ) ) { 292 292 define( 'BP_SEARCH_SLUG', 'search' ); … … 372 372 /** Paths**************************************************************/ 373 373 374 // BuddyPress root directory 374 // BuddyPress root directory. 375 375 $this->file = constant( 'BP_PLUGIN_DIR' ) . 'bp-loader.php'; 376 376 $this->basename = basename( constant( 'BP_PLUGIN_DIR' ) ) . '/bp-loader.php'; … … 378 378 $this->plugin_url = trailingslashit( constant( 'BP_PLUGIN_URL' ) . constant( 'BP_SOURCE_SUBDIRECTORY' ) ); 379 379 380 // Languages 380 // Languages. 381 381 $this->lang_dir = $this->plugin_dir . 'bp-languages'; 382 382 383 // Templates (theme compatibility) 383 // Templates (theme compatibility). 384 384 $this->themes_dir = $this->plugin_dir . 'bp-templates'; 385 385 $this->themes_url = $this->plugin_url . 'bp-templates'; 386 386 387 // Themes (for bp-default) 387 // Themes (for bp-default). 388 388 $this->old_themes_dir = $this->plugin_dir . 'bp-themes'; 389 389 $this->old_themes_url = $this->plugin_url . 'bp-themes'; … … 391 391 /** Theme Compat ******************************************************/ 392 392 393 $this->theme_compat = new stdClass(); // Base theme compatibility class 394 $this->filters = new stdClass(); // Used when adding/removing filters 393 $this->theme_compat = new stdClass(); // Base theme compatibility class. 394 $this->filters = new stdClass(); // Used when adding/removing filters. 395 395 396 396 /** Users *************************************************************/ … … 430 430 private function legacy_constants() { 431 431 432 // Define the BuddyPress version 432 // Define the BuddyPress version. 433 433 if ( ! defined( 'BP_VERSION' ) ) { 434 434 define( 'BP_VERSION', $this->version ); 435 435 } 436 436 437 // Define the database version 437 // Define the database version. 438 438 if ( ! defined( 'BP_DB_VERSION' ) ) { 439 439 define( 'BP_DB_VERSION', $this->db_version ); 440 440 } 441 441 442 // Define if deprecated functions should be ignored 442 // Define if deprecated functions should be ignored. 443 443 if ( ! defined( 'BP_IGNORE_DEPRECATED' ) ) { 444 444 define( 'BP_IGNORE_DEPRECATED', true ); … … 458 458 require( $this->plugin_dir . 'bp-core/bp-core-wpabstraction.php' ); 459 459 460 // Setup the versions (after we include multisite abstraction above) 460 // Setup the versions (after we include multisite abstraction above). 461 461 $this->versions(); 462 462 463 463 /** Update/Install ****************************************************/ 464 464 465 // Theme compatibility 465 // Theme compatibility. 466 466 require( $this->plugin_dir . 'bp-core/bp-core-template-loader.php' ); 467 467 require( $this->plugin_dir . 'bp-core/bp-core-theme-compatibility.php' ); 468 468 469 // Require all of the BuddyPress core libraries 469 // Require all of the BuddyPress core libraries. 470 470 require( $this->plugin_dir . 'bp-core/bp-core-dependency.php' ); 471 471 require( $this->plugin_dir . 'bp-core/bp-core-actions.php' ); … … 490 490 require( $this->plugin_dir . 'bp-core/bp-core-rest-api.php' ); 491 491 492 // Maybe load deprecated functionality (this double negative is proof positive!) 492 // Maybe load deprecated functionality (this double negative is proof positive!). 493 493 if ( ! bp_get_option( '_bp_ignore_deprecated_code', ! $this->load_deprecated ) ) { 494 494 require( $this->plugin_dir . 'bp-core/deprecated/1.2.php' ); … … 511 511 } 512 512 513 // Load wp-cli module if PHP 5.4+ 513 // Load wp-cli module if PHP 5.4+. 514 514 if ( defined( 'WP_CLI' ) && file_exists( $this->plugin_dir . 'cli/wp-cli-bp.php' ) && version_compare( phpversion(), '5.4.0', '>=' ) ) { 515 515 require( $this->plugin_dir . 'cli/wp-cli-bp.php' ); … … 659 659 private function setup_actions() { 660 660 661 // Add actions to plugin activation and deactivation hooks 661 // Add actions to plugin activation and deactivation hooks. 662 662 add_action( 'activate_' . $this->basename, 'bp_activation' ); 663 663 add_action( 'deactivate_' . $this->basename, 'bp_deactivation' ); 664 664 665 // If BuddyPress is being deactivated, do not add any actions 665 // If BuddyPress is being deactivated, do not add any actions. 666 666 if ( bp_is_deactivation( $this->basename ) ) { 667 667 return; … … 670 670 // Array of BuddyPress core actions 671 671 $actions = array( 672 'setup_theme', // Setup the default theme compat 673 'setup_current_user', // Setup currently logged in user 674 'register_post_types', // Register post types 675 'register_post_statuses', // Register post statuses 676 'register_taxonomies', // Register taxonomies 677 'register_views', // Register the views 678 'register_theme_directory', // Register the theme directory 679 'register_theme_packages', // Register bundled theme packages (bp-themes) 680 'load_textdomain', // Load textdomain 681 'add_rewrite_tags', // Add rewrite tags 682 'generate_rewrite_rules' // Generate rewrite rules 672 'setup_theme', // Setup the default theme compat. 673 'setup_current_user', // Setup currently logged in user. 674 'register_post_types', // Register post types. 675 'register_post_statuses', // Register post statuses. 676 'register_taxonomies', // Register taxonomies. 677 'register_views', // Register the views. 678 'register_theme_directory', // Register the theme directory. 679 'register_theme_packages', // Register bundled theme packages (bp-themes). 680 'load_textdomain', // Load textdomain. 681 'add_rewrite_tags', // Add rewrite tags. 682 'generate_rewrite_rules' // Generate rewrite rules. 683 683 ); 684 684 685 // Add the actions 685 // Add the actions. 686 686 foreach( $actions as $class_action ) { 687 687 if ( method_exists( $this, $class_action ) ) { … … 709 709 private function versions() { 710 710 711 // Get the possible DB versions (boy is this gross) 711 // Get the possible DB versions (boy is this gross). 712 712 $versions = array(); 713 713 $versions['1.6-single'] = get_blog_option( $this->root_blog_id, '_bp_db_version' ); 714 714 715 // 1.6-single exists, so trust it 715 // 1.6-single exists, so trust it. 716 716 if ( !empty( $versions['1.6-single'] ) ) { 717 717 $this->db_version_raw = (int) $versions['1.6-single']; 718 718 719 // If no 1.6-single exists, use the max of the others 719 // If no 1.6-single exists, use the max of the others. 720 720 } else { 721 721 $versions['1.2'] = get_site_option( 'bp-core-db-version' ); … … 724 724 $versions['1.5-single'] = get_blog_option( $this->root_blog_id, 'bp-db-version' ); 725 725 726 // Remove empty array items 726 // Remove empty array items. 727 727 $versions = array_filter( $versions ); 728 728 $this->db_version_raw = (int) ( !empty( $versions ) ) ? (int) max( $versions ) : 0; … … 765 765 public function register_theme_packages() { 766 766 767 // Register the default theme compatibility package 767 // Register the default theme compatibility package. 768 768 bp_register_theme_package( array( 769 769 'id' => 'legacy', … … 795 795 public function setup_theme() { 796 796 797 // Bail if something already has this under control 797 // Bail if something already has this under control. 798 798 if ( ! empty( $this->theme_compat->theme ) ) { 799 799 return; 800 800 } 801 801 802 // Setup the theme package to use for compatibility 802 // Setup the theme package to use for compatibility. 803 803 bp_setup_theme_compat( bp_get_theme_package_id() ); 804 804 }
Note: See TracChangeset
for help on using the changeset viewer.