[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/ -> class-buddypress.php (source)

   1  <?php
   2  
   3  // Exit if accessed directly.
   4  defined( 'ABSPATH' ) || exit;
   5  
   6  /**
   7   * Main BuddyPress Class.
   8   *
   9   * Tap tap tap... Is this thing on?
  10   *
  11   * @since 1.6.0
  12   */
  13  class BuddyPress {
  14  
  15      /** Magic *****************************************************************/
  16  
  17      /**
  18       * BuddyPress uses many variables, most of which can be filtered to
  19       * customize the way that it works. To prevent unauthorized access,
  20       * these variables are stored in a private array that is magically
  21       * updated using PHP 5.2+ methods. This is to prevent third party
  22       * plugins from tampering with essential information indirectly, which
  23       * would cause issues later.
  24       *
  25       * @see BuddyPress::setup_globals()
  26       * @var array
  27       */
  28      private $data;
  29  
  30      /** Not Magic *************************************************************/
  31  
  32      /**
  33       * @var array Primary BuddyPress navigation.
  34       */
  35      public $bp_nav = array();
  36  
  37      /**
  38       * @var array Secondary BuddyPress navigation to $bp_nav.
  39       */
  40      public $bp_options_nav = array();
  41  
  42      /**
  43       * @var array The unfiltered URI broken down into chunks.
  44       * @see bp_core_set_uri_globals()
  45       */
  46      public $unfiltered_uri = array();
  47  
  48      /**
  49       * @var array The canonical URI stack.
  50       * @see bp_redirect_canonical()
  51       * @see bp_core_new_nav_item()
  52       */
  53      public $canonical_stack = array();
  54  
  55      /**
  56       * @var array Additional navigation elements (supplemental).
  57       */
  58      public $action_variables = array();
  59  
  60      /**
  61       * @var string Current member directory type.
  62       */
  63      public $current_member_type = '';
  64  
  65      /**
  66       * @var array Required components (core, members).
  67       */
  68      public $required_components = array();
  69  
  70      /**
  71       * @var array Additional active components.
  72       */
  73      public $loaded_components = array();
  74  
  75      /**
  76       * @var array Active components.
  77       */
  78      public $active_components = array();
  79  
  80      /**
  81       * Whether autoload is in use.
  82       *
  83       * @since 2.5.0
  84       * @var bool
  85       */
  86      public $do_autoload = true;
  87  
  88      /** Option Overload *******************************************************/
  89  
  90      /**
  91       * @var array Optional Overloads default options retrieved from get_option().
  92       */
  93      public $options = array();
  94  
  95      /** Singleton *************************************************************/
  96  
  97      /**
  98       * Main BuddyPress Instance.
  99       *
 100       * BuddyPress is great.
 101       * Please load it only one time.
 102       * For this, we thank you.
 103       *
 104       * Insures that only one instance of BuddyPress exists in memory at any
 105       * one time. Also prevents needing to define globals all over the place.
 106       *
 107       * @since 1.7.0
 108       *
 109       * @static object $instance
 110       * @see buddypress()
 111       *
 112       * @return BuddyPress|null The one true BuddyPress.
 113       */
 114  	public static function instance() {
 115  
 116          // Store the instance locally to avoid private static replication
 117          static $instance = null;
 118  
 119          // Only run these methods if they haven't been run previously
 120          if ( null === $instance ) {
 121              $instance = new BuddyPress;
 122              $instance->constants();
 123              $instance->setup_globals();
 124              $instance->legacy_constants();
 125              $instance->includes();
 126              $instance->setup_actions();
 127          }
 128  
 129          // Always return the instance
 130          return $instance;
 131  
 132          // The last metroid is in captivity. The galaxy is at peace.
 133      }
 134  
 135      /** Magic Methods *********************************************************/
 136  
 137      /**
 138       * A dummy constructor to prevent BuddyPress from being loaded more than once.
 139       *
 140       * @since 1.7.0
 141       * @see BuddyPress::instance()
 142       * @see buddypress()
 143       */
 144  	private function __construct() { /* Do nothing here */ }
 145  
 146      /**
 147       * A dummy magic method to prevent BuddyPress from being cloned.
 148       *
 149       * @since 1.7.0
 150       */
 151  	public function __clone() { _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'buddypress' ), '1.7' ); }
 152  
 153      /**
 154       * A dummy magic method to prevent BuddyPress from being unserialized.
 155       *
 156       * @since 1.7.0
 157       */
 158  	public function __wakeup() { _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'buddypress' ), '1.7' ); }
 159  
 160      /**
 161       * Magic method for checking the existence of a certain custom field.
 162       *
 163       * @since 1.7.0
 164       *
 165       * @param string $key Key to check the set status for.
 166       *
 167       * @return bool
 168       */
 169  	public function __isset( $key ) { return isset( $this->data[$key] ); }
 170  
 171      /**
 172       * Magic method for getting BuddyPress variables.
 173       *
 174       * @since 1.7.0
 175       *
 176       * @param string $key Key to return the value for.
 177       *
 178       * @return mixed
 179       */
 180  	public function __get( $key ) { return isset( $this->data[$key] ) ? $this->data[$key] : null; }
 181  
 182      /**
 183       * Magic method for setting BuddyPress variables.
 184       *
 185       * @since 1.7.0
 186       *
 187       * @param string $key   Key to set a value for.
 188       * @param mixed  $value Value to set.
 189       */
 190  	public function __set( $key, $value ) { $this->data[$key] = $value; }
 191  
 192      /**
 193       * Magic method for unsetting BuddyPress variables.
 194       *
 195       * @since 1.7.0
 196       *
 197       * @param string $key Key to unset a value for.
 198       */
 199  	public function __unset( $key ) { if ( isset( $this->data[$key] ) ) unset( $this->data[$key] ); }
 200  
 201      /**
 202       * Magic method to prevent notices and errors from invalid method calls.
 203       *
 204       * @since 1.7.0
 205       *
 206       * @param string $name
 207       * @param array  $args
 208       *
 209       * @return null
 210       */
 211  	public function __call( $name = '', $args = array() ) { unset( $name, $args ); return null; }
 212  
 213      /** Private Methods *******************************************************/
 214  
 215      /**
 216       * Bootstrap constants.
 217       *
 218       * @since 1.6.0
 219       *
 220       */
 221  	private function constants() {
 222  
 223          // Place your custom code (actions/filters) in a file called
 224          // '/plugins/bp-custom.php' and it will be loaded before anything else.
 225          if ( file_exists( WP_PLUGIN_DIR . '/bp-custom.php' ) ) {
 226              require( WP_PLUGIN_DIR . '/bp-custom.php' );
 227          }
 228  
 229          // Path and URL
 230          if ( ! defined( 'BP_PLUGIN_DIR' ) ) {
 231              define( 'BP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
 232          }
 233  
 234          if ( ! defined( 'BP_PLUGIN_URL' ) ) {
 235              define( 'BP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
 236          }
 237  
 238          // Legacy forum constant - supported for compatibility with bbPress 2.
 239          if ( ! defined( 'BP_FORUMS_PARENT_FORUM_ID' ) ) {
 240              define( 'BP_FORUMS_PARENT_FORUM_ID', 1 );
 241          }
 242  
 243          // Legacy forum constant - supported for compatibility with bbPress 2.
 244          if ( ! defined( 'BP_FORUMS_SLUG' ) ) {
 245              define( 'BP_FORUMS_SLUG', 'forums' );
 246          }
 247  
 248          // Only applicable to those running trunk
 249          if ( ! defined( 'BP_SOURCE_SUBDIRECTORY' ) ) {
 250              define( 'BP_SOURCE_SUBDIRECTORY', '' );
 251          }
 252  
 253          // Define on which blog ID BuddyPress should run
 254          if ( ! defined( 'BP_ROOT_BLOG' ) ) {
 255  
 256              // Default to use current blog ID
 257              // Fulfills non-network installs and BP_ENABLE_MULTIBLOG installs
 258              $root_blog_id = get_current_blog_id();
 259  
 260              // Multisite check
 261              if ( is_multisite() ) {
 262  
 263                  // Multiblog isn't enabled
 264                  if ( ! defined( 'BP_ENABLE_MULTIBLOG' ) || ( defined( 'BP_ENABLE_MULTIBLOG' ) && (int) constant( 'BP_ENABLE_MULTIBLOG' ) === 0 ) ) {
 265                      // Check to see if BP is network-activated
 266                      // We're not using is_plugin_active_for_network() b/c you need to include the
 267                      // /wp-admin/includes/plugin.php file in order to use that function.
 268  
 269                      // get network-activated plugins
 270                      $plugins = get_site_option( 'active_sitewide_plugins');
 271  
 272                      // basename
 273                      $basename = basename( constant( 'BP_PLUGIN_DIR' ) ) . '/bp-loader.php';
 274  
 275                      // plugin is network-activated; use main site ID instead
 276                      if ( isset( $plugins[ $basename ] ) ) {
 277                          $current_site = get_current_site();
 278                          $root_blog_id = $current_site->blog_id;
 279                      }
 280                  }
 281  
 282              }
 283  
 284              define( 'BP_ROOT_BLOG', $root_blog_id );
 285          }
 286  
 287          // The search slug has to be defined nice and early because of the way
 288          // search requests are loaded
 289          //
 290          // @todo Make this better
 291          if ( ! defined( 'BP_SEARCH_SLUG' ) ) {
 292              define( 'BP_SEARCH_SLUG', 'search' );
 293          }
 294      }
 295  
 296      /**
 297       * Component global variables.
 298       *
 299       * @since 1.6.0
 300       *
 301       */
 302  	private function setup_globals() {
 303  
 304          /** Versions **********************************************************/
 305  
 306          $this->version    = '5.0.0-alpha';
 307          $this->db_version = 11105;
 308  
 309          /** Loading ***********************************************************/
 310  
 311          /**
 312           * Should deprecated code be loaded?
 313           *
 314           * @since 2.0.0 Defaults to false always
 315           * @since 2.8.0 Defaults to true on upgrades, false for new installs.
 316           */
 317          $this->load_deprecated = false;
 318  
 319          /** Toolbar ***********************************************************/
 320  
 321          /**
 322           * @var string The primary toolbar ID.
 323           */
 324          $this->my_account_menu_id = '';
 325  
 326          /** URIs **************************************************************/
 327  
 328          /**
 329           * @var int The current offset of the URI.
 330           * @see bp_core_set_uri_globals()
 331           */
 332          $this->unfiltered_uri_offset = 0;
 333  
 334          /**
 335           * @var bool Are status headers already sent?
 336           */
 337          $this->no_status_set = false;
 338  
 339          /** Components ********************************************************/
 340  
 341          /**
 342           * @var string Name of the current BuddyPress component (primary).
 343           */
 344          $this->current_component = '';
 345  
 346          /**
 347           * @var string Name of the current BuddyPress item (secondary).
 348           */
 349          $this->current_item = '';
 350  
 351          /**
 352           * @var string Name of the current BuddyPress action (tertiary).
 353           */
 354          $this->current_action = '';
 355  
 356          /**
 357           * @var bool Displaying custom 2nd level navigation menu (I.E a group).
 358           */
 359          $this->is_single_item = false;
 360  
 361          /** Root **************************************************************/
 362  
 363          /**
 364           * Filters the BuddyPress Root blog ID.
 365           *
 366           * @since 1.5.0
 367           *
 368           * @const constant BP_ROOT_BLOG BuddyPress Root blog ID.
 369           */
 370          $this->root_blog_id = (int) apply_filters( 'bp_get_root_blog_id', BP_ROOT_BLOG );
 371  
 372          /** Paths**************************************************************/
 373  
 374          // BuddyPress root directory
 375          $this->file           = constant( 'BP_PLUGIN_DIR' ) . 'bp-loader.php';
 376          $this->basename       = basename( constant( 'BP_PLUGIN_DIR' ) ) . '/bp-loader.php';
 377          $this->plugin_dir     = trailingslashit( constant( 'BP_PLUGIN_DIR' ) . constant( 'BP_SOURCE_SUBDIRECTORY' ) );
 378          $this->plugin_url     = trailingslashit( constant( 'BP_PLUGIN_URL' ) . constant( 'BP_SOURCE_SUBDIRECTORY' ) );
 379  
 380          // Languages
 381          $this->lang_dir       = $this->plugin_dir . 'bp-languages';
 382  
 383          // Templates (theme compatibility)
 384          $this->themes_dir     = $this->plugin_dir . 'bp-templates';
 385          $this->themes_url     = $this->plugin_url . 'bp-templates';
 386  
 387          // Themes (for bp-default)
 388          $this->old_themes_dir = $this->plugin_dir . 'bp-themes';
 389          $this->old_themes_url = $this->plugin_url . 'bp-themes';
 390  
 391          /** Theme Compat ******************************************************/
 392  
 393          $this->theme_compat   = new stdClass(); // Base theme compatibility class
 394          $this->filters        = new stdClass(); // Used when adding/removing filters
 395  
 396          /** Users *************************************************************/
 397  
 398          $this->current_user   = new stdClass();
 399          $this->displayed_user = new stdClass();
 400  
 401          /** Post types and taxonomies *****************************************/
 402  
 403          /**
 404           * Filters the post type slug for the email component.
 405           *
 406           * since 2.5.0
 407           *
 408           * @param string $value Email post type slug.
 409           */
 410          $this->email_post_type     = apply_filters( 'bp_email_post_type', 'bp-email' );
 411  
 412          /**
 413           * Filters the taxonomy slug for the email type component.
 414           *
 415           * @since 2.5.0
 416           *
 417           * @param string $value Email type taxonomy slug.
 418           */
 419          $this->email_taxonomy_type = apply_filters( 'bp_email_tax_type', 'bp-email-type' );
 420      }
 421  
 422      /**
 423       * Legacy BuddyPress constants.
 424       *
 425       * Try to avoid using these. Their values have been moved into variables
 426       * in the instance, and have matching functions to get/set their values.
 427       *
 428       * @since 1.7.0
 429       */
 430  	private function legacy_constants() {
 431  
 432          // Define the BuddyPress version
 433          if ( ! defined( 'BP_VERSION' ) ) {
 434              define( 'BP_VERSION', $this->version );
 435          }
 436  
 437          // Define the database version
 438          if ( ! defined( 'BP_DB_VERSION' ) ) {
 439              define( 'BP_DB_VERSION', $this->db_version );
 440          }
 441  
 442          // Define if deprecated functions should be ignored
 443          if ( ! defined( 'BP_IGNORE_DEPRECATED' ) ) {
 444              define( 'BP_IGNORE_DEPRECATED', true );
 445          }
 446      }
 447  
 448      /**
 449       * Include required files.
 450       *
 451       * @since 1.6.0
 452       *
 453       */
 454  	private function includes() {
 455          spl_autoload_register( array( $this, 'autoload' ) );
 456  
 457          // Load the WP abstraction file so BuddyPress can run on all WordPress setups.
 458          require( $this->plugin_dir . 'bp-core/bp-core-wpabstraction.php' );
 459  
 460          // Setup the versions (after we include multisite abstraction above)
 461          $this->versions();
 462  
 463          /** Update/Install ****************************************************/
 464  
 465          // Theme compatibility
 466          require( $this->plugin_dir . 'bp-core/bp-core-template-loader.php'     );
 467          require( $this->plugin_dir . 'bp-core/bp-core-theme-compatibility.php' );
 468  
 469          // Require all of the BuddyPress core libraries
 470          require( $this->plugin_dir . 'bp-core/bp-core-dependency.php'       );
 471          require( $this->plugin_dir . 'bp-core/bp-core-actions.php'          );
 472          require( $this->plugin_dir . 'bp-core/bp-core-caps.php'             );
 473          require( $this->plugin_dir . 'bp-core/bp-core-cache.php'            );
 474          require( $this->plugin_dir . 'bp-core/bp-core-cssjs.php'            );
 475          require( $this->plugin_dir . 'bp-core/bp-core-update.php'           );
 476          require( $this->plugin_dir . 'bp-core/bp-core-options.php'          );
 477          require( $this->plugin_dir . 'bp-core/bp-core-taxonomy.php'         );
 478          require( $this->plugin_dir . 'bp-core/bp-core-filters.php'          );
 479          require( $this->plugin_dir . 'bp-core/bp-core-attachments.php'      );
 480          require( $this->plugin_dir . 'bp-core/bp-core-avatars.php'          );
 481          require( $this->plugin_dir . 'bp-core/bp-core-widgets.php'          );
 482          require( $this->plugin_dir . 'bp-core/bp-core-template.php'         );
 483          require( $this->plugin_dir . 'bp-core/bp-core-adminbar.php'         );
 484          require( $this->plugin_dir . 'bp-core/bp-core-buddybar.php'         );
 485          require( $this->plugin_dir . 'bp-core/bp-core-catchuri.php'         );
 486          require( $this->plugin_dir . 'bp-core/bp-core-functions.php'        );
 487          require( $this->plugin_dir . 'bp-core/bp-core-moderation.php'       );
 488          require( $this->plugin_dir . 'bp-core/bp-core-loader.php'           );
 489          require( $this->plugin_dir . 'bp-core/bp-core-customizer-email.php' );
 490  
 491          // Maybe load deprecated functionality (this double negative is proof positive!)
 492          if ( ! bp_get_option( '_bp_ignore_deprecated_code', ! $this->load_deprecated ) ) {
 493              require( $this->plugin_dir . 'bp-core/deprecated/1.2.php' );
 494              require( $this->plugin_dir . 'bp-core/deprecated/1.5.php' );
 495              require( $this->plugin_dir . 'bp-core/deprecated/1.6.php' );
 496              require( $this->plugin_dir . 'bp-core/deprecated/1.7.php' );
 497              require( $this->plugin_dir . 'bp-core/deprecated/1.9.php' );
 498              require( $this->plugin_dir . 'bp-core/deprecated/2.0.php' );
 499              require( $this->plugin_dir . 'bp-core/deprecated/2.1.php' );
 500              require( $this->plugin_dir . 'bp-core/deprecated/2.2.php' );
 501              require( $this->plugin_dir . 'bp-core/deprecated/2.3.php' );
 502              require( $this->plugin_dir . 'bp-core/deprecated/2.4.php' );
 503              require( $this->plugin_dir . 'bp-core/deprecated/2.5.php' );
 504              require( $this->plugin_dir . 'bp-core/deprecated/2.6.php' );
 505              require( $this->plugin_dir . 'bp-core/deprecated/2.7.php' );
 506              require( $this->plugin_dir . 'bp-core/deprecated/2.8.php' );
 507              require( $this->plugin_dir . 'bp-core/deprecated/2.9.php' );
 508              require( $this->plugin_dir . 'bp-core/deprecated/3.0.php' );
 509              require( $this->plugin_dir . 'bp-core/deprecated/4.0.php' );
 510          }
 511  
 512          // Load wp-cli module if PHP 5.4+
 513          if ( defined( 'WP_CLI' ) && file_exists( $this->plugin_dir . 'cli/wp-cli-bp.php' ) && version_compare( phpversion(), '5.4.0', '>=' ) ) {
 514              require( $this->plugin_dir . 'cli/wp-cli-bp.php' );
 515          }
 516      }
 517  
 518      /**
 519       * Autoload classes.
 520       *
 521       * @since 2.5.0
 522       *
 523       * @param string $class
 524       */
 525  	public function autoload( $class ) {
 526          $class_parts = explode( '_', strtolower( $class ) );
 527  
 528          if ( 'bp' !== $class_parts[0] ) {
 529              return;
 530          }
 531  
 532          $components = array(
 533              'activity',
 534              'blogs',
 535              'core',
 536              'friends',
 537              'groups',
 538              'members',
 539              'messages',
 540              'notifications',
 541              'settings',
 542              'xprofile',
 543          );
 544  
 545          // These classes don't have a name that matches their component.
 546          $irregular_map = array(
 547              'BP_Akismet' => 'activity',
 548  
 549              'BP_Admin'                     => 'core',
 550              'BP_Attachment_Avatar'         => 'core',
 551              'BP_Attachment_Cover_Image'    => 'core',
 552              'BP_Attachment'                => 'core',
 553              'BP_Button'                    => 'core',
 554              'BP_Component'                 => 'core',
 555              'BP_Customizer_Control_Range'  => 'core',
 556              'BP_Date_Query'                => 'core',
 557              'BP_Email_Delivery'            => 'core',
 558              'BP_Email_Recipient'           => 'core',
 559              'BP_Email'                     => 'core',
 560              'BP_Embed'                     => 'core',
 561              'BP_Media_Extractor'           => 'core',
 562              'BP_Members_Suggestions'       => 'core',
 563              'BP_PHPMailer'                 => 'core',
 564              'BP_Recursive_Query'           => 'core',
 565              'BP_Suggestions'               => 'core',
 566              'BP_Theme_Compat'              => 'core',
 567              'BP_User_Query'                => 'core',
 568              'BP_Walker_Category_Checklist' => 'core',
 569              'BP_Walker_Nav_Menu_Checklist' => 'core',
 570              'BP_Walker_Nav_Menu'           => 'core',
 571  
 572              'BP_Core_Friends_Widget' => 'friends',
 573  
 574              'BP_Group_Extension'    => 'groups',
 575              'BP_Group_Member_Query' => 'groups',
 576  
 577              'BP_Core_Members_Template'       => 'members',
 578              'BP_Core_Members_Widget'         => 'members',
 579              'BP_Core_Recently_Active_Widget' => 'members',
 580              'BP_Core_Whos_Online_Widget'     => 'members',
 581              'BP_Registration_Theme_Compat'   => 'members',
 582              'BP_Signup'                      => 'members',
 583          );
 584  
 585          $component = null;
 586  
 587          // First check to see if the class is one without a properly namespaced name.
 588          if ( isset( $irregular_map[ $class ] ) ) {
 589              $component = $irregular_map[ $class ];
 590  
 591          // Next chunk is usually the component name.
 592          } elseif ( in_array( $class_parts[1], $components, true ) ) {
 593              $component = $class_parts[1];
 594          }
 595  
 596          if ( ! $component ) {
 597              return;
 598          }
 599  
 600          // Sanitize class name.
 601          $class = strtolower( str_replace( '_', '-', $class ) );
 602  
 603          $path = dirname( __FILE__ ) . "/bp-{$component}/classes/class-{$class}.php";
 604  
 605          // Sanity check.
 606          if ( ! file_exists( $path ) ) {
 607              return;
 608          }
 609  
 610          /*
 611           * Sanity check 2 - Check if component is active before loading class.
 612           * Skip if PHPUnit is running, or BuddyPress is installing for the first time.
 613           */
 614          if (
 615              ! in_array( $component, array( 'core', 'members' ), true ) &&
 616              ! bp_is_active( $component ) &&
 617              ! function_exists( 'tests_add_filter' )
 618          ) {
 619              return;
 620          }
 621  
 622          require $path;
 623      }
 624  
 625      /**
 626       * Set up the default hooks and actions.
 627       *
 628       * @since 1.6.0
 629       *
 630       */
 631  	private function setup_actions() {
 632  
 633          // Add actions to plugin activation and deactivation hooks
 634          add_action( 'activate_'   . $this->basename, 'bp_activation'   );
 635          add_action( 'deactivate_' . $this->basename, 'bp_deactivation' );
 636  
 637          // If BuddyPress is being deactivated, do not add any actions
 638          if ( bp_is_deactivation( $this->basename ) ) {
 639              return;
 640          }
 641  
 642          // Array of BuddyPress core actions
 643          $actions = array(
 644              'setup_theme',              // Setup the default theme compat
 645              'setup_current_user',       // Setup currently logged in user
 646              'register_post_types',      // Register post types
 647              'register_post_statuses',   // Register post statuses
 648              'register_taxonomies',      // Register taxonomies
 649              'register_views',           // Register the views
 650              'register_theme_directory', // Register the theme directory
 651              'register_theme_packages',  // Register bundled theme packages (bp-themes)
 652              'load_textdomain',          // Load textdomain
 653              'add_rewrite_tags',         // Add rewrite tags
 654              'generate_rewrite_rules'    // Generate rewrite rules
 655          );
 656  
 657          // Add the actions
 658          foreach( $actions as $class_action ) {
 659              if ( method_exists( $this, $class_action ) ) {
 660                  add_action( 'bp_' . $class_action, array( $this, $class_action ), 5 );
 661              }
 662          }
 663  
 664          /**
 665           * Fires after the setup of all BuddyPress actions.
 666           *
 667           * Includes bbp-core-hooks.php.
 668           *
 669           * @since 1.7.0
 670           *
 671           * @param BuddyPress $this. Current BuddyPress instance. Passed by reference.
 672           */
 673          do_action_ref_array( 'bp_after_setup_actions', array( &$this ) );
 674      }
 675  
 676      /**
 677       * Private method to align the active and database versions.
 678       *
 679       * @since 1.7.0
 680       */
 681  	private function versions() {
 682  
 683          // Get the possible DB versions (boy is this gross)
 684          $versions               = array();
 685          $versions['1.6-single'] = get_blog_option( $this->root_blog_id, '_bp_db_version' );
 686  
 687          // 1.6-single exists, so trust it
 688          if ( !empty( $versions['1.6-single'] ) ) {
 689              $this->db_version_raw = (int) $versions['1.6-single'];
 690  
 691          // If no 1.6-single exists, use the max of the others
 692          } else {
 693              $versions['1.2']        = get_site_option(                      'bp-core-db-version' );
 694              $versions['1.5-multi']  = get_site_option(                           'bp-db-version' );
 695              $versions['1.6-multi']  = get_site_option(                          '_bp_db_version' );
 696              $versions['1.5-single'] = get_blog_option( $this->root_blog_id,      'bp-db-version' );
 697  
 698              // Remove empty array items
 699              $versions             = array_filter( $versions );
 700              $this->db_version_raw = (int) ( !empty( $versions ) ) ? (int) max( $versions ) : 0;
 701          }
 702      }
 703  
 704      /** Public Methods ********************************************************/
 705  
 706      /**
 707       * Set up BuddyPress's legacy theme directory.
 708       *
 709       * Starting with version 1.2, and ending with version 1.8, BuddyPress
 710       * registered a custom theme directory - bp-themes - which contained
 711       * the bp-default theme. Since BuddyPress 1.9, bp-themes is no longer
 712       * registered (and bp-default no longer offered) on new installations.
 713       * Sites using bp-default (or a child theme of bp-default) will
 714       * continue to have bp-themes registered as before.
 715       *
 716       * @since 1.5.0
 717       *
 718       * @todo Move bp-default to wordpress.org/extend/themes and remove this.
 719       */
 720  	public function register_theme_directory() {
 721          if ( ! bp_do_register_theme_directory() ) {
 722              return;
 723          }
 724  
 725          register_theme_directory( $this->old_themes_dir );
 726      }
 727  
 728      /**
 729       * Register bundled theme packages.
 730       *
 731       * Note that since we currently have complete control over bp-themes and
 732       * the bp-legacy folders, it's fine to hardcode these here. If at a
 733       * later date we need to automate this, an API will need to be built.
 734       *
 735       * @since 1.7.0
 736       */
 737  	public function register_theme_packages() {
 738  
 739          // Register the default theme compatibility package
 740          bp_register_theme_package( array(
 741              'id'      => 'legacy',
 742              'name'    => __( 'BuddyPress Legacy', 'buddypress' ),
 743              'version' => bp_get_version(),
 744              'dir'     => trailingslashit( $this->themes_dir . '/bp-legacy' ),
 745              'url'     => trailingslashit( $this->themes_url . '/bp-legacy' )
 746          ) );
 747  
 748          bp_register_theme_package( array(
 749              'id'      => 'nouveau',
 750              'name'    => __( 'BuddyPress Nouveau', 'buddypress' ),
 751              'version' => bp_get_version(),
 752              'dir'     => trailingslashit( $this->themes_dir . '/bp-nouveau' ),
 753              'url'     => trailingslashit( $this->themes_url . '/bp-nouveau' )
 754          ) );
 755  
 756          // Register the basic theme stack. This is really dope.
 757          bp_register_template_stack( 'get_stylesheet_directory', 10 );
 758          bp_register_template_stack( 'get_template_directory',   12 );
 759          bp_register_template_stack( 'bp_get_theme_compat_dir',  14 );
 760      }
 761  
 762      /**
 763       * Set up the default BuddyPress theme compatibility location.
 764       *
 765       * @since 1.7.0
 766       */
 767  	public function setup_theme() {
 768  
 769          // Bail if something already has this under control
 770          if ( ! empty( $this->theme_compat->theme ) ) {
 771              return;
 772          }
 773  
 774          // Setup the theme package to use for compatibility
 775          bp_setup_theme_compat( bp_get_theme_package_id() );
 776      }
 777  }


Generated: Wed Dec 19 01:01:54 2018 Cross-referenced by PHPXref 0.7.1